ž «’f:Qc @s›dZddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z ddl m Z ddlmZdd „Zd d „Zd d „Zdadd„Zdd„Zddd„Zdaaadd„Zdd„Zddddd„Zdd„Zddddddddd„Zd d!„Zdddd"d#„Z ddddd$d%„Z!Gd&d'„d'ƒZ"dS((uudistutils.util Miscellaneous utility functions -- anything that doesn't fit into one of the other *util.py modules. iN(uDistutilsPlatformError(unewer(uspawn(ulog(uDistutilsByteCompileErrorcCsętjdkr™d}tjj|ƒ}|d*kr:tjStjjd|ƒ}tj|t|ƒ|…jƒ}|dkr‚dS|dkr’dStjSd tjkr³tjd Stjd ksŅt td ƒ rŁtjStj ƒ\}}}}}|jƒj d d ƒ}|j ddƒ}|j d dƒ}|dd…dkrTd||fS|dd…dkr×|ddkrÕd}dt |dƒd|dd…f}idd6dd6} |d | tj 7}qÕnž|dd!…d"krūd||fS|dd…d#kr"d$|||fS|dd%…d&krzd&}tjd'tjƒ} | j|ƒ} | rÕ| jƒ}qÕn[|dd%…d(krÕddl} ddl} | j| jjƒ|||ƒ\}}}nd)|||fS(+u«Return a string that identifies the current platform. This is used mainly to distinguish platform-specific build directories and platform-specific built distributions. Typically includes the OS name and version and the architecture (as supplied by 'os.uname()'), although the exact information included depends on the OS; eg. for IRIX the architecture isn't particularly important (IRIX only runs on SGI hardware), but for Linux the kernel version isn't particularly important. Examples of returned values: linux-i586 linux-alpha (?) solaris-2.6-sun4u irix-5.3 irix64-6.2 Windows will return one of: win-amd64 (64bit Windows on AMD64 (aka x86_64, Intel64, EM64T, etc) win-ia64 (64bit Windows on Itanium) win32 (all others - specifically, sys.platform is returned) For other non-POSIX platforms, currently just returns 'sys.platform'. untu bit (iu)uamd64u win-amd64uitaniumuwin-ia64u_PYTHON_HOST_PLATFORMuposixuunameu/uu u_u-Niulinuxu%s-%susunosiu5usolarisu%d.%siiu32biti’’’u64bitl’’’’u.%siuirixuaixu%s-%s.%siucygwinu[\d.]+udarwinu%s-%s-%si’’’’(uosunameusysuversionufinduplatformulenuloweruenvironuhasattruunameureplaceuintumaxsizeureucompileuASCIIumatchugroupu _osx_supportudistutils.sysconfiguget_platform_osxu sysconfiguget_config_vars(uprefixuiujulookuosnameuhostureleaseuversionumachineubitnessurel_reumu _osx_supportu distutils((u3/opt/alt/python33/lib64/python3.3/distutils/util.pyu get_platformsX #   ( u get_platformcCsÆtjdkr|S|s|S|ddkr@td|ƒ‚n|ddkrctd|ƒ‚n|jdƒ}xd|kr‘|jdƒquW|sŸtjStjj|ŒS(uĪReturn 'pathname' as a name that will work on the native filesystem, i.e. split it on '/' and put it back together again using the current directory separator. Needed because filenames in the setup script are always supplied in Unix style, and have to be converted to the local convention before we can actually use them in the filesystem. Raises ValueError on non-Unix-ish systems if 'pathname' either starts or ends with a slash. u/iupath '%s' cannot be absoluteiupath '%s' cannot end with '/'u.i’’’’(uosusepu ValueErrorusplituremoveucurdirupathujoin(upathnameupaths((u3/opt/alt/python33/lib64/python3.3/distutils/util.pyu convert_pathos u convert_pathcCs(tjdkrTtjj|ƒs4tjj||ƒStjj||dd…ƒSnŠtjdkr±tjj|ƒ\}}|ddkrž|dd…}ntjj||ƒStjdkrtjj|ƒ\}}|dtjkrž|dd…}ntjj||ƒStdtjƒ‚dS( u Return 'pathname' with 'new_root' prepended. If 'pathname' is relative, this is equivalent to "os.path.join(new_root,pathname)". Otherwise, it requires making 'pathname' relative and then joining the two, which is tricky on DOS/Windows and Mac OS. uposixiNuntiu\uos2u!nothing known about platform '%s'(uosunameupathuisabsujoinu splitdriveusepuDistutilsPlatformError(unew_rootupathnameudriveupath((u3/opt/alt/python33/lib64/python3.3/distutils/util.pyu change_root‹s u change_rootcCsƒtr dStjdkrWdtjkrWddl}|jtjƒƒdtjd._substu\$([a-zA-Z_][a-zA-Z_0-9]*)uinvalid variable '$%s'N(u check_environureusubuKeyErroru ValueError(usu local_varsu_substuvar((u3/opt/alt/python33/lib64/python3.3/distutils/util.pyu subst_vars¾s u subst_varsuerror: cCs|t|ƒS(N(ustr(uexcuprefix((u3/opt/alt/python33/lib64/python3.3/distutils/util.pyugrok_environment_error×sugrok_environment_errorcCs8tjdtjƒatjdƒatjdƒadS(Nu [^\\\'\"%s ]*u'(?:[^'\\]|\\.)*'u"(?:[^"\\]|\\.)*"(ureucompileustringu whitespaceu _wordchars_reu _squote_reu _dquote_re(((u3/opt/alt/python33/lib64/python3.3/distutils/util.pyu _init_regexąsu _init_regexcCs tdkrtƒn|jƒ}g}d}x×|rtj||ƒ}|jƒ}|t|ƒkr‚|j|d|…ƒPn||tj krĖ|j|d|…ƒ||d…j ƒ}d}n||dkr |d|…||dd…}|d}n×||dkr/t j||ƒ}n9||dkrTt j||ƒ}nt d||ƒ‚|dkr‹td||ƒ‚n|jƒ\}}|d|…||d|d…||d…}|jƒd }|t|ƒkr1|j|ƒPq1q1W|S( uSplit a string up according to Unix shell-like rules for quotes and backslashes. In short: words are delimited by spaces, as long as those spaces are not escaped by a backslash, or inside a quoted string. Single and double quotes are equivalent, and the quote characters can be backslash-escaped. The backslash is stripped from any two-character escape sequence, leaving only the escaped character. The quote characters are stripped from any quoted string. Returns a list of words. iNu\iu'u"u!this can't happen (bad char '%c')u"bad string (mismatched %s quotes?)i(u _wordchars_reuNoneu _init_regexustripumatchuendulenuappendustringu whitespaceulstripu _squote_reu _dquote_reu RuntimeErroru ValueErroruspan(usuwordsuposumuendubeg((u3/opt/alt/python33/lib64/python3.3/distutils/util.pyu split_quotedęs@     "  4 u split_quotedcCss|dkrOd|j|f}|dd…dkrO|dd…d}qOntj|ƒ|so||ŒndS( uœPerform some action that affects the outside world (eg. by writing to the filesystem). Such actions are special because they are disabled by the 'dry_run' flag. This method takes care of all that bureaucracy for you; all you have to do is supply the function to call and an argument tuple for it (to embody the "external action" being performed), and an optional message to print. u%s%riNu,)iu)iž’’’iž’’’(uNoneu__name__uloguinfo(ufuncuargsumsguverboseudry_run((u3/opt/alt/python33/lib64/python3.3/distutils/util.pyuexecute#s  uexecutecCsC|jƒ}|dkrdS|dkr,dStd|fƒ‚dS(uōConvert a string representation of truth to true (1) or false (0). True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if 'val' is anything else. uyuyesututrueuonu1iununoufufalseuoffu0iuinvalid truth value %rN(uyuyesututrueuonu1(ununoufufalseuoffu0(uloweru ValueError(uval((u3/opt/alt/python33/lib64/python3.3/distutils/util.pyu strtobool6s    u strtoboolicCstjrtdƒ‚n|dkr9to3|dk}n|sĄy&ddlm}|dƒ\} } Wn5tk rœddlm} d| dƒ} } YnXt j d| ƒ|s@| dk rŌt j | dƒ} nt | dƒ} | jdƒ| jd jtt|ƒƒd ƒ| jd |||||fƒ| jƒntj| g} |d krn| jd d ƒn|dkr| jd dƒnt| d|ƒtt j| fd| d|ƒn[ddlm}xH|D]@}|dd…dkrłq×n|dkrtj|d| ƒ}ntj|ƒ}|}|r‡|dt|ƒ…|krntd||fƒ‚n|t|ƒd…}n|r„t jj||ƒ}nt jj|ƒ}|r×|sŅt ||ƒrt j d||ƒ|s||||ƒqqt j!d||ƒq×q×WdS(uByte-compile a collection of Python source files to either .pyc or .pyo files in a __pycache__ subdirectory. 'py_files' is a list of files to compile; any files that don't end in ".py" are silently skipped. 'optimize' must be one of the following: 0 - don't optimize (generate .pyc) 1 - normal optimization (like "python -O") 2 - extra optimization (like "python -OO") If 'force' is true, all files are recompiled regardless of timestamps. The source filename encoded in each bytecode file defaults to the filenames listed in 'py_files'; you can modify these with 'prefix' and 'basedir'. 'prefix' is a string that will be stripped off of each source filename, and 'base_dir' is a directory name that will be prepended (after 'prefix' is stripped). You can supply either or both (or neither) of 'prefix' and 'base_dir', as you wish. If 'dry_run' is true, doesn't actually do anything that would affect the filesystem. Byte-compilation is either done directly in this interpreter process with the standard py_compile module, or indirectly by writing a temporary script and executing it. Normally, you should let 'byte_compile()' figure out to use direct compilation or not (see the source for details). The 'direct' flag is used by the script generated in indirect mode; unless you know what you're doing, leave it set to None. ubyte-compiling is disabled.i(umkstempu.py(umktempu$writing byte-compilation script '%s'uwu2from distutils.util import byte_compile files = [ u, u] uŒ byte_compile(files, optimize=%r, force=%r, prefix=%r, base_dir=%r, verbose=%r, dry_run=0, direct=1) iu-Oiu-OOudry_runu removing %s(ucompileiNudebug_overrideu1invalid prefix: filename %r doesn't start with %rubyte-compiling %s to %su%skipping byte-compilation of %s to %siż’’’("usysudont_write_bytecodeuDistutilsByteCompileErroruNoneu __debug__utempfileumkstempu ImportErrorumktempuloguinfouosufdopenuopenuwriteujoinumapureprucloseu executableuinsertuspawnuexecuteuremoveu py_compileucompileuimpucache_from_sourceulenu ValueErrorupathubasenameunewerudebug(upy_filesuoptimizeuforceuprefixubase_diruverboseudry_runudirectumkstempu script_fdu script_nameumktempuscriptucmducompileufileucfileudfileu cfile_base((u3/opt/alt/python33/lib64/python3.3/distutils/util.pyu byte_compileFsj"    #       u byte_compilecCs"|jdƒ}d}|j|ƒS(uŒReturn a version of the string escaped for inclusion in an RFC-822 header, by ensuring there are 8 spaces space after each newline. u iu u u (usplitujoin(uheaderulinesusep((u3/opt/alt/python33/lib64/python3.3/distutils/util.pyu rfc822_escape×su rfc822_escapecCsz|s dSddlm}m}Gdd„d|ƒ}|dkrQ|dƒ}n||d|ƒ}|j|dd ƒdS( u Invoke 2to3 on a list of Python files. The files should all come from the build area, as the modification is done in-place. To reduce the build time, only files modified since the last invocation of this function should be passed in the files argument.Ni(uRefactoringTooluget_fixers_from_packagecBs8|EeZdZdd„Zdd„Zdd„ZdS(u*run_2to3..DistutilsRefactoringToolc_stj||ŒdS(N(uloguerror(uselfumsguargsukw((u3/opt/alt/python33/lib64/python3.3/distutils/util.pyu log_errorīsu4run_2to3..DistutilsRefactoringTool.log_errorcWstj||ŒdS(N(uloguinfo(uselfumsguargs((u3/opt/alt/python33/lib64/python3.3/distutils/util.pyu log_messageńsu6run_2to3..DistutilsRefactoringTool.log_messagecWstj||ŒdS(N(ulogudebug(uselfumsguargs((u3/opt/alt/python33/lib64/python3.3/distutils/util.pyu log_debugōsu4run_2to3..DistutilsRefactoringTool.log_debugN(u__name__u __module__u __qualname__u log_erroru log_messageu log_debug(u __locals__((u3/opt/alt/python33/lib64/python3.3/distutils/util.pyuDistutilsRefactoringToolķs  uDistutilsRefactoringToolu lib2to3.fixesuoptionsuwriteT(ulib2to3.refactoruRefactoringTooluget_fixers_from_packageuNoneurefactoruTrue(ufilesu fixer_namesuoptionsuexplicituRefactoringTooluget_fixers_from_packageuDistutilsRefactoringToolur((u3/opt/alt/python33/lib64/python3.3/distutils/util.pyurun_2to3įs urun_2to3cCs|ddlm}ddlm}ddlm}|ƒ} tjƒ} tj|ƒz| j ƒWdtj| ƒX| j | j dd…<|rĢx<|j ƒD]+} | j ƒ} | søqšn| j| ƒqšWng} xz| j D]o} tjj|| ƒ}|tjj|ƒƒ|tjj|| ƒ|ddƒ}|drÜ| j|ƒqÜqÜWtdd „| Dƒd |d |d |ƒ| S( uĻRecursively copy a directory, only copying new and changed files, running run_2to3 over all newly copied Python modules afterward. If you give a template string, it's parsed like a MANIFEST.in. i(umkpath(u copy_file(uFileListNuupdateicSs+g|]!}|jƒjdƒr|‘qS(u.py(uloweruendswith(u.0ufn((u3/opt/alt/python33/lib64/python3.3/distutils/util.pyu s u$copydir_run_2to3..u fixer_namesuoptionsuexplicit(udistutils.dir_utilumkpathudistutils.file_utilu copy_fileudistutils.filelistuFileListuosugetcwduchdirufindalluallfilesufilesu splitlinesustripuprocess_template_lineupathujoinudirnameuappendurun_2to3(usrcudestutemplateu fixer_namesuoptionsuexplicitumkpathu copy_fileuFileListufilelistucurdirulineucopiedufilenameuoutnameures((u3/opt/alt/python33/lib64/python3.3/distutils/util.pyucopydir_run_2to3üs4    $ ucopydir_run_2to3cBs8|EeZdZdZdZdZdZdd„ZdS(u Mixin2to3uĄMixin class for commands that run 2to3. To configure 2to3, setup scripts may either change the class variables, or inherit from individual commands to override how 2to3 is invoked.cCst||j|j|jƒS(N(urun_2to3u fixer_namesuoptionsuexplicit(uselfufiles((u3/opt/alt/python33/lib64/python3.3/distutils/util.pyurun_2to3-suMixin2to3.run_2to3N( u__name__u __module__u __qualname__u__doc__uNoneu fixer_namesuoptionsuexpliciturun_2to3(u __locals__((u3/opt/alt/python33/lib64/python3.3/distutils/util.pyu Mixin2to3s u Mixin2to3(#u__doc__uosureuimpusysustringudistutils.errorsuDistutilsPlatformErrorudistutils.dep_utilunewerudistutils.spawnuspawnu distutilsuloguDistutilsByteCompileErroru get_platformu convert_pathu change_rootu_environ_checkedu check_environu subst_varsugrok_environment_erroruNoneu _wordchars_reu _squote_reu _dquote_reu _init_regexu split_quoteduexecuteu strtoboolu byte_compileu rfc822_escapeurun_2to3ucopydir_run_2to3u Mixin2to3(((u3/opt/alt/python33/lib64/python3.3/distutils/util.pyus>      ]      = 