miron0xff / vyatta-conf-parser

Config parser for Vyatta/VyOS
MIT License
20 stars 11 forks source link

Rxv modification and Rxz addition #2

Closed lossanarch closed 9 years ago

lossanarch commented 9 years ago

Fixed rxv regex to allow successful parsing of 'password ""' and similar lines, such as from blocks like this: repository squeeze-lts { components "main contrib non-free" distribution squeeze-lts password "" url http://mirrors.kernel.org/debian username "" } This avoids errors such as:

out = vyattaconfparser.parse_conf(data) Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python2.6/dist-packages/vyattaconfparser/parser.py", line 93, in parse_conf c, headers = parse_node(c, line, headers) File "/usr/local/lib/python2.6/dist-packages/vyattaconfparser/parser.py", line 82, in parse_node raise ParserException('Parse error: "%s"' % line) vyattaconfparser.parser.ParserException: Parse error: "password """

Added rxz regex check to match comment lines found if directly reading /config/config.boot, like these: /* Warning: Do not remove the following line. / / === vyatta-config-version: "cluster@1:config-management@1:conntrack-sync@1:conntrack@1:cron@1:dhcp-relay@1:dhcp-server@4:firewall@5:ipsec@4:nat@4:qos@1:quagga@2:system@6:vrrp@1:wanloadbalance@3:webgui@1:webproxy@1:zone-policy@1" === / / Release version: VyOS 1.1.5 */ which are found in /config/config.boot. This avoids a similar ParserException error as above.

Thank you so much for this parser, you saved me hours of work. I hope you don't mind the contribution.

miron0xff commented 9 years ago

Thanks, @lossanarch , I am still working with Vyatta configurations on my current position and every contribution also saves my time.