1 import conf, confparser
5 #log.getLogger().setLevel(log.DEBUG)
10 return conf.ConfigExpression([s], s)
13 class Test(unittest.TestCase):
15 self.t = conf.ConfigTree()
16 def parse(self, s, level=0, fname='test'):
17 c=confparser.ConfigParser(s, self.t, fname, level)
21 s1 = r"""a="1";b='2';c.d='\n';e="{a}{b}";e+='{c.d}';a+="\"\n\{\}";f+='Z{a.b}'#comment"""
22 def test_parser_nows(self):
25 root = conf.ConfigTree()
28 root.lookup('a.v%d'%i).add_operation(conf.Operation('SET', None, cs('A%d'%i)))
29 b = root.lookup('b.v%d'%i)
30 b.add_operation(conf.Operation('APPEND', None, cs(' <FOO>')))
31 b.add_operation(conf.Operation('SET', None, conf.ConfigExpression([root.lookup('a.v%d'%i)], '{a.v%d}'%i)))
32 b.add_operation(conf.Operation('APPEND', None, cs(' <BAR>')))
34 b.add_operation(conf.Operation('APPEND', None, conf.ConfigExpression([' [', root.lookup('b.v%d'%(i+1)), ']'], ' [{b.v%d}]'%(i+1))))
35 print '\n'.join(root.dump())
37 b0 = root.lookup('b.v0')
38 b0.remove_operation(b0.operations[1])
39 b0.add_operation(conf.Operation('SET', None, cs('NEW-B0')))
40 root.lookup('b.v2').add_operation(conf.Operation('APPEND', None, cs(' <NEW-B3>')))
41 root.lookup('a.v1').add_operation(conf.Operation('APPEND', None, cs(' <NEW-A1>')))
42 print '\n'.join(root.dump())
44 root.lookup('a.v0').add_operation(conf.Operation('SET', None, cs('<OVERRIDE-A0>')))
45 print '\n'.join(root.dump())
46 print 'maxdepth: %d'%conf.debug_maxdepth