5 import samweb_client
as swc
11 sys.stdout.write(
"{}/{} Updating Metadata for: {}\n".
format(ith, nfiles, f))
13 sam.modifyFileMetadata(f,md)
19 if __name__ ==
'__main__':
21 parser = argparse.ArgumentParser(
22 prog=
'update_metadata.py',
23 description=
"Update one metadata field for multiple files matching SAM dimensions.",
25 parser.add_argument(
'-d',
'--dimensions', type=str, help=
"SAM dimensions")
26 parser.add_argument(
'-m',
'--metadata', type=json.loads, help=
"metadata to be updated")
27 parser.add_argument(
'-f',
'--filejson', type=string, help=
"Json file containing metadata to be updated")
28 args = parser.parse_args()
30 sam = swc.SAMWebClient(
"dune")
32 flist=sam.listFiles(args.dimensions)
33 print(
"%d files matching dimension." % (len(flist)))
34 if args.metadata
is not None:
37 if args.metadata
is None and args.file
is not None:
38 with
open(args.filejson)
as fjson:
int open(const char *, int)
Opens a file descriptor.
static bool format(QChar::Decomposition tag, QString &str, int index, int len)