1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
#!/usr/bin/env python3
# Copyright (C) Dnspython Contributors, see LICENSE for text of ISC license
import os
import tomllib
with open("pyproject.toml", "rb") as pp:
pyproject = tomllib.load(pp)
FEATURES = "dns/_features.py"
NEW_FEATURES = FEATURES + ".new"
skip = False
with open(FEATURES, "r") as input:
with open(NEW_FEATURES, "w") as output:
for l in input.readlines():
l = l.rstrip()
if l.startswith(" ### BEGIN generated requirements"):
print(l, file=output)
for name, deps in pyproject["project"]["optional-dependencies"].items():
if name == "dev":
continue
print(
f" {repr(name)}: {repr(deps)},".replace("'", '"'),
file=output,
)
skip = True
elif l.startswith(" ### END generated requirements"):
skip = False
if not skip:
print(l, file=output)
os.rename(NEW_FEATURES, FEATURES)
|