HEX
Server: LiteSpeed
System: Linux atali.colombiahosting.com.co 5.14.0-570.12.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Tue May 13 06:11:55 EDT 2025 x86_64
User: coopserp (1713)
PHP: 8.2.29
Disabled: dl,exec,passthru,proc_open,proc_close,shell_exec,memory_limit,system,popen,curl_multi_exec,show_source,symlink,link,leak,listen,diskfreespace,tmpfile,ignore_user_abord,highlight_file,source,show_source,fpaththru,virtual,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setid,posix_times,posix_ttyname,posix_uname,proc_get_status,proc_nice,proc_terminate
Upload Files
File: //usr/local/lib/python3.9/site-packages/past/translation/__pycache__/__init__.cpython-39.pyc
a

��?hB:�@s�dZddlZejdkr ddlZnddlZddlZddlZddlZddlm	Z	ddl
mZddlm
Z
zddlmZmZWney�dZeZYn0ejdd�d	kr�ddlZe�e�Ze�ej�ee
j�ee
j�ee
j�ee
j�Zgd
�ZGdd�d�Zd
d�Z dd�Z!dd�Z"dd�Z#Gdd�de�Z$Gdd�de�Z%e%�Z&d$dd�Z'dd�Z(dd�Z)Gd d!�d!e�Z*Gd"d#�d#e�Z+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)�
PathFinder�SourceFileLoader�)r�)#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_xrangec@s8eZdZdZdZdZdZdZedd��Z	edd��Z
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.
    NcCs.dtjtjfvr*tt�t_ttddi�t_dS�zj
        Call this before using the refactoring tools to create them on demand
        if needed.
        N�print_functionT)r�_rt�_rtpr�myfixes�rr�C/usr/local/lib/python3.9/site-packages/past/translation/__init__.py�setup�s
z	RTs.setupcCs.dtjtjfvr*tt�t_ttddi�t_dSr)r�_rt_py2_detect�_rtp_py2_detectr�py2_detect_fixersrrrr�setup_detect_python2�s

�zRTs.setup_detect_python2)�__name__�
__module__�__qualname__�__doc__rrrr�staticmethodrrrrrrr�s

rcCsng}tj�|�}|d|kr0|�d|d�qjq|d|krP|�d|d�qjq|d}|�d|d�q|S)zA
    Split a path into all components. From Python Cookbook.
    r�)�os�path�split�insert)rZallparts�partsrrr�splitall�sr#cCsJg}t|�}t|�}t||�D]\}}||kr2q>|�|�qtjj|�S)z^
    Returns the longest common substring to the two strings, starting from the
    left.
    )r#�zip�appendrr�join)�s1�s2�chunksZpath1Zpath2Zdir1Zdir2rrr�common_substring�sr*c
Cs�t��ztj�||�}WnHtyb}z0|jdks>|jdkr@�tj�||�}WYd}~n
d}~00|t|�dd�kr�t	�
d�|��dSt	�
d�|��dSdS)	zD
    Returns a bool indicating whether we think the code is Py2
    �	bad input�=N���zDetected Python 2 code: {0}TzDetected Python 3 code: {0}F)rrr�refactor_stringr�msg�valuer�str�logger�debug�format��source�pathname�tree�errr�detect_python2�s$r:c
Cs|t��|d7}ztj�||�}WnHtyj}z0|jdksF|jdkrH�tj�||�}WYd}~n
d}~00t|�dd�S)N�
r+r,r-)	rrrr.rr/r0rr1r5rrr�	transform�s$r<cs@eZdZgZgZdd�Zdd�Z�fdd�Z�fdd�Z�Z	S)	�PastSourceFileLoadercsJ|j�t�fdd�|jD��r$d}n"t�fdd�|jD��rBd}nd}|S)Nc3s|]}��|�VqdS�N��
startswith��.0r��fullnamerr�	<genexpr>�z7PastSourceFileLoader._convert_needed.<locals>.<genexpr>Fc3s|]}��|�VqdSr>r?rArCrrrE
rFT)�name�any�
exclude_paths�
include_paths)�self�convertrrCr�_convert_needed	sz$PastSourceFileLoader._convert_neededcCsB|�|j�}|j}t||�r&t||�}t||d�}t||j�dS)N�exec)�
get_sourcerGrr:r<�compilerN�__dict__)rK�moduler6r7�coderrr�_exec_transformed_modules

z-PastSourceFileLoader._exec_transformed_modulecs�t�d|�|tjvr"tj|}nv|��r�t�d|�t�|�}|tj|<|j|_||_	|�
|�rpg|_||_n|�
d�d|_|�|�nt��|�}|S)NzRunning load_module for %s�Autoconverting %s�.r)r2r3�sys�modulesrM�impZ
new_moduler�__file__�
__loader__�
is_package�__path__�__package__�
rpartitionrT�super�load_module)rKrD�mod��	__class__rrras 



z PastSourceFileLoader.load_modulecs>t�d|�|��r.t�d|j�|�|�nt��|�dS)NzRunning exec_module for %srU)r2r3rMrGrTr`�exec_module)rKrRrcrrre4s
z PastSourceFileLoader.exec_module)
rrrrIrJrMrTrare�
__classcell__rrrcrr=s
	r=c@s@eZdZdZdZdd�Zdd�Zdd�Zdd
d�Zddd
�Z	d	S)�Py2Fixerzi
    An import hook class that uses lib2to3 for source-to-source translation of
    Py2 code to Py3.
    TcCs(d|_ddg|_t�|j�|_g|_dS)N�futureZpast)�foundZbase_exclude_paths�copyrIrJ�rKrrr�__init__Hs
zPy2Fixer.__init__cCs|j|7_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)rJ�rK�pathsrrr�includeNszPy2Fixer.includecCs|j|7_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)rIrmrrr�excludeVszPy2Fixer.excludeNcCsHt�d||�t�||�}|s.t�d|�dSt|_|j|_|j|_|S)NzRunning find_module: (%s, %s)�Py2Fixer could not find %s)r2r3r�find_moduler=rdrIrJ)rKrDr�loaderrrrrr_szPy2Fixer.find_modulecCsRt�d|||�t�|||�}|s2t�d|�dSt|j_|j|j_|j|j_|S)NzRunning find_spec: (%s, %s, %s)rq)	r2r3r�	find_specr=rsrdrIrJ)rKrDr�target�specrrrrtks

zPy2Fixer.find_spec)N)NN)
rrrrZPY2FIXERrlrorprrrtrrrrrg=s	
rgrcCs~t|t�r|f}t|t�r |f}t|�t|�dks<Jd��t�|�t�|�tjddk}|rzttjvrztj�	dt�dS)NrzPass at least one argumentr)
�
isinstancer1�len�_hookrorprW�version_info�	meta_pathr!)rJrI�enablerrr�
install_hookszs



r}cCsttjvrtj�t�dSr>)ryrWr{�removerrrr�remove_hooks�s
rcCs
ttjvS)zG
    Returns True if the import hooks are installed, False if not.
    )ryrWr{rrrr�detect_hooks�sr�c@s eZdZdZdd�Zdd�ZdS)�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.
    cCst�|_t�|Sr>)r��hooks_were_installedr}rkrrr�	__enter__�szhooks.__enter__cGs|jst�dSr>)r�r�rK�argsrrr�__exit__�szhooks.__exit__N�rrrrr�r�rrrrr��s	r�c@s eZdZdZdd�Zdd�ZdS)�
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.
    cCst�|_t�|Sr>)r�r�rrkrrrr��szsuspend_hooks.__enter__cGs|jrt�dSr>)r�r}r�rrrr��szsuspend_hooks.__exit__Nr�rrrrr��s
r�)rr)-rrWrz�	importlibrY�loggingrrjZlib2to3.pgen2.parser�lib2to3.refactorrZlibfuturizer�importlib.machineryrr�ImportError�object�	getLoggerrr2�setLevel�DEBUG�listZlibfuturize_fix_names_stage1Zlib2to3_fix_names_stage1Zlibfuturize_fix_names_stage2Zlib2to3_fix_names_stage2rrrr#r*r:r<r=rgryr}rr�r�r�Z
autotranslaterrrr�<module>sR!



���	;58: