command: Move override parsing into module
This commit is contained in:
parent
5e4f22bd17
commit
69caea2ef9
@ -13,7 +13,9 @@ def config_files_type(value):
|
|||||||
|
|
||||||
def config_override_type(value):
|
def config_override_type(value):
|
||||||
try:
|
try:
|
||||||
return config_lib.parse_override(value)
|
section, remainder = value.split(b'/', 1)
|
||||||
|
key, value = remainder.split(b'=', 1)
|
||||||
|
return (section.strip(), key.strip(), value.strip())
|
||||||
except ValueError:
|
except ValueError:
|
||||||
raise argparse.ArgumentTypeError(
|
raise argparse.ArgumentTypeError(
|
||||||
'%s must have the format section/key=value' % value)
|
'%s must have the format section/key=value' % value)
|
||||||
|
|||||||
@ -140,13 +140,6 @@ def _format(config, comments, schemas, display):
|
|||||||
return b'\n'.join(output)
|
return b'\n'.join(output)
|
||||||
|
|
||||||
|
|
||||||
def parse_override(override):
|
|
||||||
"""Parse ``section/key=value`` command line overrides"""
|
|
||||||
section, remainder = override.split(b'/', 1)
|
|
||||||
key, value = remainder.split(b'=', 1)
|
|
||||||
return (section.strip(), key.strip(), value.strip())
|
|
||||||
|
|
||||||
|
|
||||||
class Proxy(collections.Mapping):
|
class Proxy(collections.Mapping):
|
||||||
def __init__(self, data):
|
def __init__(self, data):
|
||||||
self._data = data
|
self._data = data
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user