X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=charisma;h=9638d89325db551074ca60501102c247d0c54d43;hb=f2f237c936b5d5727c2b70be85cdacd2903c05b2;hp=2e801dc743d6b666710bc8e7ee571cf30a3b016e;hpb=ef864c51e3eab9518c58c946b31346e598d91bb1;p=dak.git diff --git a/charisma b/charisma index 2e801dc7..9638d893 100755 --- a/charisma +++ b/charisma @@ -1,8 +1,8 @@ #!/usr/bin/env python # Generate Maintainers file used by e.g. the Debian Bug Tracking System -# Copyright (C) 2000, 2001 James Troup -# $Id: charisma,v 1.10 2001-09-26 03:47:15 troup Exp $ +# Copyright (C) 2000, 2001, 2002, 2003, 2004 James Troup +# $Id: charisma,v 1.17 2004-03-11 00:20:51 troup Exp $ # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -26,9 +26,9 @@ ################################################################################ -import os, pg, re, string, sys -import db_access, utils -import apt_pkg +import pg, sys; +import db_access, utils; +import apt_pkg; ################################################################################ @@ -39,9 +39,12 @@ packages = {} fixed_maintainer_cache = {} ################################################################################ -def usage (exit_code): + +def usage (exit_code=0): print """Usage: charisma [OPTION] EXTRA_FILE[...] Generate an index of packages <=> Maintainers. + + -h, --help show this help and exit """ sys.exit(exit_code) @@ -73,19 +76,23 @@ def get_maintainer_from_source (source_id): def main(): global Cnf, projectB; - apt_pkg.init(); + Cnf = utils.get_conf() + + Arguments = [('h',"help","Charisma::Options::Help")]; + if not Cnf.has_key("Charisma::Options::Help"): + Cnf["Charisma::Options::Help"] = ""; - Cnf = apt_pkg.newConfiguration(); - apt_pkg.ReadConfigFileISC(Cnf,utils.which_conf_file()); + extra_files = apt_pkg.ParseCommandLine(Cnf,Arguments,sys.argv); + Options = Cnf.SubTree("Charisma::Options"); - extra_files = apt_pkg.ParseCommandLine(Cnf,[],sys.argv); + if Options["Help"]: + usage(); - #projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]), None, None, Cnf["DB::ROUser"]); projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"])); db_access.init(Cnf, projectB); for suite in Cnf.SubTree("Suite").List(): - suite = string.lower(suite); + suite = suite.lower(); suite_priority = int(Cnf["Suite::%s::Priority" % (suite)]); # Source packages @@ -110,7 +117,7 @@ def main(): source_id = binary[1]; version = binary[3]; # Use the source maintainer first; falling back on the binary maintainer as a last resort only - if source_id != 0 and source_id != None: + if source_id: maintainer = get_maintainer_from_source(source_id); else: maintainer = get_maintainer(binary[2]); @@ -125,16 +132,14 @@ def main(): for filename in extra_files: file = utils.open_file(filename); for line in file.readlines(): - line = string.strip(utils.re_comments.sub('', line[:-1])) + line = utils.re_comments.sub('', line).strip(); if line == "": continue; - split = string.split(line); + split = line.split(); lhs = split[0]; - maintainer = fix_maintainer(string.join(split[1:])); - if string.find(lhs,'~') != -1: - lhs_split = string.split(lhs, '~'); - package = lhs_split[0]; - version = lhs_split[1]; + maintainer = fix_maintainer(" ".join(split[1:])); + if lhs.find('~') != -1: + (package, version) = lhs.split('~'); else: package = lhs; version = '*'; @@ -147,7 +152,7 @@ def main(): package_keys = packages.keys() package_keys.sort() for package in package_keys: - lhs = string.join([package, packages[package]["version"]], '~'); + lhs = "~".join([package, packages[package]["version"]]); print "%-30s %s" % (lhs, packages[package]["maintainer"]); ################################################################################