MCPcopy
hub / github.com/marimo-team/marimo / read_pyproject_from_script

Function read_pyproject_from_script

marimo/_utils/scripts.py:24–45  ·  view source on GitHub ↗

Read the pyproject.toml file from the script. Adapted from https://peps.python.org/pep-0723/#reference-implementation

(script: str)

Source from the content-addressed store, hash-verified

22
23
24def read_pyproject_from_script(script: str) -> dict[str, Any] | None:
25 """
26 Read the pyproject.toml file from the script.
27
28 Adapted from https://peps.python.org/pep-0723/#reference-implementation
29 """
30 name = "script"
31 matches = list(
32 filter(lambda m: m.group("type") == name, re.finditer(REGEX, script))
33 )
34 if len(matches) > 1:
35 raise ValueError(f"Multiple {name} blocks found")
36 elif len(matches) == 1:
37 content = "".join(
38 line[2:] if line.startswith("# ") else line[1:]
39 for line in matches[0].group("content").splitlines(keepends=True)
40 )
41
42 pyproject = toml_reader.reads(content)
43 return pyproject
44 else:
45 return None
46
47
48def write_pyproject_to_script(project: dict[str, Any]) -> str:

Calls 3

filterFunction · 0.85
readsMethod · 0.80
joinMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…