Gitlab Community Edition Instance

Commit ae066abd authored by Marcel Hellkamp's avatar Marcel Hellkamp
Browse files

Implemented KEY=VALUE parameters with multiple separators, e.g. KEY+=VALUE or KEY=@file

parent 70821c7e
......@@ -28,13 +28,17 @@ class KvArgType:
The value may be empty, but the '=' is required. """
def __init__(self, split="="):
self.split = split
self.split = list(split)
self.split.sort(key=lambda x: (-len(x), x))
def __call__(self, val):
k, _, v = val.partition(self.split)
if not _:
raise argparse.ArgumentTypeError("Expected KAYVALUE argument.")
return k, v
for split in self.split:
k, s, v = val.partition(split)
if s:
return k, s, v
raise argparse.ArgumentTypeError(
"Expected KAY{}VALUE argument.".format(self.split[0])
)
def globtype(str):
......
......@@ -46,7 +46,8 @@ def acl_set(ctx, args):
archive = args.ARCHIVE
changes = {}
for sub, allow in args.ALLOW:
for sub, split, allow in args.ALLOW:
# TODO: Support += and -=
if sub:
changes.setdefault(sub, set()).update(filter(None, allow.split(",")))
......
......@@ -160,12 +160,14 @@ def command(ctx, args): # noqa: C901
# Collect meta changes
meta = {}
for key, val in args.meta or []:
for key, split, val in args.meta or []:
# TODO: Support += and -= as well as @ to load from files
meta.setdefault(key, []).append(val)
# Collect ACL changes
acl = {}
for key, val in args.acl or []:
for key, split, val in args.acl or []:
# TODO: Support += and -=
acl.setdefault(key, []).append(val)
# Collect files to upload
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment