summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorHarm Weites <harm@weites.com>2014-08-26 18:10:03 +0000
committerHarm Weites <harm@weites.com>2014-08-26 18:10:03 +0000
commit1b9b66be04aafcb39f349ccb48905afc393cfc32 (patch)
tree1997876eb42a558ccf5cbd34aa2e4e0eb46ea2bf /cloudinit
parenta0e3506c6dddf140589228c1ac74f48d2a7cde49 (diff)
downloadvyos-cloud-init-1b9b66be04aafcb39f349ccb48905afc393cfc32.tar.gz
vyos-cloud-init-1b9b66be04aafcb39f349ccb48905afc393cfc32.zip
change: Use a compiled regex and use the included match groups instead
of matching yet again.
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/distros/freebsd.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/cloudinit/distros/freebsd.py b/cloudinit/distros/freebsd.py
index 415c6ba6..9c923480 100644
--- a/cloudinit/distros/freebsd.py
+++ b/cloudinit/distros/freebsd.py
@@ -69,17 +69,17 @@ class Distro(distros.Distro):
# quotes are ignored:
# hostname="bla"
def loadrcconf(self):
+ RE_MATCH = re.compile(r'^(\w+)="?(\w+)"?')
conf = {}
lines = util.load_file(self.rc_conf_fn).splitlines()
for line in lines:
- if not re.match(r'^(.+)=(.+)', line):
+ m = RE_MATCH.match(line)
+ if not m:
LOG.debug("Skipping line from /etc/rc.conf: %s", line)
continue
- # TODO: just use the matches please...
- tok = line.split('=')
- key = tok[0]
- val = re.sub(r'^"|"$', '', tok[1].rstrip())
+ key = m.group(1).rstrip()
+ val = m.group(2).rstrip()
conf[key] = val
return conf