mirror of
https://github.com/daylinmorgan/viv.git
synced 2024-12-22 10:40:44 -06:00
fix: use updated pep723 syntax
This commit is contained in:
parent
3bfdf5c095
commit
0085940f58
2 changed files with 6 additions and 30 deletions
|
@ -1,6 +1,5 @@
|
|||
#!/usr/bin/env -S viv run -s
|
||||
# /// pyproject
|
||||
# [run]
|
||||
# /// script
|
||||
# requires-python = ">=3.11"
|
||||
# dependencies = [
|
||||
# "requests<3",
|
||||
|
|
|
@ -2012,8 +2012,8 @@ METADATA_BLOCK = (
|
|||
)
|
||||
|
||||
|
||||
def read_metadata_block(script: str) -> dict:
|
||||
name = "pyproject"
|
||||
def _read_metadata_block(script: str) -> dict:
|
||||
name = "script"
|
||||
matches = list(
|
||||
filter(lambda m: m.group("type") == name, re.finditer(METADATA_BLOCK, script))
|
||||
)
|
||||
|
@ -2027,29 +2027,6 @@ def read_metadata_block(script: str) -> dict:
|
|||
return {}
|
||||
|
||||
|
||||
# DEPENDENCY_BLOCK_MARKER = r"(?i)^#\s+script\s+dependencies:\s*$"
|
||||
#
|
||||
# def read_dependency_block(txt: str) -> Generator[str, None, None]:
|
||||
# lines = iter(txt.splitlines())
|
||||
# for line in lines:
|
||||
# if re.match(DEPENDENCY_BLOCK_MARKER, line):
|
||||
# for line in lines:
|
||||
# if not line.startswith("#"):
|
||||
# break
|
||||
# # Remove comments. An inline comment is introduced by
|
||||
# # a hash, which must be preceded and followed by a
|
||||
# # space. The initial hash will be skipped as it has
|
||||
# # no space before it.
|
||||
# line = line.split(" # ", maxsplit=1)[0]
|
||||
# line = line[1:].strip()
|
||||
# if not line:
|
||||
# continue
|
||||
# # let pip handle the requirement errors
|
||||
# yield line
|
||||
# break
|
||||
#
|
||||
|
||||
|
||||
def _parse_date(txt: str) -> datetime:
|
||||
"""attempt to parse datetime string
|
||||
|
||||
|
@ -2555,9 +2532,9 @@ class Viv:
|
|||
script_text = fetch_script(script)
|
||||
|
||||
viv_used = uses_viv(script_text)
|
||||
deps = (
|
||||
read_metadata_block(script_text).get("run", {}).get("dependencies", [])
|
||||
)
|
||||
deps = _read_metadata_block(script_text).get("dependencies", [])
|
||||
|
||||
# TODO: incorporate python version checking...
|
||||
|
||||
if viv_used and deps:
|
||||
error(
|
||||
|
|
Loading…
Reference in a new issue