From 42216093fdb86b9c3f54fffc3697fbaac71bd961 Mon Sep 17 00:00:00 2001 From: Florian Apolloner Date: Mon, 22 Jan 2024 09:50:18 +0100 Subject: [PATCH] Removed genshi usage from our trac plugin. --- DjangoPlugin/tracdjangoplugin/__init__.py | 34 ++++++++++------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/DjangoPlugin/tracdjangoplugin/__init__.py b/DjangoPlugin/tracdjangoplugin/__init__.py index 1b09208..3d461df 100644 --- a/DjangoPlugin/tracdjangoplugin/__init__.py +++ b/DjangoPlugin/tracdjangoplugin/__init__.py @@ -3,6 +3,8 @@ from trac.web.api import IRequestFilter, IRequestHandler from trac.wiki.web_ui import WikiModule from trac.util import Markup +from trac.util.html import tag +from tracext.github import GitHubBrowser class CustomWikiModule(WikiModule): @@ -55,7 +57,7 @@ class CustomNavigationBar(Component): implements(INavigationContributor) def get_active_navigation_item(self, req): - return "" + return "custom_reports" def get_navigation_items(self, req): return [ @@ -67,22 +69,14 @@ def get_navigation_items(self, req): ] -try: - # Provided by https://github.com/aaugustin/trac-github - from tracext.github import GitHubBrowser -except ImportError: - pass -else: - from genshi.builder import tag - - class GitHubBrowserWithSVNChangesets(GitHubBrowser): - def _format_changeset_link(self, formatter, ns, chgset, label, fullmatch=None): - # Dead-simple version for SVN changesets - if chgset.isnumeric(): - href = formatter.href.changeset(chgset, None, "/") - return tag.a(label, class_="changeset", href=href) - - # Fallback to the default implemntation - return super(GitHubBrowserWithSVNChangesets, self)._format_changeset_link( - formatter, ns, chgset, label, fullmatch - ) +class GitHubBrowserWithSVNChangesets(GitHubBrowser): + def _format_changeset_link(self, formatter, ns, chgset, label, fullmatch=None): + # Dead-simple version for SVN changesets. + if chgset.isnumeric(): + href = formatter.href.changeset(chgset, None, "/") + return tag.a(label, class_="changeset", href=href) + + # Fallback to the default implementation. + return super(GitHubBrowserWithSVNChangesets, self)._format_changeset_link( + formatter, ns, chgset, label, fullmatch + )