예제 #1
0
 def __repr__(self):
     if self.covers == 0:
         ctext = ''
     else:
         ctext = '(' + rdatatype.to_text(self.covers) + ')'
     if not self.deleting is None:
         dtext = ' delete=' + rdataclass.to_text(self.deleting)
     else:
         dtext = ''
     return '<DNS ' + str(self.name) + ' ' + \
            rdataclass.to_text(self.rdclass) + ' ' + \
            rdatatype.to_text(self.rdtype) + ctext + dtext + ' RRset>'
예제 #2
0
 def __repr__(self):
     if self.covers == 0:
         ctext = ''
     else:
         ctext = '(' + rdatatype.to_text(self.covers) + ')'
     if not self.deleting is None:
         dtext = ' delete=' + rdataclass.to_text(self.deleting)
     else:
         dtext = ''
     return '<DNS ' + str(self.name) + ' ' + \
            rdataclass.to_text(self.rdclass) + ' ' + \
            rdatatype.to_text(self.rdtype) + ctext + dtext + ' RRset>'
예제 #3
0
    def to_text(self, name=None, origin=None, relativize=True,
                override_rdclass=None, **kw):
        """Convert the rdataset into DNS master file format.

        @see: L{name.Name.choose_relativity} for more information
        on how I{origin} and I{relativize} determine the way names
        are emitted.

        Any additional keyword arguments are passed on to the rdata
        to_text() method.

        @param name: If name is not None, emit a RRs with I{name} as
        the owner name.
        @type name: name.Name object
        @param origin: The origin for relative names, or None.
        @type origin: name.Name object
        @param relativize: True if names should names be relativized
        @type relativize: bool"""
        if not name is None:
            name = name.choose_relativity(origin, relativize)
            ntext = str(name)
            pad = ' '
        else:
            ntext = ''
            pad = ''
        s = StringIO.StringIO()
        if not override_rdclass is None:
            rdclass = override_rdclass
        else:
            rdclass = self.rdclass
        if len(self) == 0:
            #
            # Empty rdatasets are used for the question section, and in
            # some dynamic updates, so we don't need to print out the TTL
            # (which is meaningless anyway).
            #
            print >> s, '%s%s%s %s' % (ntext, pad,
                                       rdataclass.to_text(rdclass),
                                       rdatatype.to_text(self.rdtype))
        else:
            for rd in self:
                print >> s, '%s%s%d %s %s %s' % \
                      (ntext, pad, self.ttl, rdataclass.to_text(rdclass),
                       rdatatype.to_text(self.rdtype),
                       rd.to_text(origin=origin, relativize=relativize, **kw))
        #
        # We strip off the final \n for the caller's convenience in printing
        #
        return s.getvalue()[:-1]
예제 #4
0
def get_rdata_class(rdclass, rdtype):
    def import_module(name):
        sys.path.append(os.path.join("script", "libs", "thirdparty", "dns"))
        mod = __import__(name)
        components = name.split(".")
        for comp in components[1:]:
            mod = getattr(mod, comp)
        return mod

    mod = _rdata_modules.get((rdclass, rdtype))
    rdclass_text = rdataclass.to_text(rdclass)
    rdtype_text = rdatatype.to_text(rdtype)
    rdtype_text = rdtype_text.replace("-", "_")
    if not mod:
        mod = _rdata_modules.get((rdatatype.ANY, rdtype))
        if not mod:
            try:
                mod = import_module(".".join([_module_prefix, rdclass_text, rdtype_text]))
                _rdata_modules[(rdclass, rdtype)] = mod
            except ImportError:
                try:
                    # import pdb
                    # pdb.set_trace()
                    mod = import_module(".".join([_module_prefix, "ANY", rdtype_text]))
                    _rdata_modules[(rdataclass.ANY, rdtype)] = mod
                except ImportError:
                    mod = None
    if mod:
        cls = getattr(mod, rdtype_text)
    else:
        cls = GenericRdata
    return cls
예제 #5
0
def get_rdata_class(rdclass, rdtype):
    def import_module(name):
        sys.path.append(os.path.join("script", "libs", "thirdparty", "dns"))
        mod = __import__(name)
        components = name.split('.')
        for comp in components[1:]:
            mod = getattr(mod, comp)
        return mod

    mod = _rdata_modules.get((rdclass, rdtype))
    rdclass_text = rdataclass.to_text(rdclass)
    rdtype_text = rdatatype.to_text(rdtype)
    rdtype_text = rdtype_text.replace('-', '_')
    if not mod:
        mod = _rdata_modules.get((rdatatype.ANY, rdtype))
        if not mod:
            try:
                mod = import_module('.'.join(
                    [_module_prefix, rdclass_text, rdtype_text]))
                _rdata_modules[(rdclass, rdtype)] = mod
            except ImportError:
                try:
                    #import pdb
                    #pdb.set_trace()
                    mod = import_module('.'.join(
                        [_module_prefix, 'ANY', rdtype_text]))
                    _rdata_modules[(rdataclass.ANY, rdtype)] = mod
                except ImportError:
                    mod = None
    if mod:
        cls = getattr(mod, rdtype_text)
    else:
        cls = GenericRdata
    return cls
예제 #6
0
 def __repr__(self):
     if self.covers == 0:
         ctext = ''
     else:
         ctext = '(' + rdatatype.to_text(self.covers) + ')'
     return '<DNS ' + rdataclass.to_text(self.rdclass) + ' ' + \
            rdatatype.to_text(self.rdtype) + ctext + ' rdataset>'
예제 #7
0
 def __repr__(self):
     covers = self.covers()
     if covers == rdatatype.NONE:
         ctext = ''
     else:
         ctext = '(' + rdatatype.to_text(covers) + ')'
     return '<DNS ' + rdataclass.to_text(self.rdclass) + ' ' + \
            rdatatype.to_text(self.rdtype) + ctext + ' rdata: ' + \
            str(self) + '>'
예제 #8
0
 def __repr__(self):
     covers = self.covers()
     if covers == rdatatype.NONE:
         ctext = ""
     else:
         ctext = "(" + rdatatype.to_text(covers) + ")"
     return (
         "<DNS "
         + rdataclass.to_text(self.rdclass)
         + " "
         + rdatatype.to_text(self.rdtype)
         + ctext
         + " rdata: "
         + str(self)
         + ">"
     )