Gitlab Community Edition Instance
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cdstar
pycdstar3
Commits
ae066abd
Commit
ae066abd
authored
Jan 16, 2020
by
Marcel Hellkamp
Browse files
Implemented KEY=VALUE parameters with multiple separators, e.g. KEY+=VALUE or KEY=@file
parent
70821c7e
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/pycdstar3/cli/_utils.py
View file @
ae066abd
...
...
@@ -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
):
...
...
src/pycdstar3/cli/commands/acl.py
View file @
ae066abd
...
...
@@ -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
(
","
)))
...
...
src/pycdstar3/cli/commands/put.py
View file @
ae066abd
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment