*{a3dZddlZddlZddlZddlZddlZddlZddlmZddl m Z ddl m Z ej eZeejee jee jzee jzee jzZgdZGddZd Zd Zd ZGd d eZeZddZ dZ!dZ"GddeZ#GddeZ$e Z%dS)a' past.translation ================== The ``past.translation`` package provides an import hook for Python 3 which transparently runs ``futurize`` fixers over Python 2 code on import to convert print statements into functions, etc. It is intended to assist users in migrating to Python 3.x even if some dependencies still only support Python 2.x. Usage ----- Once your Py2 package is installed in the usual module search path, the import hook is invoked as follows: >>> from past.translation import autotranslate >>> autotranslate('mypackagename') Or: >>> autotranslate(['mypackage1', 'mypackage2']) You can unregister the hook using:: >>> from past.translation import remove_hooks >>> remove_hooks() Author: Ed Schofield. Inspired by and based on ``uprefix`` by Vinay M. Sajip. N) ParseError)RefactoringTool)fixes)#zlib2to3.fixes.fix_applyzlib2to3.fixes.fix_exceptzlib2to3.fixes.fix_execfilezlib2to3.fixes.fix_exitfunczlib2to3.fixes.fix_funcattrszlib2to3.fixes.fix_filterzlib2to3.fixes.fix_has_keyzlib2to3.fixes.fix_idiomszlib2to3.fixes.fix_importzlib2to3.fixes.fix_internzlib2to3.fixes.fix_isinstancezlib2to3.fixes.fix_methodattrszlib2to3.fixes.fix_nezlib2to3.fixes.fix_numliteralszlib2to3.fixes.fix_parenzlib2to3.fixes.fix_printzlib2to3.fixes.fix_raisezlib2to3.fixes.fix_renameszlib2to3.fixes.fix_reducezlib2to3.fixes.fix_reprzlib2to3.fixes.fix_standarderrorzlib2to3.fixes.fix_sys_exczlib2to3.fixes.fix_throwzlib2to3.fixes.fix_tuple_paramszlib2to3.fixes.fix_typeszlib2to3.fixes.fix_ws_commazlib2to3.fixes.fix_xreadlineszlib2to3.fixes.fix_basestringzlib2to3.fixes.fix_execzlib2to3.fixes.fix_getcwduzlib2to3.fixes.fix_longzlib2to3.fixes.fix_nextzlib2to3.fixes.fix_nonzerozlib2to3.fixes.fix_raw_inputzlib2to3.fixes.fix_xrangecNeZdZdZdZdZdZdZedZ edZ dS)RTsa& A namespace for the refactoring tools. This avoids creating these at the module level, which slows down the module import. (See issue #117). There are two possible grammars: with or without the print statement. Hence we have two possible refactoring tool implementations. NcdtjtjfvrAttt_ttddit_dSdSzj Call this before using the refactoring tools to create them on demand if needed. Nprint_functionT)r_rt_rtprmyfixesk/builddir/build/BUILD/cloudlinux-venv-1.0.10/venv/lib/python3.11/site-packages/past/translation/__init__.pysetupz RTs.setupsJ CGSX& & &%g..CG&w1A40HIICHHH ' &rcdtjtjfvrAttt_ttddit_dSdSr )r_rt_py2_detect_rtp_py2_detectrpy2_detect_fixersrrrsetup_detect_python2zRTs.setup_detect_python2sX C&(;< < > x''99: T3B3 299(CCDDDt 299(CCDDDus < B7BBc<eZdZdZdZdZdZdZd dZdZ d Z dS) Py2Fixerzi An import hook class that uses lib2to3 for source-to-source translation of Py2 code to Py3. Tcpd|_ddg|_tj|j|_g|_dS)Nfuturepast)foundbase_exclude_pathscopy exclude_paths include_pathsselfs r__init__zPy2Fixer.__init__s9 #+V"4!Yt'>??rc&|xj|z c_dS)z Pass in a sequence of module names such as 'plotrique.plotting' that, if present at the leftmost side of the full package name, would specify the module to be transformed from Py2 to Py3. N)rJrLpathss rincludezPy2Fixer.include e#rc&|xj|z c_dS)z Pass in a sequence of strings such as 'mymodule' that, if present at the leftmost side of the full package name, would cause the module not to undergo any source transformation. N)rIrOs rexcludezPy2Fixer.excluderRrNctd|d|vrO|dd\}}|2|||}||}|j}|} tj|||_n`#t$rS}tdtd||Yd}~dSd}~wwxYw|jdd|_ |j tj kr1tj |jdd|_n'|j tjkr|jd|_|S)NzRunning find_module: {0}....rzPy2Fixer could not find {0}zException was: {0})r4z __init__.py)r9r:r;rsplit find_module load_module__path__imprF Exceptionkind PKG_DIRECTORYrrr(r= PY_SOURCE)rLfullnamerparentchildloadermodr?s rrXzPy2Fixer.find_modules\ 299(CCDDD (??$OOC33MFE|))&$77((00|H  488DJJ    LL6 7 7 7 LL.55hBB C C C44444 JrN2& 9) ) )GLLA FFDMM Y#- ' ' JqMDM sB C:'AC55C:c`t|dz } tj||j}nS#t $rF}|jdks |jdkrtj||j}Yd}~nd}~wwxYwt|ddS)N r2r3r4) rrr r5r=rr6r7r r8)rLr<r>r?s r transformzPy2Fixer.transforms $ C7**64=AADD C C Cu ##qw#~~8++FDMBBDDDDDD C 4yy"~s%A Bz(Py2Fixer.load_module..@'OOODh))$//OOOrc:g|]}|Srrjrls rrnz(Py2Fixer.load_module..BrorTzExcluded {0} from translationzAutoconverting {0} ...rVrrbexecwb).r9r:r;sysmodulesr]r[ PY_COMPILED C_EXTENSION C_BUILTIN PY_FROZENanyrIrJrYrF new_moduler=__file__r __loader__r^rrdirnamerZ __package__ rpartitioncache_from_sourceexistsstatst_mtimeopenreadmarshalloadsr\r@rgcompilemakedirsdumpswriterr__dict__close)rLr`rdconvert cachename update_cache sourcetime cachetimefdatacoder<r~r?s ` rrYzPy2Fixer.load_module1s 5<&>q&ACO+ # 5dm D DI7>>)44>'+ %'WT]%;%;%D $&GI$6$6$? '0:'= (4!)T224a#$6688D4'.}T':':#,444/3 4 444444444444444$!:a=2%)Z]%7%7%9%9FF!Y#*;;;!%dm!4!42)*222222222222222*&$-@@<%)^^F%;%;F&vt}fEE"$'//)"<"<!#%7>>'#:#:5 " G 4 4 4!%i!6!6.!'.}T':': ! ............... )!!! D!s|,,,,  H- :a= " JqM   ! ! ! s2B Q <KJ'&K' J63K5J66K9 Q K  Q K  AQ )M > Q MQ MA"Q 5AP:8*P." P:.P22P:5P26P:9Q : QQ QQ Q=*Q88Q=N) rrrrPY2FIXERrMrQrTrXrgrYrrrrBrBsH   $$$$$$4$dddddrrBrct|tr|f}t|tr|f}t|t|zdks Jdt|t|t jddk}|r:tt jvr)t j dtdSdSdS)NrzPass at least one argument) isinstancer8len_hookrQrTrt version_info meta_pathr!)rJrIenables r install_hooksrs-%%)&( -%%)&( }  M 2 2 2Q 6 6 68T 6 6 6 MM-    MM-    a A %F '%s},, Q&&&&&'',,rcxttjvr&tjtdSdSr)rrtrremoverrr remove_hooksrs3   U#####rc(ttjvS)zG Returns True if the import hooks are installed, False if not. )rrtrrrr detect_hooksrs CM !!rceZdZdZdZdZdS)hooksz Acts as a context manager. Use like this: >>> from past import translation >>> with translation.hooks(): ... import mypy2module >>> import requests # py2/3 compatible anyway >>> # etc. cHt|_t|Sr)rhooks_were_installedrrKs r __enter__zhooks.__enter__s$0NN! rc4|jstdSdSr)rrrLargss r__exit__zhooks.__exit__s$(  NNNNN  rNrrrrrrrrrrrs< rrceZdZdZdZdZdS) suspend_hooksax Acts as a context manager. Use like this: >>> from past import translation >>> translation.install_hooks() >>> import http.client >>> # ... >>> with translation.suspend_hooks(): >>> import requests # or others that support Py2/3 If the hooks were disabled before the context, they are not installed when the context is left. cHt|_t|Sr)rrrrKs rrzsuspend_hooks.__enter__s$0NN! rc4|jrtdSdSr)rrrs rrzsuspend_hooks.__exit__s$  $  OOOOO  rNrrrrrrs<  rr)rr)&rr[loggingrrrtrHlib2to3.pgen2.parserlib2to3.refactorr libfuturizer getLoggerrr9setLevelDEBUGlistlibfuturize_fix_names_stage1lib2to3_fix_names_stage1libfuturize_fix_names_stage2lib2to3_fix_names_stage2r rrr$r0r@objectrBrrrrrr autotranslaterrrrs;B  ******,,,,,,  8 $ $  42 3 3 4. / / 0 42 3 3 4 4. / / 0888v!L!L!L!L!L!L!L!Lj& ! ! !"*qqqqqvqqqf   ' ' ' '"$$$ """F(F0 r