
    rbi=                         d dl T d dlmZmZmZ ddlmZ ddlZej        dk    Z G d d          Z	d	  e
e	                                          D             ZdS )
   )*)DelimitedListany_open_tagany_close_tag    )datetimeN)   
   c                   2   e Zd ZdZed             Zed             Z ee          	                    d          
                    erend           Z	  ee          	                    d          
                     eed                    Z	  ed          	                    d	          
                    erend
           Z	  e            
                    erend           dz    e            
                    erend           z   	                    d          Z	 e                    d            ee e ed                                          ez             z   z  	                    d          Z	 e                    e            ed          	                    d          
                    erend           Z	  ed          	                    d          
                    erend           Z	 eez  ez  	                    d                                          Z	  ed          	                    d          
                    erend           Z	  ed          	                    d          
                    erend           Z	  eee           	                    d          Z!	  ed           	                    d!          Z"	  ed"          	                    d#          Z#e#d$e#z   d%z  z   	                    d&          Z$ ee#d$e#z   d'z  z             d(z    ee#d$e#z   d'z  z             z   	                    d)          Z%e%&                    d*            d+e"z   	                    d,          Z' e(e$e'z  e%z  	                    d-                    	                    d-          Z)	  ed.          	                    d/          Z*	 edRd1e+fd2            Z,edSd1e+fd4            Z- ed5          	                    d6          Z.	  ed7          	                    d8          Z/	  ed9          	                    d:          Z0	  e1j                     e2j                    z  Z3ed;e+d<ed=e4fd>            Z5 e( e6 e7d?            e8             z    ee9d?@          z    e e:dA           e; e8            d?z             z             z                                                       	                    dB          Z< e= ee>?                                e<z  dCD                    	                    dE          Z@	 edF             ZAedG             ZB edH          	                    dI          ZC	  e eDdJe                    ZE e eDdKe                    ZF e eDdLe,                    ZG e eDdMe-                    ZH e eDdNe5                    ZI e eDdOeA                    ZJ e eDdPeB                    ZKdQS )Tpyparsing_commona  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`

    Examples:

    .. testcode::

        pyparsing_common.number.run_tests('''
            # any int or real number, returned as the appropriate type
            100
            -100
            +100
            3.14159
            6.02e23
            1e-12
            ''')

    .. testoutput::
        :options: +NORMALIZE_WHITESPACE


        # 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]

    .. testcode::

        pyparsing_common.fnumber.run_tests('''
            # any int or real number, returned as float
            100
            -100
            +100
            3.14159
            6.02e23
            1e-12
            ''')

    .. testoutput::
        :options: +NORMALIZE_WHITESPACE


        # 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]

    .. testcode::

        pyparsing_common.hex_integer.run_tests('''
            # hex numbers
            100
            FF
            ''')

    .. testoutput::
        :options: +NORMALIZE_WHITESPACE


        # hex numbers
        100
        [256]

        FF
        [255]

    .. testcode::

        pyparsing_common.fraction.run_tests('''
            # fractions
            1/2
            -3/4
            ''')

    .. testoutput::
        :options: +NORMALIZE_WHITESPACE


        # fractions
        1/2
        [0.5]

        -3/4
        [-0.75]

    .. testcode::

        pyparsing_common.mixed_integer.run_tests('''
            # mixed fractions
            1
            1/2
            -3/4
            1-3/4
            ''')

    .. testoutput::
        :options: +NORMALIZE_WHITESPACE


        # mixed fractions
        1
        [1]

        1/2
        [0.5]

        -3/4
        [-0.75]

        1-3/4
        [1.75]
    .. testcode::

        import uuid
        pyparsing_common.uuid.set_parse_action(token_map(uuid.UUID))
        pyparsing_common.uuid.run_tests('''
            # uuid
            12345678-1234-5678-1234-567812345678
            ''')

    .. testoutput::
        :options: +NORMALIZE_WHITESPACE


        # uuid
        12345678-1234-5678-1234-567812345678
        [UUID('12345678-1234-5678-1234-567812345678')]
    c                     d |D             S )zK
        Parse action for converting parsed integers to Python int
        c                 ,    g | ]}t          |          S  int.0tts     `/var/www/html/mdtn/previsions/meteo_cartes/venv/lib/python3.11/site-packages/pyparsing/common.py
<listcomp>z7pyparsing_common.convert_to_integer.<locals>.<listcomp>   s    $$$BB$$$    r   ___ts      r   convert_to_integerz#pyparsing_common.convert_to_integer   s    
 %$!$$$$r   c                     d |D             S )zL
        Parse action for converting parsed numbers to Python float
        c                 ,    g | ]}t          |          S r   floatr   s     r   r   z5pyparsing_common.convert_to_float.<locals>.<listcomp>   s    &&&bb		&&&r   r   r   s      r   convert_to_floatz!pyparsing_common.convert_to_float   s    
 '&A&&&&r   integerc                     d | D             S )Nc                 ,    g | ]}t          |          S r   r   r   s     r   r   z-pyparsing_common.<lambda>.<locals>.<listcomp>       000CGG000r   r   r   s    r   <lambda>zpyparsing_common.<lambda>       00a000 r   zhex integer   z[+-]?\d+zsigned integerc                     d | D             S )Nc                 ,    g | ]}t          |          S r   r   r   s     r   r   z-pyparsing_common.<lambda>.<locals>.<listcomp>   r%   r   r   r&   s    r   r'   zpyparsing_common.<lambda>   r(   r   c                     d | D             S )Nc                 ,    g | ]}t          |          S r   r   r   s     r   r   z-pyparsing_common.<lambda>.<locals>.<listcomp>       222"E"II222r   r   r&   s    r   r'   zpyparsing_common.<lambda>       22222 r   /c                     d | D             S )Nc                 ,    g | ]}t          |          S r   r   r   s     r   r   z-pyparsing_common.<lambda>.<locals>.<listcomp>   r.   r   r   r&   s    r   r'   zpyparsing_common.<lambda>   r/   r   fractionc                 $    | d         | d         z  S )Nr   r   )r   s    r   r'   zpyparsing_common.<lambda>   s    AB r   -z"fraction or mixed integer-fractionz[+-]?(?:\d+\.\d*|\.\d+)zreal numberc                     d | D             S )Nc                 ,    g | ]}t          |          S r   r   r   s     r   r   z-pyparsing_common.<lambda>.<locals>.<listcomp>  r.   r   r   r&   s    r   r'   zpyparsing_common.<lambda>  r/   r   z@[+-]?(?:\d+(?:[eE][+-]?\d+)|(?:\d+\.\d*|\.\d+)(?:[eE][+-]?\d+)?)z$real number with scientific notationc                     d | D             S )Nc                 ,    g | ]}t          |          S r   r   r   s     r   r   z-pyparsing_common.<lambda>.<locals>.<listcomp>  r.   r   r   r&   s    r   r'   zpyparsing_common.<lambda>  r/   r   numberz[+-]?\d+\.?\d*(?:[eE][+-]?\d+)?fnumberc                     d | D             S )Nc                 ,    g | ]}t          |          S r   r   r   s     r   r   z-pyparsing_common.<lambda>.<locals>.<listcomp>  r.   r   r   r&   s    r   r'   zpyparsing_common.<lambda>  r/   r   z;(?i:[+-]?(?:(?:\d+\.?\d*(?:e[+-]?\d+)?)|nan|inf(?:inity)?))
ieee_floatc                     d | D             S )Nc                 ,    g | ]}t          |          S r   r   r   s     r   r   z-pyparsing_common.<lambda>.<locals>.<listcomp>)  r.   r   r   r&   s    r   r'   zpyparsing_common.<lambda>)  r/   r   
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}zIPv4 addressz[0-9a-fA-F]{1,4}hex_integer:   zfull IPv6 address)r      z::zshort IPv6 addressc                 <    t          d | D                       dk     S )Nc              3   X   K   | ]%}t           j                            |          !d V  &dS )r   N)r   
_ipv6_partmatchesr   s     r   	<genexpr>z,pyparsing_common.<lambda>.<locals>.<genexpr>@  s9      OOB'7'B'J'J2'N'NOaOOOOOOr      )sumr&   s    r   r'   zpyparsing_common.<lambda>@  s#    #OO!OOOOORSS r   z::ffff:zmixed IPv6 addresszIPv6 addressz:[0-9a-fA-F]{2}([:.-])[0-9a-fA-F]{2}(?:\1[0-9a-fA-F]{2}){4}zMAC address%Y-%m-%dfmtc                       fd}|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:

        .. testcode::

            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:

        .. testoutput::

            [datetime.date(1999, 12, 31)]
        c                     	 t          j        |d                                                   S # t          $ r#}t	          | |t          |                    d }~ww xY wNr   )r   strptimedate
ValueErrorParseExceptionstr)ssllr   verO   s       r   cvt_fnz0pyparsing_common.convert_to_date.<locals>.cvt_fnf  sb    6(A4499;;; 6 6 6$RSWW5556s   ,0 
AAAr   rO   r[   s   ` r   convert_to_datez pyparsing_common.convert_to_dateO  s#    .	6 	6 	6 	6 	6 r   %Y-%m-%dT%H:%M:%S.%fc                       fd}|S )aI  Helper to create a parse action for converting parsed
        datetime string to Python datetime.datetime

        Params -
        - fmt - format to be passed to datetime.strptime (default= ``"%Y-%m-%dT%H:%M:%S.%f"``)

        Example:

        .. testcode::

            dt_expr = pyparsing_common.iso8601_datetime.copy()
            dt_expr.set_parse_action(pyparsing_common.convert_to_datetime())
            print(dt_expr.parse_string("1999-12-31T23:59:59.999"))

        prints:

        .. testoutput::

            [datetime.datetime(1999, 12, 31, 23, 59, 59, 999000)]
        c                     	 t          j        |d                   S # t          $ r#}t          | |t	          |                    d }~ww xY wrR   )r   rS   rU   rV   rW   )slr   rZ   rO   s       r   r[   z4pyparsing_common.convert_to_datetime.<locals>.cvt_fn  sV    4(1s333 4 4 4$Q3r773334s    
AAAr   r\   s   ` r   convert_to_datetimez$pyparsing_common.convert_to_datetimen  s#    .	4 	4 	4 	4 	4 r   z7(?P<year>\d{4})(?:-(?P<month>\d\d)(?:-(?P<day>\d\d))?)?zISO8601 datez(?P<year>\d{4})-(?P<month>\d\d)-(?P<day>\d\d)[T ](?P<hour>\d\d):(?P<minute>\d\d)(:(?P<second>\d\d(\.\d*)?)?)?(?P<tz>Z|[+-]\d\d:?\d\d)?zISO8601 datetimez2[0-9a-fA-F]{8}(-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}UUIDra   rb   tokensc                 L    t           j                            |d                   S )a\  Parse action to remove HTML tags from web page HTML source

        Example:

        .. testcode::

            # strip HTML links from normal text
            text = '<td>More info at the <a href="https://github.com/pyparsing/pyparsing/wiki">pyparsing</a> wiki page</td>'
            td, td_end = make_html_tags("TD")
            table_text = td + SkipTo(td_end).set_parse_action(
                pyparsing_common.strip_html_tags)("body") + td_end
            print(table_text.parse_string(text).body)

        Prints:

        .. testoutput::

            More info at the pyparsing wiki page
        r   )r   _html_strippertransform_string)ra   rb   re   s      r   strip_html_tagsz pyparsing_common.strip_html_tags  s    *  .??q	JJJr   ,)exclude_charsz 		commaItem )defaultzcomma separated listc                     d |D             S )z-Parse action to convert tokens to upper case.c                 6    g | ]}|                                 S r   )upperr   s     r   r   z2pyparsing_common.upcase_tokens.<locals>.<listcomp>       '''r

'''r   r   ra   rb   r   s      r   upcase_tokenszpyparsing_common.upcase_tokens       ('Q''''r   c                     d |D             S )z-Parse action to convert tokens to lower case.c                 6    g | ]}|                                 S r   )lowerr   s     r   r   z4pyparsing_common.downcase_tokens.<locals>.<listcomp>  rr   r   r   rs   s      r   downcase_tokensz pyparsing_common.downcase_tokens  ru   r   a  (?P<url>(?:(?:(?P<scheme>https?|ftp):)?\/\/)(?:(?P<auth>\S+(?::\S*)?)@)?(?P<host>(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z0-9\u00a1-\uffff][a-z0-9\u00a1-\uffff_-]{0,62})?[a-z0-9\u00a1-\uffff]\.)+(?:[a-z\u00a1-\uffff]{2,}\.?))(:(?P<port>\d{2,5}))?(?P<path>\/[^?# ]*)?(\?(?P<query>[^#]*))?(#(?P<fragment>\S*))?)urlconvertToIntegerconvertToFloatconvertToDateconvertToDatetimestripHTMLTagsupcaseTokensdowncaseTokensN)rN   )r^   )L__name__
__module____qualname____doc__staticmethodr   r!   Wordnumsset_nameset_parse_actionPY_310r"   hexnums	token_mapr   rC   Regexsigned_integerr3   add_parse_actionOptsuppressmixed_integerrM   realsci_real
streamliner;   r<   r?   
identcharsidentbodycharsrB   ipv4_addressrI   _full_ipv6_address_short_ipv6_addressadd_condition_mixed_ipv6_addressCombineipv6_addressmac_addressrW   r]   rc   iso8601_dateiso8601_datetimeuuidr   r   rg   ParseResultsri   	OneOrMoreLiteralLineEnd
printablesWhite
FollowedBy_commasepitemr   quoted_stringcopycomma_separated_listrt   ry   rz   replaced_by_pep8r{   r|   r}   r~   r   r   r   r   r   r   r   r      s~       p pd % % \% ' ' \' 	T

	)				100

 

  I 	W}-->>yyb?Q?QRR  K 	k	"	#	#		100

 

  [ 	))322	
 	

 	 .


+
+322
 

	
 hz  Y77888 	>CCC(9(9(;(;h(F$G$GGGh344  m""3''' 	())	-	 	 		322

 

 	 N 	QRR	8	9	9		322

 

 0 o.88BBMMOOFK 	011	)				322

 

  = 	LMM	,				322

 

  _j.11::<HHJd5V h~  3*++44]CCJ$j(8A'==GG  	J#
*f4455
	
#jC*,66
7
7	8 h#$$	 
 %%SS   %|3==>RSS7	1	14G	GQQ	
 	
  h~	 
 0%E h}  G S    \<      \< 5B h~  $u 	R h!""  ]5FGGPPQWXXD5*\*,,/E}/E/G/GGNK3 K3 K K K K \K. 	I799*$z5556 #eeElljjS&A&A%AABBC 	
 	
 
	+		  )=M  =0"=== h%&&  e( ( \( ( ( \(
 %*	. .\ huoo] ^ $|$4$45GI[$\$\]]!\"2"23CEU"V"VWWN L!1!1/?!S!STTM$%5%56IK^%_%_`` L!1!1/?!S!STTM< 0 0 O OPPL!\"2"23C_"U"UVVNNNr   r   c                 <    g | ]}t          |t                    |S r   )
isinstanceParserElement)r   vs     r   r   r     s7       
*Q2N2N  r   )corehelpersr   r   r   r   sysversion_infor   r   varsvalues_builtin_exprsr   r   r   <module>r      s        ? ? ? ? ? ? ? ? ? ?       



		W	$CW CW CW CW CW CW CW CWN t$%%,,..  r   