diff --git a/tools/python/jwutils/Object.py b/tools/python/jwutils/Object.py new file mode 100644 index 0000000..b51d1e5 --- /dev/null +++ b/tools/python/jwutils/Object.py @@ -0,0 +1,17 @@ +import jwutils.log + +class Object(object): # export + + def __init__(): + self.log_level = jwutils.log.NOTICE + + def log(self, prio, *args): + if prio <= self.log_level: + msg = "" + for count, thing in enumerate(args): + msg += ' ' + str(thing) + if len(msg): + print msg[1:] + + def debug(self, *args): + self.log(DEBUG, args) diff --git a/tools/python/jwutils/algo/ShuntingYard.py b/tools/python/jwutils/algo/ShuntingYard.py index 00df2e7..f1a5e7f 100644 --- a/tools/python/jwutils/algo/ShuntingYard.py +++ b/tools/python/jwutils/algo/ShuntingYard.py @@ -51,7 +51,8 @@ class ShuntingYard(object): # export def token_string(self): r = "" - for k, v in self.__ops.iteritems(): + for k in sorted(self.__ops): + v = self.__ops[k] buf = ", \"" + k if v.nargs == 1: if k[len(k)-1].isalnum(): diff --git a/tools/python/jwutils/log.py b/tools/python/jwutils/log.py new file mode 100644 index 0000000..642d505 --- /dev/null +++ b/tools/python/jwutils/log.py @@ -0,0 +1,22 @@ +import syslog + +EMERG = syslog.LOG_EMERG +ALER = syslog.LOG_ALERT +CRIT = syslog.LOG_CRIT +ERR = syslog.LOG_ERR +WARNING = syslog.LOG_WARNING +NOTICE = syslog.LOG_NOTICE +INFO = syslog.LOG_INFO +DEBUG = syslog.LOG_DEBUG +DEVEL = syslog.LOG_DEBUG + 1 +OFF = DEVEL + 1 + +level = NOTICE + +def log(prio, *args): # export + if prio <= level: + msg = "" + for count, thing in enumerate(args): + msg += ' ' + str(thing) + if len(msg): + print msg[1:]