관리-도구
편집 파일: pyparsing.cpython-38.pyc
U ��.e, � s @ s� d Z dZdZdZddlZddlmZ ddlZddl Z ddl Z ddlZddlZddl Z ddlZddlZddlZddlmZ ddlmZ ddlZdd lmZ zdd lmZ W n ek r� ddlmZ Y nX zddlmZ W n ek r� ddlmZ Y nX z dd lmZ ddlmZm Z W n2 ek �rN dd l mZ ddl mZm Z Y nX zddl m!Z" W nB ek �r� zddl#m!Z" W n ek �r� dZ"Y nX Y nX zddlm$Z$ W n$ ek �r� G dd� d�Z$Y nX e$� Z%de%_ de%_&e$� Z'de'_ de'_(de'_)de'_*de'_+de'_,dddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~dd�d�d�d�d�d�d�d�d�d�gsZ-e.e j/�dd�� Z0e0d d�kZ1e1�rVe j2Z3e4Z5e6Z7e4Z8e4Z9e:e;e<e=e>e.e?e@eAeBeCgZDn`e jEZ3eFZGd�d�� Z9g ZDddlHZHd��I� D ]8ZJzeD�KeLeHeJ�� W n eMk �r� Y �q|Y nX �q|eNd�d�� eGd��D ��ZOd�d�� ZPejQejR ZSd�ZTeTd� ZUeSeT ZVe6d��ZWd��Xd�d�� ejYD ��ZZ�dYd�d��Z[G d�d4� d4e\�Z]G d�d6� d6e]�Z^G d�d8� d8e]�Z_G d�d:� d:e_�Z`G d�d=� d=e\�ZaG d�d�� d�eb�ZcG d�d9� d9eb�Zde�eed� d�dQ� Zfd�db� Zgd�d_� Zhd�d�� Zid�d�� Zjd�d�� Zkd�di� Zl�dZd�d��ZmG d�d;� d;eb�ZnG d�d�� d�en�ZoG d�dC� dCen�ZpG d�d#� d#ep�ZqG d�d.� d.ep�ZrG d�d+� d+ep�ZsG d�d�� d�es�ZtesZuesen_vG d�d(� d(ep�ZwG d�d� des�ZxG d�d� dew�ZyG d�d�� d�ep�ZzG d�dF� dFep�Z{G d�d�� d�e{�Z|G d�dJ� dJe|�Z}G d�d>� d>ep�Z~G d�d<� d<ep�ZG d�d� dep�Z�G d�dE� dEep�Z�G d�dĄ d�ep�Z�G d�d&� d&e��Z�G d�d*� d*e��Z�G d�d)� d)e��Z�G d�dA� dAe��Z�G d�d@� d@e��Z�G d�dH� dHe��Z�G d�dG� dGe��Z�G d�d7� d7en�Z�G d�d� de��Z�G d�d3� d3e��Z�G d�d-� d-e��Z�G d�d"� d"e��Z�G d�d5� d5en�Z�G d�d$� d$e��Z�G d�d,� d,e��Z�G d�d/� d/e��Z�G d�dք d�e��Z�G d�d0� d0e��Z�G d�dI� dIe��Z�G d�dڄ d�eb�Z�G d�d2� d2e��Z�G d�d?� d?e��Z�G d�d%� d%e��Z�G d�dD� dDe��Z�G d�d � d e��Z�G d�d'� d'e��Z�G d�d!� d!e��Z�G d�dB� dBe��Z�G d�d1� d1eb�Z�d�dz� Z��d[d�dX�Z��d\d�dT�Z�d�d� Z�d�dg� Z�d�df� Z�d�d� Z��d]d�dk�Z�d�dY� Z��d^d�d�Z�d�d�� Z�d�d�� Z�eq� ��d[�Z�e�� ��da�Z�e�� ��d`�Z�e�� ��dy�Z�e�� ��dx�Z�e{eWd�d�d���d�d�� �Z�e~d����d�d�� �Z�e~d����d�d�� �Z�e�e�B e�B e�d�d�d�B Z�e�e�e�d�� e� �Z�esd��e�d����d�� e�e�e�e�B �����d � �d Z��ddw� Z��dde� Z��ddt� Z��ddr� Z��dd�� Z�e��dd�� �Z�e��dd�� �Z�e��d �e��d �f�d�d�Z��d dc� Zddd� ZÐdd}� Z�eb� e�_Őd_�dd��Z�e$� Z�eb� e�_�eb� e�_�e��d�e��d�f�dd��Z�e�Z�e�e~�d��d ����d�Z�e�e~�d��d ����d�Z�e�e~�d��d e~�d��d B ����d�Z�e�eu�d�eΠ� ����d�Zϐd�ddeΠ� f�ddh�ZАd`�dd~�Z�e��d�Z�e��d �Z�e�e{eSeV�d! ����d"��\Z�Z�e�eאd#�I� �d$��Z�e~�d%�d&�Xeؠ١ � �d' ����d(�Zڐd)ds� Z�e�e~�d*��d+ ����d,�Z�e~�d-����d.�Z�e~�d/��ޡ ���d0�Z�e~�d1����d2�Z�e�e~�d*��d+ e�B ����d3�Z�e�Z�e~�d4����d5�Z�e�e�e{eZd�d6�e�e{�d7�esd� e�� � ���� ���d8�Z�e�e�eΠ� e�B d��d9����dR�Z�G �d:d�� d��Z�G �d;�d<� �d<eb�Z�G �d=d�� d�eb�Z�G �d>d�� d�e�Z�e�j�j�j�e�j�j�j� e�j�j�j� e�j�_�e1� rXe�e�d?e�j� e�e�d@e�j� e�e�dAe�j� e�e�dBe�j� e�e�dCe�j�� e�e�dDe�j� e�e�j�dEe�j�j� e�e�j�dFe�j�j� e�e�j�dGe�j�j� e�e�dHe�j�� e�e�dIe�j�� e�e�dJe�j�� e��dKk�r�ex�dL�Z�ex�dM�Z�e{eSeV�dN �Z�e�e��dOd�dP���e��Z�e�e�e������dQ�Z��dRe�B Z�e�e��dOd�dP���e���Z e�e��e �����dS��Ze��dT�e��dQ� e� �e�dS� �Z�e���dU� e�j���dV� e�j���dV� e�j���dW� dd�l�Ze�j��e��e�j�� e�j���dX� dS (a a� pyparsing module - Classes and methods to define and execute parsing grammars ============================================================================= The pyparsing module is an alternative approach to creating and executing simple grammars, vs. the traditional lex/yacc approach, or the use of regular expressions. With pyparsing, you don't need to learn a new syntax for defining grammars or matching expressions - the parsing module provides a library of classes that you use to construct the grammar directly in Python. Here is a program to parse "Hello, World!" (or any greeting of the form ``"<salutation>, <addressee>!"``), built up using :class:`Word`, :class:`Literal`, and :class:`And` elements (the :class:`'+'<ParserElement.__add__>` operators create :class:`And` expressions, and the strings are auto-converted to :class:`Literal` expressions):: from pip._vendor.pyparsing import Word, alphas # define grammar of a greeting greet = Word(alphas) + "," + Word(alphas) + "!" hello = "Hello, World!" print (hello, "->", greet.parseString(hello)) The program outputs the following:: Hello, World! -> ['Hello', ',', 'World', '!'] The Python representation of the grammar is quite readable, owing to the self-explanatory class names, and the use of '+', '|' and '^' operators. The :class:`ParseResults` object returned from :class:`ParserElement.parseString` can be accessed as a nested list, a dictionary, or an object with named attributes. The pyparsing module handles some of the problems that are typically vexing when writing text parsers: - extra or missing whitespace (the above program will also handle "Hello,World!", "Hello , World !", etc.) - quoted strings - embedded comments Getting Started - ----------------- Visit the classes :class:`ParserElement` and :class:`ParseResults` to see the base classes that most other pyparsing classes inherit from. Use the docstrings for examples of how to: - construct literal match expressions from :class:`Literal` and :class:`CaselessLiteral` classes - construct character word-group expressions using the :class:`Word` class - see how to create repetitive expressions using :class:`ZeroOrMore` and :class:`OneOrMore` classes - use :class:`'+'<And>`, :class:`'|'<MatchFirst>`, :class:`'^'<Or>`, and :class:`'&'<Each>` operators to combine simple expressions into more complex ones - associate names with your parsed results using :class:`ParserElement.setResultsName` - access the parsed data, which is returned as a :class:`ParseResults` object - find some helpful expression short-cuts like :class:`delimitedList` and :class:`oneOf` - find more useful common expressions in the :class:`pyparsing_common` namespace class z2.4.2z29 Jul 2019 02:58 UTCz*Paul McGuire <ptmcg@users.sourceforge.net>� N)�ref)�datetime)� itemgetter)�wraps)�filterfalse)�ifilterfalse)�RLock)�Iterable)�MutableMapping�Mapping)�OrderedDict)�SimpleNamespacec @ s e Zd ZdS )r N)�__name__� __module__�__qualname__� r r �9/usr/lib/python3.8/site-packages/pip/_vendor/pyparsing.pyr � s r aA A cross-version compatibility configuration for pyparsing features that will be released in a future version. By setting values in this configuration to True, those features can be enabled in prior versions for compatibility development and testing. - collect_all_And_tokens - flag to enable fix for Issue #63 that fixes erroneous grouping of results names when an And expression is nested within an Or or MatchFirst; set to True to enable bugfix released in pyparsing 2.3.0, or False to preserve pre-2.3.0 handling of named results Ta� Diagnostic configuration (all default to False) - warn_multiple_tokens_in_named_alternation - flag to enable warnings when a results name is defined on a MatchFirst or Or expression with one or more And subexpressions (only warns if __compat__.collect_all_And_tokens is False) - warn_ungrouped_named_tokens_in_collection - flag to enable warnings when a results name is defined on a containing expression with ungrouped subexpressions that also have results names - warn_name_set_on_empty_Forward - flag to enable warnings whan a Forward is defined with a results name, but has no contents defined - warn_on_multiple_string_args_to_oneof - flag to enable warnings whan oneOf is incorrectly called with multiple str arguments - enable_debug_on_named_expressions - flag to auto-enable debug on all subsequent calls to ParserElement.setName() F�__version__�__versionTime__� __author__� __compat__�__diag__�And�CaselessKeyword�CaselessLiteral� CharsNotIn�Combine�Dict�Each�Empty� FollowedBy�Forward� GoToColumn�Group�Keyword�LineEnd� LineStart�Literal� PrecededBy� MatchFirst�NoMatch�NotAny� OneOrMore�OnlyOnce�Optional�Or�ParseBaseException�ParseElementEnhance�ParseException�ParseExpression�ParseFatalException�ParseResults�ParseSyntaxException� ParserElement�QuotedString�RecursiveGrammarException�Regex�SkipTo� StringEnd�StringStart�Suppress�Token�TokenConverter�White�Word�WordEnd� WordStart� ZeroOrMore�Char� alphanums�alphas� alphas8bit�anyCloseTag� anyOpenTag� cStyleComment�col�commaSeparatedList�commonHTMLEntity�countedArray�cppStyleComment�dblQuotedString�dblSlashComment� delimitedList�dictOf�downcaseTokens�empty�hexnums�htmlComment�javaStyleComment�line�lineEnd� lineStart�lineno�makeHTMLTags�makeXMLTags�matchOnlyAtCol�matchPreviousExpr�matchPreviousLiteral� nestedExpr�nullDebugAction�nums�oneOf�opAssoc�operatorPrecedence� printables�punc8bit�pythonStyleComment�quotedString�removeQuotes�replaceHTMLEntity�replaceWith� restOfLine�sglQuotedString�srange� stringEnd�stringStart�traceParseAction� unicodeString�upcaseTokens� withAttribute� indentedBlock�originalTextFor�ungroup� infixNotation�locatedExpr� withClass� CloseMatch�tokenMap�pyparsing_common�pyparsing_unicode�unicode_set�conditionAsParseAction� c C sf t | t�r| S z t| �W S tk r` t| ��t�� d�}td�}|�dd� � |� |� Y S X dS )a Drop-in replacement for str(obj) that tries to be Unicode friendly. It first tries str(obj). If that fails with a UnicodeEncodeError, then it tries unicode(obj). It then < returns the unicode object | encodes it with the default encoding | ... >. �xmlcharrefreplacez&#\d+;c S s$ dt t| d dd� ��dd � S )Nz\ur � ���)�hex�int��tr r r �<lambda>� � z_ustr.<locals>.<lambda>N) � isinstance�unicode�str�UnicodeEncodeError�encode�sys�getdefaultencodingr: �setParseAction�transformString)�obj�retZ xmlcharrefr r r �_ustr� s r� z6sum len sorted reversed list tuple set any all min maxc c s | ] }|V qd S �Nr )�.0�yr r r � <genexpr> s r� � c C s: d}dd� d� � D �}t||�D ]\}}| �||�} q | S )z/Escape &, <, >, ", ', etc. in a string of data.z&><"'c s s | ]}d | d V qdS )�&�;Nr )r� �sr r r r� s z_xml_escape.<locals>.<genexpr>zamp gt lt quot apos)�split�zip�replace)�dataZfrom_symbolsZ to_symbolsZfrom_Zto_r r r �_xml_escape s r� � 0123456789ZABCDEFabcdef�\ � c c s | ]}|t jkr|V qd S r� )�stringZ whitespace�r� �cr r r r� s c s@ |d k r|nd�|rt nt� t���t��� ��fdd��}|S )Nzfailed user-defined conditionc s t �| ||��s� | |���d S r� )�bool�r� �lr� ��exc_type�fn�msgr r �pa s z"conditionAsParseAction.<locals>.pa)r4 r2 �_trim_arityr )r� �message�fatalr� r r� r r� s c @ sP e Zd ZdZddd�Zedd� �Zdd � Zd d� Zdd � Z ddd�Z dd� ZdS )r0 z7base exception class for all parsing runtime exceptionsr Nc C s>