better array parsing
This commit is contained in:
parent
178d935ca4
commit
bc8dbbd2f6
1 changed files with 6 additions and 4 deletions
|
@ -59,19 +59,21 @@ def main():
|
||||||
print('\ninvalid metadata argument, format is -m "key=value"')
|
print('\ninvalid metadata argument, format is -m "key=value"')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
k, v = m.split('=', 1)
|
k, v = m.split('=', 1)
|
||||||
|
if v[0] == '[' and v[-1] == ']':
|
||||||
|
v = [v[1:-1]]
|
||||||
if k in meta:
|
if k in meta:
|
||||||
if isinstance(meta[k], str):
|
if isinstance(meta[k], str):
|
||||||
meta[k] = [meta[k]]
|
meta[k] = [meta[k]]
|
||||||
meta[k].append(v)
|
if isinstance(v, list):
|
||||||
elif v[0] == '[' and v[-1] == ']':
|
meta[k].update(v)
|
||||||
meta[k] = v[1:-1]
|
else:
|
||||||
|
meta[k].append(v)
|
||||||
else:
|
else:
|
||||||
meta[k] = v
|
meta[k] = v
|
||||||
files = opts.files
|
files = opts.files
|
||||||
if not files:
|
if not files:
|
||||||
parser.print_help()
|
parser.print_help()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
id = upload(opts.api_url, files, meta)
|
id = upload(opts.api_url, files, meta)
|
||||||
print(id)
|
print(id)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue