better array parsing

This commit is contained in:
j 2025-01-24 15:04:00 +05:30
parent 178d935ca4
commit bc8dbbd2f6

View file

@ -59,19 +59,21 @@ def main():
print('\ninvalid metadata argument, format is -m "key=value"')
sys.exit(1)
k, v = m.split('=', 1)
if v[0] == '[' and v[-1] == ']':
v = [v[1:-1]]
if k in meta:
if isinstance(meta[k], str):
meta[k] = [meta[k]]
meta[k].append(v)
elif v[0] == '[' and v[-1] == ']':
meta[k] = v[1:-1]
if isinstance(v, list):
meta[k].update(v)
else:
meta[k].append(v)
else:
meta[k] = v
files = opts.files
if not files:
parser.print_help()
sys.exit(1)
id = upload(opts.api_url, files, meta)
print(id)