File tree 3 files changed +15
-13
lines changed
3 files changed +15
-13
lines changed Original file line number Diff line number Diff line change 4
4
import sys
5
5
from pprint import pprint
6
6
7
- from pygments import highlight , lexers , formatters
8
-
9
7
__version__ = '0.1.2'
10
8
11
9
PY3 = sys .version_info [0 ] >= 3
@@ -16,16 +14,20 @@ def format_json(data):
16
14
17
15
18
16
def colorize_json (data ):
19
- if PY3 :
20
- if isinstance (data , bytes ):
21
- data = data .decode ('UTF-8' )
22
- else :
23
- if not isinstance (data , unicode ):
24
- data = unicode (data , 'UTF-8' )
25
- colorful_json = highlight (data ,
26
- lexers .JsonLexer (),
27
- formatters .TerminalFormatter ())
28
- return colorful_json
17
+ try :
18
+ from pygments import highlight , lexers , formatters
19
+ if PY3 :
20
+ if isinstance (data , bytes ):
21
+ data = data .decode ('UTF-8' )
22
+ else :
23
+ if not isinstance (data , unicode ):
24
+ data = unicode (data , 'UTF-8' )
25
+ colorful_json = highlight (data ,
26
+ lexers .JsonLexer (),
27
+ formatters .TerminalFormatter ())
28
+ return colorful_json
29
+ except ModuleNotFoundError :
30
+ return data
29
31
30
32
31
33
def print_json (data ):
Original file line number Diff line number Diff line change 1
1
prompt_toolkit >= 1.0.16 ,< 1.1
2
2
Pygments >= 2.2.0
3
- regex >= 2016.11.21
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ pytest-html>=1.10.1
11
11
pytest-xdist>=1.15.0
12
12
pylint>=1.6.5
13
13
ptyprocess==0.5.1
14
+ regex>=2016.11.21
14
15
15
16
# build-tools
16
17
pep8>=1.7.0
You can’t perform that action at this time.
0 commit comments