|
Server : LiteSpeed System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64 User : nandedex ( 1060) PHP Version : 8.1.33 Disable Function : NONE Directory : /opt/cppython/lib/python3.8/site-packages/pyparsing/__pycache__/ |
U
N��g^5 � @ sP d dl T d dlmZmZmZ ddlmZ G dd� d�Zdd� ee��� D �Z d S )
� )�*)�
DelimitedList�any_open_tag�
any_close_tag� )�datetimec @ sP e Zd ZdZee�Zee�Ze e
��d��e�Z
e e��d��eed��Zed��d��e�Ze� �e�d e� �e� �d�Ze�d d
� � eeeed��� e � B �d�Ze�e� ed
��d��e�Zed��d��e�ZeeB eB �d��� Zed��d��e�Zed��d��e�Ze ee��d�Z ed��d�Z!ed��d�Z"e"de" d �d�Z#ee"de" d �d ee"de" d � �d �Z$e$�%d!d
� � d"e! �d#�Z&e'e#e&B e$B �d$���d$�Z(ed%��d&�Z)e*dJe+d(�d)d*��Z,e*dKe+d(�d,d-��Z-ed.��d/�Z.ed0��d1�Z/ed2��d3�Z0e1�� e2�� B Z3e*e+ee4d4�d5d6��Z5e'e6e7d7� e8� e e9d7d8� ee:d9�e;e8� d7B � � ���� �d:�Z<e=ee>�?� e<B d;d<���d=�Z@e*ed>d
� ��ZAe*ed?d
� ��ZBed@��dA�ZCe*eDdBe��ZEe*eDdCe��ZFe*eDdDe,��ZGe*eDdEe-��ZHe*eDdFe5��ZIe*eDdGeA��ZJe*eDdHeB��ZKdIS )L�pyparsing_commona7 Here are some common low-level expressions that may be useful in
jump-starting parser development:
- numeric forms (:class:`integers<integer>`, :class:`reals<real>`,
:class:`scientific notation<sci_real>`)
- common :class:`programming identifiers<identifier>`
- network addresses (:class:`MAC<mac_address>`,
:class:`IPv4<ipv4_address>`, :class:`IPv6<ipv6_address>`)
- ISO8601 :class:`dates<iso8601_date>` and
:class:`datetime<iso8601_datetime>`
- :class:`UUID<uuid>`
- :class:`comma-separated list<comma_separated_list>`
- :class:`url`
Parse actions:
- :class:`convert_to_integer`
- :class:`convert_to_float`
- :class:`convert_to_date`
- :class:`convert_to_datetime`
- :class:`strip_html_tags`
- :class:`upcase_tokens`
- :class:`downcase_tokens`
Example::
pyparsing_common.number.run_tests('''
# any int or real number, returned as the appropriate type
100
-100
+100
3.14159
6.02e23
1e-12
''')
pyparsing_common.fnumber.run_tests('''
# any int or real number, returned as float
100
-100
+100
3.14159
6.02e23
1e-12
''')
pyparsing_common.hex_integer.run_tests('''
# hex numbers
100
FF
''')
pyparsing_common.fraction.run_tests('''
# fractions
1/2
-3/4
''')
pyparsing_common.mixed_integer.run_tests('''
# mixed fractions
1
1/2
-3/4
1-3/4
''')
import uuid
pyparsing_common.uuid.set_parse_action(token_map(uuid.UUID))
pyparsing_common.uuid.run_tests('''
# uuid
12345678-1234-5678-1234-567812345678
''')
prints::
# any int or real number, returned as the appropriate type
100
[100]
-100
[-100]
+100
[100]
3.14159
[3.14159]
6.02e23
[6.02e+23]
1e-12
[1e-12]
# any int or real number, returned as float
100
[100.0]
-100
[-100.0]
+100
[100.0]
3.14159
[3.14159]
6.02e23
[6.02e+23]
1e-12
[1e-12]
# hex numbers
100
[256]
FF
[255]
# fractions
1/2
[0.5]
-3/4
[-0.75]
# mixed fractions
1
[1]
1/2
[0.5]
-3/4
[-0.75]
1-3/4
[1.75]
# uuid
12345678-1234-5678-1234-567812345678
[UUID('12345678-1234-5678-1234-567812345678')]
�integerzhex integer� z[+-]?\d+zsigned integer�/�fractionc C s | d | d S )Nr ���� )�ttr r �=/opt/cppython/lib/python3.8/site-packages/pyparsing/common.py�<lambda>� � zpyparsing_common.<lambda>�-z"fraction or mixed integer-fractionz[+-]?(?:\d+\.\d*|\.\d+)zreal numberz@[+-]?(?:\d+(?:[eE][+-]?\d+)|(?:\d+\.\d*|\.\d+)(?:[eE][+-]?\d+)?)z$real number with scientific notation�numberz[+-]?\d+\.?\d*([eE][+-]?\d+)?�fnumberz2(?i)[+-]?((\d+\.?\d*(e[+-]?\d+)?)|nan|inf(inity)?)�
ieee_float�
identifierzK(25[0-5]|2[0-4][0-9]|1?[0-9]{1,2})(\.(25[0-5]|2[0-4][0-9]|1?[0-9]{1,2})){3}zIPv4 addressz[0-9a-fA-F]{1,4}�hex_integer�:� zfull IPv6 address)r � z::zshort IPv6 addressc C s t dd� | D ��dk S )Nc s s | ]}t j�|�rd V qdS )r N)r �
_ipv6_part�matches)�.0r r r r � <genexpr>� s z,pyparsing_common.<lambda>.<locals>.<genexpr>� )�sum��tr r r r � r z::ffff:zmixed IPv6 addresszIPv6 addressz:[0-9a-fA-F]{2}([:.-])[0-9a-fA-F]{2}(?:\1[0-9a-fA-F]{2}){4}zMAC address�%Y-%m-%d��fmtc s � fdd�}|S )a�
Helper to create a parse action for converting parsed date string to Python datetime.date
Params -
- fmt - format to be passed to datetime.strptime (default= ``"%Y-%m-%d"``)
Example::
date_expr = pyparsing_common.iso8601_date.copy()
date_expr.set_parse_action(pyparsing_common.convert_to_date())
print(date_expr.parse_string("1999-12-31"))
prints::
[datetime.date(1999, 12, 31)]
c
sN zt �|d � ��� W S tk
rH } zt| |t|���W 5 d }~X Y nX d S �Nr )r �strptime�date�
ValueError�ParseException�str)�ssZllr �ver% r r �cvt_fn s z0pyparsing_common.convert_to_date.<locals>.cvt_fnr �r&