summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Pryor <profjim@jimpryor.net>2009-08-11 14:05:06 +0200
committerJames Rayner <james@archlinux.org>2009-08-15 04:28:28 +0200
commit03ea89171b2376ac5b593b803ca73e7311c30de8 (patch)
treea4e03cc22d2edc28c264388215e48e9054bcbd08
parentb7d6f5afb02d5567c572149d5b6469c77980cc24 (diff)
downloadnetctl-03ea89171b2376ac5b593b803ca73e7311c30de8.tar.gz
netctl-03ea89171b2376ac5b593b803ca73e7311c30de8.tar.xz
give wireless-dbus smarter read_config
Signed-off-by: Jim Pryor <profjim@jimpryor.net>
-rw-r--r--src-wireless/wireless-dbus11
1 files changed, 8 insertions, 3 deletions
diff --git a/src-wireless/wireless-dbus b/src-wireless/wireless-dbus
index 30b77d8..d30eb21 100644
--- a/src-wireless/wireless-dbus
+++ b/src-wireless/wireless-dbus
@@ -21,9 +21,14 @@ def read_config(config):
cfg = shlex.split(open(config, "r").read())
options = {}
for line in cfg:
- (var, delim, value) = line.partition('=')
- if delim and var.lstrip()[0] != "#":
- options[var] = value
+ (var, delim, value) = line.partition('=')
+ if delim:
+ var = var.lstrip() # JP: allow assignments to be indented, as they can be when sourced
+ if var[0] != '#':
+ value = value.partition("#")[0].rstrip() # JP: strip off comments and trailing whitespace
+ if value[0] == value[-1] and value[0] in ('"',"'"): # JP: strip any surrounding quotes
+ value=value[1:-1]
+ options[var] = value
return options