3 \5Q@sddlZddlZddlZddlZddlZddlmZddlm Z ddl m Z ddl m Z ddlmZddZd d Zd d Zdad dZddZd'ddZdaaaddZddZd(ddZddZd)ddZdd Zd*d!d"Zd+d#d$Z Gd%d&d&Z!dS),N)DistutilsPlatformError)newer)spawn)log)DistutilsByteCompileErrorcCstjdkrnd}tjj|}|d(kr(tjStjjd|}tj|t||j}|dkr\dS|dkrhdStjSd tjkrtjd Stjd kst td  rtjStj \}}}}}|jj d d }|j dd}|j d d}|dddkrd||fS|dddkrV|ddkrd}dt |dd|ddf}ddd} |d| tj 7}n|ddd krtd||fS|ddd!krd"|||fS|dd#d$krd$}tjd%tj} | j|} | r| j}n>|dd#d&krddl} ddl} | j| jj|||\}}}d'|||fS))Nntz bit ()amd64z win-amd64itaniumzwin-ia64_PYTHON_HOST_PLATFORMposixuname/ _-linuxz%s-%ssunosr5solarisz%d.%s32bit64bit)ilz.%sirixaixz%s-%s.%scygwinz[\d.]+darwinz%s-%s-%s)osnamesysversionfindplatformlenlowerenvironhasattrrreplaceintmaxsizerecompileASCIImatchgroup _osx_supportZdistutils.sysconfigget_platform_osx sysconfigget_config_vars)prefixijlookosnamehostreleaser'machinebitnessrel_remr6 distutilsrF&/usr/lib64/python3.6/distutils/util.py get_platformsX            rHcCs~tjdkr|S|s|S|ddkr.td||ddkrFtd||jd}xd|krf|jdqRW|srtjStjj|S)Nrrzpath '%s' cannot be absoluterzpath '%s' cannot end with '/'.r#)r$sep ValueErrorsplitremovecurdirpathjoin)pathnamepathsrFrFrG convert_pathos       rScCstjdkr._substz\$([a-zA-Z_][a-zA-Z_0-9]*)zinvalid variable '$%s')r]r1subKeyErrorrK)sr_r`varrFrFrG subst_varss  reerror: cCs |t|S)N)r^)excr:rFrFrGgrok_environment_errorsrhcCs(tjdtjatjdatjdadS)Nz [^\\\'\"%s ]*z'(?:[^'\\]|\\.)*'z"(?:[^"\\]|\\.)*")r1r2string whitespace _wordchars_re _squote_re _dquote_rerFrFrFrG _init_regexs rncCstdkrt|j}g}d}x`|rtj||}|j}|t|kr\|j|d|P||tjkr|j|d|||dj }d}n||dkr|d|||dd}|d}n||dkrt j||}n*||dkrt j||}nt d|||dkr"t d|||j\}}|d|||d|d||d}|jd}|t|kr"|j|Pq"W|S) NrrTr'"z!this can't happen (bad char '%c')z"bad string (mismatched %s quotes?)r)rkrnstripr4endr*appendrirjlstriprlrm RuntimeErrorrKspan)rcZwordsposrDrrZbegrFrFrG split_quoteds@         ,   rxcCsP|dkr6d|j|f}|dddkr6|ddd}tj||sL||dS)Nz%s%rrz,)rr ry)__name__rinfo)funcargsmsgverbosedry_runrFrFrGexecutes  rcCs2|j}|dkrdS|dkr dStd|fdS)Nyyesttrueon1rnnoffalseoff0rzinvalid truth value %r)rrrrrr)rrrrrr)r+rK)valrFrFrG strtobool0s rrcCsTddl}tjrtd|dkr*do(|dk}|s8yddlm} | d\} } Wn.tk rzddlm} d| d} } YnXtj d| |s| dk rt j | d} n t | d} | j d | j d jtt|d | j d |||||f| jtjg}|j|j|j| t||d tt j| fd| |d nddlm}x|D]}|dddkrhqL|dkr|dkrdn|}tjj||d}n tjj|}|}|r|dt||krtd||f|t|d}|rt j j||}t j j!|}|rL|st"||r.DistutilsRefactoringToolc_stj|f|dS)N)rerror)selfr~r}kwrFrFrG log_errorsz4run_2to3..DistutilsRefactoringTool.log_errorcWstj|f|dS)N)rr{)rr~r}rFrFrG log_messagesz6run_2to3..DistutilsRefactoringTool.log_messagecWstj|f|dS)N)rr)rr~r}rFrFrG log_debugsz4run_2to3..DistutilsRefactoringTool.log_debugN)rz __module__ __qualname__rrrrFrFrFrGDistutilsRefactoringToolsrz lib2to3.fixes)optionsT)r)Zlib2to3.refactorrrZrefactor)files fixer_namesrexplicitrrrrrFrFrGrun_2to3s  rcCsddlm}ddlm}ddlm}|} tj} tj|z | j Wdtj| X| j | j dd<|rx(|j D]} | j } | sqt| j| qtWg} xV| j D]L} tjj|| }|tjj||tjj|| |dd}|dr| j|qWtdd| D|||d | S) Nr)mkpath) copy_file)FileListr)updatecSsg|]}|jjdr|qS)z.py)r+endswith).0fnrFrFrG sz$copydir_run_2to3..)rrr)Zdistutils.dir_utilrZdistutils.file_utilrZdistutils.filelistrr$getcwdchdirfindallZallfilesr splitlinesrqZprocess_template_linerOrPdirnamersr)srcdesttemplaterrrrrrZfilelistrNlineZcopiedfilenameZoutnameresrFrFrGcopydir_run_2to3s4        rc@s eZdZdZdZdZddZdS) Mixin2to3NcCst||j|j|jS)N)rrrr)rrrFrFrGr,szMixin2to3.run_2to3)rzrrrrrrrFrFrFrGrsr)rf)Nrr)rrNNrrN)NNN)NNNN)"r$r1importlib.utilrrir&Zdistutils.errorsrZdistutils.dep_utilrZdistutils.spawnrrErrrHrSrWrYr]rerhrkrlrmrnrxrrrrrrrrFrFrFrGs>     ]  =