From 3cbf2fbeadeb4ad793aaeb0621c7c011f874a7ab Mon Sep 17 00:00:00 2001 From: Will Buttinger <will@cern.ch> Date: Mon, 9 Jul 2018 15:17:37 +0100 Subject: [PATCH] support for multiple txt files as input ds lists Former-commit-id: c62e0b925a121bc6132bdb82575494a2078075ec --- Tools/PyUtils/bin/getMetadata.py | 66 ++++++++++++++++---------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/Tools/PyUtils/bin/getMetadata.py b/Tools/PyUtils/bin/getMetadata.py index e28288dcf0b..842515972d1 100755 --- a/Tools/PyUtils/bin/getMetadata.py +++ b/Tools/PyUtils/bin/getMetadata.py @@ -19,19 +19,20 @@ def readDsFromFile(txtName): dsList = [] try: # read lines - txt = open(txtName) - for tmpLine in txt: - # remove \n - tmpLine = re.sub('\n','',tmpLine) - # remove white spaces - tmpLine = tmpLine.strip() - # skip comment or empty - if tmpLine.startswith('#') or tmpLine == '': - continue - # append - dsList += [tmpLine] - # close file - txt.close() + for fileName in txtName.split(","): + txt = open(fileName) + for tmpLine in txt: + # remove \n + tmpLine = re.sub('\n','',tmpLine) + # remove white spaces + tmpLine = tmpLine.strip() + # skip comment or empty + if tmpLine.startswith('#') or tmpLine == '': + continue + # append + dsList += [tmpLine] + # close file + txt.close() except: errType,errValue = sys.exc_info()[:2] logging.error("cannot read datasets from %s due to %s:%s" % (txtName,errType,errValue)) @@ -306,25 +307,26 @@ def main(): # read lines commentcount=0 import re - txt = open(args.inDsTxt) - for tmpLine in txt: - # remove \n - tmpLine = re.sub('\n','',tmpLine) - # remove white spaces - tmpLine = tmpLine.strip() - # skip comment or empty - if tmpLine.startswith('#') or tmpLine == '': - complete_values['comment%d'%(commentcount)] = tmpLine - commentcount = commentcount+1 - continue - # append - tmpLine = tmpLine.rstrip("/") - if tmpLine in dataset_values.keys(): - complete_values[tmpLine] = dataset_values[tmpLine] - else: - print("cannot find %s" % tmpLine) - # close file - txt.close() + for fileName in args.inDsTxt.split(","): + txt = open(fileName) + for tmpLine in txt: + # remove \n + tmpLine = re.sub('\n','',tmpLine) + # remove white spaces + tmpLine = tmpLine.strip() + # skip comment or empty + if tmpLine.startswith('#') or tmpLine == '': + complete_values['comment%d'%(commentcount)] = tmpLine + commentcount = commentcount+1 + continue + # append + tmpLine = tmpLine.rstrip("/") + if tmpLine in dataset_values.keys(): + complete_values[tmpLine] = dataset_values[tmpLine] + else: + print("cannot find %s" % tmpLine) + # close file + txt.close() dataset_values = complete_values logging.info("Obtaining %s for selected datasets at timestamp=%s... (please be patient)" % (args.fields,args.timestamp)) -- GitLab