3 Re@sdZddlZddlZddlmZddlmZddlm Z e rhddl m Z m Z m Z mZmZmZmZedZdZejd Zd d d d dgZGdd d eZdddZdddZddZddZGdddeZGdd d eZGdd d eZ e reee efZ!Gdd d eZ"dS)z PEP 610 N)six)parse)MYPY_CHECK_RUNNING)AnyDictIterableOptionalTypeTypeVarUnionTzdirect_url.jsonz.^\$\{[A-Za-z0-9-_]+\}(:\$\{[A-Za-z0-9-_]+\})?$ DirectUrlDirectUrlValidationErrorDirInfo ArchiveInfoVcsInfoc@s eZdZdS)rN)__name__ __module__ __qualname__rr/builddir/build/BUILDROOT/alt-python36-pip-20.2.4-5.el9.x86_64/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/models/direct_url.pyrscCsH||kr |S||}tjr(|tkr(tj}t||sDtdj||||S)z3Get value from dictionary and verify expected type.z-{!r} has unexpected type for {} (expected {}))rPY2str string_types isinstancerformat)d expected_typekeydefaultvaluerrr_get"s  r!cCs(t||||}|dkr$tdj||S)Nz{} must have a value)r!rr)rrrrr rrr _get_required3sr"cCsFdd|D}|stdt|dkr.td|ddk s>t|dS)NcSsg|]}|dk r|qS)Nr).0inforrr =sz#_exactly_one_of..z/missing one of archive_info, dir_info, vcs_infoz1more than one of archive_info, dir_info, vcs_infor)rlenAssertionError)infosrrr_exactly_one_of;s r*cKsdd|jDS)z Make dict excluding None values.cSsi|]\}}|dk r||qS)Nr)r#kvrrr Msz _filter_none..)items)kwargsrrr _filter_noneJsr0c@s.eZdZdZd ddZeddZddZdS) rvcs_infoNcCs"||_||_||_||_||_dS)N)vcsrequested_revision commit_idresolved_revisionresolved_revision_type)selfr2r4r3r5r6rrr__init__Ss zVcsInfo.__init__c CsF|dkr dS|t|tdt|tdt|tdt|tdt|tddS)Nr2r4r3r5r6)r2r4r3r5r6)r"rr!)clsrrrr _from_dictas    zVcsInfo._from_dictcCst|j|j|j|j|jdS)N)r2r3r4r5r6)r0r2r3r4r5r6)r7rrr_to_dictns zVcsInfo._to_dict)NNN)rrrnamer8 classmethodr:r;rrrrrPs   c@s.eZdZdZd ddZeddZddZdS) r archive_infoNcCs ||_dS)N)hash)r7r?rrrr8|szArchiveInfo.__init__cCs|dkr dS|t|tddS)Nr?)r?)r!r)r9rrrrr:szArchiveInfo._from_dictcCs t|jdS)N)r?)r0r?)r7rrrr;szArchiveInfo._to_dict)N)rrrr<r8r=r:r;rrrrrys  c@s.eZdZdZd ddZeddZddZd S) rdir_infoFcCs ||_dS)N)editable)r7rArrrr8szDirInfo.__init__cCs"|dkr dS|t|tddddS)NrAF)r)rA)r"bool)r9rrrrr:szDirInfo._from_dictcCst|jp ddS)N)rA)r0rA)r7rrrr;szDirInfo._to_dictN)F)rrrr<r8r=r:r;rrrrrs  c@sZeZdZdddZddZeddZdd Zed d Z d d Z eddZ ddZ dS)r NcCs||_||_||_dS)N)urlr$ subdirectory)r7rCr$rDrrrr8szDirectUrl.__init__cCsRd|kr |S|jdd\}}t|jtr@|jjdkr@|dkr@|Stj|rN|S|S)N@r&git)splitrr$rr2 ENV_VAR_REmatch)r7netloc user_passnetloc_no_user_passrrr_remove_auth_from_netlocs   z"DirectUrl._remove_auth_from_netloccCs8tj|j}|j|j}tj|j||j|j|j f}|S)zurl with user:password part removed unless it is formed with environment variables as specified in PEP 610, or it is ``git`` in the case of a git URL. ) urllib_parseurlsplitrCrMrJ urlunsplitschemepathqueryfragment)r7purlrJsurlrrr redacted_urls   zDirectUrl.redacted_urlcCs|j|jdS)N) from_dictto_dict)r7rrrvalidateszDirectUrl.validatec CsRtt|tdt|tdttjt|tdtjt|tdt jt|tdgdS)NrCrDr>r@r1)rCrDr$) r r"rr!r*rr:dictrr)r9rrrrrXs  zDirectUrl.from_dictcCs&t|j|jd}|jj||jj<|S)N)rCrD)r0rWrDr$r;r<)r7resrrrrYs  zDirectUrl.to_dictcCs|jtj|S)N)rXjsonloads)r9srrr from_jsonszDirectUrl.from_jsoncCstj|jddS)NT) sort_keys)r]dumpsrY)r7rrrto_jsonszDirectUrl.to_json)N) rrrr8rMpropertyrWrZr=rXrYr`rcrrrrr s    )N)N)#__doc__r]re pip._vendorrZpip._vendor.six.moves.urllibrrNpip._internal.utils.typingrtypingrrrrr r r r DIRECT_URL_METADATA_NAMEcompilerH__all__ Exceptionrr!r"r*r0objectrrrZInfoTyper rrrrs4   $   )