--- a/pvl/dhcp/config.py Mon Mar 02 12:54:27 2015 +0200
+++ b/pvl/dhcp/config.py Mon Mar 02 12:59:17 2015 +0200
@@ -313,17 +313,21 @@
if block.comment:
yield build_line((), end="# {comment}".format(comment=block.comment), indent=indent)
-
- yield build_line(block.key, end=' {', indent=indent, context=block.key[0:1])
+
+ if block.key:
+ yield build_line(block.key, end=' {', indent=indent, context=block.key[0:1])
+ indent += 1
for item in block.items:
- yield build_item(item, indent=indent+1)
+ yield build_item(item, indent=indent)
for subblock in block.blocks:
- yield ''
+ if block.items:
+ yield ''
- for line in build_block(subblock, indent=indent+1):
+ for line in build_block(subblock, indent=indent):
yield line
-
- yield build_line((), end='}', indent=indent)
-
+
+ if block.key:
+ indent -= 1
+ yield build_line((), end='}', indent=indent)
--- a/pvl/dhcp/tests.py Mon Mar 02 12:54:27 2015 +0200
+++ b/pvl/dhcp/tests.py Mon Mar 02 12:59:17 2015 +0200
@@ -119,7 +119,8 @@
def testBuildConf(self):
self.assertLinesEqual(
- config.build_block(config.Block(('group', ), [
+ config.build_block(config.Block(None, [], [
+ config.Block(('group', ), [
('next-server', 'boot.test'),
('filename', "/debian/wheezy/pxelinux.0"),
('include', "hosts/test.conf"),
@@ -129,8 +130,8 @@
('fixed-address', '192.0.2.1'),
('hardware', 'ethernet', '00:11:22:33:44:55'),
]),
- ]
- )),
+ ]),
+ ])),
"""
group {
next-server boot.test;