"9QRc@sydZddlZddlZddlZddlZejejgZda da da dZ dZ dZdZdZdZdd Zd Zd Zd Zd ZdZdZdZdZdefdYZdZdefdYZdZdZ dZ!dZ"dZ#dZ$e$dZ%e&dkrue%ndS(sN Append module search paths for third-party packages to sys.path. **************************************************************** * This module is automatically imported during initialization. * **************************************************************** In earlier versions of Python (up to 1.5a3), scripts or modules that needed to use site-specific modules would place ``import site'' somewhere near the top of their code. Because of the automatic import, this is no longer necessary (but code that does it still works). This will append site-specific paths to the module search path. On Unix (including Mac OSX), it starts with sys.prefix and sys.exec_prefix (if different) and appends lib/python/site-packages as well as lib/site-python. On other platforms (such as Windows), it tries each of the prefixes directly, as well as with lib/site-packages appended. The resulting directories, if they exist, are appended to sys.path, and also inspected for path configuration files. A path configuration file is a file whose name has the form .pth; its contents are additional directories (one per line) to be added to sys.path. Non-existing directories (or non-directories) are never added to sys.path; no directory is added to sys.path more than once. Blank lines and lines beginning with '#' are skipped. Lines starting with 'import' are executed. For example, suppose sys.prefix and sys.exec_prefix are set to /usr/local and there is a directory /usr/local/lib/python2.5/site-packages with three subdirectories, foo, bar and spam, and two path configuration files, foo.pth and bar.pth. Assume foo.pth contains the following: # foo package configuration foo bar bletch and bar.pth contains: # bar package configuration bar Then the following directories are added to sys.path, in this order: /usr/local/lib/python2.5/site-packages/bar /usr/local/lib/python2.5/site-packages/foo Note that bletch is omitted because it doesn't exist; bar precedes foo because bar.pth comes alphabetically before foo.pth; and spam is omitted because it is not mentioned in either path configuration file. After these path manipulations, an attempt is made to import a module named sitecustomize, which can perform arbitrary additional site-specific customizations. If this import fails with an ImportError exception, it is silently ignored. iNcGsRtjj|}ytjj|}Wntk r;nX|tjj|fS(N(tostpathtjointabspathtOSErrortnormcase(tpathstdir((sE/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/site.pytmakepathOs  cCsixbtjjD]Q}t|dr+qnytjj|j|_Wqtt fk r`qXqWdS(s6Set all module' __file__ attribute to an absolute patht __loader__N( tsystmodulestvaluesthasattrRRRt__file__tAttributeErrorR(tm((sE/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/site.pyt abs__file__XscCslg}t}xLtjD]A}t|\}}||kr|j||j|qqW|tj(|S(sK Remove duplicate entries from sys.path along with making them absolute(tsetR RRtappendtadd(tLt known_pathsRtdircase((sE/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/site.pytremoveduppathscs    cCsddlm}d|tjf}ttdrB|d7}ntjjtjjtjj |}tjj |dS(sbAppend ./build/lib. in case we're running in the build dir (especially for Guido :-)i(t get_platformsbuild/lib.%s-%.3stgettotalrefcounts-pydebugN( t sysconfigRR tversionR RRRtdirnametpopR(Rts((sE/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/site.pyt addbuilddirws  *cCspt}x`tjD]U}y8tjj|rPt|\}}|j|nWqtk rgqqXqW|S(sDReturn a set containing all existing directory entries from sys.path(RR RRtisdirRRt TypeError(tdRR((sE/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/site.pyt_init_pathinfos   c Bs|dkred}nd}ejj||}ye|d}Wnek r^dSX|@x8e|D]*\}}|jdrqsny|jd r|dUwsn|j }e ||\}} | |krejj |re jj ||j| nWqsek r} e jdj|d|IJxEeje jD].} x%| jD]}e jd |IJqlWqYWe jd IJPqsXqsWWdQX|rd}n|S( sProcess a .pth file within the site-packages directory: For each line in the file, either combine it with sitedir to a path and add that to known_paths, or execute it if it starts with 'import '. iitrUNt#simport simport s"Error processing line {:d} of {}: s s Remainder of file ignored(simport simport (tNoneR$RRRtopentIOErrort enumeratet startswithtrstripRtexistsR RRt Exceptiontstderrtformatt tracebacktformat_exceptiontexc_infot splitlines( tsitedirtnameRtresettfullnametftntlineRRterrtrecord((sE/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/site.pyt addpackagesB       cCs|dkrt}d}nd}t|\}}||krUtjj|nytj|}Wntjk rdSXtj d}g|D]}|j |r|^q}x$t |D]}t |||qW|rd}n|S(sTAdd 'sitedir' argument to sys.path if missing and handle .pth files in 'sitedir'iiNtpth( R'R$RR RRRtlistdirterrortextseptendswithtsortedR>(R5RR7t sitedircasetnamestdotpthR6((sE/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/site.pyt addsitedirs$     ( cCstjjrtSttdrMttdrMtjtjkrMdSnttdrttdrtj tj krdSnt S(s,Check if user site directory is safe for inclusion The function tests for the command line flag (including environment var), process uid/gid equal to effective uid/gid. None: Disabled for security reasons False: Disabled by user (command line option) True: Safe and enabled tgetuidtgeteuidtgetgidtgetegidN( R tflagst no_user_sitetFalseR RRJRIR'RLRKtTrue(((sE/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/site.pytcheck_enableusersites cCs0tdk rtSddlm}|datS(sReturns the `user base` directory path. The `user base` directory can be used to store data. If the global variable ``USER_BASE`` is not initialized yet, this function will also set it. i(tget_config_vartuserbaseN(t USER_BASER'RRR(RR((sE/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/site.pyt getuserbases   cCst}tdk rtSddlm}ddl}tjdkrvddlm}|drv|ddatSn|dd |j atS( sReturns the user-specific site-packages directory path. If the global variable ``USER_SITE`` is not initialized yet, this function will also set it. i(tget_pathNtdarwin(RRtPYTHONFRAMEWORKtpurelibtosx_framework_users%s_user( RUt USER_SITER'RRVRR tplatformRRR6(t user_baseRVRRR((sE/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/site.pytgetusersitepackagess    cCs5t}tr1tjj|r1t||n|S(sAdd a per user site-package to sys.path Each user has its own python directory with site-packages in the home directory. (R^tENABLE_USER_SITERRR!RH(Rt user_site((sE/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/site.pytaddusersitepackagess c Csg}t}xtD]}| s||kr5qn|j|tjdkrs|jtjj|ddntj dkrG|jtjj|tj dtj d dtj dkr|jtjj|ddtj d dn|jtjj|tj d tj dkrv|jtjj|dd qvn/|j||jtjj|tj dtjd krd d l m }|d }|r|jtjjd|tj d dqqqW|S(s+Returns a list containing all global site-packages directories (and possibly site-python). For each directory present in the global ``PREFIXES``, this function will find its `site-packages` subdirectory depending on the system environment, and will return a list of full paths. tos2emxtriscostLibs site-packagest/tpythonitlibs site-pythonRWi(RRRXs/Library(sos2emxsriscos(RtPREFIXESRR R\RRRRtsepRgRRRR(t sitepackagestseentprefixRRt framework((sE/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/site.pytgetsitepackagess:   "  "% " cCs:x3tD](}tjj|r t||q q W|S(s8Add site-packages (and possibly site-python) to sys.path(RnRRR!RH(RR5((sE/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/site.pytaddsitepackagesGscCsotjjtjdd}tjdjd}|drK|j|n ||deZdZdZdddZdZdZdZRS(sninteractive prompt objects for printing the license text, a list of contributors and the copyright notice.icCs1||_||_||_||_d|_dS(N(t_Printer__namet_Printer__datat_Printer__filest_Printer__dirsR't_Printer__lines(RyR6tdatatfilestdirs((sE/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/site.pyRzs     cCs|jr dSd}x|jD]w}xd|jD]Y}tjj||}y*t|d}|j}|j PWq-t k rq-Xq-W|rPqqW|s|j }n|j d|_t |j|_dS(NR%s (RR'RRRRRtfiletreadR~R)RRstlent_Printer__linecnt(RyRRtfilenametfp((sE/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/site.pyt__setups&     cCsH|jt|j|jkr2dj|jSd|jfdSdS(Ns s!Type %s() to see the full %s texti(t_Printer__setupRRtMAXLINESRR(Ry((sE/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/site.pyR|s cCs|jd}d}xy1x*t|||jD]}|j|GHq3WWntk r^PqX||j7}d}x1|dkrt|}|dkrud}ququW|dkrPqqdS(Ns0Hit Return for more, or q (and Return) to quit: ittq(RR(RtrangeRRt IndexErrorR't raw_input(Rytprompttlinenotitkey((sE/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/site.pyRs"       (((RRt__doc__RRzRR|R(((sE/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/site.pyRs   cCstdtjt_tjd dkr=tddt_ntddt_tjjtj }tddtj d d gtjj |tj |tj gt_d S( s,Set 'copyright' and 'credits' in __builtin__t copyrightitjavatcreditss?Jython is maintained by the Jython developers (www.jython.org).s Thanks to CWI, CNRI, BeOpen.com, Zope Corporation and a cast of thousands for supporting Python development. See www.python.org for more information.tlicenses+See http://www.python.org/%.3s/license.htmls LICENSE.txttLICENSEN(RR RRR\RRRRRRRtpardirtcurdirR(there((sE/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/site.pyt setcopyrights   t_HelpercBs eZdZdZdZRS(sXDefine the builtin 'help'. This is a wrapper around pydoc.help (with a twist). cCsdS(NsHType help() for interactive help, or help(object) for help about object.((Ry((sE/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/site.pyR|scOsddl}|j||S(Ni(tpydocthelp(RytargstkwdsR((sE/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/site.pyRs (RRRR|R(((sE/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/site.pyRs cCstt_dS(N(RRR(((sE/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/site.pyt sethelperscCstjdkrddl}ddl}|jd}|jdry|j|Wqtk rddl}|j |j |2 - unknown error is sys.path = [s %r,t]sUSER_BASE: %r (%s)R-s doesn't existsUSER_SITE: %r (%s)sENABLE_USER_SITE: %ris --user-bases --user-siteiiii (R targvRRTRR!R[R_RRtpathsepRROR'ttextwraptdedent(RRRtbufferR((sE/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/site.pyt_script;s< !!      "t__main__('RR RRR1Rlt exec_prefixRhR'R_R[RTRRRR R$R>RHRQRUR^RaRnRoRvRRRRRRRRRRRRR(((sE/opt/poky/1.5/sysroots/x86_64-pokysdk-linux/usr/lib/python2.7/site.pyt;sH      )      +   =        1