%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core22/current/usr/share/python3/debpython/__pycache__/
Upload File :
Create Path :
Current File : //snap/core22/current/usr/share/python3/debpython/__pycache__/interpreter.cpython-310.pyc

o

年f�4�@sxddlZddlZddlZddlmZmZddlmZddlm	Z	e�
dej�Ze�
dej�Z
e�e�ZGdd�d�ZdS)	�N)�join�split)�execute)�Versionz�
    (?:\#!\s*){0,1}  # shebang prefix
    (?P<path>
        .*?/bin/.*?)?
    (?P<name>
        python|pypy)
    (?P<version>
        \d[\.\d]*)?
    (?P<debug>
        -dbg)?
    (?P<options>.*)
    a-
    (?P<name>.*?)
    (?:\.
        (?P<stableabi>abi\d+)
     |(?:\.
        (?P<soabi>
            (?P<impl>cpython|pypy)
            -
            (?P<ver>\d{2})
            (?P<flags>[a-z]*?)
        )
        (?:
            -(?P<multiarch>[^/]*?)
        )?
    ))?
    (?P<debug>_d)?
    \.so$c@s�eZdZdZdZdZdZdZdZiZ			d)dd�Z
dd	�Zd
d�Zdd
�Z
dd�Zedd��Zd*dd�Zd+dd�Zd+dd�Zd+dd�Zd+dd�Zd+dd�Zd+dd�Zd+d d!�Zd+d"d#�Zd+d$d%�Zd,d'd(�ZdS)-�InterpreterN�pythonF�cpython�cCs�t�}|d=|d=t|t�r#|��D]}	||	dur!t||	�||	<qn)|rL|�dd���r6|s6t|�|d<n|�|��	�D]\}	}
||	durK|
||	<q=|�	�D]
\}	}
t
||	|
�qPdS)N�self�value�.��version)�locals�
isinstancer�keys�getattr�replace�isdigitr�parse�items�setattr)r
r�path�namer�debug�impl�options�params�key�valr	r	�+/usr/share/python3/debpython/interpreter.py�__init__Es&
����zInterpreter.__init__cCs�|dkr%|r%|�d�rd|jd<n
|�d�rd|jd<d|vr$d|jd<n|d	kr1|dur1t|�}|d
vrC|durCtt|�|j|<dS||j|<dS)Nrrrr�pypyz-dbgTrr)rrrr)�
startswith�__dict__rrr)r
rrr	r	r �__setattr__Zs



�zInterpreter.__setattr__cCs8|jpd}||�|j�7}|jr|dd�|j�7}|S)Nr
� )r�_vstrrrr)r
�resultr	r	r �__repr__js

zInterpreter.__repr__cCs|�|j�S�N)r'r)r
r	r	r �__str__qszInterpreter.__str__cCsF|jdkr|jS|r t|�|jvr |jrd�|�S|jt|�S|jS)Nr"zpython{}-dbg)rr�strr�format�r
rr	r	r r'ts

zInterpreter._vstrcCs:t�|�}|s	iS|��}d|vrt|d���|d<|S)a�Return dict with parsed shebang

        >>> sorted(Interpreter.parse('pypy').items())
        [('debug', None), ('name', 'pypy'), ('options', ()), ('path', None), ('version', None)]
        >>> sorted(Interpreter.parse('/usr/bin/python3.3-dbg').items())
        [('debug', '-dbg'), ('name', 'python'), ('options', ()), ('path', '/usr/bin/'), ('version', '3.3')]
        >>> sorted(Interpreter.parse('#! /usr/bin/pypy --foo').items())
        [('debug', None), ('name', 'pypy'), ('options', ('--foo',)), ('path', '/usr/bin/'), ('version', None)]
        >>> sorted(Interpreter.parse('#! /usr/bin/python3.2').items())
        [('debug', None), ('name', 'python'), ('options', ()), ('path', '/usr/bin/'), ('version', '3.2')]
        >>> sorted(Interpreter.parse('/usr/bin/python3.2-dbg --foo --bar').items())
        [('debug', '-dbg'), ('name', 'python'), ('options', ('--foo', '--bar')), ('path', '/usr/bin/'), ('version', '3.2')]
        r)�
SHEBANG_RE�search�	groupdict�tupler)�shebangr(r	r	r r~s
zInterpreter.parsecCsnt|p|j�}|jdkrd}n|td�>rd|}n
|td�>r%d|}nd}|r-d|}|r5d	||f}|S)
a�Return path to site-packages directory.

        Note that returned path is not the final location of .py files

        >>> i = Interpreter('python')
        >>> i.sitedir(version='3.1')
        '/usr/lib/python3/dist-packages/'
        >>> i.sitedir(version='2.5')
        '/usr/lib/python2.5/site-packages/'
        >>> i.sitedir(version=Version('2.7'))
        '/usr/lib/python2.7/dist-packages/'
        >>> i.sitedir(version='3.1', gdb=True, package='python3-foo')
        'debian/python3-foo/usr/lib/debug/usr/lib/python3/dist-packages/'
        >>> i.sitedir(version=Version('3.2'))
        '/usr/lib/python3/dist-packages/'
        >>> Interpreter('pypy').sitedir(version='2.0')
        '/usr/lib/pypy/dist-packages/'
        r"z/usr/lib/pypy/dist-packages/�2.6z /usr/lib/python%s/site-packages/z3.0z /usr/lib/python%s/dist-packages/z/usr/lib/python3/dist-packages/z/usr/lib/debug%szdebian/%s%s)rrr)r
�gdb�packagerrr	r	r �sitedir�s


zInterpreter.sitedircCsvt|p|j�}d|jvrdnd}|td�kr||St|�\}}|�d�s)|d7}t|dd|dd	�|�|�|f�S)
a�Given path to a .py file, return path to its .pyc/.pyo file.

        This function is inspired by Python 3.2's imp.cache_from_source.

        :param fpath: path to file name
        :param version: Python version

        >>> i = Interpreter('python')
        >>> i.cache_file('foo.py', Version('3.1'))
        'foo.pyc'
        >>> i.cache_file('bar/foo.py', '3.2')
        'bar/__pycache__/foo.cpython-32.pyc'
        z-O�o�c�3.1z.py�__pycache__z
%s.%s.py%sN���)rrrr�endswithr�	magic_tag)r
�fpathr�	last_char�fdir�fnamer	r	r �
cache_file�s
�zInterpreter.cache_filecCs~t|p|j�}|�|�\}}|�dd�d}|r(|d�|�7}|r(|d�|�7}|jr:|jdkr:|td�>r:|d7}d	�|�S)
z5Return extension name with soname and multiarch tags.r�rz.{}z-{}r�3�_dz{}.so)rr�_get_configrr-rr)r
rr�soabi�	multiarchr(r	r	r �ext_file�s
�
zInterpreter.ext_filecCs<t|p|j�}|jdkr|td�>rdS|�d|�}t|�S)zReturn magic number.rrEr
z"import imp; print(imp.get_magic()))rrr�_execute�eval)r
rr(r	r	r �magic_number�s
zInterpreter.magic_numbercCs4t|p|j�}|jdkr|td�>rdS|�d|�S)z�Return Python magic tag (used in __pycache__ dir to tag files).

        >>> i = Interpreter('python')
        >>> i.magic_tag(version='3.2')
        'cpython-32'
        r�3.2r
z import imp; print(imp.get_tag()))rrrrKr.r	r	r r>�szInterpreter.magic_tagcCsFt|p|j�}z
|�|�\}}W|Sty"tjddd�YdSw)zReturn multiarch tag.zcannot get multiarchT��exc_infor
�rrrG�	Exception�logr�r
rrHrIr	r	r rI�s��zInterpreter.multiarchcCs8t|p|j�}|jdkr|td�?rd�|j�SdSdS)NrrNzabi{})rrrr-�majorr.r	r	r �	stableabis�zInterpreter.stableabicCsFt|p|j�}z
|�|�\}}W|Sty"tjddd�YdSw)z�Return SOABI flag (used to in .so files).

        >>> i = Interpreter('python')
        >>> i.soabi(version=Version('3.3'))
        'cpython-33m'
        zcannot get soabiTrOr
rQrTr	r	r rH	s��zInterpreter.soabic	Cslt|p|j�}d|vr|�dd�\}}nd}t�|�}|sdS|��}|dr)dSt||d�}|drBd�|dd	|dd�|_|jsT|d
sQd|dpOdvrTd
|_z|�	�\}}Wnt
ymtjdd
d�YdSw|d}|jdkr�|jd?r�|�
d�r�|dd�}|ds�|r�d�||dp�|�}|ds�|r�d�||dp�|�}|d7}||kr�dSt||�S)a�Return extension file name if file can be renamed.

        >>> i = Interpreter('python')
        >>> i.check_extname('foo.so', version='3.3') # doctest: +ELLIPSIS
        'foo.cpython-33m-....so'
        >>> i.check_extname('foo.abi3.so', version='3.3')
        >>> i.check_extname('foo/bar/bazmodule.so', version='3.3') # doctest: +ELLIPSIS
        'foo/bar/baz.cpython-33m-....so'
        �/rDr
NrV)r�verz{}.{}rr�d�flagsTzcannot get soabi/multiarchrOrrrN�modulei����rHrIz{}-{}z.so)rr�rsplit�
EXTFILE_REr0r1rr-rrGrRrSrr=r)	r
rBrrA�info�irHrIr(r	r	r �
check_extnames@

�
zInterpreter.check_extnamecCs�t|p|j�}|jdks!|jdkr$|d?r|d>s!|d?s!|dkr$d}nd}|d7}|�||��d	�}z
tjd
|d<W|StyGY|Sw)Nr"rr4rEr:zimport sysconfig as s;z%from distutils import sysconfig as s;zOprint("__SEP__".join(i or "" for i in s.get_config_vars("SOABI", "MULTIARCH")))�__SEP__�DEB_HOST_MULTIARCHrD)rrrrKr�os�environ�KeyError)r
r�cmd�	conf_varsr	r	r rGKs(�����zInterpreter._get_configTcCs�t|p|j�}d�|�|�|�dd��}|r"||jjvr"|jj|St|�}|ddkr=t�	|d�t
d�||d���|d��}t|�dkrM|d}|rU||jj|<|S)	Nz
{} -c '{}'�'�
returncoder�stderrz{} failed with status code {}�stdoutrD)
rrr-r'r�	__class__�_cacherrSrrR�
splitlines�len)r
�commandr�cache�outputr(r	r	r rK^szInterpreter._execute)NNNNNNN)FNNr*)NT)�__name__�
__module__�__qualname__rrrrrrrmr!r%r)r+r'�staticmethodrr7rCrJrMr>rIrVrHr`rGrKr	r	r	r r<s8
�



&







1r)�loggingrc�re�os.pathrr�	debpythonr�debpython.versionr�compile�VERBOSEr/r]�	getLoggerrsrSrr	r	r	r �<module>s��


Zerion Mini Shell 1.0