diff options
author | John Smith <mrdoctorwho@gmail.com> | 2017-04-30 17:45:20 +0300 |
---|---|---|
committer | John Smith <mrdoctorwho@gmail.com> | 2017-04-30 17:45:20 +0300 |
commit | cd574a61090a81fe7cb2165fe552bfb1d4f15dbe (patch) | |
tree | 76788b3569ee7664cdd3f3b72b3a6d76a6a5a731 | |
parent | 2e484a34afedceed5a3ea7f112d2ebe9542a495f (diff) |
Don't colorize JSON on NT systems
-rw-r--r-- | library/printer.py | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/library/printer.py b/library/printer.py index 51aca5e..7daac60 100644 --- a/library/printer.py +++ b/library/printer.py @@ -5,6 +5,7 @@ Provides a “safe” way to print a text """ +import os import sys import time @@ -48,24 +49,26 @@ def Print(text, line=True): def colorizeJSON(data): - text = "" - iter = list(repr(data)).__iter__() - for c in iter: - if c == "'": - text += BIYellow + c - for x in iter: - text += x - if x == "'": - text += Nocolor - break - elif c.isdigit(): - text += BICyan + c - for x in iter: - if x.isdigit(): + if os.name() != "nt": + text = "" + iter = list(repr(data)).__iter__() + for c in iter: + if c == "'": + text += BIYellow + c + for x in iter: text += x - else: - text += Nocolor + x - break - else: - text += c - return text + if x == "'": + text += Nocolor + break + elif c.isdigit(): + text += BICyan + c + for x in iter: + if x.isdigit(): + text += x + else: + text += Nocolor + x + break + else: + text += c + return text + return data |