From b725acf55b2dd26cd8deb36c68b2083fbd0d52e4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Mart=C3=AD?= Date: Thu, 2 Jan 2014 19:28:55 +0100 Subject: [PATCH] New 'lint' subcommand in testing phase --- fdroid | 1 + fdroidserver/common.py | 7 ++- fdroidserver/lint.py | 82 ++++++++++++++++++++++++++++++++++ sampleconfigs/config.sample.py | 7 +++ 4 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 fdroidserver/lint.py diff --git a/fdroid b/fdroid index 0f75fc96..02396313 100755 --- a/fdroid +++ b/fdroid @@ -30,6 +30,7 @@ commands = [ "checkupdates", "import", "rewritemeta", + "lint", "scanner", "stats", "server"] diff --git a/fdroidserver/common.py b/fdroidserver/common.py index f2e4b661..aefa78de 100644 --- a/fdroidserver/common.py +++ b/fdroidserver/common.py @@ -60,7 +60,12 @@ def read_config(opts, config_file='config.py'): 'archive_older': 0, 'max_icon_size': 72, 'stats_to_carbon': False, - 'repo_maxage': 0 + 'repo_maxage': 0, + 'char_limits': { + 'Summary' : 40, + 'Description' : 1500 + } + } config = {} diff --git a/fdroidserver/lint.py b/fdroidserver/lint.py new file mode 100644 index 00000000..4ff4b43e --- /dev/null +++ b/fdroidserver/lint.py @@ -0,0 +1,82 @@ +#!/usr/bin/env python2 +# -*- coding: utf-8 -*- +# +# rewritemeta.py - part of the FDroid server tool +# Copyright (C) 2010-12, Ciaran Gultnieks, ciaran@ciarang.com +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See th +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public Licen +# along with this program. If not, see . + +from optparse import OptionParser +import common, metadata + +config = None +options = None + +appid = None + +def warn(message): + global appid + if appid: + print "%s:" % appid + appid = None + print(' %s' % message) + +def main(): + + global config, options, appid + + # Parse command line... + parser = OptionParser(usage="Usage: %prog [options] [APPID [APPID ...]]") + parser.add_option("-v", "--verbose", action="store_true", default=False, + help="Spew out even more information than normal") + (options, args) = parser.parse_args() + + config = common.read_config(options) + + # Get all apps... + allapps = metadata.read_metadata(xref=False) + apps = common.read_app_args(args, allapps, False) + + for app in apps: + appid = app['id'] + lastcommit = '' + + for build in app['builds']: + if 'commit' in build and 'disable' not in build: + lastcommit = build['commit'] + + if (app['Update Check Mode'] == 'RepoManifest' and + any(s in lastcommit for s in ('.', ',', '_', '-', '/'))): + warn("Last used commit '%s' looks like a tag, but Update Check Mode is RepoManifest" % lastcommit) + + summ_chars = len(app['Summary']) + if summ_chars > config['char_limits']['Summary']: + warn("Summary of length %s is over the %i char limit" % ( + summ_chars, config['char_limits']['Summary'])) + + desc_chars = 0 + for line in app['Description']: + desc_chars += len(line) + if desc_chars > config['char_limits']['Description']: + warn("Description of length %s is over the %i char limit" % ( + desc_chars, config['char_limits']['Description'])) + + if not appid: + print + + print "Finished." + +if __name__ == "__main__": + main() + diff --git a/sampleconfigs/config.sample.py b/sampleconfigs/config.sample.py index 0f4aeb2c..6f4988d3 100644 --- a/sampleconfigs/config.sample.py +++ b/sampleconfigs/config.sample.py @@ -118,3 +118,10 @@ carbon_port = 2003 #Set this to true to always use a build server. This saves specifying the #--server option on dedicated secure build server hosts. build_server_always = False + +# Limit in number of characters that fields can take up +# Only the fields listed here are supported, defaults shown +char_limits: { + 'Summary' : 40 + 'Description' : 1500 +} -- 2.30.2