home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 January / Chip_2003-01_cd2.bin / convert / eJayMp3Pro / mp3pro_demo.exe / SITE.PYC (.txt) < prev    next >
Encoding:
Python Compiled Bytecode  |  2000-06-05  |  4.8 KB  |  144 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyc (Python 1.5)
  3.  
  4. """Append module search paths for third-party packages to sys.path.
  5.  
  6. ****************************************************************
  7. * This module is automatically imported during initialization. *
  8. ****************************************************************
  9.  
  10. In earlier versions of Python (up to 1.5a3), scripts or modules that
  11. needed to use site-specific modules would place ``import site''
  12. somewhere near the top of their code.  Because of the automatic
  13. import, this is no longer necessary (but code that does it still
  14. works).
  15.  
  16. This will append site-specific paths to to the module search path.  On
  17. Unix, it starts with sys.prefix and sys.exec_prefix (if different) and
  18. appends lib/python<version>/site-packages as well as lib/site-python.
  19. On other platforms (mainly Mac and Windows), it uses just sys.prefix
  20. (and sys.exec_prefix, if different, but this is unlikely).  The
  21. resulting directories, if they exist, are appended to sys.path, and
  22. also inspected for path configuration files.
  23.  
  24. A path configuration file is a file whose name has the form
  25. <package>.pth; its contents are additional directories (one per line)
  26. to be added to sys.path.  Non-existing directories (or
  27. non-directories) are never added to sys.path; no directory is added to
  28. sys.path more than once.  Blank lines and lines beginning with
  29. \\code{#} are skipped.
  30.  
  31. For example, suppose sys.prefix and sys.exec_prefix are set to
  32. /usr/local and there is a directory /usr/local/lib/python1.5/site-packages
  33. with three subdirectories, foo, bar and spam, and two path
  34. configuration files, foo.pth and bar.pth.  Assume foo.pth contains the
  35. following:
  36.  
  37.   # foo package configuration
  38.   foo
  39.   bar
  40.   bletch
  41.  
  42. and bar.pth contains:
  43.  
  44.   # bar package configuration
  45.   bar
  46.  
  47. Then the following directories are added to sys.path, in this order:
  48.  
  49.   /usr/local/lib/python1.5/site-packages/bar
  50.   /usr/local/lib/python1.5/site-packages/foo
  51.  
  52. Note that bletch is omitted because it doesn't exist; bar precedes foo
  53. because bar.pth comes alphabetically before foo.pth; and spam is
  54. omitted because it is not mentioned in either path configuration file.
  55.  
  56. After these path manipulations, an attempt is made to import a module
  57. named sitecustomize, which can perform arbitrary additional
  58. site-specific customizations.  If this import fails with an
  59. ImportError exception, it is silently ignored.
  60.  
  61. """
  62. import sys
  63. import os
  64.  
  65. def addsitedir(sitedir):
  66.     if sitedir not in sys.path:
  67.         sys.path.append(sitedir)
  68.     
  69.     
  70.     try:
  71.         names = os.listdir(sitedir)
  72.     except os.error:
  73.         return None
  74.  
  75.     names = map(os.path.normcase, names)
  76.     names.sort()
  77.     for name in names:
  78.         pass
  79.     
  80.  
  81.  
  82. def addpackage(sitedir, name):
  83.     fullname = os.path.join(sitedir, name)
  84.     
  85.     try:
  86.         f = open(fullname)
  87.     except IOError:
  88.         return None
  89.  
  90.     while 1:
  91.         dir = f.readline()
  92.         if not dir:
  93.             break
  94.         
  95.         if dir[0] == '#':
  96.             continue
  97.         
  98.         if dir[-1] == '\n':
  99.             dir = dir[:-1]
  100.         
  101.         dir = os.path.join(sitedir, dir)
  102.         if dir not in sys.path and os.path.exists(dir):
  103.             sys.path.append(dir)
  104.         
  105.  
  106. prefixes = [
  107.     sys.prefix]
  108. if sys.exec_prefix != sys.prefix:
  109.     prefixes.append(sys.exec_prefix)
  110.  
  111. for prefix in prefixes:
  112.     if prefix:
  113.         for sitedir in sitedirs:
  114.             pass
  115.         
  116.     
  117.  
  118. if os.sep == ':':
  119.     exit = 'Use Cmd-Q to quit.'
  120. elif os.sep == '\\':
  121.     exit = 'Use Ctrl-Z plus Return to exit.'
  122. else:
  123.     exit = 'Use Ctrl-D (i.e. EOF) to exit.'
  124. import __builtin__
  125. __builtin__.quit = __builtin__.exit = exit
  126. del exit
  127.  
  128. try:
  129.     import sitecustomize
  130. except ImportError:
  131.     pass
  132.  
  133.  
  134. def _test():
  135.     print 'sys.path = ['
  136.     for dir in sys.path:
  137.         print '    %s,' % `dir`
  138.     
  139.     print ']'
  140.  
  141. if __name__ == '__main__':
  142.     _test()
  143.  
  144.