home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 October / maximum-cd-2011-10.iso / DiscContents / digsby_setup.exe / lib / dns / edns.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2011-06-22  |  3.3 KB  |  100 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.6)
  3.  
  4. NSID = 3
  5.  
  6. class Option(object):
  7.     
  8.     def __init__(self, otype):
  9.         self.otype = otype
  10.  
  11.     
  12.     def to_wire(self, file):
  13.         raise NotImplementedError
  14.  
  15.     
  16.     def from_wire(cls, otype, wire, current, olen):
  17.         raise NotImplementedError
  18.  
  19.     from_wire = classmethod(from_wire)
  20.     
  21.     def _cmp(self, other):
  22.         raise NotImplementedError
  23.  
  24.     
  25.     def __eq__(self, other):
  26.         if not isinstance(other, Option):
  27.             return False
  28.         if self.otype != other.otype:
  29.             return False
  30.         return self._cmp(other) == 0
  31.  
  32.     
  33.     def __ne__(self, other):
  34.         if not isinstance(other, Option):
  35.             return False
  36.         if self.otype != other.otype:
  37.             return False
  38.         return self._cmp(other) != 0
  39.  
  40.     
  41.     def __lt__(self, other):
  42.         if not isinstance(other, Option) or self.otype != other.otype:
  43.             return NotImplemented
  44.         return self._cmp(other) < 0
  45.  
  46.     
  47.     def __le__(self, other):
  48.         if not isinstance(other, Option) or self.otype != other.otype:
  49.             return NotImplemented
  50.         return self._cmp(other) <= 0
  51.  
  52.     
  53.     def __ge__(self, other):
  54.         if not isinstance(other, Option) or self.otype != other.otype:
  55.             return NotImplemented
  56.         return self._cmp(other) >= 0
  57.  
  58.     
  59.     def __gt__(self, other):
  60.         if not isinstance(other, Option) or self.otype != other.otype:
  61.             return NotImplemented
  62.         return self._cmp(other) > 0
  63.  
  64.  
  65.  
  66. class GenericOption(Option):
  67.     
  68.     def __init__(self, otype, data):
  69.         super(GenericOption, self).__init__(otype)
  70.         self.data = data
  71.  
  72.     
  73.     def to_wire(self, file):
  74.         file.write(self.data)
  75.  
  76.     
  77.     def from_wire(cls, otype, wire, current, olen):
  78.         return cls(otype, wire[current:current + olen])
  79.  
  80.     from_wire = classmethod(from_wire)
  81.     
  82.     def _cmp(self, other):
  83.         return cmp(self.data, other.data)
  84.  
  85.  
  86. _type_to_class = { }
  87.  
  88. def get_option_class(otype):
  89.     cls = _type_to_class.get(otype)
  90.     if cls is None:
  91.         cls = GenericOption
  92.     
  93.     return cls
  94.  
  95.  
  96. def option_from_wire(otype, wire, current, olen):
  97.     cls = get_option_class(otype)
  98.     return cls.from_wire(otype, wire, current, olen)
  99.  
  100.