# -*- coding: utf-8 -*- # # common.py - part of the FDroid server tools # Copyright (C) 2010, 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 the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . import glob, os, sys, re def parse_metadata(metafile, **kw): def parse_buildline(value): parts = [p.replace("\\,", ",") for p in re.split(r"(? 0): thisinfo['description'] += ' ' thisinfo['description'] += line elif mode == 2: # line continuation if line.endswith("\\"): buildline.append(line[:-1]) else: buildline.append(line) thisinfo['builds'].append( parse_buildline("".join(buildline))) mode = 0 if mode == 1: print "Description not terminated in " + metafile.name sys.exit(1) if len(thisinfo['description']) == 0: thisinfo['description'] = 'No description available' return thisinfo def read_metadata(verbose=False): apps = [] for metafile in glob.glob(os.path.join('metadata', '*.txt')): apps.append(parse_metadata(metafile, verbose=verbose)) return apps