home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 January / maximum-cd-2011-01.iso / DiscContents / calibre-0.7.26.msi / file_1942 (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2010-10-31  |  1.8 KB  |  59 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. __docformat__ = 'restructuredtext en'
  5. import os
  6. from foolscap import Tub, UnauthenticatedTub
  7.  
  8. def check_furl_file_security(furl_file, secure):
  9.     if os.path.isfile(furl_file):
  10.         f = open(furl_file, 'r')
  11.         oldfurl = f.read().strip()
  12.         f.close()
  13.         if (oldfurl.startswith('pb://') or not secure or oldfurl.startswith('pbu://')) and secure:
  14.             os.remove(furl_file)
  15.         
  16.     
  17.  
  18.  
  19. def is_secure(furl):
  20.     if is_valid(furl):
  21.         if furl.startswith('pb://'):
  22.             return True
  23.         if furl.startswith('pbu://'):
  24.             return False
  25.     else:
  26.         raise ValueError('invalid furl: %s' % furl)
  27.     return furl.startswith('pbu://')
  28.  
  29.  
  30. def is_valid(furl):
  31.     if isinstance(furl, str):
  32.         if furl.startswith('pb://') or furl.startswith('pbu://'):
  33.             return True
  34.     else:
  35.         return False
  36.     return furl.startswith('pbu://')
  37.  
  38.  
  39. def find_furl(furl_or_file):
  40.     if isinstance(furl_or_file, str):
  41.         if is_valid(furl_or_file):
  42.             return furl_or_file
  43.     
  44.     if os.path.isfile(furl_or_file):
  45.         furl = open(furl_or_file, 'r').read().strip()
  46.         if is_valid(furl):
  47.             return furl
  48.     
  49.     raise ValueError('not a furl or a file containing a furl: %s' % furl_or_file)
  50.  
  51.  
  52. try:
  53.     import OpenSSL
  54. except:
  55.     Tub = UnauthenticatedTub
  56.     have_crypto = False
  57.  
  58. have_crypto = True
  59.