pvl/dhcp/config.py
changeset 685 668f934bb958
parent 682 60dbd952a15e
child 695 c60924eca185
--- 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)