<s> """<STR_LIT>""" <EOL> import sys <EOL> import os <EOL> import __builtin__ <EOL> import traceback <EOL> PREFIXES = [ sys . prefix , sys . exec_prefix ] <EOL> ENABLE_USER_SITE = None <EOL> USER_SITE = None <EOL> USER_BASE = None <EOL> def makepath ( * paths ) : <EOL> dir = os . path . join ( * paths ) <EOL> try : <EOL> dir = os . path . abspath ( dir ) <EOL> except OSError : <EOL> pass <EOL> return dir , os . path . normcase ( dir ) <EOL> def abs__file__ ( ) : <EOL> """<STR_LIT>""" <EOL> for m in sys . modules . values ( ) : <EOL> if hasattr ( m , '<STR_LIT>' ) : <EOL> continue <EOL> try : <EOL> m . __file__ = os . path . abspath ( m . __file__ ) <EOL> except ( AttributeError , OSError ) : <EOL> pass <EOL> def removeduppaths ( ) : <EOL> """<STR_LIT>""" <EOL> L = [ ] <EOL> known_paths = set ( ) <EOL> for dir in sys . path : <EOL> dir , dircase = makepath ( dir ) <EOL> if not dircase in known_paths : <EOL> L . append ( dir ) <EOL> known_paths . add ( dircase ) <EOL> sys . path [ : ] = L <EOL> return known_paths <EOL> def _init_pathinfo ( ) : <EOL> """<STR_LIT>""" <EOL> d = set ( ) <EOL> for dir in sys . path : <EOL> try : <EOL> if os . path . isdir ( dir ) : <EOL> dir , dircase = makepath ( dir ) <EOL> d . add ( dircase ) <EOL> except TypeError : <EOL> continue <EOL> return d <EOL> def addpackage ( sitedir , name , known_paths ) : <EOL> """<STR_LIT>""" <EOL> if known_paths is None : <EOL> _init_pathinfo ( ) <EOL> reset = <NUM_LIT:1> <EOL> else : <EOL> reset = <NUM_LIT:0> <EOL> fullname = os . path . join ( sitedir , name ) <EOL> try : <EOL> f = open ( fullname , "<STR_LIT>" ) <EOL> except IOError : <EOL> return <EOL> with f : <EOL> for n , line in enumerate ( f ) : <EOL> if line . startswith ( "<STR_LIT:#>" ) : <EOL> continue <EOL> try : <EOL> if line . startswith ( ( "<STR_LIT>" , "<STR_LIT>" ) ) : <EOL> exec line <EOL> continue <EOL> line = line . rstrip ( ) <EOL> dir , dircase = makepath ( sitedir , line ) <EOL> if not dircase in known_paths and os . path . exists ( dir ) : <EOL> sys . path . append ( dir ) <EOL> known_paths . add ( dircase ) <EOL> except Exception as err : <EOL> print >> sys . stderr , "<STR_LIT>" . format ( <EOL> n + <NUM_LIT:1> , fullname ) <EOL> for record in traceback . format_exception ( * sys . exc_info ( ) ) : <EOL> for line in record . splitlines ( ) : <EOL> print >> sys . stderr , '<STR_LIT:U+0020>' + line <EOL> print >> sys . stderr , "<STR_LIT>" <EOL> break <EOL> if reset : <EOL> known_paths = None <EOL> return known_paths <EOL> def addsitedir ( sitedir , known_paths = None ) : <EOL> """<STR_LIT>""" <EOL> if known_paths is None : <EOL> known_paths = _init_pathinfo ( ) <EOL> reset = <NUM_LIT:1> <EOL> else : <EOL> reset = <NUM_LIT:0> <EOL> sitedir , sitedircase = makepath ( sitedir ) <EOL> if not sitedircase in known_paths : <EOL> sys . path . append ( sitedir ) <EOL> try : <EOL> names = os . listdir ( sitedir ) <EOL> except os . error : <EOL> return <EOL> dotpth = os . extsep + "<STR_LIT>" <EOL> names = [ name for name in names if name . endswith ( dotpth ) ] <EOL> for name in sorted ( names ) : <EOL> addpackage ( sitedir , name , known_paths ) <EOL> if reset : <EOL> known_paths = None <EOL> return known_paths <EOL> def check_enableusersite ( ) : <EOL> """<STR_LIT>""" <EOL> if sys . flags . no_user_site : <EOL> return False <EOL> if hasattr ( os , "<STR_LIT>" ) and hasattr ( os , "<STR_LIT>" ) : <EOL> if os . geteuid ( ) != os . getuid ( ) : <EOL> return None <EOL> if hasattr ( os , "<STR_LIT>" ) and hasattr ( os , "<STR_LIT>" ) : <EOL> if os . getegid ( ) != os . getgid ( ) : <EOL> return None <EOL> return True <EOL> def getuserbase ( ) : <EOL> """<STR_LIT>""" <EOL> global USER_BASE <EOL> if USER_BASE is not None : <EOL> return USER_BASE <EOL> from sysconfig import get_config_var <EOL> USER_BASE = get_config_var ( '<STR_LIT>' ) <EOL> return USER_BASE <EOL> def getusersitepackages ( ) : <EOL> """<STR_LIT>""" <EOL> global USER_SITE <EOL> user_base = getuserbase ( ) <EOL> if USER_SITE is not None : <EOL> return USER_SITE <EOL> from sysconfig import get_path <EOL> import os <EOL> if sys . platform == '<STR_LIT>' : <EOL> from sysconfig import get_config_var <EOL> if get_config_var ( '<STR_LIT>' ) : <EOL> USER_SITE = get_path ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> return USER_SITE <EOL> USER_SITE = get_path ( '<STR_LIT>' , '<STR_LIT>' % os . name ) <EOL> return USER_SITE <EOL> def addusersitepackages ( known_paths ) : <EOL> """<STR_LIT>""" <EOL> user_site = getusersitepackages ( ) <EOL> if ENABLE_USER_SITE and os . path . isdir ( user_site ) : <EOL> addsitedir ( user_site , known_paths ) <EOL> return known_paths <EOL> def getsitepackages ( ) : <EOL> """<STR_LIT>""" <EOL> sitepackages = [ ] <EOL> seen = set ( ) <EOL> for prefix in PREFIXES : <EOL> if not prefix or prefix in seen : <EOL> continue <EOL> seen . add ( prefix ) <EOL> if sys . platform in ( '<STR_LIT>' , '<STR_LIT>' ) : <EOL> sitepackages . append ( os . path . join ( prefix , "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> elif os . sep == '<STR_LIT:/>' : <EOL> sitepackages . append ( os . path . join ( prefix , "<STR_LIT>" , <EOL> "<STR_LIT>" + sys . version [ : <NUM_LIT:3> ] , <EOL> "<STR_LIT>" ) ) <EOL> sitepackages . append ( os . path . join ( prefix , "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> else : <EOL> sitepackages . append ( prefix ) <EOL> sitepackages . append ( os . path . join ( prefix , "<STR_LIT>" , "<STR_LIT>" ) ) <EOL> if sys . platform == "<STR_LIT>" : <EOL> from sysconfig import get_config_var <EOL> framework = get_config_var ( "<STR_LIT>" ) <EOL> if framework : <EOL> sitepackages . append ( <EOL> os . path . join ( "<STR_LIT>" , framework , <EOL> sys . version [ : <NUM_LIT:3> ] , "<STR_LIT>" ) ) <EOL> return sitepackages <EOL> def addsitepackages ( known_paths ) : <EOL> """<STR_LIT>""" <EOL> for sitedir in getsitepackages ( ) : <EOL> if os . path . isdir ( sitedir ) : <EOL> addsitedir ( sitedir , known_paths ) <EOL> return known_paths <EOL> def setBEGINLIBPATH ( ) : <EOL> """<STR_LIT>""" <EOL> dllpath = os . path . join ( sys . prefix , "<STR_LIT>" , "<STR_LIT>" ) <EOL> libpath = os . environ [ '<STR_LIT>' ] . split ( '<STR_LIT:;>' ) <EOL> if libpath [ - <NUM_LIT:1> ] : <EOL> libpath . append ( dllpath ) <EOL> else : <EOL> libpath [ - <NUM_LIT:1> ] = dllpath <EOL> os . environ [ '<STR_LIT>' ] = '<STR_LIT:;>' . join ( libpath ) <EOL> def setquit ( ) : <EOL> """<STR_LIT>""" <EOL> if os . sep == '<STR_LIT::>' : <EOL> eof = '<STR_LIT>' <EOL> elif os . sep == '<STR_LIT:\\>' : <EOL> eof = '<STR_LIT>' <EOL> else : <EOL> eof = '<STR_LIT>' <EOL> class Quitter ( object ) : <EOL> def __init__ ( self , name ) : <EOL> self . name = name <EOL> def __repr__ ( self ) : <EOL> return '<STR_LIT>' % ( self . name , eof ) <EOL> def __call__ ( self , code = None ) : <EOL> try : <EOL> sys . stdin . close ( ) <EOL> except : <EOL> pass <EOL> raise SystemExit ( code ) <EOL> __builtin__ . quit = Quitter ( '<STR_LIT>' ) <EOL> __builtin__ . exit = Quitter ( '<STR_LIT>' ) <EOL> class _Printer ( object ) : <EOL> """<STR_LIT>""" <EOL> MAXLINES = <NUM_LIT> <EOL> def __init__ ( self , name , data , files = ( ) , dirs = ( ) ) : <EOL> self . __name = name <EOL> self . __data = data <EOL> self . __files = files <EOL> self . __dirs = dirs <EOL> self . __lines = None <EOL> def __setup ( self ) : <EOL> if self . __lines : <EOL> return <EOL> data = None <EOL> for dir in self . __dirs : <EOL> for filename in self . __files : <EOL> filename = os . path . join ( dir , filename ) <EOL> try : <EOL> fp = file ( filename , "<STR_LIT>" ) <EOL> data = fp . read ( ) <EOL> fp . close ( ) <EOL> break <EOL> except IOError : <EOL> pass <EOL> if data : <EOL> break <EOL> if not data : <EOL> data = self . __data <EOL> self . __lines = data . split ( '<STR_LIT:\n>' ) <EOL> self . __linecnt = len ( self . __lines ) <EOL> def __repr__ ( self ) : <EOL> self . __setup ( ) <EOL> if len ( self . __lines ) <= self . MAXLINES : <EOL> return "<STR_LIT:\n>" . join ( self . __lines ) <EOL> else : <EOL> return "<STR_LIT>" % ( ( self . __name , ) * <NUM_LIT:2> ) <EOL> def __call__ ( self ) : <EOL> self . __setup ( ) <EOL> prompt = '<STR_LIT>' <EOL> lineno = <NUM_LIT:0> <EOL> while <NUM_LIT:1> : <EOL> try : <EOL> for i in range ( lineno , lineno + self . MAXLINES ) : <EOL> print self . __lines [ i ] <EOL> except IndexError : <EOL> break <EOL> else : <EOL> lineno += self . MAXLINES <EOL> key = None <EOL> while key is None : <EOL> key = raw_input ( prompt ) <EOL> if key not in ( '<STR_LIT>' , '<STR_LIT:q>' ) : <EOL> key = None <EOL> if key == '<STR_LIT:q>' : <EOL> break <EOL> def setcopyright ( ) : <EOL> """<STR_LIT>""" <EOL> __builtin__ . copyright = _Printer ( "<STR_LIT>" , sys . copyright ) <EOL> if sys . platform [ : <NUM_LIT:4> ] == '<STR_LIT>' : <EOL> __builtin__ . credits = _Printer ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" ) <EOL> else : <EOL> __builtin__ . credits = _Printer ( "<STR_LIT>" , """<STR_LIT>""" ) <EOL> here = os . path . dirname ( os . __file__ ) <EOL> __builtin__ . license = _Printer ( <EOL> "<STR_LIT>" , "<STR_LIT>" % sys . version , <EOL> [ "<STR_LIT>" , "<STR_LIT>" ] , <EOL> [ os . path . join ( here , os . pardir ) , here , os . curdir ] ) <EOL> class _Helper ( object ) : <EOL> """<STR_LIT>""" <EOL> def __repr__ ( self ) : <EOL> return "<STR_LIT>" "<STR_LIT>" <EOL> def __call__ ( self , * args , ** kwds ) : <EOL> import pydoc <EOL> return pydoc . help ( * args , ** kwds ) <EOL> def sethelper ( ) : <EOL> __builtin__ . help = _Helper ( ) <EOL> def aliasmbcs ( ) : <EOL> """<STR_LIT>""" <EOL> if sys . platform == '<STR_LIT:win32>' : <EOL> import locale , codecs <EOL> enc = locale . getdefaultlocale ( ) [ <NUM_LIT:1> ] <EOL> if enc . startswith ( '<STR_LIT>' ) : <EOL> try : <EOL> codecs . lookup ( enc ) <EOL> except LookupError : <EOL> import encodings <EOL> encodings . _cache [ enc ] = encodings . _unknown <EOL> encodings . aliases . aliases [ enc ] = '<STR_LIT>' <EOL> def setencoding ( ) : <EOL> """<STR_LIT>""" <EOL> encoding = "<STR_LIT:ascii>" <EOL> if <NUM_LIT:0> : <EOL> import locale <EOL> loc = locale . getdefaultlocale ( ) <EOL> if loc [ <NUM_LIT:1> ] : <EOL> encoding = loc [ <NUM_LIT:1> ] <EOL> if <NUM_LIT:0> : <EOL> encoding = "<STR_LIT>" <EOL> if encoding != "<STR_LIT:ascii>" : <EOL> sys . setdefaultencoding ( encoding ) <EOL> def execsitecustomize ( ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> import sitecustomize <EOL> except ImportError : <EOL> pass <EOL> except Exception : <EOL> if sys . flags . verbose : <EOL> sys . excepthook ( * sys . exc_info ( ) ) <EOL> else : <EOL> print >> sys . stderr , "<STR_LIT>" <EOL> def execusercustomize ( ) : <EOL> """<STR_LIT>""" <EOL> try : <EOL> import usercustomize <EOL> except ImportError : <EOL> pass <EOL> except Exception : <EOL> if sys . flags . verbose : <EOL> sys . excepthook ( * sys . exc_info ( ) ) <EOL> else : <EOL> print >> sys . stderr , "<STR_LIT>" <EOL> def main ( ) : <EOL> global ENABLE_USER_SITE <EOL> abs__file__ ( ) <EOL> known_paths = removeduppaths ( ) <EOL> if ENABLE_USER_SITE is None : <EOL> ENABLE_USER_SITE = check_enableusersite ( ) <EOL> known_paths = addusersitepackages ( known_paths ) <EOL> known_paths = addsitepackages ( known_paths ) <EOL> if sys . platform == '<STR_LIT>' : <EOL> setBEGINLIBPATH ( ) <EOL> setquit ( ) <EOL> setcopyright ( ) <EOL> sethelper ( ) <EOL> aliasmbcs ( ) <EOL> setencoding ( ) <EOL> execsitecustomize ( ) <EOL> if ENABLE_USER_SITE : <EOL> execusercustomize ( ) <EOL> if hasattr ( sys , "<STR_LIT>" ) : <EOL> del sys . setdefaultencoding <EOL> main ( ) <EOL> def _script ( ) : <EOL> help = """<STR_LIT>""" <EOL> args = sys . argv [ <NUM_LIT:1> : ] <EOL> if not args : <EOL> print "<STR_LIT>" <EOL> for dir in sys . path : <EOL> print "<STR_LIT>" % ( dir , ) <EOL> print "<STR_LIT:]>" <EOL> print "<STR_LIT>" % ( USER_BASE , <EOL> "<STR_LIT>" if os . path . isdir ( USER_BASE ) else "<STR_LIT>" ) <EOL> print "<STR_LIT>" % ( USER_SITE , <EOL> "<STR_LIT>" if os . path . isdir ( USER_SITE ) else "<STR_LIT>" ) <EOL> print "<STR_LIT>" % ENABLE_USER_SITE <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> buffer = [ ] <EOL> if '<STR_LIT>' in args : <EOL> buffer . append ( USER_BASE ) <EOL> if '<STR_LIT>' in args : <EOL> buffer . append ( USER_SITE ) <EOL> if buffer : <EOL> print os . pathsep . join ( buffer ) <EOL> if ENABLE_USER_SITE : <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> elif ENABLE_USER_SITE is False : <EOL> sys . exit ( <NUM_LIT:1> ) <EOL> elif ENABLE_USER_SITE is None : <EOL> sys . exit ( <NUM_LIT:2> ) <EOL> else : <EOL> sys . exit ( <NUM_LIT:3> ) <EOL> else : <EOL> import textwrap <EOL> print textwrap . dedent ( help % ( sys . argv [ <NUM_LIT:0> ] , os . pathsep ) ) <EOL> sys . exit ( <NUM_LIT:10> ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> _script ( ) </s>
