home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 May / maximum-cd-2010-05.iso / DiscContents / boxee-0.9.20.10711.exe / system / python / Lib / lib-old / addpack.pyo (.txt) next >
Encoding:
Python Compiled Bytecode  |  2009-07-20  |  1.1 KB  |  47 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.4)
  3.  
  4. _packs = { }
  5.  
  6. def addpack(pack, *locations):
  7.     import os
  8.     if os.path.isabs(pack):
  9.         base = os.path.basename(pack)
  10.     else:
  11.         base = pack
  12.     if _packs.has_key(base):
  13.         return None
  14.     
  15.     import sys
  16.     path = []
  17.     for loc in _flatten(locations) + sys.path:
  18.         fn = os.path.join(loc, base)
  19.         if fn not in path and os.path.isdir(fn):
  20.             path.append(fn)
  21.             continue
  22.     
  23.     if pack != base and pack not in path and os.path.isdir(pack):
  24.         path.append(pack)
  25.     
  26.     if not path:
  27.         raise ImportError, 'package ' + pack + ' not found'
  28.     
  29.     _packs[base] = path
  30.     for fn in path:
  31.         if fn not in sys.path:
  32.             sys.path.append(fn)
  33.             continue
  34.     
  35.  
  36.  
  37. def _flatten(locations):
  38.     locs = []
  39.     for loc in locations:
  40.         if type(loc) == type(''):
  41.             locs.append(loc)
  42.             continue
  43.         locs = locs + _flatten(loc)
  44.     
  45.     return locs
  46.  
  47.