2 # -*- coding: utf-8 -*-
4 # rewritemeta.py - part of the FDroid server tools
5 # This cleans up the original .txt metadata file format.
6 # Copyright (C) 2010-12, Ciaran Gultnieks, ciaran@ciarang.com
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU Affero General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU Affero General Public License for more details.
18 # You should have received a copy of the GNU Affero General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 from optparse import OptionParser
33 global config, options
35 # Parse command line...
36 parser = OptionParser(usage="Usage: %prog [options] [APPID [APPID ...]]")
37 parser.add_option("-v", "--verbose", action="store_true", default=False,
38 help="Spew out even more information than normal")
39 parser.add_option("-q", "--quiet", action="store_true", default=False,
40 help="Restrict output to warnings and errors")
41 (options, args) = parser.parse_args()
43 config = common.read_config(options)
46 allapps = metadata.read_metadata(xref=True)
47 apps = common.read_app_args(args, allapps, False)
49 for appid, app in apps.iteritems():
50 metadatapath = app['metadatapath']
51 ext = os.path.splitext(metadatapath)[1][1:]
53 logging.info("Rewriting " + metadatapath)
54 metadata.write_metadata(metadatapath, app)
56 logging.info("Ignoring %s file at '%s'"
57 % (ext.upper(), metadatapath))
59 logging.info("Finished.")
61 if __name__ == "__main__":