diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..023ce00 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +map.txt diff --git a/create-nginx-map.py b/create-nginx-map.py index eb60936..cc741b1 100644 --- a/create-nginx-map.py +++ b/create-nginx-map.py @@ -11,6 +11,8 @@ import json TRAEFIK_HOST_RE = re.compile(r"Host\(`([a-z0-9\.-]+)`\)") CONFIG_FILE = Path.cwd() / "config.toml" +OUTPUT_FILE = Path.cwd() / "map.txt" + class Route(NamedTuple): name: str @@ -94,8 +96,9 @@ def main(): for route in routes: grouped_routes[route.hostname, route.destination].add(route.name) - for (hostname, destination), names in sorted(grouped_routes.items()): - print(f"{hostname}\t{destination}; # {', '.join(names)}") + with OUTPUT_FILE.open("w", buffering=1024 * 1024) as f: + for (hostname, destination), names in sorted(grouped_routes.items()): + print(f"{hostname}\t{destination}; # {', '.join(names)}", file=f) print("Found", len(routes), "routes, grouped into", len(grouped_routes), "groups")