line = line.lstrip()
if setting is None:
if line[0] == "[" and line.rstrip()[-1] == "]":
- section = (line.strip()[1:-1], None)
+ key = line.strip()
+ pts = key[1:-1].split(" ", 1)
+ if len(pts) == 2:
+ if pts[1][0] != "\"" or pts[1][-1] != "\"":
+ raise ValueError(pts[1])
+ section = (pts[0], pts[1][1:-1])
+ else:
+ section = (pts[0], None)
ret._values[section[0]] = {section[1]: {}}
- # FIXME: Parse section
elif "=" in line:
setting, value = line.split("=", 1)
if section is None:
def test_from_file_section(self):
cf = self.from_file("[core]\nfoo = bar\n")
self.assertEquals("bar", cf.get("core.foo"))
+ self.assertEquals("bar", cf.get("core.foo.foo"))
+
+ def test_from_file_subsection(self):
+ cf = self.from_file("[branch \"foo\"]\nfoo = bar\n")
+ self.assertEquals("bar", cf.get("branch.foo.foo"))
def test_write_to_file_empty(self):
c = ConfigFile()