From 12d042cf09ab41e7eaa45bca6ca9fae52ad90e80 Mon Sep 17 00:00:00 2001 From: Ricardo Branco Date: Sun, 17 Sep 2023 12:38:49 +0200 Subject: [PATCH] Drop Jinja2 dependency --- Dockerfile | 1 - bugme.py | 15 +++++---------- requirements-dev.txt | 1 - requirements.txt | 2 -- 4 files changed, 5 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index b330b77..3ba746d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,6 @@ RUN zypper addrepo https://download.opensuse.org/repositories/SUSE:/CA/openSUSE_ python3-dulwich \ python3-python-dateutil \ python3-pytz \ - python3-Jinja2 \ python3-bugzilla \ python3-PyGithub \ python3-python-gitlab \ diff --git a/bugme.py b/bugme.py index 7084e0f..59865ee 100755 --- a/bugme.py +++ b/bugme.py @@ -12,8 +12,6 @@ from concurrent.futures import ThreadPoolExecutor from typing import Any, Generator -from jinja2 import Template - from scantags import scan_tags from services import get_item, Item, MyBugzilla, MyGithub, MyGitlab, MyRedmine from utils import dateit @@ -124,19 +122,16 @@ def print_items( "created": "<15" if time_format == "timeago" else "<30", "updated": "<15" if time_format == "timeago" else "<30", } - keys = {key: keys.get(key, "") for key in output_format.split(",")} # Print header if output_type == "html": header = "".join(f"{key.upper()}" for key in keys) print(f"{header}") - elif "{{" not in output_format: - output_format = " ".join( - f'{{{{"{{:{align}}}".format({key})}}}}' for key, align in keys.items() - ) - if "json" not in output_format: - print(Template(output_format).render({key: key.upper() for key in keys})) + else: + output_format = " ".join(f"{{{key}:{align}}}" for key, align in keys.items()) + if "json" not in keys: + print(output_format.format(**{key: key.upper() for key in keys})) xtags = {} if not urltags: @@ -156,7 +151,7 @@ def print_items( href = f'{info["file"]} {info["lineno"]}' print(f"{tds}") else: - print(Template(output_format).render(item.__dict__)) + print(output_format.format(**item.__dict__)) for info in xtags.get(item.tag, []): print("\t".join([info["file"], info["url"]])) diff --git a/requirements-dev.txt b/requirements-dev.txt index 93193d3..6d984c7 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -1,5 +1,4 @@ dulwich -Jinja2 PyGithub python-bugzilla python-gitlab diff --git a/requirements.txt b/requirements.txt index 618969b..93308bc 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,8 +5,6 @@ cryptography==41.0.3 Deprecated==1.2.14 dulwich==0.21.6 idna==3.4 -Jinja2==3.1.2 -MarkupSafe==2.1.3 pycparser==2.21 PyGithub==1.59.1 PyJWT==2.8.0
{href}