Файловый менеджер - Редактировать - /usr/lib/python3/dist-packages/pip/_vendor/pyparsing/__pycache__/helpers.cpython-310.pyc
Ðазад
o !��h�� � @ s d dl Zd dlZddlmZ ddlT ddlmZmZm Z dgdd�d e eef d e eef de dee d ee de defdd�Z dhdd�d edee dee defdd�Zd edefdd�Zd edefdd�Z diddd�de ee ef de de d e d!e d"e defd#d$�Zd%ed&edefd'd(�Z djdd)�d ed*e d+e defd,d-�Zd edefd.d/�Zd edefd0d1�Zd2d3de� fe� d4�d5e eef d6e eef d7ee d8ed9edefd:d;�Zed<�ed=�fd>d?�Zd@e eef deeef fdAdB�Zd@e eef deeef fdCdD�Z ee!e"e#dE ��$dF��\Z%Z&dGdH� ej'j(�)� D �Z*e+dIdJ�,e*� dK ��$dL�Z-dMdN� Z.G dOdP� dPe/�Z0e eeee eef e eef f f Z1e ee1ee0ee2 f ee1ee0f f Z3ed2�ed3�fdQedRe4e3 dSe eef dTe eef def dUdV�Z5dg fdWdX�Z6e7e+dY�dZ ��$d[�Z8 e+d\��$d]�Z9 e+d^��:� �$d_�Z;e+d`��$da�Z< e7e+dY�dZ e<B ��$db�Z= e=Z> e+dc��$dd�Z? dedf� e@� �A� D �ZBeZCeZDeZEeZFeZGeZHeZIeZJeZKe ZLe%e&ZMZNe-ZOe.ZPe0ZQe5ZRe8ZSe9ZTe;ZUe<ZVe=ZWe>ZXe?ZYdS )k� N� )�__diag__)�*)�_bslash�_flatten�_escape_regex_range_chars�,F)�allow_trailing_delim�expr�delim�combine�min�maxr �returnc C s� t | t�r t�| �} djt| �� �� �t|�|rd�t|��ndd�}|s)t|�}|dur9|dk r5t d��|d8 }|durM|durI||krIt d��|d8 }| || ||f }|r_|t |�7 }|rht|��|�S |�|�S ) a/ Helper to define a delimited list of expressions - the delimiter defaults to ','. By default, the list elements and delimiters can have intervening whitespace, and comments, but this can be overridden by passing ``combine=True`` in the constructor. If ``combine`` is set to ``True``, the matching tokens are returned as a single token string, with the delimiters included; otherwise, the matching tokens are returned as a list of tokens, with the delimiters suppressed. If ``allow_trailing_delim`` is set to True, then the list may end with a delimiter. Example:: delimited_list(Word(alphas)).parse_string("aa,bb,cc") # -> ['aa', 'bb', 'cc'] delimited_list(Word(hexnums), delim=':', combine=True).parse_string("AA:BB:CC:DD:EE") # -> ['AA:BB:CC:DD:EE'] z{expr} [{delim} {expr}]...{end}z [{}]� )r r �endNr zmin must be greater than 0z)max must be greater than, or equal to min) � isinstance�str_type� ParserElement�_literalStringClass�format�str�copy� streamline�Suppress� ValueError�Opt�Combine�set_name)r r r r r r �dlName�delimited_list_expr� r! �?/usr/lib/python3/dist-packages/pip/_vendor/pyparsing/helpers.py�delimited_list s. � r# )�intExpr�int_exprr$ c sr |p|}t � � � �fdd�}|du rtt��dd� �}n|�� }|�d� |j|dd� |� �d t�� d �S )a~ Helper to define a counted list of expressions. This helper defines a pattern of the form:: integer expr expr expr... where the leading integer tells how many expr expressions follow. The matched tokens returns the array of expr tokens as a list - the leading count token is suppressed. If ``int_expr`` is specified, it should be a pyparsing expression that produces an integer value. Example:: counted_array(Word(alphas)).parse_string('2 ab cd ef') # -> ['ab', 'cd'] # in this parser, the leading integer value is given in binary, # '10' indicating that 2 values are in the array binary_constant = Word('01').set_parse_action(lambda t: int(t[0], 2)) counted_array(Word(alphas), int_expr=binary_constant).parse_string('10 ab cd ef') # -> ['ab', 'cd'] # if other fields must be parsed after the count but before the # list items, give the fields results names and they will # be preserved in the returned ParseResults: count_with_metadata = integer + Word(alphas)("type") typed_array = counted_array(Word(alphanums), int_expr=count_with_metadata)("items") result = typed_array.parse_string("3 bool True True False") print(result.dump()) # prints # ['True', 'True', 'False'] # - items: ['True', 'True', 'False'] # - type: 'bool' c s, |d }� |r�| nt � K � |d d �= d S �Nr )�Empty)�s�l�t�n�� array_exprr r! r"