16
16
# this program; if not, write to the Free Software Foundation, Inc.,
17
17
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
90
def normalize_package_description(desc):
91
""" this takes a package description and normalizes it
92
so that all uneeded \n are stripped away and all
93
enumerations are at the start of the line and start with a "*"
95
Some potentially very long paragrah that is in a single line.
99
* item2 that may again be very very long
101
BULLETS = ('- ', '* ', 'o ')
102
norm_description = ""
106
for i, part in enumerate(desc.split("\n")):
110
norm_description += "\n"
113
for j, c in enumerate(part):
114
if not c in string.whitespace+"".join([s.strip() for s in BULLETS]):
117
# check if in a enumeration
118
if part[:2] in BULLETS:
120
norm_description += "\n* " + part[2:]
121
elif in_blist and old_indent_level == indent_level:
122
norm_description += " " + part
125
if not norm_description.endswith("\n"):
126
norm_description += " "
127
norm_description += part
128
old_indent_level = indent_level
129
return norm_description.strip()
91
def htmlize_package_desc(desc):
93
return re.match("^(\s*[-*])", line)
131
def htmlize_package_description(desc):
97
for line in desc.splitlines():
98
stripped_line = line.strip()
101
not _is_bullet(line) and
103
yield '<p tabindex="0">'
106
match = re.match("^(\s*[-*])", line)
134
for part in normalize_package_description(desc).split("\n"):
135
if part.startswith("* "):
112
indent_len = len(match.group(1))
113
stripped_line = line[indent_len:].strip()
116
if not line.startswith(" " * indent_len):
139
html += '<li>%s</li>' % part[2:]
143
html += '<p tabindex="0">%s</p>' % part
134
149
def get_parent_xid(widget):
135
150
while widget.get_parent():
214
228
return xml.sax.saxutils.unescape(text, ESCAPE_ENTITIES)
216
#def get_current_arch():
217
# return apt_pkg.config.find("Apt::Architecture")
219
230
def uri_to_filename(uri):
220
232
return apt_pkg.uri_to_filename(uri)
222
234
def human_readable_name_from_ppa_uri(ppa_uri):
513
525
upstream_version = get_pkg_info().upstream_version
514
526
version_compare = get_pkg_info().version_compare
531
size_to_str = apt_pkg.size_to_str
533
def size_to_str(size):
517
536
if __name__ == "__main__":
518
537
s = decode_xml_char_reference('Search…')