pvl.dns.zone: fix runon name handling; typofix $ORIGIN
authorTero Marttila <terom@paivola.fi>
Mon, 16 Dec 2013 20:01:21 +0200
changeset 274 81af20dd142d
parent 273 c8deaa9a2746
child 275 4dc5cc30a278
pvl.dns.zone: fix runon name handling; typofix $ORIGIN
pvl/dns/zone.py
--- a/pvl/dns/zone.py	Mon Dec 16 19:32:40 2013 +0200
+++ b/pvl/dns/zone.py	Mon Dec 16 20:01:21 2013 +0200
@@ -167,6 +167,8 @@
             Parse ZoneRecord items from the given zonefile, ignoring non-record lines.
         """
 
+        name = None
+
         for line in ZoneLine.load(file, **opts) :
             if not line.parts :
                 log.debug("%s: skip empty line", line)
@@ -182,7 +184,7 @@
                     
                     log.info("%s: origin: %s", line, origin)
 
-                if directive == 'TTL' :
+                elif directive == 'TTL' :
                     ttl, = args
                     
                     log.info("%s: ttl: %s", line, ttl)
@@ -210,21 +212,31 @@
                 
             else :
                 # normal record?
-                record = ZoneRecord.parse(line, origin=origin, ttl=ttl,
-                        comment = line.comment
+                record = ZoneRecord.parse(line,
+                        name    = name,
+                        origin  = origin,
+                        ttl     = ttl,
+                        comment = line.comment,
                 )
 
                 if record :
                     yield record
+                    
+                    # keep name across lines
+                    name = record.name
 
                 else :
                     # unknown
                     log.warning("%s: skip unknown line: %s", line, line.line)
      
     @classmethod
-    def parse (cls, line, parts=None, ttl=None, **opts) :
+    def parse (cls, line, name=None, parts=None, ttl=None, **opts) :
         """
             Build a ZoneRecord from a ZoneLine.
+
+                name        - default for name, if continuing previous line
+
+            Return: (name, ZoneRecord)
         """
 
         if parts is None :
@@ -234,9 +246,9 @@
             # skip
             return
         
-        # XXX: indented lines keep name from previous record
         if line.indent :
-            name = None
+            # indented lines keep name from previous record
+            pass
 
         else :
             name = parts.pop(0)