diff options
| author | Sebastian Heinlein <sebi@glatzor.de> | 2008-08-14 22:00:38 +0200 |
|---|---|---|
| committer | Sebastian Heinlein <sebi@glatzor.de> | 2008-08-14 22:00:38 +0200 |
| commit | 945b06bc69749ae0543a2e27b46bf9d1b8b9353a (patch) | |
| tree | 0d16db894d1551b07e0e8f076db07121b4461d97 /apt | |
| parent | 1d96f36591c56798021c4e33d01a781507592add (diff) | |
| download | python-apt-945b06bc69749ae0543a2e27b46bf9d1b8b9353a.tar.gz | |
Enhance the package description by using line breaks only for abstracts and replacing the ASCII art bullets by an unicode dot. This was implemented in several applications e.g. gnome-app-install, update-manager or packagekit. As a side effect it breaks the behavior of those.
Diffstat (limited to 'apt')
| -rw-r--r-- | apt/package.py | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/apt/package.py b/apt/package.py index 096b1bd1..f1ea02c5 100644 --- a/apt/package.py +++ b/apt/package.py @@ -19,11 +19,13 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA -import apt_pkg import sys import random +import re import string +import apt_pkg + #from gettext import gettext as _ import gettext def _(s): return gettext.dgettext("python-apt", s) @@ -235,7 +237,9 @@ class Package(object): summary = property(summary) def description(self, format=True): - """ Return the formated long description """ + """ + Return the formated long description + """ if not self._lookupRecord(): return "" # get the translated description @@ -248,12 +252,23 @@ class Package(object): except UnicodeDecodeError,e: s = _("Invalid unicode in description for '%s' (%s). " "Please report.") % (self.name,e) - for line in string.split(s,"\n"): - tmp = string.strip(line) - if tmp == ".": - desc += "\n" - else: - desc += tmp + "\n" + lines = string.split(s, "\n") + for i in range(len(lines)): + # Skip the first line, since its a duplication of the summary + if i == 0: continue + line = lines[i].strip() + # Replace all empty lines by line breaks + if line == ".": + desc += "\n" + continue + # Use dots for lists + p = re.compile(r'^(\s|\t)*(\*|0|-)',re.MULTILINE) + line = p.sub(ur'\n\u2022', line) + # Use line breaks only for abstracts + if desc == "" or desc[-1] == "\n": + desc += line + else: + desc += " " + line return desc description = property(description) |
