& dK4ddlddlmZmZmZddlmZGddZeejDcgc]}e |e s |c}Z ycc}w))*) DelimitedList any_open_tag any_close_tag)datetimec eZdZdZeeZ eeZ e e jdjeZ e ejdjeedZ edjdjeZ ejedzejezjdZ ej'd eeeed j+ezzzjd Z ej'eed jd jeZ edjdjeZ eezezj5dj7Z edjdjeZ e eejdZ edjdZ! edjdZ"e"de"zdzzjdZ#ee"de"zdzzdzee"de"zdzzzjdZ$e$jKdde!zjd Z&e'e#e&ze$zjd!jd!Z( ed"jd#Z) e*d=d$e+fd%Z,e*d>d$e+fd&Z-ed'jd(Z. ed)jd*Z/ ed+jd,Z0 e1j*e2j*zZ3e*d-e+d.ed/e4fd0Z5e'e6e7d1e8ze e9d12zee:d3e;e8d1zzzj7jd4Z<e=ee>je`, :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 2/usr/lib/python3/dist-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+)?fnumber 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)Nc3`K|]&}tjj|s#d(yw)rN)r _ipv6_partmatches).0rs r z,pyparsing_common...s$OB'7'B'B'J'J2'NaOs$..)sumts rrzpyparsing_common.s#O!OORSSrz::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 addressfmtcfd}|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|djS#t$r}t ||t |d}~wwxYwNr)rstrptimedate ValueErrorParseExceptionstr)ssllrver(s rcvt_fnz0pyparsing_common.convert_to_date..cvt_fnsK 6((A499;; 6$RSW55 6s&* AA  Arr(r4s` rconvert_to_datez pyparsing_common.convert_to_dates& 6  rcfd}|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,r.r/r0)slr'r3r(s rr4z4pyparsing_common.convert_to_datetime..cvt_fn*sB 4((1s33 4$Q3r733 4s A;Arr5s` rconvert_to_datetimez$pyparsing_common.convert_to_datetimes& 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}UUIDr9r:tokenscFtjj|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)r9r:r=s rstrip_html_tagsz pyparsing_common.strip_html_tagsAs  ..??q JJr,) exclude_charsz commaItem)defaultzcomma separated listc"|jSN)upperr&s rrzpyparsing_common.ds QWWYrc"|jSrH)lowerr&s rrzpyparsing_common.gs qwwyra(?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*))?)urlN)z%Y-%m-%d)z%Y-%m-%dT%H:%M:%S.%f)K__name__ __module__ __qualname____doc__ token_mapintconvert_to_integerfloatconvert_to_floatWordnumsset_nameset_parse_actionr hexnumsrRegexsigned_integerradd_parse_actionOptsuppress mixed_integerr%realsci_realsetName streamlinerr identcharsidentbodycharsr ipv4_addressr _full_ipv6_address_short_ipv6_address add_condition_mixed_ipv6_addressCombine ipv6_address mac_address staticmethodr0r6r; iso8601_dateiso8601_datetimeuuidrrr? ParseResultsrA OneOrMoreLiteralLineEnd printablesWhite FollowedBy _commasepitemr quoted_stringcopycomma_separated_list upcase_tokensdowncase_tokensrLconvertToIntegerconvertToFloat convertToDateconvertToDatetime stripHTMLTags upcaseTokensdowncaseTokensrrrr r sYOb#3!'4j!!),==>PQGD W }->>yb?QRG k " #  , - W ))*:;     + +,< = >hz  U 78 >CC(9(9(;h(F$GGGh34g""3' () -  * + M QR 8 9  * + /o. 7 7 A L L NFG ./ )   * + 4j.1::<HJdVh~3*+44]CJ$j(8A'==GG J# *f4 45   jC*,66 7 8h#$  %%S%|3==>RS 1 14G GQQ  h~  0Eh}GS44Bh~$ Rh!"] F G P PQW XD5*\**,/E}/E/E/GGNK3K3K KK$   9*z56eEljS&A%AABC    + ) M   = 0"=h%&e +>!?@M7"9-@#ABO7 * . \huo]^&*6%N4#M3+7#M3 L1$N3rr N) corehelpersrrrrr varsvalues isinstance ParserElement_builtin_exprs)vs0rrsR??c4c4N $%,,. *Q 2NAs AA