python-configshell/0002-Remove-epydoc-imports-and-epydoc-calls.patch
wang--ge 9c71304d67 Remove epydoc imports and epydoc calls
(cherry picked from commit b36b5ce04a29f3f19f01a25feee1f2d4add4a66d)
2024-05-27 16:46:06 +08:00

80 lines
2.9 KiB
Diff

From 2c2d91e430fe841ee0afe8deaec318b74d756cee Mon Sep 17 00:00:00 2001
From: Christophe Vu-Brugier <cvubrugier@fastmail.fm>
Date: Sun, 28 Jul 2019 18:19:59 +0200
Subject: [PATCH] Remove epydoc imports and epydoc calls
Epydoc is no longer maintained and only supported for Python 2 whereas
most distributions package targetcli-fb for Python 3 (RHEL, Fedora,
Debian). As a consequence, the help messages for configshell commands
are not rendered with Epydoc on most systems and it is probably safe
to remove the Epydoc dependency entirely.
For more information, see:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=881554
Signed-off-by: Christophe Vu-Brugier <cvubrugier@fastmail.fm>
---
configshell/console.py | 31 +++++++++----------------------
1 file changed, 9 insertions(+), 22 deletions(-)
diff --git a/configshell/console.py b/configshell/console.py
index 8ed6b50..80e723c 100644
--- a/configshell/console.py
+++ b/configshell/console.py
@@ -26,12 +26,6 @@ import tty
from .prefs import Prefs
-# avoid requiring epydoc at runtime
-try:
- import epydoc.markup.epytext
-except ImportError:
- pass
-
class Console(object):
'''
Implements various utility methods providing a console UI support toolkit,
@@ -166,19 +160,12 @@ class Console(object):
Renders and print and epytext-formatted text on the console.
'''
text = self.dedent(text)
- try:
- dom_tree = epydoc.markup.epytext.parse(text, None)
- except NameError:
- # epydoc not installed, strip markup
- dom_tree = text
- dom_tree = dom_tree.replace("B{", "")
- dom_tree = dom_tree.replace("I{", "")
- dom_tree = dom_tree.replace("C{", "")
- dom_tree = dom_tree.replace("}", "")
- dom_tree += "\n"
- except:
- self.display(text)
- raise
+ dom_tree = text
+ dom_tree = dom_tree.replace("B{", "")
+ dom_tree = dom_tree.replace("I{", "")
+ dom_tree = dom_tree.replace("C{", "")
+ dom_tree = dom_tree.replace("}", "")
+ dom_tree += "\n"
text = self.render_domtree(dom_tree)
# We need to remove the last line feed, but there might be
# escape characters after it...
@@ -412,9 +399,9 @@ class Console(object):
text = self.render_text(
childstr, styles=['underline'], todefault=True)
elif tree.tag == 'symbol':
- text = '%s' \
- % epydoc.markup.epytext.SYMBOL_TO_PLAINTEXT.get(
- childstr, childstr)
+ # Should not occur because this module does not have
+ # docstrings with symbols (e.g. S{alpha}).
+ raise NotImplementedError
elif tree.tag == 'graph':
text = '<<%s graph: %s>>' \
% (variables[0], ', '.join(variables[1:]))
--
2.42.0.windows.2