MCPcopy
hub / github.com/pex-tool/pex / parse_scheme

Function parse_scheme

pex/artifact_url.py:72–104  ·  view source on GitHub ↗
(scheme)

Source from the content-addressed store, hash-verified

70
71
72def parse_scheme(scheme):
73 # type: (str) -> Union[str, ArchiveScheme.Value, VCSScheme]
74 match = re.match(
75 r"""
76 ^
77 (?:
78 (?P<archive_scheme>
79 # Archives
80 ftp
81 | https?
82 )
83 |
84 (?P<vcs_type>
85 # VCSs: https://pip.pypa.io/en/stable/reference/pip_install/#vcs-support
86 bzr
87 | git
88 | hg
89 | svn
90 )\+(?P<vcs_scheme>.+)
91 )
92 $
93 """,
94 scheme,
95 re.VERBOSE,
96 )
97 if not match:
98 return scheme
99
100 archive_scheme = match.group("archive_scheme")
101 if archive_scheme:
102 return cast(ArchiveScheme.Value, ArchiveScheme.for_value(archive_scheme))
103
104 return VCSScheme(vcs=VCS.for_value(match.group("vcs_type")), scheme=match.group("vcs_scheme"))
105
106
107@attr.s(frozen=True)

Callers 2

test_parse_schemeFunction · 0.90
from_url_infoMethod · 0.85

Calls 3

castFunction · 0.90
VCSSchemeClass · 0.85
for_valueMethod · 0.45

Tested by 1

test_parse_schemeFunction · 0.72