home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_1632 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-08-06  |  1.9 KB  |  56 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import dns.exception as dns
  5. QUERY = 0
  6. IQUERY = 1
  7. STATUS = 2
  8. NOTIFY = 4
  9. UPDATE = 5
  10. _by_text = {
  11.     'QUERY': QUERY,
  12.     'IQUERY': IQUERY,
  13.     'STATUS': STATUS,
  14.     'NOTIFY': NOTIFY,
  15.     'UPDATE': UPDATE }
  16. _by_value = []([ (y, x) for x, y in _by_text.iteritems() ])
  17.  
  18. class UnknownOpcode(dns.exception.DNSException):
  19.     pass
  20.  
  21.  
  22. def from_text(text):
  23.     if text.isdigit():
  24.         value = int(text)
  25.         if value >= 0 and value <= 15:
  26.             return value
  27.     
  28.     value = _by_text.get(text.upper())
  29.     if value is None:
  30.         raise UnknownOpcode
  31.     value is None
  32.     return value
  33.  
  34.  
  35. def from_flags(flags):
  36.     return (flags & 30720) >> 11
  37.  
  38.  
  39. def to_flags(value):
  40.     return value << 11 & 30720
  41.  
  42.  
  43. def to_text(value):
  44.     text = _by_value.get(value)
  45.     if text is None:
  46.         text = str(value)
  47.     
  48.     return text
  49.  
  50.  
  51. def is_update(flags):
  52.     if from_flags(flags) == UPDATE:
  53.         return True
  54.     return False
  55.  
  56.