gi5ddlTddlmZmZmZddlmZGddZdeeDZ dS) )*) DelimitedList any_open_tag any_close_tag)datetimec  eZdZdZeeZ eeZ e e  d eZ e e d eedZ ed d eZ e edze ez dZ ed eeeed ezzz d Z eeed  d  eZ ed d eZ eezez dZ ed d eZ ed d eZ e ee dZ ed dZ! ed dZ"e"de"zdzz dZ#ee"de"zdzzdzee"de"zdzzz dZ$e$%d d!e!z d"Z&e'e#e&ze$z d# d#Z( ed$ d%Z) e*dHd'e+fd(Z,e*dId'e+fd*Z-ed+ d,Z. ed- d.Z/ ed/ d0Z0 e1je2jzZ3e*d1e+d2ed3e4fd4Z5e'e6e7d5e8ze e9d56zee:d7e;e8d5zzz d8Z<e=ee>?e d?ZC e*eDd@eZEe*eDdAeZFe*eDdBe,ZGe*eDdCe-ZHe*eDdDe5ZIe*eDdEeAZJe*eDdFeBZKdGS)Jpyparsing_commona7 Here are some common low-level expressions that may be useful in jump-starting parser development: - numeric forms (:class:`integers`, :class:`reals`, :class:`scientific notation`) - common :class:`programming identifiers` - network addresses (:class:`MAC`, :class:`IPv4`, :class:`IPv6`) - ISO8601 :class:`dates` and :class:`datetime` - :class:`UUID` - :class:`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')] integerz hex integerz[+-]?\d+zsigned integer/fractionc$|d|dz S)Nr)tts `/home/jenkins/workspace/simtester-sanitize/venv/lib/python3.11/site-packages/pyparsing/common.pyzpyparsing_common.sAB-z"fraction or mixed integer-fractionz[+-]?(?:\d+\.\d*|\.\d+)z real numberz@[+-]?(?:\d+(?:[eE][+-]?\d+)|(?:\d+\.\d*|\.\d+)(?:[eE][+-]?\d+)?)z$real number with scientific notationnumberz[+-]?\d+\.?\d*(?:[eE][+-]?\d+)?fnumberz;(?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}z IPv4 addressz[0-9a-fA-F]{1,4} hex_integer:zfull IPv6 address)rz::zshort IPv6 addressc<td|DdkS)Nc3XK|]%}tj|!dV&dS)rN)r _ipv6_partmatches).0rs r z,pyparsing_common...s9OOB'7'B'J'J2'N'NOaOOOOOOr)sumts rrzpyparsing_common.s##OO!OOOOORSSrz::ffff:zmixed 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-%dfmtcfd}|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 tj|dS#t$r#}t ||t |d}~wwxYwNr)rstrptimedate ValueErrorParseExceptionstr)ssllrver*s rcvt_fnz0pyparsing_common.convert_to_date..cvt_fnsb 6(A4499;;; 6 6 6$RSWW555 6s,0 AAArr*r6s` rconvert_to_datez pyparsing_common.convert_to_dates#& 6 6 6 6 6  r%Y-%m-%dT%H:%M:%S.%fcfd}|S)aHelper 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:: 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:: [datetime.datetime(1999, 12, 31, 23, 59, 59, 999000)] c tj|dS#t$r#}t||t |d}~wwxYwr-)rr.r0r1r2)slr(r5r*s rr6z4pyparsing_common.convert_to_datetime..cvt_fn1sV 4(1s333 4 4 4$Q3r77333 4s A AA rr7s` rconvert_to_datetimez$pyparsing_common.convert_to_datetimes#& 4 4 4 4 4  rz7(?P\d{4})(?:-(?P\d\d)(?:-(?P\d\d))?)?z ISO8601 datez(?P\d{4})-(?P\d\d)-(?P\d\d)[T ](?P\d\d):(?P\d\d)(:(?P\d\d(\.\d*)?)?)?(?PZ|[+-]\d\d:?\d\d)?zISO8601 datetimez2[0-9a-fA-F]{8}(-[0-9a-fA-F]{4}){3}-[0-9a-fA-F]{12}UUIDr<r=tokenscLtj|dS)aParse action to remove HTML tags from web page HTML source Example:: # strip HTML links from normal text text = 'More info at the pyparsing wiki page' 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:: More info at the pyparsing wiki page r)r _html_strippertransform_string)r<r=r@s rstrip_html_tagsz pyparsing_common.strip_html_tagsHs  .??q JJJr,) exclude_charsz commaItem)defaultzcomma separated listc*|SN)upperr's rrzpyparsing_common.ksQWWYYrc*|SrK)lowerr's rrzpyparsing_common.nsqwwyyra(?P(?:(?:(?Phttps?|ftp):)?\/\/)(?:(?P\S+(?::\S*)?)@)?(?P(?!(?: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\d{2,5}))?(?P\/[^?# ]*)?(\?(?P[^#]*))?(#(?P\S*))?)urlconvertToIntegerconvertToFloat convertToDateconvertToDatetime stripHTMLTags upcaseTokensdowncaseTokensN)r))r9)L__name__ __module__ __qualname____doc__ token_mapintconvert_to_integerfloatconvert_to_floatWordnumsset_nameset_parse_actionr hexnumsrRegexsigned_integerradd_parse_actionOptsuppress mixed_integerr&realsci_real streamlinerrr identcharsidentbodycharsr ipv4_addressr!_full_ipv6_address_short_ipv6_address add_condition_mixed_ipv6_addressCombine ipv6_address mac_address staticmethodr2r8r> iso8601_dateiso8601_datetimeuuidrrrB ParseResultsrD OneOrMoreLiteralLineEnd printablesWhite FollowedBy _commasepitemr quoted_stringcopycomma_separated_list upcase_tokensdowncase_tokensrOreplaced_by_pep8rPrQrRrSrTrUrVrrrr r sOOb#3!y''d4jj!!),,==>PQQGD W }-->>yyb?Q?QRRG k " # #  , - - W ))*:;;   .   + +,< = = >hz  U 77888 >CCC(9(9(;(;h(F$G$GGGh344g""3''' ()) -  * + + M QRR 8 9 9  * + + /o. 8 8 B B M M O OFG 011 )    * + + 4 LMM ,    * + + ]j.11::<HHJd5Vh~3*++44]CCJ$j(8A'==GG J# *f4 455   #jC*,66 7 7 8h#$$  %%SS%|3==>RSS7 1 14G GQQ   h~  0%Eh}GS\4\45Bh~$u Rh!""] 5F G G P PQW X XD5*\*,,/E}/E/G/GGNK3K3K KKK\K$  I 799*$z5556#eeElljjS&A&A%AABBC      +  )= M   = 0"===h%&&e L+>+>!?!?@@M7"l99-@-@#A#ABBO7 %* . . \huoo]^& $|$4$45GI[$\$\]]!\"2"23CEU"V"VWWN L!1!1/?!S!STTM$ %5%56IK^%_%_`` L!1!1/?!S!STTM< 0 0 O OPPL!\"2"23C_"U"UVVNNNrr c<g|]}t|t|Sr) isinstance ParserElement)r#vs r rs7 *Q 2N2NrN) corehelpersrrrrr varsvalues_builtin_exprsrrrrs??????????dWdWdWdWdWdWdWdWP t$%%,,..r