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

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 2.6)
  3.  
  4. import os
  5. import warnings
  6. from stat import *
  7. import genericpath
  8. from genericpath import *
  9. __all__ = [
  10.     'normcase',
  11.     'isabs',
  12.     'join',
  13.     'splitdrive',
  14.     'split',
  15.     'splitext',
  16.     'basename',
  17.     'dirname',
  18.     'commonprefix',
  19.     'getsize',
  20.     'getmtime',
  21.     'getatime',
  22.     'getctime',
  23.     'islink',
  24.     'exists',
  25.     'lexists',
  26.     'isdir',
  27.     'isfile',
  28.     'walk',
  29.     'expanduser',
  30.     'expandvars',
  31.     'normpath',
  32.     'abspath',
  33.     'curdir',
  34.     'pardir',
  35.     'sep',
  36.     'pathsep',
  37.     'defpath',
  38.     'altsep',
  39.     'extsep',
  40.     'devnull',
  41.     'realpath',
  42.     'supports_unicode_filenames']
  43. curdir = ':'
  44. pardir = '::'
  45. extsep = '.'
  46. sep = ':'
  47. pathsep = '\n'
  48. defpath = ':'
  49. altsep = None
  50. devnull = 'Dev:Null'
  51.  
  52. def normcase(path):
  53.     return path.lower()
  54.  
  55.  
  56. def isabs(s):
  57.     if ':' in s:
  58.         pass
  59.     return s[0] != ':'
  60.  
  61.  
  62. def join(s, *p):
  63.     path = s
  64.     for t in p:
  65.         if not s or isabs(t):
  66.             path = t
  67.             continue
  68.         
  69.         if t[:1] == ':':
  70.             t = t[1:]
  71.         
  72.         if ':' not in path:
  73.             path = ':' + path
  74.         
  75.         if path[-1:] != ':':
  76.             path = path + ':'
  77.         
  78.         path = path + t
  79.     
  80.     return path
  81.  
  82.  
  83. def split(s):
  84.     if ':' not in s:
  85.         return ('', s)
  86.     colon = 0
  87.     for i in range(len(s)):
  88.         if s[i] == ':':
  89.             colon = i + 1
  90.             continue
  91.         ':' not in s
  92.     
  93.     path = s[:colon - 1]
  94.     file = s[colon:]
  95.     if path and ':' not in path:
  96.         path = path + ':'
  97.     
  98.     return (path, file)
  99.  
  100.  
  101. def splitext(p):
  102.     return genericpath._splitext(p, sep, altsep, extsep)
  103.  
  104. splitext.__doc__ = genericpath._splitext.__doc__
  105.  
  106. def splitdrive(p):
  107.     return ('', p)
  108.  
  109.  
  110. def dirname(s):
  111.     return split(s)[0]
  112.  
  113.  
  114. def basename(s):
  115.     return split(s)[1]
  116.  
  117.  
  118. def ismount(s):
  119.     if not isabs(s):
  120.         return False
  121.     components = split(s)
  122.     if len(components) == 2:
  123.         pass
  124.     return components[1] == ''
  125.  
  126.  
  127. def islink(s):
  128.     
  129.     try:
  130.         import Carbon.File as Carbon
  131.         return Carbon.File.ResolveAliasFile(s, 0)[2]
  132.     except:
  133.         return False
  134.  
  135.  
  136.  
  137. def lexists(path):
  138.     
  139.     try:
  140.         st = os.lstat(path)
  141.     except os.error:
  142.         return False
  143.  
  144.     return True
  145.  
  146.  
  147. def expandvars(path):
  148.     return path
  149.  
  150.  
  151. def expanduser(path):
  152.     return path
  153.  
  154.  
  155. class norm_error(Exception):
  156.     pass
  157.  
  158.  
  159. def normpath(s):
  160.     if ':' not in s:
  161.         return ':' + s
  162.     comps = s.split(':')
  163.     i = 1
  164.     while i < len(comps) - 1:
  165.         if comps[i] == '' and comps[i - 1] != '':
  166.             if i > 1:
  167.                 del comps[i - 1:i + 1]
  168.                 i = i - 1
  169.             else:
  170.                 raise norm_error, 'Cannot use :: immediately after volume name'
  171.         i > 1
  172.         i = i + 1
  173.         continue
  174.         ':' not in s
  175.     s = ':'.join(comps)
  176.     if s[-1] == ':' and len(comps) > 2 and s != ':' * len(s):
  177.         s = s[:-1]
  178.     
  179.     return s
  180.  
  181.  
  182. def walk(top, func, arg):
  183.     warnings.warnpy3k('In 3.x, os.path.walk is removed in favor of os.walk.', stacklevel = 2)
  184.     
  185.     try:
  186.         names = os.listdir(top)
  187.     except os.error:
  188.         return None
  189.  
  190.     func(arg, top, names)
  191.     for name in names:
  192.         name = join(top, name)
  193.         if isdir(name) and not islink(name):
  194.             walk(name, func, arg)
  195.             continue
  196.     
  197.  
  198.  
  199. def abspath(path):
  200.     if not isabs(path):
  201.         path = join(os.getcwd(), path)
  202.     
  203.     return normpath(path)
  204.  
  205.  
  206. def realpath(path):
  207.     path = abspath(path)
  208.     
  209.     try:
  210.         import Carbon.File as Carbon
  211.     except ImportError:
  212.         return path
  213.  
  214.     if not path:
  215.         return path
  216.     components = path.split(':')
  217.     path = components[0] + ':'
  218.     for c in components[1:]:
  219.         path = join(path, c)
  220.         path = Carbon.File.FSResolveAliasFile(path, 1)[0].as_pathname()
  221.     
  222.     return path
  223.  
  224. supports_unicode_filenames = False
  225.