From: James Troup Date: Thu, 11 Mar 2004 00:20:51 +0000 (+0000) Subject: 2004-02-27 James Troup * rose (process_tree): use 'if var in... X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=33f1fc6121322c1ace0bdfec4aa55f23770af680;p=dak 2004-02-27 James Troup * rose (process_tree): use 'if var in [ list ]' rather than long 'if var == foo or var == bar or var == baz'. Suggested by Martin Michlmayr. * jennifer (check_files): reduce 'if var != None' to 'if var' as suggested by Martin Michlmayr. * catherine (poolize): likewise. * charisma (main): likewise. * halle (check_changes): likewise. * heidi (main): likewise. (process_file): likewise. * kelly (install): likewise. (stable_install): likewise. * utils.py (fix_maintainer): likewise. --- diff --git a/catherine b/catherine index de5b6cc8..66efca2d 100755 --- a/catherine +++ b/catherine @@ -1,8 +1,8 @@ #!/usr/bin/env python # Poolify (move packages from "legacy" type locations to pool locations) -# Copyright (C) 2000, 2001, 2002, 2003 James Troup -# $Id: catherine,v 1.18 2003-09-07 13:52:50 troup Exp $ +# Copyright (C) 2000, 2001, 2002, 2003, 2004 James Troup +# $Id: catherine,v 1.19 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 @@ -79,7 +79,7 @@ def poolize (q, limit, verbose, no_action): base_filename = os.path.basename(legacy_filename); destination_filename = base_filename; # Work out the source package name - if re_isadeb.match(base_filename) != None: + if re_isadeb.match(base_filename): control = apt_pkg.ParseSection(apt_inst.debExtractControl(utils.open_file(legacy_filename))) package = control.Find("Package", ""); source = control.Find("Source", package); @@ -95,7 +95,7 @@ def poolize (q, limit, verbose, no_action): destination_filename = "%s_%s_%s.deb" % (package, version, architecture); else: m = utils.re_issource.match(base_filename) - if m != None: + if m: source = m.group(1); else: utils.fubar("expansion of source filename '%s' failed." % (legacy_filename)); diff --git a/charisma b/charisma index 04ef3ecb..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, 2002, 2003 James Troup -# $Id: charisma,v 1.16 2003-04-15 16:03:31 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 @@ -117,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]); diff --git a/halle b/halle index bf9e6fd5..655c83de 100755 --- a/halle +++ b/halle @@ -2,7 +2,7 @@ # Remove obsolete .changes files from proposed-updates # Copyright (C) 2001, 2002, 2003, 2004 James Troup -# $Id: halle,v 1.11 2004-02-27 20:07:40 troup Exp $ +# $Id: halle,v 1.12 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 @@ -56,7 +56,7 @@ def check_changes (filename): return; num_files = len(files.keys()); for file in files.keys(): - if utils.re_isadeb.match(file) != None: + if utils.re_isadeb.match(file): m = re_isdeb.match(file); pkg = m.group(1); version = m.group(2); @@ -65,7 +65,7 @@ def check_changes (filename): print "BINARY: %s ==> %s_%s_%s" % (file, pkg, version, arch); else: m = utils.re_issource.match(file) - if m != None: + if m: pkg = m.group(1); version = m.group(2); type = m.group(3); diff --git a/heidi b/heidi index 4ad52cfb..2a603024 100755 --- a/heidi +++ b/heidi @@ -1,8 +1,8 @@ #!/usr/bin/env python # Manipulate suite tags -# Copyright (C) 2000, 2001, 2002, 2003 James Troup -# $Id: heidi,v 1.17 2003-04-15 16:03:31 troup Exp $ +# Copyright (C) 2000, 2001, 2002, 2003, 2004 James Troup +# $Id: heidi,v 1.18 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 @@ -176,7 +176,7 @@ def process_file (file, suite, action): assoication_id = ql[0][0]; # Take action if action == "add": - if assoication_id != None: + if assoication_id: utils.warn("'%s~%s~%s' already exists in suite %s." % (package, version, architecture, suite)); continue; else: @@ -197,7 +197,7 @@ def process_file (file, suite, action): assoication_id = ql[0][0]; # Take action if action == "add": - if assoication_id != None: + if assoication_id: utils.warn("'%s~%s~%s' already exists in suite %s." % (package, version, architecture, suite)); continue; else: @@ -262,7 +262,7 @@ def main (): if not Cnf.has_key("Suite::%s" % (suite)): utils.fubar("Unknown suite '%s'." %(suite)); else: - if action != None: + if action: utils.fubar("Can only perform one action at a time."); action = i; diff --git a/jennifer b/jennifer index 2ba18ad0..9f98cfb0 100755 --- a/jennifer +++ b/jennifer @@ -2,7 +2,7 @@ # Checks Debian packages from Incoming # Copyright (C) 2000, 2001, 2002, 2003, 2004 James Troup -# $Id: jennifer,v 1.44 2004-02-27 20:07:40 troup Exp $ +# $Id: jennifer,v 1.45 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 @@ -45,7 +45,7 @@ re_valid_pkg_name = re.compile(r"^[\dA-Za-z][\dA-Za-z\+\-\.]+$"); ################################################################################ # Globals -jennifer_version = "$Revision: 1.44 $"; +jennifer_version = "$Revision: 1.45 $"; Cnf = None; Options = None; @@ -335,7 +335,7 @@ def check_files(): files[file]["byhand"] = 1; files[file]["type"] = "byhand"; # Checks for a binary package... - elif utils.re_isadeb.match(file) != None: + elif utils.re_isadeb.match(file): has_binaries = 1; files[file]["type"] = "deb"; @@ -388,9 +388,9 @@ def check_files(): reject("%s: Depends field is empty." % (file)); # Check the section & priority match those given in the .changes (non-fatal) - if control.Find("Section") != None and files[file]["section"] != "" and files[file]["section"] != control.Find("Section"): + if control.Find("Section") and files[file]["section"] != "" and files[file]["section"] != control.Find("Section"): reject("%s control file lists section as `%s', but changes file has `%s'." % (file, control.Find("Section", ""), files[file]["section"]), "Warning: "); - if control.Find("Priority") != None and files[file]["priority"] != "" and files[file]["priority"] != control.Find("Priority"): + if control.Find("Priority") and files[file]["priority"] != "" and files[file]["priority"] != control.Find("Priority"): reject("%s control file lists priority as `%s', but changes file has `%s'." % (file, control.Find("Priority", ""), files[file]["priority"]),"Warning: "); files[file]["package"] = package; @@ -456,7 +456,7 @@ def check_files(): # Checks for a source package... else: m = utils.re_issource.match(file); - if m != None: + if m: has_source = 1; files[file]["package"] = m.group(1); files[file]["version"] = m.group(2); diff --git a/kelly b/kelly index 69fc3194..37a4ac4f 100755 --- a/kelly +++ b/kelly @@ -1,8 +1,8 @@ #!/usr/bin/env python # Installs Debian packages from queue/accepted into the pool -# Copyright (C) 2000, 2001, 2002, 2003 James Troup -# $Id: kelly,v 1.13 2003-11-07 01:48:38 troup Exp $ +# Copyright (C) 2000, 2001, 2002, 2003, 2004 James Troup +# $Id: kelly,v 1.14 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 @@ -37,7 +37,7 @@ import db_access, katie, logging, utils; ############################################################################### # Globals -kelly_version = "$Revision: 1.13 $"; +kelly_version = "$Revision: 1.14 $"; Cnf = None; Options = None; @@ -334,7 +334,7 @@ def install (): orig_tar_id = Katie.pkg.orig_tar_id; orig_tar_location = Katie.pkg.orig_tar_location; legacy_source_untouchable = Katie.pkg.legacy_source_untouchable; - if orig_tar_id != None and orig_tar_location == "legacy": + if orig_tar_id and orig_tar_location == "legacy": q = projectB.query("SELECT DISTINCT ON (f.id) l.path, f.filename, f.id as files_id, df.source, df.id as dsc_files_id, f.size, f.md5sum FROM files f, dsc_files df, location l WHERE df.source IN (SELECT source FROM dsc_files WHERE file = %s) AND f.id = df.file AND l.id = f.location AND (l.type = 'legacy' OR l.type = 'legacy-mixed')" % (orig_tar_id)); qd = q.dictresult(); for qid in qd: @@ -354,7 +354,7 @@ def install (): # cross-component we need to copy the .orig.tar.gz into the new # component too for the same reasons as above. # - if changes["architecture"].has_key("source") and orig_tar_id != None and \ + if changes["architecture"].has_key("source") and orig_tar_id and \ orig_tar_location != "legacy" and orig_tar_location != dsc_location_id: q = projectB.query("SELECT l.path, f.filename, f.size, f.md5sum FROM files f, location l WHERE f.id = %s AND f.location = l.id" % (orig_tar_id)); ql = q.getresult()[0]; @@ -492,7 +492,7 @@ def stable_install (summary, short_summary): for file in files.keys(): if files[file]["type"] == "deb": new_changelog.write("stable/%s/binary-%s/%s\n" % (files[file]["component"], files[file]["architecture"], file)); - elif utils.re_issource.match(file) != None: + elif utils.re_issource.match(file): new_changelog.write("stable/%s/source/%s\n" % (files[file]["component"], file)); else: new_changelog.write("%s\n" % (file)); diff --git a/rose b/rose index 37deb505..d462ca48 100755 --- a/rose +++ b/rose @@ -1,8 +1,8 @@ #!/usr/bin/env python # Initial setup of an archive -# Copyright (C) 2002 James Troup -# $Id: rose,v 1.3 2003-01-02 18:10:02 troup Exp $ +# Copyright (C) 2002, 2004 James Troup +# $Id: rose,v 1.4 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 @@ -57,7 +57,7 @@ def process_tree(config, tree): for entry in config.SubTree(tree).List(): entry = entry.lower(); if tree == "Dir": - if entry == "poolroot" or entry == "queue" or entry == "morguereject": + if entry in [ "poolroot", "queue" , "morguereject" ]: continue; config_name = "%s::%s" % (tree, entry); target = config[config_name]; diff --git a/utils.py b/utils.py index 9b3ab2a1..c537bf8f 100644 --- a/utils.py +++ b/utils.py @@ -2,7 +2,7 @@ # Utility functions # Copyright (C) 2000, 2001, 2002, 2003, 2004 James Troup -# $Id: utils.py,v 1.63 2004-02-27 20:07:40 troup Exp $ +# $Id: utils.py,v 1.64 2004-03-11 00:20:51 troup Exp $ ################################################################################ @@ -274,7 +274,7 @@ def fix_maintainer (maintainer): rfc822 = maintainer; name = ""; email = ""; - if m != None and len(m.groups()) == 2: + if m and len(m.groups()) == 2: name = m.group(1); email = m.group(2); if name.find(',') != -1 or name.find('.') != -1: