mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-05-09 16:01:28 +00:00
Support quoted values
This commit is contained in:
parent
324c2957fd
commit
453112f342
@ -36,13 +36,20 @@ def get_devscripts_config():
|
|||||||
dictionary
|
dictionary
|
||||||
"""
|
"""
|
||||||
config = {}
|
config = {}
|
||||||
var_re = re.compile(r'^\s*([A-Z_]+?)=(.+)$')
|
var_re = re.compile(r'^\s*([A-Z_]+?)=(.+?)\s*$')
|
||||||
for fn in ('/etc/devscripts.conf', '~/.devscripts'):
|
for fn in ('/etc/devscripts.conf', '~/.devscripts'):
|
||||||
f = open(os.path.expanduser(fn), 'r')
|
f = open(os.path.expanduser(fn), 'r')
|
||||||
for line in f:
|
for line in f:
|
||||||
m = var_re.match(line)
|
m = var_re.match(line)
|
||||||
if m:
|
if m:
|
||||||
config[m.group(1)] = m.group(2)
|
value = m.group(2)
|
||||||
|
# This isn't quite the same as bash's parsing, but
|
||||||
|
# mostly-compatible for configuration files that aren't broken
|
||||||
|
# like this: KEY=foo bar
|
||||||
|
if (len(value) > 2 and value[0] == value[-1]
|
||||||
|
and value[0] in ("'", '"')):
|
||||||
|
value = value[1:-1]
|
||||||
|
config[m.group(1)] = value
|
||||||
f.close()
|
f.close()
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user