File: //lib/python3/dist-packages/automat/__pycache__/_discover.cpython-310.pyc
o
q+WZ � @ s� d dl Z d dlZd dlmZ d dlmZmZ dd� Zdd� ZG dd � d e �Z
G d
d� de
�ZG dd
� d
e
�Zdd� Z
dd� ZdS )� N)�MethodicalMachine)�PythonModule� getModulec C sD t �| �� �}|du r
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�isOriginalLocation s
�r c c s� � t �| g�}t� }|rc|�� }|�� }t|t�r)||vr)|�|� |j|fV n6t �
|�rCt|�rC||vrC|�|� |�|�
� � nt|t�r_||vr_|�|� |�|�
� � |�|�� � |sdS dS )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 �valuer r r �findMachinesViaWrapper s$ �
�r c @ � e Zd ZdZdS )�InvalidFQPNzH
The given FQPN was not a dot-separated list of Python objects.
N�r �
__module__�__qualname__�__doc__r r r r r! >