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

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import socket
  5. import dns.ipv4 as dns
  6. import dns.ipv6 as dns
  7. AF_INET = socket.AF_INET
  8.  
  9. try:
  10.     AF_INET6 = socket.AF_INET6
  11. except AttributeError:
  12.     AF_INET6 = 9999
  13.  
  14.  
  15. def inet_pton(family, text):
  16.     if family == AF_INET:
  17.         return dns.ipv4.inet_aton(text)
  18.     if family == AF_INET6:
  19.         return dns.ipv6.inet_aton(text)
  20.     raise NotImplementedError
  21.  
  22.  
  23. def inet_ntop(family, address):
  24.     if family == AF_INET:
  25.         return dns.ipv4.inet_ntoa(address)
  26.     if family == AF_INET6:
  27.         return dns.ipv6.inet_ntoa(address)
  28.     raise NotImplementedError
  29.  
  30.  
  31. def af_for_address(text):
  32.     
  33.     try:
  34.         junk = dns.ipv4.inet_aton(text)
  35.         return AF_INET
  36.     except:
  37.         
  38.         try:
  39.             junk = dns.ipv6.inet_aton(text)
  40.             return AF_INET6
  41.         raise ValueError
  42.  
  43.  
  44.  
  45.  
  46. def is_multicast(text):
  47.     
  48.     try:
  49.         first = ord(dns.ipv4.inet_aton(text)[0])
  50.         if first >= 224:
  51.             pass
  52.         return first <= 239
  53.     except:
  54.         
  55.         try:
  56.             first = ord(dns.ipv6.inet_aton(text)[0])
  57.             return first == 255
  58.         raise ValueError
  59.  
  60.  
  61.  
  62.