diff --git a/fdroidserver/index.py b/fdroidserver/index.py index 078b64fb..e707824d 100644 --- a/fdroidserver/index.py +++ b/fdroidserver/index.py @@ -405,7 +405,7 @@ def make_v0(apps, apks, repodir, repodict, requestsdict, fdroid_signing_key_fing addElement('icon', app.icon, doc, apel) addElementCheckLocalized('desc', app, 'Description', doc, apel, - '

No description available

') + 'No description available') addElement('license', app.License, doc, apel) if app.Categories: diff --git a/fdroidserver/lint.py b/fdroidserver/lint.py index dd48e05f..7ee37865 100644 --- a/fdroidserver/lint.py +++ b/fdroidserver/lint.py @@ -583,7 +583,7 @@ def main(): config = common.read_config(options) # Get all apps... - allapps = metadata.read_metadata(xref=True) + allapps = metadata.read_metadata() apps = common.read_app_args(options.appid, allapps, False) anywarns = check_for_unsupported_metadata_files() diff --git a/fdroidserver/metadata.py b/fdroidserver/metadata.py index 79195289..2b6c8482 100644 --- a/fdroidserver/metadata.py +++ b/fdroidserver/metadata.py @@ -21,10 +21,7 @@ import os import re import glob -import html import logging -import textwrap -import io import yaml try: from yaml import CSafeLoader as SafeLoader @@ -467,196 +464,6 @@ def check_metadata(app): v.check(app[k], app.id) -# Formatter for descriptions. Create an instance, and call parseline() with -# each line of the description source from the metadata. At the end, call -# end() and then text_txt and text_html will contain the result. -class DescriptionFormatter: - - stNONE = 0 - stPARA = 1 - stUL = 2 - stOL = 3 - - def __init__(self, linkres): - self.bold = False - self.ital = False - self.state = self.stNONE - self.laststate = self.stNONE - self.text_html = '' - self.text_txt = '' - self.html = io.StringIO() - self.text = io.StringIO() - self.para_lines = [] - self.linkResolver = None - self.linkResolver = linkres - - def endcur(self, notstates=None): - if notstates and self.state in notstates: - return - if self.state == self.stPARA: - self.endpara() - elif self.state == self.stUL: - self.endul() - elif self.state == self.stOL: - self.endol() - - def endpara(self): - self.laststate = self.state - self.state = self.stNONE - whole_para = ' '.join(self.para_lines) - self.addtext(whole_para) - wrapped = textwrap.fill(whole_para, 80, - break_long_words=False, - break_on_hyphens=False) - self.text.write(wrapped) - self.html.write('

') - del self.para_lines[:] - - def endul(self): - self.html.write('') - self.laststate = self.state - self.state = self.stNONE - - def endol(self): - self.html.write('') - self.laststate = self.state - self.state = self.stNONE - - def formatted(self, txt, htmlbody): - res = '' - if htmlbody: - txt = html.escape(txt, quote=False) - while True: - index = txt.find("''") - if index == -1: - return res + txt - res += txt[:index] - txt = txt[index:] - if txt.startswith("'''"): - if htmlbody: - if self.bold: - res += '' - else: - res += '' - self.bold = not self.bold - txt = txt[3:] - else: - if htmlbody: - if self.ital: - res += '' - else: - res += '' - self.ital = not self.ital - txt = txt[2:] - - def linkify(self, txt): - res_plain = '' - res_html = '' - while True: - index = txt.find("[") - if index == -1: - return (res_plain + self.formatted(txt, False), res_html + self.formatted(txt, True)) - res_plain += self.formatted(txt[:index], False) - res_html += self.formatted(txt[:index], True) - txt = txt[index:] - if txt.startswith("[["): - index = txt.find("]]") - if index == -1: - _warn_or_exception(_("Unterminated ]]")) - url = txt[2:index] - if self.linkResolver: - url, urltext = self.linkResolver.resolve_description_link(url) - else: - urltext = url - res_html += '' + html.escape(urltext, quote=False) + '' - res_plain += urltext - txt = txt[index + 2:] - else: - index = txt.find("]") - if index == -1: - _warn_or_exception(_("Unterminated ]")) - url = txt[1:index] - index2 = url.find(' ') - if index2 == -1: - urltxt = url - else: - urltxt = url[index2 + 1:] - url = url[:index2] - if url == urltxt: - _warn_or_exception(_("URL title is just the URL, use brackets: [URL]")) - res_html += '' + html.escape(urltxt, quote=False) + '' - res_plain += urltxt - if urltxt != url: - res_plain += ' (' + url + ')' - txt = txt[index + 1:] - - def addtext(self, txt): - p, h = self.linkify(txt) - self.html.write(h) - - def parseline(self, line): - if not line: - self.endcur() - elif line.startswith('* '): - self.endcur([self.stUL]) - if self.state != self.stUL: - self.html.write('