pvl/dns/process.py
changeset 716 4fecd0d1cf23
parent 648 8e3e6be9ac70
child 717 e37b0a857a5d
equal deleted inserted replaced
715:76ed62924d50 716:4fecd0d1cf23
    33                     line=rr.line, origin=rr.origin, comment=rr.comment,
    33                     line=rr.line, origin=rr.origin, comment=rr.comment,
    34             )
    34             )
    35         else:
    35         else:
    36             yield rr
    36             yield rr
    37 
    37 
    38 def zone_includes_path (rrs, includes_path):
    38 def zone_includes (rrs, includes_path,
       
    39         include_trace=None,
       
    40 ):
    39     """
    41     """
    40         Rewrite include paths in zones.
    42         Rewrite include paths in zones.
       
    43 
       
    44             include_trace           - append included paths to given list
    41     """
    45     """
    42 
    46 
    43     for rr in rrs:
    47     for rr in rrs:
    44         if isinstance(rr, zone.ZoneDirective) and rr.directive == 'INCLUDE':
    48         if isinstance(rr, zone.ZoneDirective) and rr.directive == 'INCLUDE':
    45             include_path, = rr.arguments
    49             include_path, = rr.arguments
    46 
    50 
    47             yield zone.ZoneDirective.INCLUDE(os.path.join(includes_path, include_path))
    51             include = os.path.join(includes_path, include_path)
       
    52 
       
    53             if include_trace is not None:
       
    54                 include_trace.append(include)
       
    55 
       
    56             yield zone.ZoneDirective.INCLUDE(include)
    48         else:
    57         else:
    49             yield rr
    58             yield rr
    50 
       
    51 def zone_includes (rrs):
       
    52     """
       
    53         Extract $INCLUDE paths from zone.
       
    54     """
       
    55 
       
    56     for rr in rrs:
       
    57         if isinstance(rr, pvl.dns.ZoneDirective) and rr.directive == 'INCLUDE':
       
    58             include_path, = rr.arguments
       
    59 
       
    60             yield include_path
       
    61 
    59 
    62 def apply_zone_output (options, zone):
    60 def apply_zone_output (options, zone):
    63     """
    61     """
    64         Output given ZoneDirective/ZoneRecord items to the output file/stdout.
    62         Output given ZoneDirective/ZoneRecord items to the output file/stdout.
    65     """
    63     """