MCPcopy
hub / github.com/tox-dev/tox / _parse_script_metadata

Function _parse_script_metadata

src/tox/tox_env/python/pep723.py:149–165  ·  view source on GitHub ↗
(script: str)

Source from the content-addressed store, hash-verified

147
148
149def _parse_script_metadata(script: str) -> ScriptMetadata:
150 blocks = [(m.group("type"), m.group("content")) for m in _SCRIPT_METADATA_RE.finditer(script)]
151 script_blocks = [(t, c) for t, c in blocks if t == "script"]
152 if len(script_blocks) > 1:
153 msg = "multiple [script] metadata blocks found in script"
154 raise ValueError(msg)
155 if not script_blocks:
156 return ScriptMetadata()
157 content = script_blocks[0][1]
158 stripped = "".join(
159 line[2:] if len(line) > 1 and line[1] == " " else line[1:] for line in content.splitlines(keepends=True)
160 )
161 metadata = tomllib.loads(stripped)
162 return ScriptMetadata(
163 requires_python=metadata.get("requires-python"),
164 dependencies=metadata.get("dependencies", []),
165 )
166
167
168__all__ = [

Callers 1

_get_script_metadataMethod · 0.85

Calls 3

ScriptMetadataClass · 0.85
joinMethod · 0.80
getMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…