Changeset 103:adf3cd83bf7a for nagslang
- Timestamp:
- 09/02/13 11:05:25 (9 years ago)
- Branch:
- default
- Phase:
- public
- Rebase:
- 38323238613265633737366534633963326263633366393564373333653762656537363239643735
- Location:
- nagslang
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
nagslang/tests/test_yamlish.py
r102 r103 8 8 9 9 from nagslang.yamlish import load, dump 10 11 12 class TestParse(TestCase): 13 def assertParsesAs(self, yaml, expected): 14 f = StringIO(yaml.strip()) 15 self.assertEqual(load(f), expected) 16 17 def test_dict_list_1(self): 18 self.assertParsesAs(''' 19 foo: 20 - bar 21 - baz 22 ''', {'foo': ['bar', 'baz']}) 23 24 def test_dict_list_2(self): 25 self.assertParsesAs(''' 26 foo: 27 - bar 28 - baz 29 ''', {'foo': ['bar', 'baz']}) 10 30 11 31 -
nagslang/yamlish.py
r102 r103 64 64 65 65 if len(spaces) > indent(): 66 # Nested dict67 assert dm68 66 assert parent_key 69 stack.append((len(spaces), {})) 67 if dm: 68 # Nested dict 69 stack.append((len(spaces), {})) 70 elif lm: 71 # Over-indented list in a dict 72 stack.append((len(spaces), [])) 70 73 stack[-2][1][parent_key] = obj() 71 74 parent_key = None
Note:
See TracChangeset
for help on using the changeset viewer.