From 5a5c86b6b7f9658511334a38f2fc07d36232e395 Mon Sep 17 00:00:00 2001
From: Jerome Martin <tramjoe.merin@gmail.com>
Date: Wed, 2 Oct 2013 10:24:21 +0200
Subject: [PATCH] Fixes agrover "Do not require epydoc" patch

* Rewrote markup deletion code to be generic and cleaner
* Fixed console.py
  . epydoc was still imported unconditionaly!
  . try/except an epydoc call left behind
* Fixed packaging files
  . Removed epydoc requirement for RPM
  . Moved python-epydoc from Depends: to Suggests: for .deb
---
 configshell/console.py           | 22 +++++++++++-----------
 debian/control                   |  4 ++--
 rpm/python-configshell.spec.tmpl |  4 ++--
 3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/configshell/console.py b/configshell/console.py
index 985d789..76d314d 100644
--- a/configshell/console.py
+++ b/configshell/console.py
@@ -22,7 +22,6 @@ import prefs
 import struct
 import textwrap
 from fcntl import ioctl
-import epydoc.markup.epytext
 from termios import TIOCGWINSZ, TCSADRAIN, tcsetattr, tcgetattr
 
 # avoid requiring epydoc at runtime
@@ -55,6 +54,8 @@ class Console(object):
     _ansi_fgcolors = dict(zip(colors, range(30, 38)))
     _ansi_bgcolors = dict(zip(colors, range(40, 48)))
 
+    _epy_markup_re = re.compile("[A-Z]\{(.*?)\}")
+
     __borg_state = {}
 
     def __init__(self, stdin=sys.stdin, stdout=sys.stdout):
@@ -162,16 +163,13 @@ class Console(object):
             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"
+            text = "%s\n\n" % re.sub(self._epy_markup_re, r'\1', text)
         except:
             self.display(text)
             raise
-        text = self.render_domtree(dom_tree)
+        else:
+            text = self.render_domtree(dom_tree)
+
         # We need to remove the last line feed, but there might be
         # escape characters after it...
         clean_text = ''
@@ -404,9 +402,11 @@ 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)
+            try:
+                text = '%s' % epydoc.markup.epytext.SYMBOL_TO_PLAINTEXT.get(
+                    childstr, childstr)
+            except NameError:
+                pass
         elif tree.tag == 'graph':
             text = '<<%s graph: %s>>' \
                     % (variables[0], ', '.join(variables[1:]))
diff --git a/debian/control b/debian/control
index af9ad15..518c2fc 100644
--- a/debian/control
+++ b/debian/control
@@ -7,8 +7,8 @@ Standards-Version: 3.8.1
 
 Package: python-configshell
 Architecture: all
-Depends: python (>= 2.6)|python2.6, python-epydoc, python-simpleparse, python-urwid (>=0.9.9)
-Suggests: configshell-doc
+Depends: python (>= 2.6)|python2.6, python-simpleparse, python-urwid (>=0.9.9)
+Suggests: configshell-doc, python-epydoc
 Description: Framework to create CLI interfaces.
  .
  This package contains the configshell library.
diff --git a/rpm/python-configshell.spec.tmpl b/rpm/python-configshell.spec.tmpl
index 75f7906..1facd56 100644
--- a/rpm/python-configshell.spec.tmpl
+++ b/rpm/python-configshell.spec.tmpl
@@ -11,8 +11,8 @@ Source:         %{oname}-%{version}.tar.gz
 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-rpmroot
 BuildArch:      noarch
 BuildRequires:  python-devel, epydoc, python-simpleparse
-Requires:       python-simpleparse, python-urwid >= 0.9.9, epydoc
-Vendor:         RisingTide Systems
+Requires:       python-simpleparse, python-urwid >= 0.9.9
+Vendor:         Datera, Inc.
 
 %description
 A framework to implement simple but nice command-line interfaces.
-- 
1.8.1.4

