From: Christian Van Wambeke Date: Wed, 27 Jun 2018 09:28:28 +0000 (+0200) Subject: merge from master 8B7B X-Git-Tag: 5.1.0~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=a73105d0c22ff213d31a6502a0b4cf1b77bb754a;p=tools%2Fsat.git merge from master 8B7B --- a73105d0c22ff213d31a6502a0b4cf1b77bb754a diff --cc src/options.py index 911cb71,2cfeae0..b84eae1 mode 100755,100644..100755 --- a/src/options.py +++ b/src/options.py @@@ -246,56 -192,5 +246,56 @@@ class Options(object) # free the option in order to be able to make # a new free call of options (API case) option['result'] = None + + self.results = {"optlist": optlist, "optResult": optResult, "args": args, "argList": argList} + DBG.write("results", self.results) return optResult, args + + def filterLevel(self, aLevel): + """filter level logging values""" - import src.loggingSimple as LOG ++ import src.loggingSat as LOG + aLev = aLevel.upper() + knownLevels = LOG._knownLevels + maxLen = max([len(i) for i in knownLevels]) + for i in range(maxLen): + for lev in knownLevels: + if aLev == lev[:i]: + DBG.write("filterLevel", "%s -> %s" % (aLevel, lev)) + return lev + msg = "Unknown level '%s', accepted are:\n%s" % (aLev, ", ".join(knownLevels)) + raise Exception(msg) + + def filterList2(self, aStr): + """filter a list as 'KERNEL,YACS,etc.'""" + aList = aStr.strip().split(",") + # fix list leading ',' as ',KERNEL,...' + aList = [i for i in aList if i != ""] # split old list leadin "," as ",KERNEL,ETC..." + return aList + + + def __repr__(self): + """ + repr for only self.options and self.results (if present) + """ + aDict = {'options': self.options, 'results': self.results} + aStr = PP.pformat(aDict) + res = "%s(\n %s\n)" % (self.__class__.__name__, aStr[1:-1]) + return res + + def __str__(self): + """ + str for only resume expected self.options + """ + #aDict = [(k["longName"], k["shortName", k["helpString"]) for k in self.options} + #aList = [(k, self.options[k]) for k in sorted(self.options.keys())] + aDict = {} + for o in self.options: + aDict[o["longName"]] = (o["shortName"], o["helpString"]) + aStr = PP.pformat(aDict) + res = "%s(\n %s)" % (self.__class__.__name__, aStr[1:-1]) + return res + + def debug_write(self): + DBG.write("options and results", self, True) +