Current File : //usr/lib/python3/dist-packages/automat/__pycache__/_discover.cpython-312.pyc |
�
�~�b � � � d dl Z d dlZd dlmZ d dlmZmZ d� Zd� Z G d� de � Z
G d� d e
� Z G d
� de
� Zd� Z
d
� Zy)� N)�MethodicalMachine)�PythonModule� getModulec �� � t j | j � � }|�y| }t |t � s|j
}t |t � s�|j |j k( S )z�
Attempt to discover if this appearance of a PythonAttribute
representing a class refers to the module where that class was
defined.
F)�inspect� getmodule�load�
isinstancer �onObject�name�__name__)�attr�sourceModule�
currentModules �3/usr/lib/python3/dist-packages/automat/_discover.py�isOriginalLocationr sb � � �$�$�T�Y�Y�[�1�L�����M����5�%�.�.�
� ���5� ����!6�!6�6�6� c # �x K � t j | g� }t � }|�r|j � }|j � }t |t � r&||vr"|j |� |j |f�� n�t j |� r@t |� r5||vr1|j |� |j |j � � nct |t � rS||vrO|j |� |j |j � � |j |j � � |r��yy�w)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�popr r
r �addr r �isclassr �
extendleft�iterAttributesr �iterModules)�within�queue�visitedr �values r �findMachinesViaWrapperr"