From 4f0d01aab0040372d842bb84e74e44f3a72e57e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C3=ABl=20Ricart?= Date: Thu, 27 Feb 2025 15:20:16 +0100 Subject: [PATCH] add pretty routes debian --- parsers/base.py | 5 +---- template/debian.rst.j2 | 6 +++++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/parsers/base.py b/parsers/base.py index 38efd4f..4b4c85d 100644 --- a/parsers/base.py +++ b/parsers/base.py @@ -17,7 +17,6 @@ def find_os(content): osystem = [line.split("=")[-1] for line in version.splitlines() if line.startswith("ID=")] if osystem: return osystem[0] - print(content) if "ID" in jcontent: return jcontent["ID"] return "freebox" @@ -30,6 +29,7 @@ def main(): env = Environment(loader = FileSystemLoader('../template')) for file in onlyfiles: + print("opening {} file ...".format(file.split("/")[-1])) with open(file,"r") as f: content = f.read() current_os = find_os(content) @@ -37,13 +37,10 @@ def main(): infos = parse_freebsd(content) template = env.get_template('freebsd.rst.j2') output = template.render(**infos) - print(output) elif "debian" in current_os: infos = parse_debian(content) template = env.get_template('debian.rst.j2') output = template.render(**infos) - print(output) - else: parse_freebox(content) with open("../source/devices/{host}.rst".format(host=infos["hostname"].replace("\n","")), "w") as f: diff --git a/template/debian.rst.j2 b/template/debian.rst.j2 index 7378ce1..655b52f 100644 --- a/template/debian.rst.j2 +++ b/template/debian.rst.j2 @@ -15,7 +15,11 @@ interface adresses routes ###### -{{ routes }} +============ =============== ============== +destination gateway interface +============ =============== =============={% for route in routes %} +{{ "{:<12}".format(route["destination"]) }} {{ "{:<15}".format(route["gateway"]) }} {{ route["iface"] }}{% endfor %} +============ =============== ============== services --------