diff --git a/common/python/nomadcore/ActivateLogging.py b/common/python/nomadcore/ActivateLogging.py index 09f666233bc9c0024aa455d5975121c586b0c89a..a3d419dac6d8ec30a9335f5fc8975d75cb33b9d7 100644 --- a/common/python/nomadcore/ActivateLogging.py +++ b/common/python/nomadcore/ActivateLogging.py @@ -5,16 +5,18 @@ ch = logging.StreamHandler() ch.setLevel(logging.INFO) logger=logging.getLogger("nomadcore") -logger.setLevel(logging.DEBUG) +logger.setLevel(logging.WARNING) logger.addHandler(ch) logger2=logging.getLogger("nomad") -logger2.setLevel(logging.DEBUG) +logger2.setLevel(logging.WARNING) logger2.addHandler(ch) def debugToFile(): - "makes a full log to a file named detailed.log" - fh = logging.FileHandler('detailed.log') - fh.setLevel(logging.DEBUG) - logger.addHandler(fh) - logger2.addHandler(fh) + "makes a full log to a file named detailed.log" + fh = logging.FileHandler('detailed.log') + fh.setLevel(logging.DEBUG) + logger.setLevel(logging.DEBUG) + logger2.setLevel(logging.DEBUG) + logger.addHandler(fh) + logger2.addHandler(fh) diff --git a/common/python/nomadcore/simple_parser.py b/common/python/nomadcore/simple_parser.py index 405fefa9ae7a9ef76880a7c8b86cfd8a96bc73c5..5cd49c826a748c9171577681276dddfaeda05ac0 100644 --- a/common/python/nomadcore/simple_parser.py +++ b/common/python/nomadcore/simple_parser.py @@ -674,6 +674,9 @@ class CompiledMatcher(object): def findNextWithRe(self, regex, possible, parser): # searching for match would be more efficient than doing line by line as here... + # catch empty regular expression + if regex.pattern == '': + return -3 while True: line = parser.fIn.readline() if not line: @@ -1026,7 +1029,7 @@ class SimpleParser(object): cNames = self.contextDesc() while self.context: self.contextPop() - if nextI != -1: + if nextI != -1 and nextI != -3: raise Exception("finished with error with parsing context %s" % (cNames)) else: index = nextI / 2 @@ -1092,12 +1095,13 @@ def mainFunction(mainFileDescription, metaInfoEnv, parserInfo, defaultSectionCachingLevel = CachingLevel.Forward, superContext = None, onClose = {}): - usage = """{exeName} [--meta-info] [--help] [--specialize] [--stream] [--uri uri] [path/toFile] + usage = """{exeName} [--meta-info] [--help] [--specialize] [--stream] [--uri uri] [--verbose] [path/toFile] --meta-info outputs the meta info supported by this parser --help prints this message --specialize expects inclusion and exclusion of meta info to parse via a json dictionary on stdin --stream expects the files to parse via dictionary on stdin + --verbose writes metainfo to stderr and detailed debug info of parsing process to file detailed.log If a path to a file is given this is parsed """.format(exeName = os.path.basename(sys.argv[0] if len(sys.argv) > 0 else "simple_parser"))