home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Narzedzia / Calibre / calibre-0.8.18.msi / file_262 / macpath.pyo (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2011-09-09  |  5.0 KB  |  223 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.7)
  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.         if t[:1] == ':':
  69.             t = t[1:]
  70.         if ':' not in path:
  71.             path = ':' + path
  72.         if path[-1:] != ':':
  73.             path = path + ':'
  74.         path = path + t
  75.     
  76.     return path
  77.  
  78.  
  79. def split(s):
  80.     if ':' not in s:
  81.         return ('', s)
  82.     colon = None
  83.     for i in range(len(s)):
  84.         if s[i] == ':':
  85.             colon = i + 1
  86.             continue
  87.     path = s[:colon - 1]
  88.     file = s[colon:]
  89.     if path and ':' not in path:
  90.         path = path + ':'
  91.     return (path, file)
  92.  
  93.  
  94. def splitext(p):
  95.     return genericpath._splitext(p, sep, altsep, extsep)
  96.  
  97. splitext.__doc__ = genericpath._splitext.__doc__
  98.  
  99. def splitdrive(p):
  100.     return ('', p)
  101.  
  102.  
  103. def dirname(s):
  104.     return split(s)[0]
  105.  
  106.  
  107. def basename(s):
  108.     return split(s)[1]
  109.  
  110.  
  111. def ismount(s):
  112.     if not isabs(s):
  113.         return False
  114.     components = None(s)
  115.     if len(components) == 2:
  116.         pass
  117.     return components[1] == ''
  118.  
  119.  
  120. def islink(s):
  121.     
  122.     try:
  123.         import Carbon.File as Carbon
  124.         return Carbon.File.ResolveAliasFile(s, 0)[2]
  125.     except:
  126.         return False
  127.  
  128.  
  129.  
  130. def lexists(path):
  131.     
  132.     try:
  133.         st = os.lstat(path)
  134.     except os.error:
  135.         return False
  136.  
  137.     return True
  138.  
  139.  
  140. def expandvars(path):
  141.     return path
  142.  
  143.  
  144. def expanduser(path):
  145.     return path
  146.  
  147.  
  148. class norm_error(Exception):
  149.     pass
  150.  
  151.  
  152. def normpath(s):
  153.     if ':' not in s:
  154.         return ':' + s
  155.     comps = None.split(':')
  156.     i = 1
  157.     while i < len(comps) - 1:
  158.         if comps[i] == '' and comps[i - 1] != '':
  159.             if i > 1:
  160.                 del comps[i - 1:i + 1]
  161.                 i = i - 1
  162.             else:
  163.                 raise norm_error, 'Cannot use :: immediately after volume name'
  164.         i = i + 1
  165.     s = ':'.join(comps)
  166.     if s[-1] == ':' and len(comps) > 2 and s != ':' * len(s):
  167.         s = s[:-1]
  168.     return s
  169.  
  170.  
  171. def walk(top, func, arg):
  172.     warnings.warnpy3k('In 3.x, os.path.walk is removed in favor of os.walk.', stacklevel = 2)
  173.     
  174.     try:
  175.         names = os.listdir(top)
  176.     except os.error:
  177.         return None
  178.  
  179.     func(arg, top, names)
  180.     for name in names:
  181.         name = join(top, name)
  182.         if isdir(name) and not islink(name):
  183.             walk(name, func, arg)
  184.             continue
  185.  
  186.  
  187. def abspath(path):
  188.     if not isabs(path):
  189.         if isinstance(path, unicode):
  190.             cwd = os.getcwdu()
  191.         else:
  192.             cwd = os.getcwd()
  193.         path = join(cwd, path)
  194.     return normpath(path)
  195.  
  196.  
  197. def realpath(path):
  198.     path = abspath(path)
  199.     
  200.     try:
  201.         import Carbon.File as Carbon
  202.     except ImportError:
  203.         return path
  204.  
  205.     if not path:
  206.         return path
  207.     components = None.split(':')
  208.     path = components[0] + ':'
  209.     for c in components[1:]:
  210.         path = join(path, c)
  211.         
  212.         try:
  213.             path = Carbon.File.FSResolveAliasFile(path, 1)[0].as_pathname()
  214.         continue
  215.         except Carbon.File.Error:
  216.             continue
  217.         
  218.  
  219.     
  220.     return path
  221.  
  222. supports_unicode_filenames = True
  223.