a qeg,@sdZddlZddlZddlZddlZddlmZddlmZm Z ddl m Z dgZ edZd d hZd d Zd dZddZGdddeZedZddZeZ[eZdddZdS)zG Parser for the environment markers micro-language defined in PEP 508. N) string_types)in_venv parse_marker) LegacyVersion interpretz<((\d+(\.\d+)*\w*)|\'(\d+(\.\d+)*\w*)\'|\"(\d+(\.\d+)*\w*)\")python_versionpython_full_versioncCst|to|tvSN) isinstancer_VERSION_MARKERSsr9/usr/local/lib/python3.9/site-packages/distlib/markers.py_is_version_markersrcCst|tr|sdS|ddvS)NFr'")r r)orrr _is_literal"srcCsddt|DS)NcSsh|]}t|dqS)r)LVgroups).0mrrr )z _get_versions..)_VERSION_PATTERNfinditerr rrr _get_versions(src @sfeZdZdZddddddddddddd dd dd dd dd dddd ZddZdS) Evaluatorz< This class is used to evaluate marker expressions. cCs||kSr rxyrrr2rzEvaluator.cCs||kSr rrrrrr"3rcCs||kp||kSr rrrrrr"4rcCs||kSr rrrrrr"5rcCs||kSr rrrrrr"6rcCs||kp||kSr rrrrrr"7rcCs||kSr rrrrrr"8rcCs||kp||kSr rrrrrr"9rcCs|o|Sr rrrrrr":rcCs|p|Sr rrrrrr";rcCs||vSr rrrrrr"<rcCs||vSr rrrrrr"=r) =====~=!=<<=>>=andorinnot inc Cs"t|trB|ddvr$|dd}n||vr8td|||}nt|tsPJ|d}||jvrntd||d}|d }t|drt|d rtd |||f|||}|||}t|st|r|d vrt |}t |}n$t|r|d vrt |}t |}|j|||}|S) z Evaluate a marker expression returned by the :func:`parse_requirement` function in the specified context. rrrzunknown variable: %sopzop not implemented: %slhsrhszinvalid comparison: %s %s %s)r'r(r)r*r$r#r&r%)r-r.) r r SyntaxErrordict operationsNotImplementedErrorrevaluaterrr) selfexprcontextresultr0ZelhsZerhsr1r2rrrr7@s4         zEvaluator.evaluateN)__name__ __module__ __qualname____doc__r5r7rrrrr,srz\d+\.\d+c Csdd}ttdr(|tjj}tjj}nd}d}t}t|}| d}||t jt t t tttt||tjd }|S)NcSs<d|j|j|jf}|j}|dkr8||dt|j7}|S)Nz%s.%s.%sfinalr)majorminormicro releaselevelstrserial)infoversionkindrrrformat_full_versionhs z,default_context..format_full_versionimplementation0r) implementation_nameimplementation_versionos_nameplatform_machineplatform_python_implementationplatform_releaseplatform_systemplatform_versionZplatform_in_venvr r sys_platform)hasattrsysrKrHnameplatformr_DIGITSmatchgrouposmachinepython_implementationreleasesystemrEr)rJrOrNZppvrpvr;rrrdefault_contextfs.     rdc Cszt|\}}Wn4tyD}ztd||fWYd}~n d}~00|rf|ddkrftd||ftt}|r|||t||S)z Interpret a marker and return a result depending on environment. :param marker: The marker to interpret. :type marker: str :param execution_context: The context used for name lookup. :type execution_context: mapping z)Unable to interpret marker syntax: %s: %sNr#z*unexpected trailing data in marker: %s: %s)r Exceptionr3r4DEFAULT_CONTEXTupdate evaluatorr7)markerZexecution_contextr9rester:rrrrs & )N)r?r^rerXrZcompatrutilrrrHrr__all__compilerr rrrobjectrr[rdrgrirrrrrs(   7 $