diff options
author | John Smith <mrdoctorwho@gmail.com> | 2016-01-10 14:36:15 +0300 |
---|---|---|
committer | John Smith <mrdoctorwho@gmail.com> | 2016-01-10 14:36:15 +0300 |
commit | 9ff35f9acd823b1d47284fa9aa7a310347f00ff9 (patch) | |
tree | 1956142b17fc7a8aff33ad7d0688591edcb78109 /library/printer.py | |
parent | 128782b7690530bc6a660595537a5f21f895c307 (diff) |
Update to support API v5.42
Fix not requesting subscription if user has no friends (#96)
Fix wrong message type detection
The xmpp monitor publisher is now an extension
Add colored API debug
LongPoll now uses https
Split groupchats extension into two modules + 1 extension
Fix #95
Diffstat (limited to 'library/printer.py')
-rw-r--r-- | library/printer.py | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/library/printer.py b/library/printer.py index ac9f9e0..51aca5e 100644 --- a/library/printer.py +++ b/library/printer.py @@ -10,6 +10,14 @@ import time __author__ = "mrDoctorWho <mrdoctorwho@gmail.com>" +# Bold + Inensity +BIYellow = "\x1b[1;93m" # Yellow +BICyan = "\x1b[1;96m" # Cyan +BIRed = "\x1b[1;91m" # Red +BIGreen = "\x1b[1;92m" # Green + +Nocolor = "\x1b[0m" + def use_lsd(text): import random @@ -25,7 +33,7 @@ def use_lsd(text): def Print(text, line=True): """ This function is needed to prevent errors - like IOError: device is not ready + like IOError: device is not ready which is probably happens when script running under screen """ if (time.gmtime().tm_mon, time.gmtime().tm_mday) == (4, 1): @@ -37,3 +45,27 @@ def Print(text, line=True): sys.stdout.flush() except (IOError, OSError): pass + + +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(): + text += x + else: + text += Nocolor + x + break + else: + text += c + return text |