37 lines
842 B
Python
37 lines
842 B
Python
#!/usr/bin/env python3
|
|
"""Write a copy of requirements.txt without the self-hosted packages.
|
|
|
|
Usage: filter_requirements.py <input> <output>
|
|
"""
|
|
import re
|
|
import sys
|
|
|
|
# Self-hosted packages that are not on PyPI. One per line.
|
|
SKIP = {
|
|
"lib-db-module",
|
|
"lib-secret-manager",
|
|
"lib-send-notifications",
|
|
"simple-logger-handler",
|
|
}
|
|
|
|
NAME_RE = re.compile(r"^\s*([A-Za-z0-9][A-Za-z0-9._-]*)")
|
|
|
|
|
|
def main(src: str, dst: str) -> None:
|
|
skipped = []
|
|
|
|
with open(src) as fin, open(dst, "w") as fout:
|
|
for line in fin:
|
|
match = NAME_RE.match(line)
|
|
if match and match.group(1) in SKIP:
|
|
skipped.append(match.group(1))
|
|
continue
|
|
fout.write(line)
|
|
|
|
print(f"Skipped {len(skipped)} self-hosted package(s): {', '.join(skipped) or '-'}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
if len(sys.argv) != 3:
|
|
sys.exit(__doc__)
|
|
main(sys.argv[1], sys.argv[2]) |