HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/automat/__pycache__/_discover.cpython-310.pyc
o

q+WZ�@s�ddlZddlZddlmZddlmZmZdd�Zdd�ZGdd	�d	e	�Z
Gd
d�de
�ZGdd
�d
e
�Zdd�Z
dd�ZdS)�N)�MethodicalMachine)�PythonModule�	getModulecCsDt�|���}|dur
dS|}t|t�s|j}t|t�r|j|jkS)z�
    Attempt to discover if this appearance of a PythonAttribute
    representing a class refers to the module where that class was
    defined.
    NF)�inspect�	getmodule�load�
isinstancer�onObject�name�__name__)�attr�sourceModule�
currentModule�r�3/usr/lib/python3/dist-packages/automat/_discover.py�isOriginalLocations

�rccs��t�|g�}t�}|rc|��}|��}t|t�r)||vr)|�|�|j|fVn6t	�
|�rCt|�rC||vrC|�|�|�|�
��nt|t�r_||vr_|�|�|�|�
��|�|���|sdSdS)a�
    Recursively yield L{MethodicalMachine}s and their FQPNs within a
    L{PythonModule} or a L{twisted.python.modules.PythonAttribute}
    wrapper object.

    Note that L{PythonModule}s may refer to packages, as well.

    The discovery heuristic considers L{MethodicalMachine} instances
    that are module-level attributes or class-level attributes
    accessible from module scope.  Machines inside nested classes will
    be discovered, but those returned from functions or methods will not be.

    @type within: L{PythonModule} or L{twisted.python.modules.PythonAttribute}
    @param within: Where to start the search.

    @return: a generator which yields FQPN, L{MethodicalMachine} pairs.
    N)�collections�deque�set�poprrr�addr
r�isclassr�
extendleft�iterAttributesr�iterModules)�within�queue�visitedr�valuerrr�findMachinesViaWrappers$�


�rc@�eZdZdZdS)�InvalidFQPNzH
    The given FQPN was not a dot-separated list of Python objects.
    N�r�
__module__�__qualname__�__doc__rrrrr!>�r!c@r )�NoModulezG
    A prefix of the FQPN was not an importable module or package.
    Nr"rrrrr'Dr&r'c@r )�NoObjectz;
    A suffix of the FQPN was not an accessible object
    Nr"rrrrr(Jr&r(c	s�|std��t�|�d��}d|vrtd|f��|���zt��}Wnty.t���w|rP|���z|�}WntyI|���Yn	w|�	�|s1|S|}|D]!�zt
�fdd�|��D��}WqVtywt
d�|j����w|S)z�
    Given an FQPN, retrieve the object via the global Python module
    namespace and wrap it with a L{PythonModule} or a
    L{twisted.python.modules.PythonAttribute}.
    zFQPN was empty�.�zOname must be a string giving a '.'-separated list of Python identifiers, not %rc3s*�|]}|j�dd�d�kr|VqdS)r)����N)r
�rsplit)�.0�child��	componentrr�	<genexpr>ys���zwrapFQPN.<locals>.<genexpr>z{}.{})r!rr�split�popleftr�KeyErrorr'�
appendleftr�nextr�
StopIterationr(�formatr
)�fqpn�
components�module�	attributerr0r�wrapFQPNPsD���
��
�r>cCstt|��S)a'
    Recursively yield L{MethodicalMachine}s and their FQPNs in and
    under the a Python object specified by an FQPN.

    The discovery heuristic considers L{MethodicalMachine} instances
    that are module-level attributes or class-level attributes
    accessible from module scope.  Machines inside nested classes will
    be discovered, but those returned from functions or methods will not be.

    @type within: an FQPN
    @param within: Where to start the search.

    @return: a generator which yields FQPN, L{MethodicalMachine} pairs.
    )rr>)r:rrr�findMachines�sr?)rr�automatr�twisted.python.modulesrrrr�	Exceptionr!r'r(r>r?rrrr�<module>s&1