2 # -*- coding: utf-8 -*-
4 # rewritemeta.py - part of the FDroid server tool
5 # Copyright (C) 2010-12, Ciaran Gultnieks, ciaran@ciarang.com
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU Affero General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See th
15 # GNU Affero General Public License for more details.
17 # You should have received a copy of the GNU Affero General Public Licen
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 from optparse import OptionParser
22 import common, metadata
34 print(' %s' % message)
38 global config, options, appid
40 # Parse command line...
41 parser = OptionParser(usage="Usage: %prog [options] [APPID [APPID ...]]")
42 parser.add_option("-v", "--verbose", action="store_true", default=False,
43 help="Spew out even more information than normal")
44 (options, args) = parser.parse_args()
46 config = common.read_config(options)
49 allapps = metadata.read_metadata(xref=False)
50 apps = common.read_app_args(args, allapps, False)
54 (re.compile(r'.*github\.com/[^/]+/[^/]+\.git'),
55 "Appending .git is not necessary"),
56 (re.compile(r'.*code\.google\.com/p/[^/]+/[^w]'),
57 "Possible incorrect path appended to google code project site")
60 (re.compile(r'.*github\.com/[^/]+/[^/]+\.git'),
61 "Appending .git is not necessary"),
62 (re.compile(r'.*code\.google\.com/p/[^/]+/source/.*'),
63 "/source is often enough on its own"),
64 (re.compile(r'.*code\.google\.com/p/[^/]+[/]*$'),
68 (re.compile(r'.*code\.google\.com/p/[^/]+/issues/.*'),
69 "/issues is often enough on its own"),
70 (re.compile(r'.*code\.google\.com/p/[^/]+[/]*$'),
71 "/issues is missing"),
72 (re.compile(r'.*github\.com/[^/]+/[^/]+/issues/.*'),
73 "/issues is often enough on its own"),
74 (re.compile(r'.*github\.com/[^/]+/[^/]+[/]*$'),
86 for build in app['builds']:
87 if 'commit' in build and 'disable' not in build:
88 lastcommit = build['commit']
90 # Potentially incorrect UCM
91 if (app['Update Check Mode'] in ['RepoManifest', 'None'] and
92 any(s in lastcommit for s in ('.', ',', '_', '-', '/'))):
93 warn("Last used commit '%s' looks like a tag, but Update Check Mode is '%s'" % (
94 lastcommit, app['Update Check Mode']))
97 if app['License'] == 'Unknown':
98 warn("License was not properly set")
101 summ_chars = len(app['Summary'])
102 if summ_chars > config['char_limits']['Summary']:
103 warn("Summary of length %s is over the %i char limit" % (
104 summ_chars, config['char_limits']['Summary']))
106 # Description size limit
108 for line in app['Description']:
109 if re.match(r'[ ]*\*[^ ]', line):
110 warn("Invalid bulleted list: '%s'" % line)
111 desc_chars += len(line)
112 if desc_chars > config['char_limits']['Description']:
113 warn("Description of length %s is over the %i char limit" % (
114 desc_chars, config['char_limits']['Description']))
116 # No punctuation in summary
118 lastchar = app['Summary'][-1]
119 if any(lastchar==c for c in ['.', ',', '!', '?']):
120 warn("Summary should not end with a %s" % lastchar)
122 # Common mistakes in urls
123 for f in regex_warnings:
124 for m, r in regex_warnings[f]:
126 warn("%s url '%s': %s" % (f, app[f], r))
129 for build in app['builds']:
130 for n in ['master', 'origin/', 'default', 'trunk']:
131 if 'commit' not in build:
133 if build['commit'].startswith(n):
134 warn("Branch '%s' used as commit" % n)
141 if __name__ == "__main__":