chiark / gitweb /
New 'lint' subcommand in testing phase
authorDaniel Martí <mvdan@mvdan.cc>
Thu, 2 Jan 2014 18:28:55 +0000 (19:28 +0100)
committerDaniel Martí <mvdan@mvdan.cc>
Thu, 9 Jan 2014 15:23:48 +0000 (16:23 +0100)
fdroid
fdroidserver/common.py
fdroidserver/lint.py [new file with mode: 0644]
sampleconfigs/config.sample.py

diff --git a/fdroid b/fdroid
index 0f75fc96a33f50964727b7aa43afa1f2d8d310a5..02396313bd9ed6839e16a92be9a87c7270b4d337 100755 (executable)
--- a/fdroid
+++ b/fdroid
@@ -30,6 +30,7 @@ commands = [
         "checkupdates",
         "import",
         "rewritemeta",
+        "lint",
         "scanner",
         "stats",
         "server"]
index f2e4b661dabf5754ff2052618caeed4e6fb01155..aefa78de10fd43c526068838cac5e1ad899fee4e 100644 (file)
@@ -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 (file)
index 0000000..4ff4b43
--- /dev/null
@@ -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 <http://www.gnu.org/licenses/>.
+
+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()
+
index 0f4aeb2cf8fd79ed572168d3a62fe7c5b4bcde84..6f4988d34e3b52ed4a8448d9459c8d1e5d37b3b9 100644 (file)
@@ -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
+}