home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.6)
-
- NSID = 3
-
- class Option(object):
-
- def __init__(self, otype):
- self.otype = otype
-
-
- def to_wire(self, file):
- raise NotImplementedError
-
-
- def from_wire(cls, otype, wire, current, olen):
- raise NotImplementedError
-
- from_wire = classmethod(from_wire)
-
- def _cmp(self, other):
- raise NotImplementedError
-
-
- def __eq__(self, other):
- if not isinstance(other, Option):
- return False
- if self.otype != other.otype:
- return False
- return self._cmp(other) == 0
-
-
- def __ne__(self, other):
- if not isinstance(other, Option):
- return False
- if self.otype != other.otype:
- return False
- return self._cmp(other) != 0
-
-
- def __lt__(self, other):
- if not isinstance(other, Option) or self.otype != other.otype:
- return NotImplemented
- return self._cmp(other) < 0
-
-
- def __le__(self, other):
- if not isinstance(other, Option) or self.otype != other.otype:
- return NotImplemented
- return self._cmp(other) <= 0
-
-
- def __ge__(self, other):
- if not isinstance(other, Option) or self.otype != other.otype:
- return NotImplemented
- return self._cmp(other) >= 0
-
-
- def __gt__(self, other):
- if not isinstance(other, Option) or self.otype != other.otype:
- return NotImplemented
- return self._cmp(other) > 0
-
-
-
- class GenericOption(Option):
-
- def __init__(self, otype, data):
- super(GenericOption, self).__init__(otype)
- self.data = data
-
-
- def to_wire(self, file):
- file.write(self.data)
-
-
- def from_wire(cls, otype, wire, current, olen):
- return cls(otype, wire[current:current + olen])
-
- from_wire = classmethod(from_wire)
-
- def _cmp(self, other):
- return cmp(self.data, other.data)
-
-
- _type_to_class = { }
-
- def get_option_class(otype):
- cls = _type_to_class.get(otype)
- if cls is None:
- cls = GenericOption
-
- return cls
-
-
- def option_from_wire(otype, wire, current, olen):
- cls = get_option_class(otype)
- return cls.from_wire(otype, wire, current, olen)
-
-