Your IP : 216.73.216.52


Current Path : /snap/certbot/5451/lib/python3.12/site-packages/pycparser/__pycache__/
Upload File :
Current File : //snap/certbot/5451/lib/python3.12/site-packages/pycparser/__pycache__/_ast_gen.cpython-312.pyc

�

q[�i,���ddlmZddlZddlmZGd�d�ZGd�d�ZdZd	Ze	d
k(r�ejjejje
��Zejjed�Zejjed�Zee�Zeed
�5Zej+e�ddd�yy#1swYyxYw)�)�TemplateN)�IOc�0�eZdZdd�Zdeeddfd�Zd�Zy)�ASTCodeGeneratorc��||_|j|�D��cgc]\}}t||���c}}|_ycc}}w)zIInitialize the code generator from a configuration
        file.
        N)�cfg_filename�
parse_cfgfile�NodeCfg�node_cfg)�selfr�name�contentss    ��/build/snapcraft-certbot-8ace4148c346cc61c23dfdbf9a13f72e/parts/certbot/install/lib/python3.12/site-packages/pycparser/_ast_gen.py�__init__zASTCodeGenerator.__init__sC��)���%)�$6�$6�|�$D�
� ��x�
�D�(�#�
��
��
s�<�file�returnNc���tt�j|j��}|tz
}|j
D]}||j
�dzz
}�|j|�y)z2Generates the code into file, an open file buffer.)rz

N)r�_PROLOGUE_COMMENT�
substituter�_PROLOGUE_CODEr�generate_source�write)rr�srcrs    r�generatezASTCodeGenerator.generate sc���(�)�4�4�$�BS�BS�4�T���~����
�
�	7�H��8�+�+�-��6�6�C�	7�	
�
�
�3��c	#��K�t|d�5}|D]�}|j�}|r|jd�r�'|jd�}|jd�}|jd�}|dks
||ks||krt	d|�d|�d	���|d
|}||dz|}|r-|jd�D�	cgc]}	|	j���c}	ng}
||
f����	d
d
d
�y
cc}	w#1swYy
xYw�w)z`Parse the configuration file and yield pairs of
        (name, contents) for each node.
        �r�#�:�[�]�zInvalid line in �:
�
N�,)�open�strip�
startswith�find�RuntimeError�split)r�filename�f�line�colon_i�
lbracket_i�
rbracket_ir
�val�v�vallists           rr	zASTCodeGenerator.parse_cfgfile*s������(�C�
 �	$�A��

$���z�z�|���t���s�3���)�)�C�.��!�Y�Y�s�^�
�!�Y�Y�s�^�
��Q�;�*��"7�:��;S�&�)9�(��3�t�f�B�'O�P�P��H�W�~���:��>�J�7��AD�c�i�i��n�=��1�7�7�9�=�"���G�m�#�

$�	$�	$��>�	$�	$�s/�
C.�B C"�/C�
C"�	C.�C"�"C+�'C.)�
_c_ast.cfg)�__name__�
__module__�__qualname__rr�strrr	�rrrrs#��
��R��W����$rrc�4�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	y)	r
z�Node configuration.

    name: node name
    contents: a list of contents - attributes and child nodes
    See comment at the top of the configuration file for details.
    c��||_g|_g|_g|_g|_|D]�}|jd�}|jj
|�|jd�r|jj
|��\|jd�r|jj
|���|jj
|���y)N�*z**)r
�all_entries�attr�child�	seq_child�rstrip�append�endswith)rr
r�entry�clean_entrys     rrzNodeCfg.__init__Gs�����	������	���
�����		(�E��,�,�s�+�K����#�#�K�0��~�~�d�#����%�%�k�2�����$��
�
�!�!�+�.��	�	� � ��'�		(rc��|j�}|d|j�zz
}|d|j�zz
}|d|j�zz
}|S)Nr$)�	_gen_init�
_gen_children�	_gen_iter�_gen_attr_names�rrs  rrzNodeCfg.generate_sourceYsY���n�n����t�d�(�(�*�*�*���t�d�n�n�&�&�&���t�d�*�*�,�,�,���
rc�>�d|j�d�}|jrIdj|j�}djd�|jD��}|dz
}d|�d�}nd}d	}|d
|�d�z
}|d|�d
�z
}|jdgzD]}|d|�d|�d�z
}�|S)Nzclass z(Node):
�, c3�(K�|]
}d|�d����y�w)�'Nr:)�.0�es  r�	<genexpr>z$NodeCfg._gen_init.<locals>.<genexpr>es����A�1��!��A�h�A�s�z, 'coord', '__weakref__'z(self, z
, coord=None)z'coord', '__weakref__'z(self, coord=None)z    __slots__ = (z)
z    def __init__r#�coordz
        self.z = r$)r
r>�join)rr�args�slots�arglistr
s      rrHzNodeCfg._gen_init`s����t�y�y�k��+������9�9�T�-�-�.�D��I�I�A��0@�0@�A�A�E��/�/�E���v�]�3�G�,�E�*�G��"�5�'��-�-���!�'��#�.�.���$�$��y�0�	5�D��]�4�&��D�6��4�4�C�	5��
rc���d}|jrU|dz
}|jD]}|d|�d�z
}|d|�d|�d�z
}�|jD]}|d|�d	�z
}|d
|�d�z
}�|dz
}|S|d
z
}|S)Nz    def children(self):
z        nodelist = []
�        if self.� is not None:
z            nodelist.append(("z", self.z))
z'        for i, child in enumerate(self.�	 or []):
z            nodelist.append((f"z[{i}]", child))
z        return tuple(nodelist)
z        return ()
�r>r@rA�rrr@rAs    rrIzNodeCfg._gen_childrents���)������,�,�C����
S���)�%���@�@���7��w�h�u�g�T�R�R��
S�"�^�^�
X�	��@���:�V�V���8���CV�W�W��
X�
�5�5�C��
�
�(�(�C��
rc���d}|jra|jD]}|d|�d�z
}|d|�d�z
}�|jD]}|d|�d�z
}|dz
}�|js|js|d	z
}|S|d	z
}|S)
Nz    def __iter__(self):
rZr[z            yield self.r$z        for child in (self.r\z            yield child
z        return
        yield
r]r^s    rrJzNodeCfg._gen_iter�s���)��������
;���)�%���@�@���0���r�:�:��
;�"�^�^�
3�	��4�Y�K�z�J�J���2�2��
3��J�J�$�.�.��=�=��
�
�
�9�9�C��
rc�V�ddjd�|jD��zdz}|S)Nz    attr_names = (�c3�&K�|]	}|�d����y�w)rNNr:)rQ�nms  rrSz*NodeCfg._gen_attr_names.<locals>.<genexpr>�s����,M�R��v�R�[�,M�s��))rUr?rLs  rrKzNodeCfg._gen_attr_names�s*��"�R�W�W�,M�4�9�9�,M�%M�M�PS�S���
rN)
r6r7r8�__doc__rrrHrIrJrKr:rrr
r
?s%���(�$��(�(�*rr
a�#-----------------------------------------------------------------
# ** ATTENTION **
# This code was automatically generated from _c_ast.cfg
#
# Do not modify it directly. Modify the configuration file and
# run the generator again.
# ** ** *** ** **
#
# pycparser: c_ast.py
#
# AST Node classes.
#
# Eli Bendersky [https://eli.thegreenplace.net/]
# License: BSD
#-----------------------------------------------------------------

ae
import sys
from typing import Any, ClassVar, IO, Optional

def _repr(obj):
    """
    Get the representation of an object, with dedicated pprint-like format for lists.
    """
    if isinstance(obj, list):
        return '[' + (',\n '.join((_repr(e).replace('\n', '\n ') for e in obj))) + '\n]'
    else:
        return repr(obj)

class Node:
    __slots__ = ()
    """ Abstract base class for AST nodes.
    """
    attr_names: ClassVar[tuple[str, ...]] = ()
    coord: Optional[Any]
    def __repr__(self):
        """ Generates a python representation of the current node
        """
        result = self.__class__.__name__ + '('

        indent = ''
        separator = ''
        for name in self.__slots__[:-2]:
            result += separator
            result += indent
            result += name + '=' + (_repr(getattr(self, name)).replace('\n', '\n  ' + (' ' * (len(name) + len(self.__class__.__name__)))))

            separator = ','
            indent = '\n ' + (' ' * len(self.__class__.__name__))

        result += indent + ')'

        return result

    def children(self):
        """ A sequence of all children that are Nodes
        """
        pass

    def show(
        self,
        buf: IO[str] = sys.stdout,
        offset: int = 0,
        attrnames: bool = False,
        showemptyattrs: bool = True,
        nodenames: bool = False,
        showcoord: bool = False,
        _my_node_name: Optional[str] = None,
    ):
        """ Pretty print the Node and all its attributes and
            children (recursively) to a buffer.

            buf:
                Open IO buffer into which the Node is printed.

            offset:
                Initial offset (amount of leading spaces)

            attrnames:
                True if you want to see the attribute names in
                name=value pairs. False to only see the values.

            showemptyattrs:
                False if you want to suppress printing empty attributes.

            nodenames:
                True if you want to see the actual node names
                within their parents.

            showcoord:
                Do you want the coordinates of each Node to be
                displayed.
        """
        lead = ' ' * offset
        if nodenames and _my_node_name is not None:
            buf.write(lead + self.__class__.__name__+ ' <' + _my_node_name + '>: ')
        else:
            buf.write(lead + self.__class__.__name__+ ': ')

        if self.attr_names:
            def is_empty(v):
                v is None or (hasattr(v, '__len__') and len(v) == 0)
            nvlist = [(n, getattr(self,n)) for n in self.attr_names \
                        if showemptyattrs or not is_empty(getattr(self,n))]
            if attrnames:
                attrstr = ', '.join(f'{name}={value}' for name, value in nvlist)
            else:
                attrstr = ', '.join(f'{value}' for _, value in nvlist)
            buf.write(attrstr)

        if showcoord:
            buf.write(f' (at {self.coord})')
        buf.write('\n')

        for (child_name, child) in self.children():
            child.show(
                buf,
                offset=offset + 2,
                attrnames=attrnames,
                showemptyattrs=showemptyattrs,
                nodenames=nodenames,
                showcoord=showcoord,
                _my_node_name=child_name)


class NodeVisitor:
    """ A base NodeVisitor class for visiting c_ast nodes.
        Subclass it and define your own visit_XXX methods, where
        XXX is the class name you want to visit with these
        methods.

        For example:

        class ConstantVisitor(NodeVisitor):
            def __init__(self):
                self.values = []

            def visit_Constant(self, node):
                self.values.append(node.value)

        Creates a list of values of all the constant nodes
        encountered below the given node. To use it:

        cv = ConstantVisitor()
        cv.visit(node)

        Notes:

        *   generic_visit() will be called for AST nodes for which
            no visit_XXX method was defined.
        *   The children of nodes for which a visit_XXX was
            defined will not be visited - if you need this, call
            generic_visit() on the node.
            You can use:
                NodeVisitor.generic_visit(self, node)
        *   Modeled after Python's own AST visiting facilities
            (the ast module of Python 3.0)
    """

    _method_cache = None

    def visit(self, node: Node):
        """ Visit a node.
        """

        if self._method_cache is None:
            self._method_cache = {}

        visitor = self._method_cache.get(node.__class__.__name__, None)
        if visitor is None:
            method = 'visit_' + node.__class__.__name__
            visitor = getattr(self, method, self.generic_visit)
            self._method_cache[node.__class__.__name__] = visitor

        return visitor(node)

    def generic_visit(self, node: Node):
        """ Called if no explicit visitor function exists for a
            node. Implements preorder visiting of the node.
        """
        for _, c in node.children():
            self.visit(c)

�__main__r5zc_ast.py�w)�stringr�os�typingrrr
rrr6�path�dirname�abspath�__file__�base_dirrU�cfg_path�out_path�ast_genr&�outrr:rr�<module>rts��� �	��'$�'$�T`�`�F��"g��T�z���w�w���r�w�w���x�8�9�H��w�w�|�|�H�l�3�H��w�w�|�|�H�j�1�H��x�(�G�	
�h��	�����������
��s�+C�C