Hacked By AnonymousFox

Current Path : /opt/imunify360/venv/lib/python3.11/site-packages/docutils/__pycache__/
Upload File :
Current File : //opt/imunify360/venv/lib/python3.11/site-packages/docutils/__pycache__/statemachine.cpython-311.pyc

�

i��f|���v�dZdZddlZddlZddlmZddlmZGd�d��ZGd�d	��Z	Gd
�de��Z
Gd�d
e	��ZGd�d��ZGd�dee��Z
Gd�dee
��ZGd�d��ZGd�de��ZGd�de��ZGd�de��ZGd�de��ZGd�de��ZGd �d!e��ZGd"�d#e��ZGd$�d%e��ZGd&�d'e��ZGd(�d)e��ZGd*�d+e��Zd,d-ejd.��fd/�Zd0�ZdS)1a�

A finite state machine specialized for regular-expression-based text filters,
this module defines the following classes:

- `StateMachine`, a state machine
- `State`, a state superclass
- `StateMachineWS`, a whitespace-sensitive version of `StateMachine`
- `StateWS`, a state superclass for use with `StateMachineWS`
- `SearchStateMachine`, uses `re.search()` instead of `re.match()`
- `SearchStateMachineWS`, uses `re.search()` instead of `re.match()`
- `ViewList`, extends standard Python lists.
- `StringList`, string-specific ViewList.

Exception classes:

- `StateMachineError`
- `UnknownStateError`
- `DuplicateStateError`
- `UnknownTransitionError`
- `DuplicateTransitionError`
- `TransitionPatternNotFound`
- `TransitionMethodNotFound`
- `UnexpectedIndentationError`
- `TransitionCorrection`: Raised to switch to another transition.
- `StateCorrection`: Raised to switch to another state & transition.

Functions:

- `string2lines()`: split a multi-line string into a list of one-line strings


How To Use This Module
======================
(See the individual classes, methods, and attributes for details.)

1. Import it: ``import statemachine`` or ``from statemachine import ...``.
   You will also need to ``import re``.

2. Derive a subclass of `State` (or `StateWS`) for each state in your state
   machine::

       class MyState(statemachine.State):

   Within the state's class definition:

   a) Include a pattern for each transition, in `State.patterns`::

          patterns = {'atransition': r'pattern', ...}

   b) Include a list of initial transitions to be set up automatically, in
      `State.initial_transitions`::

          initial_transitions = ['atransition', ...]

   c) Define a method for each transition, with the same name as the
      transition pattern::

          def atransition(self, match, context, next_state):
              # do something
              result = [...]  # a list
              return context, next_state, result
              # context, next_state may be altered

      Transition methods may raise an `EOFError` to cut processing short.

   d) You may wish to override the `State.bof()` and/or `State.eof()` implicit
      transition methods, which handle the beginning- and end-of-file.

   e) In order to handle nested processing, you may wish to override the
      attributes `State.nested_sm` and/or `State.nested_sm_kwargs`.

      If you are using `StateWS` as a base class, in order to handle nested
      indented blocks, you may wish to:

      - override the attributes `StateWS.indent_sm`,
        `StateWS.indent_sm_kwargs`, `StateWS.known_indent_sm`, and/or
        `StateWS.known_indent_sm_kwargs`;
      - override the `StateWS.blank()` method; and/or
      - override or extend the `StateWS.indent()`, `StateWS.known_indent()`,
        and/or `StateWS.firstknown_indent()` methods.

3. Create a state machine object::

       sm = StateMachine(state_classes=[MyState, ...],
                         initial_state='MyState')

4. Obtain the input text, which needs to be converted into a tab-free list of
   one-line strings. For example, to read text from a file called
   'inputfile'::

       with open('inputfile', encoding='utf-8') as fp:
           input_string = fp.read()
       input_lines = statemachine.string2lines(input_string)

5. Run the state machine on the input text and collect the results, a list::

       results = sm.run(input_lines)

6. Remove any lingering circular references::

       sm.unlink()
�restructuredtext�N)�east_asian_width)�utilsc��eZdZdZdd�Zd�Z		dd�Zd d�Zd!d
�Zd�Z	d�Z
d
�Zd!d�Zd�Z
d�Zd�Zd�Zd d�Zd�Zdd�Zd d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZdS)"�StateMachinea�
    A finite state machine for text filters using regular expressions.

    The input is provided in the form of a list of one-line strings (no
    newlines). States are subclasses of the `State` class. Transitions consist
    of regular expression patterns and transition methods, and are defined in
    each state.

    The state machine is started with the `run()` method, which returns the
    results of processing in a list.
    Fc��d|_	d|_	d|_	d|_	||_	||_	||_	i|_	|�|��g|_	dS)a+
        Initialize a `StateMachine` object; add state objects.

        Parameters:

        - `state_classes`: a list of `State` (sub)classes.
        - `initial_state`: a string, the class name of the initial state.
        - `debug`: a boolean; produce verbose output if true (nonzero).
        Nr���)
�input_lines�input_offset�line�line_offset�debug�
initial_state�
current_state�states�
add_states�	observers)�self�
state_classesrrs    �u/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/docutils/statemachine.py�__init__zStateMachine.__init__�s��� ���	#����J���	�!����M���
�$�*���C�*���C����4����
�&�&�&����	*�	*�c�t�|j���D]}|����d|_dS�z9Remove circular references to objects no longer required.N)r�values�unlink�r�states  rrzStateMachine.unlink�s9���[�'�'�)�)�	�	�E��L�L�N�N�N�N�����rrNc��|���t|t��r||_nt||���|_||_d|_|p|j|_|jr>td|j�dd�
|j����tj���d}g}|�
��}	|jrtdtj���|�|��\}}	|�|	��			|���|jrK|j�|j��\}
}td
|
�d|�d|j��tj���|�|||��\}}}	|�|	��nj#t($r]|jr(td|jjztj���|�|��}	|�|	��Y�nwxYw	d}n�#t0$rf}
|���|
jd
f}|jr2td|jj�d|d
�d�tj���Yd}
~
��sd}
~
wt6$r�}
|���|
jd
}t9|
j��dkrd}n|
jdf}|jr(td|�d|d
�d�tj���Yd}
~
nd}
~
wwxYw|�
|��}��n!#|jr|����xYwg|_|S)a�
        Run the state machine on `input_lines`. Return results (a list).

        Reset `self.line_offset` and `self.current_state`. Run the
        beginning-of-file transition. Input one line at a time and check for a
        matching transition. If a match is found, call the transition method
        and possibly change the state. Store the context returned by the
        transition method to be passed on to the next transition matched.
        Accumulate the results returned by the transition methods in a list.
        Run the end-of-file transition. Finally, return the accumulated
        results.

        Parameters:

        - `input_lines`: a list of strings without newlines, or `StringList`.
        - `input_offset`: the line offset of `input_lines` from the beginning
          of the file.
        - `context`: application-specific storage.
        - `input_source`: name or path of source of `input_lines`.
        - `initial_state`: name of initial state.
        )�sourcer	z,
StateMachine.run: input_lines (line_offset=z):
| z
| ��fileNz!
StateMachine.run: bof transitionTz 
StateMachine.run: line (source=z	, offset=z$
StateMachine.run: %s.eof transitionrz2
StateMachine.run: TransitionCorrection to state "z", transition �.�z-
StateMachine.run: StateCorrection to state ")�runtime_init�
isinstance�
StringListr
rr
rrr�print�join�sys�stderr�	get_state�bof�extend�	next_line�infor�
check_line�EOFError�	__class__�__name__�eof�TransitionCorrection�
previous_line�args�StateCorrection�len�errorr)rr
r�context�input_sourcer�transitions�resultsr�resultr �offset�
next_state�	exceptions              r�runzStateMachine.run�s*��.	
�������k�:�.�.�	L�*�D���)�+�l�K�K�K�D��(������*�@�d�.@����:�	#��E��%�%�%�v�{�{�4�3C�'D�'D�'D�F��z�
#�
#�
#�
#�������� � ��4	��z�
M��:���L�L�L�L�#�i�i��0�0�O�G�V��N�N�6�"�"�"�+
3�)'�/����(�(�(��:�E�-1�-=�-B�-B� $� 0�.2�.2�N�F�F�!�#3�-3�#3�#3�@F�#3�#3�'+�y�#3�#3�9<��E�E�E�E�7;�o�o�#�U�K�79�79�3���V� ���v�.�.�.�.��$�����:�O�!�"I�$)�O�$<�#=�CF�:�O�O�O�O�!&���7�!3�!3�����v�.�.�.���
����/�,#'�K�K��+,�����&�&�(�(�(�#,�>�!�#4�"6�K��z�/��>�(-��(@�>�>�,7��N�>�>�>�$'�:�/�/�/�/��H�H�H�H�����&�
/�
/�
/��&�&�(�(�(�!*���!2�J��9�>�*�*�a�/�/�&*���'0�~�a�'8�&:���z�/��N�",�N�N�<G��N�N�N�N�#&�:�/�/�/�/����������
/�������z�2�2��W+
3�$��4	��z�
��
�
������������sq�AL/�BF+�H�+A#H�H�L/�H�H�L/�
L�#AJ�>L/�
L�A9L�
L/�L�L/�/M
c	��|rU|jrG||jkr<td|j�d|�d|����d�tj���||_	|j|jS#t$rt|j���wxYw)z�
        Return current state object; set it first if `next_state` given.

        Parameter `next_state`: a string, the name of the next state.

        Exception: `UnknownStateError` raised if `next_state` unknown.
        z.
StateMachine.get_state: Changing state from "z" to "z" (input line z).r!)	rrr(�abs_line_numberr*r+r�KeyError�UnknownStateError)rrBs  rr,zStateMachine.get_states����	,��z�
C�j�D�,>�>�>����+�+�+�Z�Z�Z��-�-�/�/�/�/�1�8;�z�C�C�C�C�",�D��	8��;�t�1�2�2���	8�	8�	8�#�D�$6�7�7�7�	8���s�A+�+B
r$c��		|xj|z
c_|j|j|_n#t$rd|_t�wxYw|j|���S#|���wxYw)z9Load `self.line` with the `n`'th next line and return it.N)r
r
r�
IndexErrorr2�notify_observers�r�ns  rr/zStateMachine.next_line&s���		$�
�� � �A�%� � � �,�T�-=�>��	�	���
�
�
� ��	���
�����9��!�!�#�#�#�#��D�!�!�#�#�#�#���s�'+�A"�A�	A"�"A8c�v�	|j|jdz���S#t$rYdSwxYw)z6Return True if the next line is blank or non-existent.r$)r
r
�striprJ�rs r�is_next_line_blankzStateMachine.is_next_line_blank3sN��	��'��(8�1�(<�=�C�C�E�E�E�E���	�	�	��1�1�	���s�'*�
8�8c�B�|jt|j��dz
kS)z0Return 1 if the input is at or past end-of-file.r$)r
r:r
rPs r�at_eofzStateMachine.at_eof:s ����3�t�'7�#8�#8�1�#<�<�<rc��|jdkS)z8Return 1 if the input is at or before beginning-of-file.r)r
rPs r�at_bofzStateMachine.at_bof>s����1�$�$rc��|xj|zc_|jdkrd|_n|j|j|_|���|jS)z=Load `self.line` with the `n`'th previous line and return it.rN)r
rr
rKrLs  rr7zStateMachine.previous_lineBsY�����A������a����D�I�I��(��)9�:�D�I��������y�rc���		||jz
|_|j|j|_n#t$rd|_t
�wxYw|j|���S#|���wxYw)z?Jump to absolute line offset `line_offset`, load and return it.N)rr
r
rrJr2rK�rr
s  r�	goto_linezStateMachine.goto_lineLs���		$�
�#.��1B�#B�� � �,�T�-=�>��	�	���
�
�
� ��	���
�����9��!�!�#�#�#�#��D�!�!�#�#�#�#���s�&*�A!�A�	A!�!A7c�F�|j�||jz
��S)z<Return source of line at absolute line offset `line_offset`.)r
r rrXs  r�
get_sourcezStateMachine.get_sourceYs!����&�&�{�T�5F�'F�G�G�Grc� �|j|jzS)z;Return line offset of current line, from beginning of file.�r
rrPs r�abs_line_offsetzStateMachine.abs_line_offset]s����$�"3�3�3rc�&�|j|jzdzS)z5Return line number of current line (counting from 1).r$r]rPs rrFzStateMachine.abs_line_numberas����$�"3�3�a�7�7rc��|�|j}n
||jz
dz
}	|j�|��\}}|dz}nG#t$r*|�||jz��\}}||dzfcYSt$rd\}}YnwxYw||fS)a\Return (source, line) tuple for current or given line number.

        Looks up the source and line number in the `self.input_lines`
        StringList instance to count for included source files.

        If the optional argument `lineno` is given, convert it from an
        absolute line number to the corresponding (source, line) pair.
        Nr$�NN)r
rr
r0�	TypeError�get_source_and_linerJ)r�linenorA�src�	srcoffset�srclines      rrcz StateMachine.get_source_and_linees����>��%�F�F��d�/�/�!�3�F�	&�!�-�2�2�6�:�:�N�C���!�m�G�G���	$�	$�	$��3�3�F�T�=N�4N�O�O�L�C����!��#�#�#�#��	&�	&�	&�%�L�C����	&����
�G�|�s�"<�1B�/B�?Bc�&�|j�|jdzdd|zt|�����|j�|jdzdd|zd���|j�|jdzt	||����dS)Nr$�zinternal padding after )r rAzinternal padding before r	�)r
�insertr
r:r')rr
r s   r�insert_inputzStateMachine.insert_input�s�������� 0�1� 4�b�'@��'G�'*�;�'7�'7�	 �	9�	9�	9�	
����� 0�1� 4�b�'A�&�'H�')�	 �	+�	+�	+�	
����� 0�1� 4� *�;�� ?� ?�	A�	A�	A�	A�	Arc��	|j�|j|��}|�t	|��dz
��|S#t
$r8}|jd}|�t	|��dz
���d}~wwxYw)��
        Return a contiguous block of text.

        If `flush_left` is true, raise `UnexpectedIndentationError` if an
        indented line is encountered before the text block ends (with a blank
        line).
        r$rN)r
�get_text_blockr
r/r:�UnexpectedIndentationErrorr8)r�
flush_left�block�errs    rrozStateMachine.get_text_block�s���	��$�3�3�D�4D�4>�@�@�E��N�N�3�u�:�:��>�*�*�*��L��)�	�	�	��H�Q�K�E��N�N�3�u�:�:��>�*�*�*������	���s�AA	�	
B�3B�Bc���|�|j}|jr,td|jj�d|�d�t
j���|D]q}|j|\}}}|�|j	��}|rB|jr,td|�d|jj�d�t
j���||||��cS�r|jr(td	|jjzt
j���|�
||��S)
a�
        Examine one line of input for a transition match & execute its method.

        Parameters:

        - `context`: application-dependent storage.
        - `state`: a `State` object, the current state.
        - `transitions`: an optional ordered list of transition names to try,
          instead of ``state.transition_order``.

        Return the values returned by the transition method:

        - context: possibly modified from the parameter `context`;
        - next state name (`State` subclass name);
        - the result output of the transition, a list.

        When there is no match, ``state.no_match()`` is called and its return
        value is returned.
        Nz!
StateMachine.check_line: state="z", transitions=r#r!z.
StateMachine.check_line: Matched transition "z" in state "z".z1
StateMachine.check_line: No match in state "%s".)�transition_orderrr(r3r4r*r+r>�matchr�no_match)	rr<rr>�name�pattern�methodrBrvs	         rr1zStateMachine.check_line�s]��(���0�K��:�	N��E��_�-�-�-�{�{�{�<�BE�*�
N�
N�
N�
N��
	8�
	8�D�*/�*;�D�*A�'�G�V�Z��M�M�$�)�,�,�E��
:��:�+��M�"�M�M�05��0H�M�M�M�"�z�+�+�+�+��v�e�W�j�9�9�9�9�9�
:��z�
C��J���0�1�7:�z�C�C�C�C��>�>�'�;�7�7�7rc�v�|j}||jvrt|���|||j��|j|<dS)z�
        Initialize & add a `state_class` (`State` subclass) object.

        Exception: `DuplicateStateError` raised if `state_class` was already
        added.
        N)r4r�DuplicateStateErrorr)r�state_class�	statenames   r�	add_statezStateMachine.add_state�sG�� �(�	����#�#�%�i�0�0�0�!,��T�4�:�!>�!>���I���rc�:�|D]}|�|���dS)zE
        Add `state_classes` (a list of `State` subclasses).
        N)r)rrr}s   rrzStateMachine.add_states�s2��)�	(�	(�K��N�N�;�'�'�'�'�	(�	(rc�f�|j���D]}|����dS)z+
        Initialize `self.states`.
        N)rrr%rs  rr%zStateMachine.runtime_init�s@���[�'�'�)�)�	!�	!�E���� � � � �	!�	!rc��t��\}}}}}t|�d|��tj���td|���ztj���td|�d|�d|��tj���dS)zReport error details.z: r!z
input line %szmodule z, line z, function N)�_exception_datar(r*r+rF)r�type�value�moduler�functions      rr;zStateMachine.error�s���.=�.?�.?�+��e�V�T�8�
�$�$�$���&�S�Z�8�8�8�8�
�o��!5�!5�!7�!7�8�s�z�J�J�J�J�
��6�6�6�4�4�4���J��:�	�	�	�	�	�	rc�:�|j�|��dS)z�
        The `observer` parameter is a function or bound method which takes two
        arguments, the source and offset of the current line.
        N)r�append�r�observers  r�attach_observerzStateMachine.attach_observer�s ��
	
����h�'�'�'�'�'rc�:�|j�|��dS�N)r�remover�s  r�detach_observerzStateMachine.detach_observer�s������h�'�'�'�'�'rc��|jD]:}	|j�|j��}n#t$rd}YnwxYw||��;dS)Nra)rr
r0r
rJ)rr�r0s   rrKzStateMachine.notify_observers�sn����	�	�H�
$��'�,�,�T�-=�>�>�����
$�
$�
$�#����
$�����H�d�O�O�O�	�	s�+�:�:�F)rNNNr��r$)r4�
__module__�__qualname__�__doc__rrrDr,r/rQrSrUr7rYr[r^rFrcrlror1rrr%r;r�r�rK�rrrrus�������
�
�)*�)*�)*�)*�V���8<�-1�\�\�\�\�|8�8�8�8�($�$�$�$����=�=�=�%�%�%�����$�$�$�H�H�H�4�4�4�8�8�8�����6A�A�A�����$&8�&8�&8�&8�P
?�
?�
?�(�(�(�!�!�!����(�(�(�(�(�(�����rrc�|�eZdZdZdZ	dZ	dZ	dZ	dd�Zd�Z	d�Z
d�Zd�Zd	�Z
d
�Zdd�Zd�Zd
�Zd�Zd�Zd�ZdS)�Stateaw
    State superclass. Contains a list of transitions, and transition methods.

    Transition methods all have the same signature. They take 3 parameters:

    - An `re` match object. ``match.string`` contains the matched input line,
      ``match.start()`` gives the start index of the match, and
      ``match.end()`` gives the end index.
    - A context object, whose meaning is application-defined (initial value
      ``None``). It can be used to store any information required by the state
      machine, and the returned context is passed on to the next transition
      method unchanged.
    - The name of the next state, a string, taken from the transitions list;
      normally it is returned unchanged, but it may be altered by the
      transition method if necessary.

    Transition methods all return a 3-tuple:

    - A context object, as (potentially) modified by the transition method.
    - The next state name (a return value of ``None`` means no state change).
    - The processing result, a list, which is accumulated by the state
      machine.

    Transition methods may raise an `EOFError` to cut processing short.

    There are two implicit transitions, and corresponding transition methods
    are defined: `bof()` handles the beginning-of-file, and `eof()` handles
    the end-of-file. These methods have non-standard signatures and return
    values. `bof()` returns the initial context and results, and may be used
    to return a header string, or do any other processing needed. `eof()`
    should handle any remaining context and wrap things up; it returns the
    final processing result.

    Typical applications need only subclass `State` (or a subclass), set the
    `patterns` and `initial_transitions` class attributes, and provide
    corresponding transition methods. The default object initialization will
    take care of constructing the list of transitions.
    NFc���g|_	i|_	|���||_	||_	|j�|jj|_|j�|jg|jjd�|_dSdS)z�
        Initialize a `State` object; make & add initial transitions.

        Parameters:

        - `statemachine`: the controlling `StateMachine` object.
        - `debug`: a boolean; produce verbose output if true.
        N)rr)	rur>�add_initial_transitions�
state_machiner�	nested_smr3�nested_sm_kwargsr4�rr�rs   rrzState.__init__Fs���!#���9����	�	
�$�$�&�&�&�*���C���
�$��>�!�!�/�9�D�N�� �(�7;�~�6F�6:�n�6M�%O�%O�D�!�!�!�)�(rc��dS)z{
        Initialize this `State` before running the state machine; called from
        `self.state_machine.run()`.
        Nr�rPs rr%zState.runtime_initjs	��
	
�rc��d|_dSr)r�rPs rrzState.unlinkqs��!����rc�~�|jr5|�|j��\}}|�||��dSdS)z>Make and add transitions listed in `self.initial_transitions`.N)�initial_transitions�make_transitions�add_transitions�r�namesr>s   rr�zState.add_initial_transitionsusS���#�	5�!%�!6�!6�%)�%=�"?�"?��E�;�� � ���4�4�4�4�4�	5�	5rc��|D]-}||jvrt|���||vrt|����.||jdd�<|j�|��dS)a"
        Add a list of transitions to the start of the transition list.

        Parameters:

        - `names`: a list of transition names.
        - `transitions`: a mapping of names to transition tuples.

        Exceptions: `DuplicateTransitionError`, `UnknownTransitionError`.
        Nr)r>�DuplicateTransitionError�UnknownTransitionErrorru�update)rr�r>rxs    rr�zState.add_transitions|s{���	3�	3�D��t�'�'�'�.�t�4�4�4��;�&�&�,�T�2�2�2�'�$)���b�q�b�!������,�,�,�,�,rc�d�||jvrt|���|g|jdd�<||j|<dS)z�
        Add a transition to the start of the transition list.

        Parameter `transition`: a ready-made transition 3-tuple.

        Exception: `DuplicateTransitionError`.
        Nr)r>r�ru)rrx�
transitions   r�add_transitionzState.add_transition�sF���4�#�#�#�*�4�0�0�0�%)�F���b�q�b�!�!+������rc�t�	|j|=|j�|��dS#t|���xYw)z^
        Remove a transition by `name`.

        Exception: `UnknownTransitionError`.
        N)r>rur�r�)rrxs  r�remove_transitionzState.remove_transition�sF��	/�� ��&��!�(�(��.�.�.�.�.��	/�(��.�.�.���s�"&�7c�x�|�|jj}	|j|}t|d��st	j|��x}|j|<n-#t$r t|jj�d|�d����wxYw	t||��}n,#t$rt|jj�d|�����wxYw|||fS)a�
        Make & return a transition tuple based on `name`.

        This is a convenience function to simplify transition creation.

        Parameters:

        - `name`: a string, the name of the transition pattern & method. This
          `State` object must have a method called '`name`', and a dictionary
          `self.patterns` containing a key '`name`'.
        - `next_state`: a string, the name of the next `State` object for this
          transition. A value of ``None`` (or absent) implies no state change
          (i.e., continue with the same state).

        Exceptions: `TransitionPatternNotFound`, `TransitionMethodNotFound`.
        Nrvz
.patterns[�]r#)r3r4�patterns�hasattr�re�compilerG�TransitionPatternNotFound�getattr�AttributeError�TransitionMethodNotFound)rrxrBryrzs     r�make_transitionzState.make_transition�s��"����0�J�	G��m�D�)�G��7�G�,�,�
D�02�
�7�0C�0C�C��$�-��-����	G�	G�	G�+�'+�~�'>�'>�'>����E�G�G�
G�	G����	=��T�4�(�(�F�F���	=�	=�	=�*�!�^�4�4�4�d�d�;�=�=�
=�	=������
�*�*s�;A�*A6�:B�)B4c��g}i}|D]s}t|t��r.|�|��||<|�|���E|j|�||d<|�|d���t||fS)z�
        Return a list of transition names and a transition mapping.

        Parameter `name_list`: a list, where each entry is either a transition
        name string, or a 1- or 2-tuple (transition name, optional next state
        name).
        r)r&�strr�r�)r�	name_listr�r>�	namestates     rr�zState.make_transitions�s�������"�	+�	+�I��)�S�)�)�
+�)-�)=�)=�i�)H�)H��I�&����Y�'�'�'�'�,@�D�,@�)�,L��I�a�L�)����Y�q�\�*�*�*�*��k�!�!rc��|dgfS)a'
        Called when there is no match from `StateMachine.check_line()`.

        Return the same values returned by transition methods:

        - context: unchanged;
        - next state name: ``None``;
        - empty result list.

        Override in subclasses to catch this event.
        Nr�)rr<r>s   rrwzState.no_match�s����b� � rc�
�|gfS)z�
        Handle beginning-of-file. Return unchanged `context`, empty result.

        Override in subclasses.

        Parameter `context`: application-defined storage.
        r��rr<s  rr-z	State.bof�s����{�rc��gS)z�
        Handle end-of-file. Return empty result.

        Override in subclasses.

        Parameter `context`: application-defined storage.
        r�r�s  rr5z	State.eof�s	���	rc��||gfS)z�
        A "do nothing" transition method.

        Return unchanged `context` & `next_state`, empty result. Useful for
        simple state changes (actionless transitions).
        r��rrvr<rBs    r�nopz	State.nop�s���
�B�&�&rr�r�)r4r�r�r�r�r�r�r�rr%rr�r�r�r�r�r�rwr-r5r�r�rrr�r��s$������%�%�N�H��
����I�����"O�"O�"O�"O�H
�
�
�"�"�"�5�5�5�-�-�-�&,�,�,�
/�
/�
/�+�+�+�+�B"�"�"�&!�!�!�������'�'�'�'�'rr�c�.�eZdZdZdd�Zdd�Z		d	d�ZdS)
�StateMachineWSaq
    `StateMachine` subclass specialized for whitespace recognition.

    There are three methods provided for extracting indented text blocks:

    - `get_indented()`: use when the indent is unknown.
    - `get_known_indented()`: use when the indent is known for all lines.
    - `get_first_known_indented()`: use when only the first line's indent is
      known.
    FTc�p�|���}|j�|j||��\}}}|r%|�t|��dz
��|rO|d���s5|���|dz
}|r|d����5||||fS)a
        Return a block of indented lines of text, and info.

        Extract an indented block where the indent is unknown for all lines.

        :Parameters:
            - `until_blank`: Stop collecting at the first blank line if true.
            - `strip_indent`: Strip common leading indent if true (default).

        :Return:
            - the indented block (a list of lines of text),
            - its indent,
            - its first line offset from BOF, and
            - whether or not it finished with a blank line.
        r$r�r^r
�get_indentedr
r/r:rO�
trim_start)r�until_blank�strip_indentrA�indented�indent�blank_finishs       rr�zStateMachineWS.get_indenteds��� �%�%�'�'��)-�)9�)F�)F����\�*;�*;�&��&�,��	.��N�N�3�x�=�=�1�,�-�-�-��	�x��{�0�0�2�2�	����!�!�!��a�K�F��	�x��{�0�0�2�2�	�����5�5rc�n�|���}|j�|j|||���\}}}|�t|��dz
��|rO|d���s5|���|dz
}|r|d����5|||fS)a�
        Return an indented block and info.

        Extract an indented block where the indent is known for all lines.
        Starting with the current line, extract the entire text block with at
        least `indent` indentation (which must be whitespace, except for the
        first line).

        :Parameters:
            - `indent`: The number of indent columns/characters.
            - `until_blank`: Stop collecting at the first blank line if true.
            - `strip_indent`: Strip `indent` characters of indentation if true
              (default).

        :Return:
            - the indented block,
            - its first line offset from BOF, and
            - whether or not it finished with a blank line.
        )�block_indentr$rr�)rr�r�r�rAr�r�s       r�get_known_indentedz!StateMachineWS.get_known_indented/s���(�%�%�'�'��)-�)9�)F�)F����\�!�*G�*#�*#�&��&�,�	
���s�8�}�}�q�(�)�)�)��	�x��{�0�0�2�2�	����!�!�!��a�K�F��	�x��{�0�0�2�2�	����-�-rc�t�|���}|j�|j|||���\}}}|�t|��dz
��|rQ|rO|d���s5|���|dz
}|r|d����5||||fS)a�
        Return an indented block and info.

        Extract an indented block where the indent is known for the first line
        and unknown for all other lines.

        :Parameters:
            - `indent`: The first line's indent (# of columns/characters).
            - `until_blank`: Stop collecting at the first blank line if true
              (1).
            - `strip_indent`: Strip `indent` characters of indentation if true
              (1, default).
            - `strip_top`: Strip blank lines from the beginning of the block.

        :Return:
            - the indented block,
            - its indent,
            - its first line offset from BOF, and
            - whether or not it finished with a blank line.
        )�first_indentr$rr�)rr�r�r��	strip_toprAr�r�s        r�get_first_known_indentedz'StateMachineWS.get_first_known_indentedMs���,�%�%�'�'��)-�)9�)F�)F����\�!�*G�*#�*#�&��&�,�	
���s�8�}�}�q�(�)�)�)��	��
�8�A�;�#4�#4�#6�#6�
��#�#�%�%�%��!����
�8�A�;�#4�#4�#6�#6�
�����5�5rN)FT)FTT)r4r�r�r�r�r�r�r�rrr�r�sc������	�	�6�6�6�6�4.�.�.�.�<<A�>B�6�6�6�6�6�6rr�c��eZdZdZdZ	dZ	dZ	dZ	ej	d��ej	d��d�Z
	dZ	d
d�Zd�Z
d	�Zd
�Zd�Zd�ZdS)�StateWSa�
    State superclass specialized for whitespace (blank lines & indents).

    Use this class with `StateMachineWS`.  The transitions 'blank' (for blank
    lines) and 'indent' (for indented text blocks) are added automatically,
    before any other transitions.  The transition method `blank()` handles
    blank lines and `indent()` handles nested indented blocks.  Indented
    blocks trigger a new state machine to be created by `indent()` and run.
    The class of the state machine to be created is in `indent_sm`, and the
    constructor keyword arguments are in the dictionary `indent_sm_kwargs`.

    The methods `known_indent()` and `firstknown_indent()` are provided for
    indented blocks where the indent (all lines' and first line's only,
    respectively) is known to the transition method, along with the attributes
    `known_indent_sm` and `known_indent_sm_kwargs`.  Neither transition method
    is triggered automatically.
    Nz *$z +)�blankr�Fc���t�|||��|j�|j|_|j�|j|_|j�|j|_|j�|j|_dSdS)z�
        Initialize a `StateSM` object; extends `State.__init__()`.

        Check for indent state machine attributes, set defaults if not set.
        N)r�r�	indent_smr��indent_sm_kwargsr��known_indent_sm�known_indent_sm_kwargsr�s   rrzStateWS.__init__�st��	���t�]�E�2�2�2��>�!�!�^�D�N�� �(�$(�$9�D�!���'�#'�>�D� ��&�.�*.�*?�D�'�'�'�/�.rc��t�|��|j�i|_|j�|j��|�|j��\}}|�||��dS)z�
        Add whitespace-specific transitions before those defined in subclass.

        Extends `State.add_initial_transitions()`.
        N)r�r�r�r��ws_patternsr��ws_initial_transitionsr�r�s   rr�zStateWS.add_initial_transitions�s|��	�%�%�d�+�+�+��=� ��D�M��
���T�-�.�.�.�!�2�2��'�)�)���{����U�K�0�0�0�0�0rc�0�|�|||��S)z9Handle blank lines. Does nothing. Override in subclasses.)r�r�s    rr�z
StateWS.blank�s���x�x��w�
�3�3�3rc��|j���\}}}}|jdd|ji|j��}|�||���}	|||	fS)z�
        Handle an indented text block. Extend or override in subclasses.

        Recursively run the registered state machine for indented blocks
        (`self.indent_sm`).
        r�rr�)r�r�r�rr�rD)
rrvr<rBr�r�r
r��smr?s
          rr�zStateWS.indent�sf���
�
,�
,�
.�
.�	��6�;��
�T�^�
F�
F�$�*�
F��0E�
F�
F���&�&���&�<�<���
�G�+�+rc���|j�|�����\}}}|jdd|ji|j��}|�||���}|||fS)a
        Handle a known-indent text block. Extend or override in subclasses.

        Recursively run the registered state machine for known-indent indented
        blocks (`self.known_indent_sm`). The indent is the length of the
        match, ``match.end()``.
        rr�r�)r�r��endr�rr�rD�	rrvr<rBr�r
r�r�r?s	         r�known_indentzStateWS.known_indent�s���
�
2�
2�5�9�9�;�;�
?�
?�	��;��
!�T�
!�A�A��
�A�$(�$?�A�A���&�&���&�<�<���
�G�+�+rc���|j�|�����\}}}|jdd|ji|j��}|�||���}|||fS)a0
        Handle an indented text block (first line's indent known).

        Extend or override in subclasses.

        Recursively run the registered state machine for known-indent indented
        blocks (`self.known_indent_sm`). The indent is the length of the
        match, ``match.end()``.
        rr�r�)r�r�r�r�rr�rDr�s	         r�first_known_indentzStateWS.first_known_indent�s���
�
8�
8������
E�
E�	��;��
!�T�
!�A�A��
�A�$(�$?�A�A���&�&���&�<�<���
�G�+�+rr�)r4r�r�r�r�r�r�r�r�r�r�r�rr�r�r�r�r�r�rrr�r�os���������$�I������O��"���'�B�J�u�-�-�'�R�Z��-�-�/�/�K��1��F�@�@�@�@� 1�1�1�4�4�4�,�,�,�
,�
,�
,�,�,�,�,�,rr�c��eZdZdZd�ZdS)�_SearchOverridea�
    Mix-in class to override `StateMachine` regular expression behavior.

    Changes regular expression matching, from the default `re.match()`
    (succeeds only if the pattern matches at the start of `self.line`) to
    `re.search()` (succeeds if the pattern matches anywhere in `self.line`).
    When subclassing a `StateMachine`, list this class **first** in the
    inheritance list of the class definition.
    c�6�|�|j��S)z�
        Return the result of a regular expression search.

        Overrides `StateMachine.match()`.

        Parameter `pattern`: `re` compiled regular expression.
        )�searchr)rrys  rrvz_SearchOverride.matchs���~�~�d�i�(�(�(rN)r4r�r�r�rvr�rrr�r��s-��������)�)�)�)�)rr�c��eZdZdZdS)�SearchStateMachinez@`StateMachine` which uses `re.search()` instead of `re.match()`.N�r4r�r�r�r�rrr�r�s������J�J��Drr�c��eZdZdZdS)�SearchStateMachineWSzB`StateMachineWS` which uses `re.search()` instead of `re.match()`.Nr�r�rrr�r�s������L�L��Drr�c��eZdZdZ		d+d�Zd�Zd�Zd�Zd�Zd�Z	d	�Z
d
�Zd�Zd�Z
d
�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�ZeZd�Zd�Zd,d�Zd,d�Zd-d�Zd.d�Zd.d�Zd �Zd!�Z d"�Z!d#�Z"d$�Z#d%�Z$d&�Z%d'�Z&d(�Z'd)�Z(d*�Z)dS)/�ViewLista>
    List with extended functionality: slices of ViewList objects are child
    lists, linked to their parents. Changes made to a child list also affect
    the parent list.  A child list is effectively a "view" (in the SQL sense)
    of the parent list.  Changes to parent lists, however, do *not* affect
    active child lists.  If a parent list is changed, any active child lists
    should be recreated.

    The start and end of the slice can be trimmed using the `trim_start()` and
    `trim_end()` methods, without affecting the parent list.  The link between
    child and parent lists can be broken by calling `disconnect()` on the
    child list.

    Also, ViewList objects keep track of the source & offset of each item.
    This information is accessible via the `source()`, `offset()`, and
    `info()` methods.
    Nc����g|_	g|_	||_	||_	t	|t
��r)|jdd�|_|jdd�|_nM|�Kt
|��|_|r||_n-�fd�tt|����D��|_t|j��t|j��ks
Jd���dS)Nc���g|]}�|f��Sr�r�)�.0�ir s  �r�
<listcomp>z%ViewList.__init__.<locals>.<listcomp>Is���H�H�H�a�v�q�k�H�H�Hr�
data mismatch)	�data�items�parent�
parent_offsetr&r��list�ranger:)r�initlistr rrrs  `   rrzViewList.__init__1s������	�F���
�	�����*���H��h��)�)�	I� �
�a�a�a�(�D�I�!�����*�D�J�J�
�
!��X���D�I��
I�"��
�
�H�H�H�H�5��X���3G�3G�H�H�H��
��4�9�~�~��T�Z���0�0�0�/�0�0�0�0�0rc�*�t|j��Sr�)r�r�rPs r�__str__zViewList.__str__L����4�9�~�~�rc�@�|jj�d|j�d|j�d�S)N�(z, items=�))r3r4r�rrPs r�__repr__zViewList.__repr__Os*���.�)�L�L�D�I�L�L�t�z�L�L�L�Lrc�>�|j|�|��kSr��r��_ViewList__cast�r�others  r�__lt__zViewList.__lt__R���D�I����E�0B�0B�$B�Brc�>�|j|�|��kSr�rrs  r�__le__zViewList.__le__S���D�I����U�1C�1C�$C�Crc�>�|j|�|��kSr�rrs  r�__eq__zViewList.__eq__Trrc�>�|j|�|��kSr�rrs  r�__ne__zViewList.__ne__Urrc�>�|j|�|��kSr�rrs  r�__gt__zViewList.__gt__Vrrc�>�|j|�|��kSr�rrs  r�__ge__zViewList.__ge__Wrrc�>�t|t��r|jS|Sr�)r&r�r�rs  r�__castzViewList.__castYs!���e�X�&�&�	��:���Lrc��||jvSr��r��r�items  r�__contains__zViewList.__contains___s���t�y� � rc�*�t|j��Sr�)r:r�rPs r�__len__zViewList.__len__brrc��t|t��ra|jdvs
Jd���|�|j|j|j�|j|j|j�||jpd���S|j|S)N�Nr$�cannot handle slice with strider)rrr)r&�slice�stepr3r��start�stopr�rr�s  r�__getitem__zViewList.__getitem__is����a����	 ��6�Y�&�&�&�(I�&�&�&��>�>�$�)�A�G�A�F�N�";�(,�
�1�7�1�6�>�(B�)-�Q�W�\��"�K�K�
K��9�Q�<�rc�H�t|t��r�|jdvs
Jd���t|t��st	d���|j|j|j|j�<|j|j|j|j�<t|j��t|j��ks
Jd���|j
r=|jpd|jz}|jpt|��|jz}||j
||�<dSdS||j|<|j
r||j
||jz<dSdS)Nr)r*z(assigning non-ViewList to ViewList slicer�r)r&r+r,r�rbr�r-r.rr:rr)rr�r$�krMs     r�__setitem__zViewList.__setitem__rs9���a����	;��6�Y�&�&�&�(I�&�&�&��d�H�-�-�
L�� J�K�K�K�(,�	�D�I�a�g�a�f�n�%�)-��D�J�q�w�q�v�~�&��t�y�>�>�S���_�_�4�4�4�o�4�4�4��{�
(��W�\��T�%7�7���V�(�s�4�y�y�D�,>�>��#'���A�a�C� � � �
(�
(�
 �D�I�a�L��{�
;�6:���A�� 2�2�3�3�3�
;�
;rc�t�	|j|=|j|=|jr|j||jz=dSdS#t$r�|j�
Jd���|j|j|j�=|j|j|j�=|jr<|jpd|jz}|jpt|��|jz}|j||�=YdSYdSwxYw)Nr*r)	r�rrrrbr,r-r.r:)rr�r2rMs    r�__delitem__zViewList.__delitem__�s���	%��	�!���
�1�
��{�
8��K��D�$6� 6�7�7�7�
8�
8���	%�	%�	%��6�>�>�#D�>�>�>��	�!�'�!�&�.�)��
�1�7�1�6�>�*��{�
%��W�\��T�%7�7���V�(�s�4�y�y�D�,>�>���K��!��$�$�$�$�
%�
%�
%�		%���s�'-�BB7�6B7c��t|t��r1|�|j|jz|j|jz���Std���)N�rz!adding non-ViewList to a ViewList�r&r�r3r�rrbrs  r�__add__zViewList.__add__�s[���e�X�&�&�	A��>�>�$�)�e�j�"8�)-��e�k�)A�"�D�D�
D��?�@�@�@rc��t|t��r1|�|j|jz|j|jz���Std���)Nr7z!adding ViewList to a non-ViewListr8rs  r�__radd__zViewList.__radd__�s[���e�X�&�&�	A��>�>�%�*�t�y�"8�).��t�z�)A�"�D�D�
D��?�@�@�@rc�z�t|t��r|xj|jz
c_ntd���|S)Nz!argument to += must be a ViewList)r&r�r�rbrs  r�__iadd__zViewList.__iadd__�s=���e�X�&�&�	A��I�I���#�I�I�I��?�@�@�@��rc�P�|�|j|z|j|z���S)Nr7)r3r�rrLs  r�__mul__zViewList.__mul__�s$���~�~�d�i�!�m�D�J��N�~�D�D�Drc�F�|xj|zc_|xj|zc_|Sr�)r�rrLs  r�__imul__zViewList.__imul__�s%���	�	�Q��	�	��
�
�a��
�
��rc�B�t|t��std���|jr5|j�t|j��|jz|��|j�|j��|j	�|j	��dS)Nz(extending a ViewList with a non-ViewList)
r&r�rbrrkr:r�rr.rrs  rr.zViewList.extend�s����%��*�*�	H��F�G�G�G��;�	K��K���s�4�9�~�~��0B�B�E�J�J�J��	�����$�$�$��
���%�+�&�&�&�&�&rrc� �|�|�|��dS|jr7|j�t|j��|jz|||��|j�|��|j�||f��dSr�)r.rrkr:r�rr�r)rr$r rAs    rr�zViewList.append�s����>��K�K��������{�
3���"�"�3�t�y�>�>�D�4F�#F��#)�6�3�3�3��I���T�"�"�"��J���v�v�.�/�/�/�/�/rc�n�|��t|t��std���|j|j||�<|j|j||�<|jrQt
|j��|zt
|j��z}|j�||jz|��dSdS|j�||��|j�|||f��|jrSt
|j��|zt
|j��z}|j�||jz|||��dSdS)Nz+inserting non-ViewList with no source given)	r&r�rbr�rrr:rkr)rr�r$r rA�indexs      rrkzViewList.insert�sF���>��d�H�-�-�
O�� M�N�N�N�!�Y�D�I�a��c�N�"�j�D�J�q��s�O��{�
E��T�Y���!�+�s�4�9�~�~�=����"�"�5�4�+=�#=�t�D�D�D�D�D�
E�
E�
�I���Q��%�%�%��J���a�&�&�!1�2�2�2��{�
3��T�Y���!�+�s�4�9�~�~�=����"�"�5�4�+=�#=�t�#)�6�3�3�3�3�3�
3�
3rr	c��|jrNt|j��|zt|j��z}|j�||jz��|j�|��|j�|��Sr�)rr:r��poprr)rr�rEs   rrGzViewList.pop�so���;�	8����^�^�a�'�3�t�y�>�>�9�E��K�O�O�E�D�$6�6�7�7�7��
���q�����y�}�}�Q���rr$c�
�|t|j��kr(td|�dt|j���d����|dkrtd���|jd|�=|jd|�=|jr|xj|z
c_dSdS)zW
        Remove items from the start of the list, without touching the parent.
        �#Size of trim too large; can't trim � items from a list of size r#r�Trim size must be >= 0.N)r:r�rJrrrrLs  rr�zViewList.trim_start�s���
�s�4�9�~�~����*�:;�!�!�S���^�^�^�^�M�N�N�
N�
��U�U��6�7�7�7��I�b�q�b�M��J�r��r�N��;�	$����!�#�����	$�	$rc���|t|j��kr(td|�dt|j���d����|dkrtd���|j|d�=|j|d�=dS)zU
        Remove items from the end of the list, without touching the parent.
        rIrJr#rrKN)r:r�rJrrLs  r�trim_endzViewList.trim_end�s���
�s�4�9�~�~����*�:;�!�!�S���^�^�^�^�M�N�N�
N�
��U�U��6�7�7�7��I�q�b�c�c�N��J��r�s�s�O�O�Orc�6�|�|��}||=dSr�)rE)rr$rEs   rr�zViewList.remove�s���
�
�4� � ����K�K�Krc�6�|j�|��Sr�)r��countr#s  rrPzViewList.count�����y���t�$�$�$rc�6�|j�|��Sr�)r�rEr#s  rrEzViewList.index�rQrc�x�|j���|j���d|_dSr�)r��reverserrrPs rrTzViewList.reverse�s5���	�������
����������rc��tt|j|j��g|�R�}d�|D��|_d�|D��|_d|_dS)Nc��g|]
}|d��S)rr��r��entrys  rr�z!ViewList.sort.<locals>.<listcomp>s��/�/�/�%�U�1�X�/�/�/rc��g|]
}|d��Sr�r�rWs  rr�z!ViewList.sort.<locals>.<listcomp>s��0�0�0�5�e�A�h�0�0�0r)�sorted�zipr�rr)rr8�tmps   r�sortz
ViewList.sortsZ���S���D�J�/�/�7�$�7�7�7��/�/�3�/�/�/��	�0�0�C�0�0�0��
�����rc��	|j|S#t$r4|t|j��kr|j|dz
ddfcYS�wxYw)z%Return source & offset for index `i`.r$rN)rrJr:r�r/s  rr0z
ViewList.info
se��	��:�a�=� ���	�	�	��C��	�N�N�"�"��z�!�a�%�(��+�T�1�1�1�1��		���s��:A
�A
c�8�|�|��dS)zReturn source for index `i`.r�r0r/s  rr zViewList.source����y�y��|�|�A��rc�8�|�|��dS)zReturn offset for index `i`.r$r`r/s  rrAzViewList.offsetrarc��d|_dS)z-Break link between this list and parent list.N)rrPs r�
disconnectzViewList.disconnects
������rc#�^K�t|j|j��D]\}\}}|||fV��dS)z8Return iterator yielding (source, offset, value) tuples.N)r[r�r)rr�r rAs    r�xitemszViewList.xitems sM����),�T�Y��
�)C�)C�	(�	(�%�U�$�V�V��&�%�'�'�'�'�'�	(�	(rc�X�|���D]}td|z���dS)z=Print the list in `grep` format (`source:offset:value` lines)z%s:%d:%sN)rfr()rrs  r�pprintzViewList.pprint%s9���K�K�M�M�	%�	%�D��*�t�#�$�$�$�$�	%�	%r)NNNNN)Nr)r	r�)*r4r�r�r�rrrrrrrrrrr%r'r0r3r5r9r;r=r?�__rmul__rAr.r�rkrGr�rMr�rPrErTr]r0r rArdrfrhr�rrr�r�se��������$:>�,0�B�B�B�B�6���M�M�M�C�B�B�C�C�C�C�C�C�C�C�C�B�B�B�C�C�C����!�!�!���� � � �;�;�;�"
%�
%�
%�A�A�A�A�A�A����E�E�E��H����
'�'�'�0�0�0�0�3�3�3�3�" � � � �$�$�$�$�
�
�
�
����%�%�%�%�%�%����
���������������(�(�(�
%�%�%�%�%rr�c�P�eZdZdZdejfd�Zdd�Z		d
d�Zdd	�Z	d
�Z
d�ZdS)r'z*A `ViewList` with string-specific methods.rc�R���fd�|j||�D��|j||�<dS)z�
        Trim `length` characters off the beginning of each item, in-place,
        from index `start` to `end`.  No whitespace-checking is done on the
        trimmed text.  Does not affect slice parent.
        c�$��g|]}|�d���
Sr�r�)r�r�lengths  �rr�z(StringList.trim_left.<locals>.<listcomp>5s7��� B� B� B�$(�!%�V�W�W�
� B� B� BrNr")rrmr-r�s `  r�	trim_leftzStringList.trim_left/sN��� B� B� B� B�,0�I�e�C�i�,@� B� B� B��	�%��)���rFc�,�|}t|j��}||kro|j|}|���snM|r@|ddkr4|�|��\}}t	|||�||dz���|dz
}||k�o|||�S)rnr� r$)r:r�rOr0rp)rr-rqr��lastrr rAs        rrozStringList.get_text_block8s������4�9�~�~���D�j�j��9�S�>�D��:�:�<�<�
���
=�t�A�w�#�~�~�!%���3������0��e�C�i��&�17�!��=�=�=��1�H�C��D�j�j��E�#�I��rTNc�z�|}|}|�|�|}|�|dz
}t|j��}||kr�|j|}	|	rT|	ddks|�F|	d|����r*||ko"|j|dz
���}
n_|	���}|s|rd}
nDn6|�4t|	��t|��z
}|�|}nt	||��}|dz
}||k��d}
|||�}
|�|
r|
jd|d�|
jd<|r|r|
�||du���|
|pd|
fS)a�
        Extract and return a StringList of indented lines of text.

        Collect all lines with indentation, determine the minimum indentation,
        remove the minimum indentation from all indented lines (unless
        `strip_indent` is false), and return them. All lines up to but not
        including the first unindented line will be returned.

        :Parameters:
          - `start`: The index of the first line to examine.
          - `until_blank`: Stop collecting at the first blank line if true.
          - `strip_indent`: Strip common leading indent if true (default).
          - `block_indent`: The indent of the entire block, if known.
          - `first_indent`: The indent of the first line, if known.

        :Return:
          - a StringList of indented lines with minimum indent removed;
          - the amount of the indent;
          - a boolean: did the indented block finish with a blank line or EOF?
        Nr$rrp)r-)r:r�rO�lstrip�minrn)rr-r�r�r�r�r�r�rqrr��stripped�line_indentrrs              rr�zStringList.get_indentedMs���,�����#��(<�'�L��#��1�H�C��4�9�~�~���D�j�j��9�S�>�D��
��a��C���)�5�!%�m�|�m�!4�!:�!:�!<�!<�6�"%�u��!C�(,�	�#��'�(:�(@�(@�(B�(B�$B����{�{�}�}�H��	
6���#$�L����%�!�$�i�i�#�h�-�-�7���>�(�F�F� ���5�5�F��1�H�C�+�D�j�j�.�L��U�3�Y����#��#�!�J�q�M�,�-�-�8�E�J�q�M��	F�l�	F��O�O�F�<�t�+C�O�E�E�E��f�k��<�/�/rc	��
�|||�}|�
tt|j����D�]"}tj|j|��}	||}n=#t
$r0|t|j|��t|��z
z
}YnwxYw	||}n=#t
$r0|t|j|��t|��z
z
}YnwxYw|j|||����x|j|<}	|	r?t�
t|	��t|	�����z
���
��$|r(d�
cxkr|krnn�
fd�|jD��|_|S)Nrc�$��g|]}|�d���
Sr�r�)r�rr�s  �rr�z+StringList.get_2D_block.<locals>.<listcomp>�s!���?�?�?�D�$�v�w�w�-�?�?�?r)	rr:r�r�column_indicesrJ�rstriprtrs)r�top�left�bottom�rightr�rrr��cirr�s          @r�get_2D_blockzStringList.get_2D_block�s�����S��Z� �����s�5�:���'�'�
	E�
	E�A��%�e�j��m�4�4�B�
5��$�x�����
5�
5�
5���E�J�q�M�*�*�S��W�W�4�4����
5����
6��5�	�����
6�
6�
6���U�Z��]�+�+�c�"�g�g�5�5����
6����#(�:�a�=��e��#<�#C�#C�#E�#E�E�E�J�q�M�D��
E��V�S��Y�Y��T�[�[�]�]�1C�1C�%C�D�D����	@�A��.�.�.�.��.�.�.�.�.�?�?�?�?�E�J�?�?�?�E�J��s$�A�7B�B�B"�"7C�Cc�P�tt|j����D]�}|j|}t|t��r_g}|D]=}|�|��t
|��dvr|�|���>d�|��|j|<��dS)zrPad all double-width characters in `self` appending `pad_char`.

        For East Asian language support.
        �WFriN)rr:r�r&r�r�rr))r�pad_charr�r�new�chars      r�pad_double_widthzStringList.pad_double_width�s���
�s�4�9�~�~�&�&�	,�	,�A��9�Q�<�D��$��$�$�
,��� �-�-�D��J�J�t�$�$�$�'��-�-��5�5��
�
�8�,�,�,��!�w�w�s�|�|��	�!���	,�	,rc��tt|j����D]+}|j|�||��|j|<�,dS)z6Replace all occurrences of substring `old` with `new`.N)rr:r��replace)r�oldr�r�s    rr�zStringList.replace�sN���s�4�9�~�~�&�&�	:�	:�A��9�Q�<�/�/��S�9�9�D�I�a�L�L�	:�	:rr�)rFTNN)T)r4r�r�r�r*�maxsizernror�r�r�r�r�rrr'r'+s�������4�4�&'�S�[�B�B�B�B�����*EI�59�:0�:0�:0�:0�x����*
,�
,�
,�:�:�:�:�:rr'c��eZdZdS)�StateMachineErrorN�r4r�r�r�rrr�r����������rr�c��eZdZdS)rHNr�r�rrrHrH�r�rrHc��eZdZdS)r|Nr�r�rrr|r|�r�rr|c��eZdZdS)r�Nr�r�rrr�r��r�rr�c��eZdZdS)r�Nr�r�rrr�r��r�rr�c��eZdZdS)r�Nr�r�rrr�r��r�rr�c��eZdZdS)r�Nr�r�rrr�r��r�rr�c��eZdZdS)rpNr�r�rrrprp�r�rrpc��eZdZdZdS)r6z�
    Raise from within a transition method to switch to another transition.

    Raise with one argument, the new transition name.
    Nr�r�rrr6r6�s���������rr6c��eZdZdZdS)r9z�
    Raise from within a transition method to switch to another state.

    Raise with one or two arguments: new state name, and an optional new
    transition name.
    Nr�r�rrr9r9�s���������rr9�Fz[]c�t��|r|�d|��}�fd�|���D��S)a6
    Return a list of one-line strings with tabs expanded, no newlines, and
    trailing whitespace stripped.

    Each tab is expanded with between 1 and `tab_width` spaces, so that the
    next character's index becomes a multiple of `tab_width` (8 by default).

    Parameters:

    - `astring`: a multi-line string.
    - `tab_width`: the number of columns between tab stops.
    - `convert_whitespace`: convert form feeds and vertical tabs to spaces?
    - `whitespace`: pattern object with the to-be-converted
      whitespace characters (default [\v\f]).
    rpc�^��g|])}|���������*Sr�)�
expandtabsrz)r��s�	tab_widths  �rr�z string2lines.<locals>.<listcomp>�s1���K�K�K��A�L�L��#�#�*�*�,�,�K�K�Kr)�sub�
splitlines)�astringr��convert_whitespace�
whitespaces `  r�string2linesr��sF���"�/��.�.��g�.�.��K�K�K�K�g�6H�6H�6J�6J�K�K�K�Krc��tj��\}}}|jr|j}|j�|jj}|j||j|j|jfS)z�
    Return exception information:

    - the exception's class name;
    - the exception object;
    - the name of the file containing the offending code;
    - the line number of the offending code;
    - the function name of the offending code.
    )	r*�exc_info�tb_next�tb_frame�f_coder4�co_filename�	tb_lineno�co_name)r�r��	traceback�codes    rr�r��sa��!�\�^�^��D�%��
�
�&��%�	��
�&���$�D��M�5�$�"2�I�4G��L��r)r��
__docformat__r*r��unicodedatar�docutilsrrr�r�r�r�r�r�r�r'�	Exceptionr�rHr|r�r�r�r�rpr6r9r�r�r�r�rr�<module>r�so��
e�e�N#�
�
�
�
�
�	�	�	�	�(�(�(�(�(�(�������A�A�A�A�A�A�A�A�HL'�L'�L'�L'�L'�L'�L'�L'�^d6�d6�d6�d6�d6�\�d6�d6�d6�NJ,�J,�J,�J,�J,�e�J,�J,�J,�Z)�)�)�)�)�)�)�)�.	�	�	�	�	��,�	�	�	�
	�	�	�	�	�?�N�	�	�	�
K%�K%�K%�K%�K%�K%�K%�K%�\E:�E:�E:�E:�E:��E:�E:�E:�P)�(�(�(�(�	�(�(�(�0�0�0�0�0�)�0�0�0�2�2�2�2�2�+�2�2�2�5�5�5�5�5�.�5�5�5�7�7�7�7�7�0�7�7�7�8�8�8�8�8� 1�8�8�8�7�7�7�7�7�0�7�7�7�9�9�9�9�9�!2�9�9�9������9���������i����%&�%�&�B�J�x�0�0�L�L�L�L�,����r

Hacked By AnonymousFox1.0, Coded By AnonymousFox