diff --git a/dak/add_user.py b/dak/add_user.py index 3528b632f6e0d252c79bdf1efac21299c97eb2b0..f485a129d5abe137c6d396158e8f9a80bed442b7 100755 --- a/dak/add_user.py +++ b/dak/add_user.py @@ -55,8 +55,9 @@ def main(): ] for i in [ "help" ]: - if not Cnf.has_key("Add-User::Options::%s" % (i)): - Cnf["Add-User::Options::%s" % (i)] = "" + key = "Add-User::Options::%s" % i + if key not in Cnf: + Cnf[key] = "" apt_pkg.parse_commandline(Cnf, Arguments, sys.argv) @@ -83,7 +84,7 @@ def main(): primary_key = primary_key.replace(" ","") uid = "" - if Cnf.has_key("Add-User::Options::User") and Cnf["Add-User::Options::User"]: + if "Add-User::Options::User" in Cnf and Cnf["Add-User::Options::User"]: uid = Cnf["Add-User::Options::User"] name = Cnf["Add-User::Options::User"] else: @@ -120,7 +121,7 @@ def main(): session.commit() # Lets add user to the email-whitelist file if its configured. - if Cnf.has_key("Dinstall::MailWhiteList") and Cnf["Dinstall::MailWhiteList"] != "": + if "Dinstall::MailWhiteList" in Cnf and Cnf["Dinstall::MailWhiteList"] != "": f = utils.open_file(Cnf["Dinstall::MailWhiteList"], "a") for mail in emails: f.write(mail+'\n') diff --git a/dak/admin.py b/dak/admin.py index 02e5409f26c1d197595339735b1cccd6cbd6d53a..6ecbb3b3f7f633a8c4efab46c87deb2029aeb0e8 100755 --- a/dak/admin.py +++ b/dak/admin.py @@ -836,13 +836,13 @@ def show_config(command): if mode == 'db': connstr = "" - if cnf.has_key("DB::Service"): + if "DB::Service" in cnf: # Service mode connstr = "postgresql://service=%s" % cnf["DB::Service"] - elif cnf.has_key("DB::Host"): + elif "DB::Host" in cnf: # TCP/IP connstr = "postgres://%s" % cnf["DB::Host"] - if cnf.has_key("DB::Port") and cnf["DB::Port"] != "-1": + if "DB::Port" in cnf and cnf["DB::Port"] != "-1": connstr += ":%s" % cnf["DB::Port"] connstr += "/%s" % cnf["DB::Name"] else: @@ -853,16 +853,16 @@ def show_config(command): print connstr elif mode == 'db-shell': e = [] - if cnf.has_key("DB::Service"): + if "DB::Service" in cnf: e.append('PGSERVICE') print "PGSERVICE=%s" % cnf["DB::Service"] - if cnf.has_key("DB::Name"): + if "DB::Name" in cnf: e.append('PGDATABASE') print "PGDATABASE=%s" % cnf["DB::Name"] - if cnf.has_key("DB::Host"): + if "DB::Host" in cnf: print "PGHOST=%s" % cnf["DB::Host"] e.append('PGHOST') - if cnf.has_key("DB::Port") and cnf["DB::Port"] != "-1": + if "DB::Port" in cnf and cnf["DB::Port"] != "-1": print "PGPORT=%s" % cnf["DB::Port"] e.append('PGPORT') print "export " + " ".join(e) @@ -1018,8 +1018,9 @@ def main(): arguments = [('h', "help", "Admin::Options::Help"), ('n', "dry-run", "Admin::Options::Dry-Run")] for i in [ "help", "dry-run" ]: - if not Cnf.has_key("Admin::Options::%s" % (i)): - Cnf["Admin::Options::%s" % (i)] = "" + key = "Admin::Options::%s" % i + if key not in Cnf: + Cnf[key] = "" arguments = apt_pkg.parse_commandline(Cnf, arguments, sys.argv) diff --git a/dak/archive_dedup_pool.py b/dak/archive_dedup_pool.py index dfe1be797e4ebea33e8f23aa7e7981872105eae5..2d49969f703a502608b9f70d4814deff16a97d3c 100755 --- a/dak/archive_dedup_pool.py +++ b/dak/archive_dedup_pool.py @@ -124,8 +124,9 @@ def main(): apt_pkg.parse_commandline(cnf.Cnf,Arguments,sys.argv) for i in ["help"]: - if not cnf.has_key("Archive-Dedup-Pool::Options::%s" % (i)): - cnf["Archive-Dedup-Pool::Options::%s" % (i)] = "" + key = "Archive-Dedup-Pool::Options::%s" % i + if key not in cnf: + cnf[key] = "" Options = cnf.subtree("Archive-Dedup-Pool::Options") diff --git a/dak/auto_decruft.py b/dak/auto_decruft.py index 88956cc33a0a2f19996eca6f4f8e9f25fb4571ac..a1281aa1b80f81c9f3cd671858a811d5f23ddd94 100644 --- a/dak/auto_decruft.py +++ b/dak/auto_decruft.py @@ -426,8 +426,9 @@ def main (): ("\0",'decruft-equal-versions',"Auto-Decruft::Options::OtherSuiteDecruftEqual") ] for i in ["help", "Dry-Run", "Debug", "OtherSuite", "OtherSuiteRMMsg", "OtherSuiteDecruftEqual"]: - if not cnf.has_key("Auto-Decruft::Options::%s" % (i)): - cnf["Auto-Decruft::Options::%s" % (i)] = "" + key = "Auto-Decruft::Options::%s" % i + if key not in cnf: + cnf[key] = "" cnf["Auto-Decruft::Options::Suite"] = cnf.get("Dinstall::DefaultSuite", "unstable") diff --git a/dak/bts_categorize.py b/dak/bts_categorize.py index c8739af65618fa16ff2c569306f61a45e94dc975..b449c023240c90862801c69bad7c35c836410d32 100755 --- a/dak/bts_categorize.py +++ b/dak/bts_categorize.py @@ -159,7 +159,7 @@ def main(): for arg in arguments: opt = "BtsCategorize::Options::%s" % arg[1] - if not Cnf.has_key(opt): + if opt not in Cnf: Cnf[opt] = "" packages = apt_pkg.parse_commandline(Cnf, arguments, sys.argv) diff --git a/dak/check_archive.py b/dak/check_archive.py index ca5713314d0158b40488064c0a4bc3b07ff9f739..97b53d47bcd20b0a6aad30de1e8fddd967254de9 100755 --- a/dak/check_archive.py +++ b/dak/check_archive.py @@ -98,7 +98,7 @@ def process_dir (unused, dirname, filenames): return for name in filenames: filename = os.path.abspath(os.path.join(dirname,name)) - if os.path.isfile(filename) and not os.path.islink(filename) and not db_files.has_key(filename) and not excluded.has_key(filename): + if os.path.isfile(filename) and not os.path.islink(filename) and filename not in db_files and filename not in excluded: waste += os.stat(filename)[stat.ST_SIZE] print "%s" % (filename) @@ -532,8 +532,9 @@ def main (): Arguments = [('h',"help","Check-Archive::Options::Help")] for i in [ "help" ]: - if not cnf.has_key("Check-Archive::Options::%s" % (i)): - cnf["Check-Archive::Options::%s" % (i)] = "" + key = "Check-Archive::Options::%s" % i + if key not in cnf: + cnf[key] = "" args = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) diff --git a/dak/check_overrides.py b/dak/check_overrides.py index 1683aa667a395d84bea61a344f773d009fc3cd3b..55023f29c4888da83930ee2d5390108219ae344f 100755 --- a/dak/check_overrides.py +++ b/dak/check_overrides.py @@ -148,10 +148,10 @@ SELECT s.source FROM source s if otype == "dsc": for i in q.fetchall(): package = i[0] - if src_packages.has_key(package): + if package in src_packages: src_packages[package] = 1 else: - if blacklist.has_key(package): + if package in blacklist: utils.warn("%s in incoming, not touching" % package) continue Logger.log(["removing unused override", osuite, component, @@ -170,7 +170,7 @@ SELECT s.source FROM source s {'suite_id': osuite_id, 'component_id': component_id}) for i in q.fetchall(): package = i[0] - if not src_packages.has_key(package) or src_packages[package]: + if package not in src_packages or src_packages[package]: continue src_packages[package] = 1 @@ -202,7 +202,7 @@ SELECT s.source FROM source s 'component_id': component_id, 'type_id': type_id}) for i in q.fetchall(): package = i[0] - if not src_packages.has_key(package) or src_packages[package]: + if package not in src_packages or src_packages[package]: if i[4] and (i[1] != i[4] or i[2] != i[5] or i[3] != i[6]): Logger.log(["syncing override", osuite, component, otype, package, "source", sections[i[5]], i[6], "source", sections[i[2]], i[3]]) @@ -240,10 +240,10 @@ SELECT s.source FROM source s else: # binary override for i in q.fetchall(): package = i[0] - if packages.has_key(package): + if package in packages: packages[package] = 1 else: - if blacklist.has_key(package): + if package in blacklist: utils.warn("%s in incoming, not touching" % package) continue Logger.log(["removing unused override", osuite, component, @@ -274,7 +274,7 @@ SELECT s.source FROM source s 'component_id': component_id, 'type_id': type_id}) for i in q.fetchall(): package = i[0] - if not packages.has_key(package) or packages[package]: + if package not in packages or packages[package]: if i[4] and (i[1] != i[4] or i[2] != i[5] or i[3] != i[6]): Logger.log(["syncing override", osuite, component, otype, package, priorities[i[4]], sections[i[5]], @@ -324,8 +324,9 @@ def main (): Arguments = [('h',"help","Check-Overrides::Options::Help"), ('n',"no-action", "Check-Overrides::Options::No-Action")] for i in [ "help", "no-action" ]: - if not cnf.has_key("Check-Overrides::Options::%s" % (i)): - cnf["Check-Overrides::Options::%s" % (i)] = "" + key = "Check-Overrides::Options::%s" % i + if key not in cnf: + cnf[key] = "" apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("Check-Overrides::Options") diff --git a/dak/clean_queues.py b/dak/clean_queues.py index 209591ac01b913d6eef2c2369e201b9ec579d231..5538f579e3b07c298e8aafb731991b73f8efd281 100755 --- a/dak/clean_queues.py +++ b/dak/clean_queues.py @@ -173,7 +173,7 @@ def flush_orphans (): for i in (files.keys(), dsc_files.keys(), [changes_filename]): keys.extend(i) for key in keys: - if all_files.has_key(key): + if key in all_files: if Options["Verbose"]: print "Skipping, has parents, '%s'." % (key) del all_files[key] @@ -195,9 +195,10 @@ def main (): cnf = Config() for i in ["Help", "Incoming", "No-Action", "Verbose" ]: - if not cnf.has_key("Clean-Queues::Options::%s" % (i)): - cnf["Clean-Queues::Options::%s" % (i)] = "" - if not cnf.has_key("Clean-Queues::Options::Days"): + key = "Clean-Queues::Options::%s" % i + if key not in cnf: + cnf[key] = "" + if "Clean-Queues::Options::Days" not in cnf: cnf["Clean-Queues::Options::Days"] = "14" Arguments = [('h',"help","Clean-Queues::Options::Help"), diff --git a/dak/clean_suites.py b/dak/clean_suites.py index 20e942f92d821a9b6ab6743e45b68c7655f77e3e..9ae2ba25e88d508c5dd0ca5d05381f1a6b362ea8 100755 --- a/dak/clean_suites.py +++ b/dak/clean_suites.py @@ -471,8 +471,9 @@ def main(): cnf = Config() for i in ["Help", "No-Action", "Maximum" ]: - if not cnf.has_key("Clean-Suites::Options::%s" % (i)): - cnf["Clean-Suites::Options::%s" % (i)] = "" + key = "Clean-Suites::Options::%s" % i + if key not in cnf: + cnf[key] = "" Arguments = [('h',"help","Clean-Suites::Options::Help"), ('a','archive','Clean-Suites::Options::Archive','HasArg'), diff --git a/dak/control_overrides.py b/dak/control_overrides.py index 63c55f0b4ed183ff3e18df3eb323be6d8bc8eba2..50fb24c6f4246b37cf1c329f9e05f12c13126eda 100755 --- a/dak/control_overrides.py +++ b/dak/control_overrides.py @@ -161,27 +161,27 @@ def process_file(file, suite, component, otype, mode, action, session): c_error += 1 continue - if not section_cache.has_key(section): + if section not in section_cache: utils.warn("'%s' is not a valid section. ['%s' in suite %s, component %s]." % (section, package, suite, component)) c_error += 1 continue section_id = section_cache[section] - if not priority_cache.has_key(priority): + if priority not in priority_cache: utils.warn("'%s' is not a valid priority. ['%s' in suite %s, component %s]." % (priority, package, suite, component)) c_error += 1 continue priority_id = priority_cache[priority] - if new.has_key(package): + if package in new: utils.warn("Can't insert duplicate entry for '%s'; ignoring all but the first. [suite %s, component %s]" % (package, suite, component)) c_error += 1 continue new[package] = "" - if original.has_key(package): + if package in original: (old_priority_id, old_section_id, old_maintainer_override, old_priority, old_section) = original[package] if mode == "add" or old_priority_id == priority_id and \ old_section_id == section_id and \ @@ -236,7 +236,7 @@ def process_file(file, suite, component, otype, mode, action, session): if mode == "set": # Delete any packages which were removed for package in original.keys(): - if not new.has_key(package): + if package not in new: if action: session.execute("""DELETE FROM override WHERE suite = :suiteid AND component = :componentid @@ -311,13 +311,14 @@ def main (): # Default arguments for i in [ "add", "help", "list", "quiet", "set", "change", "no-action" ]: - if not cnf.has_key("Control-Overrides::Options::%s" % (i)): - cnf["Control-Overrides::Options::%s" % (i)] = "" - if not cnf.has_key("Control-Overrides::Options::Component"): + key = "Control-Overrides::Options::%s" % i + if key not in cnf: + cnf[key] = "" + if "Control-Overrides::Options::Component" not in cnf: cnf["Control-Overrides::Options::Component"] = "main" - if not cnf.has_key("Control-Overrides::Options::Suite"): + if "Control-Overrides::Options::Suite" not in cnf: cnf["Control-Overrides::Options::Suite"] = "unstable" - if not cnf.has_key("Control-Overrides::Options::Type"): + if "Control-Overrides::Options::Type" not in cnf: cnf["Control-Overrides::Options::Type"] = "deb" file_list = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) diff --git a/dak/control_suite.py b/dak/control_suite.py index 1b386795e9c76e8f44498d56bb7b248a5c694acd..e326aa6f97aa08290abe0f865ca8df5af3f525e3 100755 --- a/dak/control_suite.py +++ b/dak/control_suite.py @@ -398,8 +398,9 @@ def main (): ('s',"set", "Control-Suite::Options::Set", "HasArg")] for i in ["add", "britney", "help", "list", "remove", "set", "version" ]: - if not cnf.has_key("Control-Suite::Options::%s" % (i)): - cnf["Control-Suite::Options::%s" % (i)] = "" + key = "Control-Suite::Options::%s" % i + if key not in cnf: + cnf[key] = "" try: file_list = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv); @@ -411,7 +412,7 @@ def main (): if Options["Help"]: usage() - force = Options.has_key("Force") and Options["Force"] + force = "Force" in Options and Options["Force"] action = None diff --git a/dak/copy_installer.py b/dak/copy_installer.py index 44ee0bf1845656191828dc71de925ef588ebf132..02fe22d2dcd4851e7d4a7af033f57b1db520ddc7 100755 --- a/dak/copy_installer.py +++ b/dak/copy_installer.py @@ -43,8 +43,9 @@ def main(): ('n', "no-action", "Copy-Installer::Options::No-Action"), ] for option in [ "help", "source", "destination", "no-action" ]: - if not cnf.has_key("Copy-Installer::Options::%s" % (option)): - cnf["Copy-Installer::Options::%s" % (option)] = "" + key = "Copy-Installer::Options::%s" % option + if key not in cnf: + cnf[key] = "" extra_arguments = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("Copy-Installer::Options") diff --git a/dak/cruft_report.py b/dak/cruft_report.py index 8ed425bae888b968148a808386809092f2becd11..4b075f2c8d971b2bbfa13a8ff80b02b3687ec09a 100755 --- a/dak/cruft_report.py +++ b/dak/cruft_report.py @@ -68,7 +68,7 @@ Check for obsolete or duplicated packages. def add_nbs(nbs_d, source, version, package, suite_id, session): # Ensure the package is still in the suite (someone may have already removed it) - if no_longer_in_suite.has_key(package): + if package in no_longer_in_suite: return else: q = session.execute("""SELECT b.id FROM binaries b, bin_associations ba @@ -105,7 +105,7 @@ def do_anais(architecture, binaries_list, source, session): for i in ql: arch = i[0] version = i[1] - if architectures.has_key(arch): + if arch in architectures: versions.append(version) versions.sort(apt_pkg.version_compare) if versions: @@ -117,7 +117,7 @@ def do_anais(architecture, binaries_list, source, session): for i in ql: arch = i[0] version = i[1] - if not architectures.has_key(arch): + if arch not in architectures: versions_d.setdefault(version, []) versions_d[version].append(arch) @@ -508,15 +508,16 @@ def main (): ('s',"suite","Cruft-Report::Options::Suite","HasArg"), ('w',"wanna-build-dump","Cruft-Report::Options::Wanna-Build-Dump","HasArg")] for i in [ "help", "Rdep-Check" ]: - if not cnf.has_key("Cruft-Report::Options::%s" % (i)): - cnf["Cruft-Report::Options::%s" % (i)] = "" + key = "Cruft-Report::Options::%s" % i + if key not in cnf: + cnf[key] = "" cnf["Cruft-Report::Options::Suite"] = cnf.get("Dinstall::DefaultSuite", "unstable") - if not cnf.has_key("Cruft-Report::Options::Mode"): + if "Cruft-Report::Options::Mode" not in cnf: cnf["Cruft-Report::Options::Mode"] = "daily" - if not cnf.has_key("Cruft-Report::Options::Wanna-Build-Dump"): + if "Cruft-Report::Options::Wanna-Build-Dump" not in cnf: cnf["Cruft-Report::Options::Wanna-Build-Dump"] = "/srv/ftp-master.debian.org/scripts/nfu" apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) @@ -591,7 +592,7 @@ def main (): if "bnb" in checks: # Check for binaries not built on any architecture. for binary in binaries_list: - if not bins_in_suite.has_key(binary): + if binary not in bins_in_suite: bin_not_built.setdefault(source, {}) bin_not_built[source][binary] = "" @@ -632,7 +633,7 @@ def main (): version = Packages.section.find('Version') if source == "": source = package - if bin2source.has_key(package) and \ + if package in bin2source and \ apt_pkg.version_compare(version, bin2source[package]["version"]) > 0: bin2source[package]["version"] = version bin2source[package]["source"] = source @@ -644,7 +645,7 @@ def main (): m = re_extract_src_version.match(source) source = m.group(1) version = m.group(2) - if not bin_pkgs.has_key(package): + if package not in bin_pkgs: nbs.setdefault(source,{}) nbs[source].setdefault(package, {}) nbs[source][package][version] = "" diff --git a/dak/dakdb/update70.py b/dak/dakdb/update70.py index 72421b49155433e8f8b2029f9cb8dc9ad0d579ac..859c3132cf55a07bf238d70035e62de3e3566c4a 100644 --- a/dak/dakdb/update70.py +++ b/dak/dakdb/update70.py @@ -46,7 +46,7 @@ def do_update(self): c.execute("COMMENT ON COLUMN suite.overrideprocess IS %s", ['If NOT NULL, check-overrides will take missing overrides from the named suite']) # Migrate config file values into database - if cnf.has_key("Check-Overrides::OverrideSuites"): + if "Check-Overrides::OverrideSuites" in cnf: for suitename in cnf.subtree("Check-Overrides::OverrideSuites").list(): if cnf.get("Check-Overrides::OverrideSuites::%s::Process" % suitename, "0") == "1": print "Marking %s to have overrides processed automatically" % suitename.lower() diff --git a/dak/examine_package.py b/dak/examine_package.py index c6fef45628628711b870a2ca334d6318dfed53fe..ab74889101aaa6e31cf904e39b3f9088bc243f35 100755 --- a/dak/examine_package.py +++ b/dak/examine_package.py @@ -426,7 +426,7 @@ def output_deb_info(suite, filename, packagename, session = None): if control == '': return formatted_text("no control info") to_print = "" - if not package_relations.has_key(packagename): + if packagename not in package_relations: package_relations[packagename] = {} for key in control_keys : if key == 'Pre-Depends': @@ -507,7 +507,7 @@ def get_copyright (deb_filename): copyrightmd5 = md5.md5(cright).hexdigest() res = "" - if printed.copyrights.has_key(copyrightmd5) and printed.copyrights[copyrightmd5] != "%s (%s)" % (package, os.path.basename(deb_filename)): + if copyrightmd5 in printed.copyrights and printed.copyrights[copyrightmd5] != "%s (%s)" % (package, os.path.basename(deb_filename)): res += formatted_text( "NOTE: Copyright is the same as %s.\n\n" % \ (printed.copyrights[copyrightmd5])) else: @@ -623,8 +623,9 @@ def main (): ('H',"html-output","Examine-Package::Options::Html-Output"), ] for i in [ "Help", "Html-Output", "partial-html" ]: - if not Cnf.has_key("Examine-Package::Options::%s" % (i)): - Cnf["Examine-Package::Options::%s" % (i)] = "" + key = "Examine-Package::Options::%s" % i + if key not in Cnf: + Cnf[key] = "" args = apt_pkg.parse_commandline(Cnf,Arguments,sys.argv) Options = Cnf.subtree("Examine-Package::Options") diff --git a/dak/external_overrides.py b/dak/external_overrides.py index 40bdb80e67ac5ac7ff158d6daf422b68455f2cb5..02e40bc7260cf34d8540b5461e29b35e1ac60aa4 100755 --- a/dak/external_overrides.py +++ b/dak/external_overrides.py @@ -159,11 +159,11 @@ def main(): except KeyError: Options = {} - if Options.has_key("Help"): + if "Help" in Options: usage() force = False - if Options.has_key("Force") and Options["Force"]: + if "Force" in Options and Options["Force"]: force = True logger = daklog.Logger('external-overrides') diff --git a/dak/generate_index_diffs.py b/dak/generate_index_diffs.py index c3a9968d087262bde710e4c59907300630f90d3c..fe7d5783dd3066e0ca02d78c3577e0535a2bc9fe 100755 --- a/dak/generate_index_diffs.py +++ b/dak/generate_index_diffs.py @@ -135,7 +135,7 @@ class Updates: fname = l[2] if fname.endswith('.gz'): fname = fname[:-3] - if not self.history.has_key(fname): + if fname not in self.history: self.history[fname] = [None,None,None] self.history_order.append(fname) if not self.history[fname][ind]: @@ -262,7 +262,7 @@ def sizehashes(f): return (size, sha1sum, sha256sum) def genchanges(Options, outdir, oldfile, origfile, maxdiffs = 56): - if Options.has_key("NoAct"): + if "NoAct" in Options: print "Not acting on: od: %s, oldf: %s, origf: %s, md: %s" % (outdir, oldfile, origfile, maxdiffs) return @@ -304,7 +304,7 @@ def genchanges(Options, outdir, oldfile, origfile, maxdiffs = 56): # if upd.filesizesha1 != oldsizesha1: # print "info: old file " + oldfile + " changed! %s %s => %s %s" % (upd.filesizesha1 + oldsizesha1) - if Options.has_key("CanonicalPath"): upd.can_path=Options["CanonicalPath"] + if "CanonicalPath" in Options: upd.can_path=Options["CanonicalPath"] if os.path.exists(newfile): os.unlink(newfile) smartlink(origfile, newfile) @@ -364,14 +364,14 @@ def main(): ] suites = apt_pkg.parse_commandline(Cnf,Arguments,sys.argv) Options = Cnf.subtree("Generate-Index-Diffs::Options") - if Options.has_key("Help"): usage() + if "Help" in Options: usage() maxdiffs = Options.get("MaxDiffs::Default", "56") maxpackages = Options.get("MaxDiffs::Packages", maxdiffs) maxcontents = Options.get("MaxDiffs::Contents", maxdiffs) maxsources = Options.get("MaxDiffs::Sources", maxdiffs) - if not Options.has_key("PatchName"): + if "PatchName" not in Options: format = "%Y-%m-%d-%H%M.%S" Options["PatchName"] = time.strftime( format ) @@ -442,12 +442,12 @@ def main(): # Process Contents file = "%s/%s/Contents-%s" % (tree, component, architecture) - if Options.has_key("Verbose"): print(file) + if "Verbose" in Options: print(file) storename = "%s/%s_%s_contents_%s" % (Options["TempDir"], suite, component, architecture) genchanges(Options, file + ".diff", storename, file, maxcontents) file = "%s/%s/%s/%s" % (tree, component, longarch, packages) - if Options.has_key("Verbose"): print(file) + if "Verbose" in Options: print(file) storename = "%s/%s_%s_%s" % (Options["TempDir"], suite, component, architecture) genchanges(Options, file + ".diff", storename, file, maxsuite) diff --git a/dak/generate_packages_sources2.py b/dak/generate_packages_sources2.py index a18457c8fcf5a53c744d66f581994c1bc31867d3..51fa74a1bddc6f4632ff6b49e04e4f3dfc16a11b 100755 --- a/dak/generate_packages_sources2.py +++ b/dak/generate_packages_sources2.py @@ -367,7 +367,7 @@ def main(): except KeyError: Options = {} - if Options.has_key("Help"): + if "Help" in Options: usage() from daklib.dakmultiprocessing import DakProcessPool, PROC_STATUS_SUCCESS, PROC_STATUS_SIGNALRAISED @@ -382,7 +382,7 @@ def main(): import daklib.utils - if Options.has_key("Suite"): + if "Suite" in Options: suites = [] suite_names = daklib.utils.split_args(Options['Suite']) for s in suite_names: @@ -399,7 +399,7 @@ def main(): query = query.join(Suite.archive).filter(Archive.archive_name.in_(archive_names)) suites = query.all() - force = Options.has_key("Force") and Options["Force"] + force = "Force" in Options and Options["Force"] def parse_results(message): diff --git a/dak/generate_releases.py b/dak/generate_releases.py index 43b73904ca545f72f8afbb3ed67a686e0a8ea782..b470750a88051207d27a768bfca4899a59d4ee0d 100755 --- a/dak/generate_releases.py +++ b/dak/generate_releases.py @@ -452,8 +452,9 @@ def main (): cnf = Config() for i in ["Help", "Suite", "Force", "Quiet"]: - if not cnf.has_key("Generate-Releases::Options::%s" % (i)): - cnf["Generate-Releases::Options::%s" % (i)] = "" + key = "Generate-Releases::Options::%s" % i + if key not in cnf: + cnf[key] = "" Arguments = [('h',"help","Generate-Releases::Options::Help"), ('a','archive','Generate-Releases::Options::Archive','HasArg'), diff --git a/dak/graph.py b/dak/graph.py index e1f40f6a537db1e144b6266731006a0a4cfe1dcd..849c3bec8f130b534cc2e1c195fc855c11d5eabf 100755 --- a/dak/graph.py +++ b/dak/graph.py @@ -172,8 +172,9 @@ def main(): ('i',"images","Graph::Options::Images", "HasArg"), ('n',"names","Graph::Options::Names", "HasArg")] for i in [ "help" ]: - if not Cnf.has_key("Graph::Options::%s" % (i)): - Cnf["Graph::Options::%s" % (i)] = "" + key = "Graph::Options::%s" % i + if key not in Cnf: + Cnf[key] = "" apt_pkg.parse_commandline(Cnf, Arguments, sys.argv) @@ -183,36 +184,36 @@ def main(): names = [] - if Cnf.has_key("Graph::Options::Names"): + if "Graph::Options::Names" in Cnf: for i in Cnf["Graph::Options::Names"].split(","): names.append(i) - elif Cnf.has_key("Graph::Names"): + elif "Graph::Names" in Cnf: names = Cnf.value_list("Graph::Names") else: names = default_names extra_rrdtool_args = [] - if Cnf.has_key("Graph::Options::Extra-Rrd"): + if "Graph::Options::Extra-Rrd" in Cnf: for i in Cnf["Graph::Options::Extra-Rrd"].split(","): f = open(i) extra_rrdtool_args.extend(f.read().strip().split("\n")) f.close() - elif Cnf.has_key("Graph::Extra-Rrd"): + elif "Graph::Extra-Rrd" in Cnf: for i in Cnf.value_list("Graph::Extra-Rrd"): f = open(i) extra_rrdtool_args.extend(f.read().strip().split("\n")) f.close() - if Cnf.has_key("Graph::Options::Rrd"): + if "Graph::Options::Rrd" in Cnf: rrd_dir = Cnf["Graph::Options::Rrd"] - elif Cnf.has_key("Dir::Rrd"): + elif "Dir::Rrd" in Cnf: rrd_dir = Cnf["Dir::Rrd"] else: print >> sys.stderr, "No directory to read RRD files from\n" sys.exit(1) - if Cnf.has_key("Graph::Options::Images"): + if "Graph::Options::Images" in Cnf: image_dir = Cnf["Graph::Options::Images"] else: print >> sys.stderr, "No directory to write graph images to\n" diff --git a/dak/import_keyring.py b/dak/import_keyring.py index 3b53bff39f5973a496be04d730b3e34f1e601b7b..50c5a1cd55dbe0dd658f0b2c6e885bab05cd7b2a 100755 --- a/dak/import_keyring.py +++ b/dak/import_keyring.py @@ -89,9 +89,10 @@ def main(): ] for i in [ "help", "report-changes", "generate-users", - "import-ldap-users", "list-uids", "no-action" ]: - if not cnf.has_key("Import-Keyring::Options::%s" % (i)): - cnf["Import-Keyring::Options::%s" % (i)] = "" + "import-ldap-users", "list-uids", "no-action" ]: + key = "Import-Keyring::Options::%s" % i + if key not in cnf: + cnf[key] = "" keyring_names = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) diff --git a/dak/import_users_from_passwd.py b/dak/import_users_from_passwd.py index ed121398fe43ece4320a65dc4d6a214c3d1c4835..87c99bfa6f0c62490a8a4b4f0374b593a025ac6d 100755 --- a/dak/import_users_from_passwd.py +++ b/dak/import_users_from_passwd.py @@ -61,8 +61,9 @@ def main (): ('v', "verbose", "Import-Users-From-Passwd::Options::Verbose"), ('h', "help", "Import-Users-From-Passwd::Options::Help")] for i in [ "no-action", "quiet", "verbose", "help" ]: - if not cnf.has_key("Import-Users-From-Passwd::Options::%s" % (i)): - cnf["Import-Users-From-Passwd::Options::%s" % (i)] = "" + key = "Import-Users-From-Passwd::Options::%s" % i + if key not in cnf: + cnf[key] = "" arguments = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("Import-Users-From-Passwd::Options") @@ -103,7 +104,7 @@ def main (): keys = postgres_unames.keys() keys.sort() for uname in keys: - if not passwd_unames.has_key(uname) and not known_postgres_unames.has_key(uname): + if uname not in passwd_unames and uname not in known_postgres_unames: print "I: Deleting %s from Postgres, no longer in passwd or list of known Postgres users" % (uname) q = session.execute('DROP USER "%s"' % (uname)) @@ -111,7 +112,7 @@ def main (): keys.sort() safe_name = re.compile('^[A-Za-z0-9]+$') for uname in keys: - if not postgres_unames.has_key(uname): + if uname not in postgres_unames: if not Options["Quiet"]: print "Creating %s user in Postgres." % (uname) if not Options["No-Action"]: diff --git a/dak/init_dirs.py b/dak/init_dirs.py index 6f800e7e0cb0c3511024ddff829c133953343d16..952ed808934ad9b765d189a80a29dd5997efc29f 100755 --- a/dak/init_dirs.py +++ b/dak/init_dirs.py @@ -58,7 +58,7 @@ it.""" def process_file(config, config_name): """Create directories for a config entry that's a filename.""" - if config.has_key(config_name): + if config_name in config: target = os.path.dirname(config[config_name]) do_dir(target, config_name) @@ -75,7 +75,7 @@ def process_morguesubdir(subdir): """Create directories for morgue sub directories.""" config_name = "%s::MorgueSubDir" % (subdir) - if Cnf.has_key(config_name): + if config_name in Cnf: target = os.path.join(Cnf["Dir::Morgue"], Cnf[config_name]) do_dir(target, config_name) @@ -113,7 +113,7 @@ def create_directories(): process_tree(Cnf, "Dir") # Hardcode creation of the unchecked directory - if Cnf.has_key("Dir::Base"): + if "Dir::Base" in Cnf: do_dir(os.path.join(Cnf["Dir::Base"], "queue", "unchecked"), 'unchecked directory') # Process queue directories @@ -133,10 +133,10 @@ def create_directories(): suite_suffix = "%s" % (Cnf.find("Dinstall::SuiteSuffix")) # Process secret keyrings - if Cnf.has_key('Dinstall::SigningKeyring'): + if 'Dinstall::SigningKeyring' in Cnf: process_keyring(Cnf['Dinstall::SigningKeyring'], secret=True) - if Cnf.has_key('Dinstall::SigningPubKeyring'): + if 'Dinstall::SigningPubKeyring' in Cnf: process_keyring(Cnf['Dinstall::SigningPubKeyring'], secret=True) # Process public keyrings @@ -176,8 +176,9 @@ def main (): Cnf = utils.get_conf() arguments = [('h', "help", "Init-Dirs::Options::Help")] for i in [ "help" ]: - if not Cnf.has_key("Init-Dirs::Options::%s" % (i)): - Cnf["Init-Dirs::Options::%s" % (i)] = "" + key = "Init-Dirs::Options::%s" % i + if key not in Cnf: + Cnf[key] = "" d = DBConn() diff --git a/dak/ls.py b/dak/ls.py index 3e40c66da713684b5408106848c63cdf9842c8cd..40a21dc9d6eeecad2fda96ac47a76581d6127081 100755 --- a/dak/ls.py +++ b/dak/ls.py @@ -80,8 +80,9 @@ def main (): for i in [ "architecture", "binarytype", "component", "format", "greaterorequal", "greaterthan", "regex", "suite", "source-and-binary", "help" ]: - if not cnf.has_key("Ls::Options::%s" % (i)): - cnf["Ls::Options::%s" % (i)] = "" + key = "Ls::Options::%s" % i + if key not in cnf: + cnf[key] = "" packages = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("Ls::Options") diff --git a/dak/make_changelog.py b/dak/make_changelog.py index ca8ed95eeadaf92907e50df2abbb203b2af8adab..d21ac22c094f4f8008d656d8bd3ca4fd41b960fb 100755 --- a/dak/make_changelog.py +++ b/dak/make_changelog.py @@ -186,7 +186,7 @@ def export_files(session, archive, clpool, progress=False): ORDER BY s.source, suite""" for p in session.execute(query, {'archive_id': archive.archive_id}): - if not sources.has_key(p[0]): + if p[0] not in sources: sources[p[0]] = {} sources[p[0]][p[1]] = (re_no_epoch.sub('', p[2]), p[3]) @@ -197,7 +197,7 @@ def export_files(session, archive, clpool, progress=False): os.makedirs(path) if not os.path.exists(os.path.join(path, \ '%s_%s_changelog' % (p, sources[p][s][0]))): - if not unpack.has_key(os.path.join(pool, sources[p][s][1])): + if os.path.join(pool, sources[p][s][1]) not in unpack: unpack[os.path.join(pool, sources[p][s][1])] = (path, set()) unpack[os.path.join(pool, sources[p][s][1])][1].add(s) else: @@ -301,8 +301,9 @@ def main(): ('p','progress','Make-Changelog::Options::progress')] for i in ['help', 'suite', 'base-suite', 'binnmu', 'export', 'progress']: - if not Cnf.has_key('Make-Changelog::Options::%s' % (i)): - Cnf['Make-Changelog::Options::%s' % (i)] = '' + key = 'Make-Changelog::Options::%s' % i + if key not in Cnf: + Cnf[key] = '' apt_pkg.parse_commandline(Cnf, Arguments, sys.argv) Options = Cnf.subtree('Make-Changelog::Options') diff --git a/dak/make_maintainers.py b/dak/make_maintainers.py index 0f6bb5b80b5d8f21a62c78e073ba0f6fbd9f6d97..5d4f431e8837095f783f5ad9388ced137a53bbad 100755 --- a/dak/make_maintainers.py +++ b/dak/make_maintainers.py @@ -71,8 +71,9 @@ def main(): ('s',"source","Make-Maintainers::Options::Source"), ('p',"print","Make-Maintainers::Options::Print")] for i in ["Help", "Source", "Print" ]: - if not cnf.has_key("Make-Maintainers::Options::%s" % (i)): - cnf["Make-Maintainers::Options::%s" % (i)] = "" + key = "Make-Maintainers::Options::%s" % i + if key not in cnf: + cnf[key] = "" extra_files = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("Make-Maintainers::Options") diff --git a/dak/make_overrides.py b/dak/make_overrides.py index 1662b87e68a8863fb51a3994a533cc4abd0d6ce3..b4d0c00c7876972f745670ae66635ba48da467be 100755 --- a/dak/make_overrides.py +++ b/dak/make_overrides.py @@ -102,8 +102,9 @@ def main (): cnf = Config() Arguments = [('h',"help","Make-Overrides::Options::Help")] for i in [ "help" ]: - if not cnf.has_key("Make-Overrides::Options::%s" % (i)): - cnf["Make-Overrides::Options::%s" % (i)] = "" + key = "Make-Overrides::Options::%s" % i + if key not in cnf: + cnf[key] = "" apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("Make-Overrides::Options") if Options["Help"]: diff --git a/dak/manage_build_queues.py b/dak/manage_build_queues.py index f69ed5e80f732f2a1ea64dfa79aae305e57b916c..dcf07f0da5d8fe99e4b191e4cea5f3b2499955c9 100755 --- a/dak/manage_build_queues.py +++ b/dak/manage_build_queues.py @@ -128,8 +128,9 @@ def main (): cnf = Config() for i in ["Help", "No-Action", "All"]: - if not cnf.has_key("Manage-Build-Queues::Options::%s" % (i)): - cnf["Manage-Build-Queues::Options::%s" % (i)] = "" + key = "Manage-Build-Queues::Options::%s" % i + if key not in cnf: + cnf[key] = "" Arguments = [('h',"help","Manage-Build-Queues::Options::Help"), ('n',"no-action","Manage-Build-Queues::Options::No-Action"), diff --git a/dak/manage_debug_suites.py b/dak/manage_debug_suites.py index 5405f476fb551c1736d4da6a22189df6acea33b3..9f5a966c70fca91a98ac59cd62f3dae766fee846 100644 --- a/dak/manage_debug_suites.py +++ b/dak/manage_debug_suites.py @@ -92,8 +92,9 @@ def main (): cnf = Config() for i in ["Help", "No-Action", "All"]: - if not cnf.has_key("Manage-Debug-Suites::Options::%s" % (i)): - cnf["Manage-Debug-Suites::Options::%s" % (i)] = "" + key = "Manage-Debug-Suites::Options::%s" % i + if key not in cnf: + cnf[key] = "" Arguments = [('h',"help","Manage-Debug-Suites::Options::Help"), ('n',"no-action","Manage-Debug-Suites::Options::No-Action"), diff --git a/dak/manage_external_signature_requests.py b/dak/manage_external_signature_requests.py index 273ed03116c8b5f600eb5c866b330a5e1b9ecdad..55b8bb9a3edfd415ba3255cf2e7194f178a08fa9 100644 --- a/dak/manage_external_signature_requests.py +++ b/dak/manage_external_signature_requests.py @@ -55,8 +55,9 @@ def main (): cnf = Config() for i in ["Help"]: - if not cnf.has_key("Manage-External-Signature-Requests::Options::{}".format(i)): - cnf["Manage-External-Signature-Requests::Options::{}".format(i)] = "" + key = "Manage-External-Signature-Requests::Options::{}".format(i) + if key not in cnf: + cnf[key] = "" Arguments = [('h',"help","Manage-External-Signature-Requests::Options::Help")] diff --git a/dak/new_security_install.py b/dak/new_security_install.py index 05d2bcf4184cc4b49b84378df79543cfb0eebfff..07d0ae9276a99cc86f2a3acba1ab044225812ed9 100755 --- a/dak/new_security_install.py +++ b/dak/new_security_install.py @@ -129,8 +129,9 @@ def main(): ] for i in ["Help", "No-Action", "Changesfile", "Sudo", "Approve"]: - if not cnf.has_key("Security::Options::%s" % (i)): - cnf["Security::Options::%s" % (i)] = "" + key = "Security::Options::%s" % i + if key not in cnf: + cnf[key] = "" changes_files = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) diff --git a/dak/override.py b/dak/override.py index a55013a8d2c74e8910300e73cd90fb28798daeca..fb983a9eddd5bd678aa4e75ef697549200c45249 100755 --- a/dak/override.py +++ b/dak/override.py @@ -66,9 +66,10 @@ def main (): ('s',"suite","Override::Options::Suite", "HasArg"), ] for i in ["help", "check", "no-action"]: - if not cnf.has_key("Override::Options::%s" % (i)): - cnf["Override::Options::%s" % (i)] = "" - if not cnf.has_key("Override::Options::Suite"): + key = "Override::Options::%s" % i + if key not in cnf: + cnf[key] = "" + if "Override::Options::Suite" not in cnf: cnf["Override::Options::Suite"] = "unstable" arguments = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) @@ -186,7 +187,7 @@ def main (): print "I: Would change priority from %s to %s" % (oldpriority,newpriority) if newsection != oldsection: print "I: Would change section from %s to %s" % (oldsection,newsection) - if Options.has_key("Done"): + if "Done" in Options: print "I: Would also close bug(s): %s" % (Options["Done"]) sys.exit(0) @@ -197,7 +198,7 @@ def main (): if newsection != oldsection: print "I: Will change section from %s to %s" % (oldsection,newsection) - if not Options.has_key("Done"): + if "Done" not in Options: pass #utils.warn("No bugs to close have been specified. Noone will know you have done this.") else: @@ -236,8 +237,8 @@ def main (): session.commit() - if Options.has_key("Done"): - if not cnf.has_key("Dinstall::BugServer"): + if "Done" in Options: + if "Dinstall::BugServer" not in cnf: utils.warn("Asked to send Done message but Dinstall::BugServer is not configured") Logger.close() return @@ -252,7 +253,7 @@ def main (): Subst["__BCC__"] = "Bcc: " + ", ".join(bcc) else: Subst["__BCC__"] = "X-Filler: 42" - if cnf.has_key("Dinstall::PackagesServer"): + if "Dinstall::PackagesServer" in cnf: Subst["__CC__"] = "Cc: " + package + "@" + cnf["Dinstall::PackagesServer"] + "\nX-DAK: dak override" else: Subst["__CC__"] = "X-DAK: dak override" diff --git a/dak/process_new.py b/dak/process_new.py index 4e5f58b6d43457c68802f71e160dafedbe0444a4..c53fd81e13dbd4d86e9d065ec4cdc6b4a7d3bdaa 100755 --- a/dak/process_new.py +++ b/dak/process_new.py @@ -699,7 +699,7 @@ def do_pkg(upload, session): group = cnf.get('Dinstall::UnprivGroup') or None #bcc = "X-DAK: dak process-new" - #if cnf.has_key("Dinstall::Bcc"): + #if "Dinstall::Bcc" in cnf: # u.Subst["__BCC__"] = bcc + "\nBcc: %s" % (cnf["Dinstall::Bcc"]) #else: # u.Subst["__BCC__"] = bcc @@ -806,8 +806,9 @@ def main(): changes_files = apt_pkg.parse_commandline(cnf.Cnf,Arguments,sys.argv) for i in ["automatic", "no-binaries", "comments", "help", "manual-reject", "no-action", "version", "trainee"]: - if not cnf.has_key("Process-New::Options::%s" % (i)): - cnf["Process-New::Options::%s" % (i)] = "" + key = "Process-New::Options::%s" % i + if key not in cnf: + cnf[key] = "" queue_name = cnf.get('Process-New::Options::Queue', 'new') new_queue = session.query(PolicyQueue).filter_by(queue_name=queue_name).one() diff --git a/dak/process_policy.py b/dak/process_policy.py index cad7e59c4171a791221929c2f4754b22dc193ab8..7a6d7c8b534feb0ffbbd0f254a555a344874b841 100755 --- a/dak/process_policy.py +++ b/dak/process_policy.py @@ -481,8 +481,9 @@ def main(): ('n',"no-action","Process-Policy::Options::No-Action")] for i in ["help", "no-action"]: - if not cnf.has_key("Process-Policy::Options::%s" % (i)): - cnf["Process-Policy::Options::%s" % (i)] = "" + key = "Process-Policy::Options::%s" % i + if key not in cnf: + cnf[key] = "" queue_name = apt_pkg.parse_commandline(cnf.Cnf,Arguments,sys.argv) diff --git a/dak/process_upload.py b/dak/process_upload.py index 0f88c86cef92f20012a68fdcbbfa52432dfbcee1..6995f31aa8ff4add2358d8d4c976c33e62781bc0 100755 --- a/dak/process_upload.py +++ b/dak/process_upload.py @@ -497,7 +497,7 @@ def process_changes(changes_filenames): def process_buildinfos(upload): cnf = Config() - if not cnf.has_key('Dir::BuildinfoArchive'): + if 'Dir::BuildinfoArchive' not in cnf: return target_dir = os.path.join( @@ -529,8 +529,9 @@ def main(): for i in ["automatic", "help", "no-action", "no-lock", "no-mail", "version", "directory"]: - if not cnf.has_key("Dinstall::Options::%s" % (i)): - cnf["Dinstall::Options::%s" % (i)] = "" + key = "Dinstall::Options::%s" % i + if key not in cnf: + cnf[key] = "" changes_files = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) Options = cnf.subtree("Dinstall::Options") diff --git a/dak/queue_report.py b/dak/queue_report.py index 85e23cb67dcdda98453ae1331b5cd7671856cd52..d5affaf93e46d8588e30a7c6fd1d36ce3e168186 100755 --- a/dak/queue_report.py +++ b/dak/queue_report.py @@ -401,7 +401,7 @@ def process_queue(queue, log, rrd_dir): have_note = 0 for d in per_source[source]["list"]: mtime = time.mktime(d.changes.created.timetuple()) - if Cnf.has_key("Queue-Report::Options::New"): + if "Queue-Report::Options::New" in Cnf: if mtime > oldest: oldest = mtime else: @@ -450,7 +450,7 @@ def process_queue(queue, log, rrd_dir): dbc = j.changes changesbase = dbc.changesname - if Cnf.has_key("Queue-Report::Options::New") or Cnf.has_key("Queue-Report::Options::822"): + if "Queue-Report::Options::New" in Cnf or "Queue-Report::Options::822" in Cnf: try: (maintainer["maintainer822"], maintainer["maintainer2047"], maintainer["maintainername"], maintainer["maintaineremail"]) = \ @@ -508,13 +508,13 @@ def process_queue(queue, log, rrd_dir): # Look for the options for sort and then do the sort. age = "h" - if Cnf.has_key("Queue-Report::Options::Age"): + if "Queue-Report::Options::Age" in Cnf: age = Cnf["Queue-Report::Options::Age"] - if Cnf.has_key("Queue-Report::Options::New"): + if "Queue-Report::Options::New" in Cnf: # If we produce html we always have oldest first. direction.append([6,-1,"ao"]) else: - if Cnf.has_key("Queue-Report::Options::Sort"): + if "Queue-Report::Options::Sort" in Cnf: for i in Cnf["Queue-Report::Options::Sort"].split(","): if i == "ao": # Age, oldest first. @@ -540,7 +540,7 @@ def process_queue(queue, log, rrd_dir): # have with it. (If you combine options it will simply take the last one at the moment). # Will be enhanced in the future. - if Cnf.has_key("Queue-Report::Options::822"): + if "Queue-Report::Options::822" in Cnf: # print stuff out in 822 format for entry in entries: (source, binary, version_list, arch_list, processed, note, last_modified, maint, distribution, closes, fingerprint, sponsor, changedby, changes_file) = entry @@ -579,7 +579,7 @@ def process_queue(queue, log, rrd_dir): total_count = len(queue.uploads) source_count = len(per_source_items) - if Cnf.has_key("Queue-Report::Options::New"): + if "Queue-Report::Options::New" in Cnf: direction.append([6,1,"ao"]) entries.sort(sortfunc) # Output for a html file. First table header. then table_footer. @@ -590,7 +590,7 @@ def process_queue(queue, log, rrd_dir): (source, binary, version_list, arch_list, processed, note, last_modified, maint, distribution, closes, fingerprint, sponsor, changedby, _) = entry table_row(source, version_list, arch_list, last_modified, maint, distribution, closes, fingerprint, sponsor, changedby) table_footer(type.upper()) - elif not Cnf.has_key("Queue-Report::Options::822"): + elif "Queue-Report::Options::822" not in Cnf: # The "normal" output without any formatting. msg = "" for entry in entries: @@ -627,8 +627,9 @@ def main(): ('r',"rrd","Queue-Report::Options::Rrd", "HasArg"), ('d',"directories","Queue-Report::Options::Directories", "HasArg")] for i in [ "help" ]: - if not Cnf.has_key("Queue-Report::Options::%s" % (i)): - Cnf["Queue-Report::Options::%s" % (i)] = "" + key = "Queue-Report::Options::%s" % i + if key not in Cnf: + Cnf[key] = "" apt_pkg.parse_commandline(Cnf, Arguments, sys.argv) @@ -636,28 +637,28 @@ def main(): if Options["Help"]: usage() - if Cnf.has_key("Queue-Report::Options::New"): + if "Queue-Report::Options::New" in Cnf: header() queue_names = [] - if Cnf.has_key("Queue-Report::Options::Directories"): + if "Queue-Report::Options::Directories" in Cnf: for i in Cnf["Queue-Report::Options::Directories"].split(","): queue_names.append(i) - elif Cnf.has_key("Queue-Report::Directories"): + elif "Queue-Report::Directories" in Cnf: queue_names = Cnf.value_list("Queue-Report::Directories") else: queue_names = [ "byhand", "new" ] - if Cnf.has_key("Queue-Report::Options::Rrd"): + if "Queue-Report::Options::Rrd" in Cnf: rrd_dir = Cnf["Queue-Report::Options::Rrd"] - elif Cnf.has_key("Dir::Rrd"): + elif "Dir::Rrd" in Cnf: rrd_dir = Cnf["Dir::Rrd"] else: rrd_dir = None f = None - if Cnf.has_key("Queue-Report::Options::822"): + if "Queue-Report::Options::822" in Cnf: # Open the report file f = sys.stdout filename822 = Cnf.get("Queue-Report::ReportLocations::822Location") @@ -673,10 +674,10 @@ def main(): else: utils.warn("Cannot find queue %s" % queue_name) - if Cnf.has_key("Queue-Report::Options::822"): + if "Queue-Report::Options::822" in Cnf: f.close() - if Cnf.has_key("Queue-Report::Options::New"): + if "Queue-Report::Options::New" in Cnf: footer() ################################################################################ diff --git a/dak/rm.py b/dak/rm.py index 1d0f8ea7074b4f1d9607a5e78a7ca020df783064..bffb2e6f3746348a1b128067ac9d529a60e856bd 100755 --- a/dak/rm.py +++ b/dak/rm.py @@ -140,9 +140,10 @@ def main (): "architecture", "binary", "binary-only", "carbon-copy", "component", "done", "help", "no-action", "partial", "rdep-check", "reason", "source-only", "Do-Close" ]: - if not cnf.has_key("Rm::Options::%s" % (i)): - cnf["Rm::Options::%s" % (i)] = "" - if not cnf.has_key("Rm::Options::Suite"): + key = "Rm::Options::%s" % (i) + if key not in cnf: + cnf[key] = "" + if "Rm::Options::Suite" not in cnf: cnf["Rm::Options::Suite"] = "unstable" arguments = apt_pkg.parse_commandline(cnf.Cnf, Arguments, sys.argv) @@ -162,7 +163,7 @@ def main (): or (Options["Binary"] and Options["Binary-Only"]) or (Options["Binary-Only"] and Options["Source-Only"])): utils.fubar("Only one of -b/--binary, -B/--binary-only and -S/--source-only can be used.") - if Options.has_key("Carbon-Copy") and not Options.has_key("Done"): + if "Carbon-Copy" not in Options and "Done" not in Options: utils.fubar("can't use -C/--carbon-copy without also using -d/--done option.") if Options["Architecture"] and not Options["Partial"]: utils.warn("-a/--architecture implies -p/--partial.") @@ -288,13 +289,13 @@ def main (): carbon_copy = [] for copy_to in utils.split_args(Options.get("Carbon-Copy")): if copy_to.isdigit(): - if cnf.has_key("Dinstall::BugServer"): + if "Dinstall::BugServer" in cnf: carbon_copy.append(copy_to + "@" + cnf["Dinstall::BugServer"]) else: utils.fubar("Asked to send mail to #%s in BTS but Dinstall::BugServer is not configured" % copy_to) elif copy_to == 'package': for package in set([s[5] for s in to_remove]): - if cnf.has_key("Dinstall::PackagesServer"): + if "Dinstall::PackagesServer" in cnf: carbon_copy.append(package + "@" + cnf["Dinstall::PackagesServer"]) elif '@' in copy_to: carbon_copy.append(copy_to) @@ -323,9 +324,9 @@ def main (): architecture = i[2] maintainer = i[4] maintainers[maintainer] = "" - if not d.has_key(package): + if package not in d: d[package] = {} - if not d[package].has_key(version): + if version not in d[package]: d[package][version] = [] if architecture not in d[package][version]: d[package][version].append(architecture) diff --git a/dak/show_deferred.py b/dak/show_deferred.py index eb6166d762259b6ee2e50afced4706734428bc7a..8ecf5f9ef26164f4b41c7dcf88139c288993f14f 100755 --- a/dak/show_deferred.py +++ b/dak/show_deferred.py @@ -178,7 +178,7 @@ def get_upload_data(changesfn): uploader = re.sub(r'^\s*(\S.*)\s+<.*>',r'\1',uploader) with utils.open_file(changesfn) as f: fingerprint = SignedFile(f.read(), keyrings=get_active_keyring_paths(), require_signature=False).fingerprint - if Cnf.has_key("Show-Deferred::LinkPath"): + if "Show-Deferred::LinkPath" in Cnf: isnew = 0 suites = get_suites_source_in(achanges['source']) if 'unstable' not in suites and 'experimental' not in suites: @@ -215,7 +215,7 @@ def list_uploads(filelist, rrd_dir): print '

Currently no deferred uploads to Debian

' print footer() # machine readable summary - if Cnf.has_key("Show-Deferred::LinkPath"): + if "Show-Deferred::LinkPath" in Cnf: fn = os.path.join(Cnf["Show-Deferred::LinkPath"],'.status.tmp') f = open(fn,"w") try: @@ -262,12 +262,14 @@ def init(): ('r',"rrd","Show-Deferred::Options::Rrd", "HasArg")] args = apt_pkg.parse_commandline(Cnf,Arguments,sys.argv) for i in ["help"]: - if not Cnf.has_key("Show-Deferred::Options::%s" % (i)): - Cnf["Show-Deferred::Options::%s" % (i)] = "" - for i,j in [("DeferredQueue","--deferred-queue")]: - if not Cnf.has_key("Show-Deferred::%s" % (i)): - print >> sys.stderr, """Show-Deferred::%s is mandatory. - set via config file or command-line option %s"""%(i,j) + key = "Show-Deferred::Options::%s" % i + if key not in Cnf: + Cnf[key] = "" + for i, j in [("DeferredQueue", "--deferred-queue")]: + key = "Show-Deferred::%s" % i + if key not in Cnf: + print >>sys.stderr, """%s is mandatory. + set via config file or command-line option %s""" % (key, j) Options = Cnf.subtree("Show-Deferred::Options") if Options["help"]: @@ -283,9 +285,9 @@ def main(): if len(args)!=0: usage(1) - if Cnf.has_key("Show-Deferred::Options::Rrd"): + if "Show-Deferred::Options::Rrd" in Cnf: rrd_dir = Cnf["Show-Deferred::Options::Rrd"] - elif Cnf.has_key("Dir::Rrd"): + elif "Dir::Rrd" in Cnf: rrd_dir = Cnf["Dir::Rrd"] else: rrd_dir = None @@ -297,7 +299,7 @@ def main(): list_uploads(filelist, rrd_dir) available_changes = set(map(os.path.basename,filelist)) - if Cnf.has_key("Show-Deferred::LinkPath"): + if "Show-Deferred::LinkPath" in Cnf: # remove dead links for r,d,f in os.walk(Cnf["Show-Deferred::LinkPath"]): for af in f: diff --git a/dak/show_new.py b/dak/show_new.py index af1b8a6480b0b58ea6c1af99a90ea94fffa732b6..2f1e226743f550be9de79683945d685187313fb3 100755 --- a/dak/show_new.py +++ b/dak/show_new.py @@ -217,8 +217,9 @@ def init(session): ('q','queue','Show-New::Options::Queue','HasArg')] for i in ["help"]: - if not cnf.has_key("Show-New::Options::%s" % (i)): - cnf["Show-New::Options::%s" % (i)] = "" + key = "Show-New::Options::%s" % i + if key not in cnf: + cnf[key] = "" changesnames = apt_pkg.parse_commandline(cnf.Cnf,Arguments,sys.argv) Options = cnf.subtree("Show-New::Options") diff --git a/dak/stats.py b/dak/stats.py index 6f69e1a7f4239429fac841b78cdb47c92605a278..27b01d907cb9072935fc5067019bcb69d934dcc9 100755 --- a/dak/stats.py +++ b/dak/stats.py @@ -109,7 +109,7 @@ def daily_install_stats(): if action != "installing changes" and action != "installed": continue date = split[0][:8] - if not stats.has_key(date): + if date not in stats: stats[date] = {} stats[date]["packages"] = 0 stats[date]["size"] = 0.0 @@ -203,7 +203,7 @@ def number_of_packages(): arch_id = arch_ids[arch] output = output + arch.center(longest_arch)+" |" for suite_id in suite_id_list: - if suite_arches[suite_id].has_key(arch): + if arch in suite_arches[suite_id]: count = "%d" % d[suite_id][arch_id] else: count = "-" @@ -390,8 +390,9 @@ def main (): Cnf = utils.get_conf() Arguments = [('h',"help","Stats::Options::Help")] for i in [ "help" ]: - if not Cnf.has_key("Stats::Options::%s" % (i)): - Cnf["Stats::Options::%s" % (i)] = "" + key = "Stats::Options::%s" % i + if key not in Cnf: + Cnf[key] = "" args = apt_pkg.parse_commandline(Cnf, Arguments, sys.argv) diff --git a/dak/transitions.py b/dak/transitions.py index 96396c61800e9e60765070b366b6b8777779b116..e9fc7293303d8a91950487268996c84b9c14a8af 100755 --- a/dak/transitions.py +++ b/dak/transitions.py @@ -73,8 +73,9 @@ def init(): ('n',"no-action","Edit-Transitions::Options::No-Action")] for i in ["automatic", "help", "no-action", "edit", "import", "check", "sudo"]: - if not Cnf.has_key("Edit-Transitions::Options::%s" % (i)): - Cnf["Edit-Transitions::Options::%s" % (i)] = "" + key = "Edit-Transitions::Options::%s" % i + if key not in Cnf: + Cnf[key] = "" apt_pkg.parse_commandline(Cnf, Arguments, sys.argv) @@ -465,7 +466,7 @@ def check_transitions(transitions): print "Sending notification to %s" % subst['__TRANSITION_EMAIL__'] subst['__DAK_ADDRESS__'] = Cnf["Dinstall::MyEmailAddress"] subst['__BCC__'] = 'X-DAK: dak transitions' - if Cnf.has_key("Dinstall::Bcc"): + if "Dinstall::Bcc" in Cnf: subst["__BCC__"] += '\nBcc: %s' % Cnf["Dinstall::Bcc"] message = utils.TemplateSubst(subst, os.path.join(Cnf["Dir::Templates"], 'transition.removed')) diff --git a/dak/update_db.py b/dak/update_db.py index dcf17ced1bee16f1887eff0e742563e60927caf0..7610589a90666d1ad38f16e4cf794710bdb22b8f 100755 --- a/dak/update_db.py +++ b/dak/update_db.py @@ -126,13 +126,13 @@ Updates dak's database schema to the lastest version. You should disable crontab try: # Build a connect string - if cnf.has_key("DB::Service"): + if "DB::Service" in cnf: connect_str = "service=%s" % cnf["DB::Service"] else: connect_str = "dbname=%s"% (cnf["DB::Name"]) - if cnf.has_key("DB::Host") and cnf["DB::Host"] != '': + if "DB::Host" in cnf and cnf["DB::Host"] != '': connect_str += " host=%s" % (cnf["DB::Host"]) - if cnf.has_key("DB::Port") and cnf["DB::Port"] != '-1': + if "DB::Port" in cnf and cnf["DB::Port"] != '-1': connect_str += " port=%d" % (int(cnf["DB::Port"])) self.db = psycopg2.connect(connect_str) @@ -210,8 +210,9 @@ Updates dak's database schema to the lastest version. You should disable crontab arguments = [('h', "help", "Update-DB::Options::Help"), ("y", "yes", "Update-DB::Options::Yes")] for i in [ "help" ]: - if not cnf.has_key("Update-DB::Options::%s" % (i)): - cnf["Update-DB::Options::%s" % (i)] = "" + key = "Update-DB::Options::%s" % i + if key not in cnf: + cnf[key] = "" arguments = apt_pkg.parse_commandline(cnf.Cnf, arguments, sys.argv) diff --git a/daklib/changes.py b/daklib/changes.py index 1bdc7cfc53d8dec30ffd4abfba78e791c4ece9ec..8207fc283c1e4fa2cbbc484e67e83842dc7df2f4 100644 --- a/daklib/changes.py +++ b/daklib/changes.py @@ -103,7 +103,7 @@ class Changes(object): def file_summary(self): # changes["distribution"] may not exist in corner cases # (e.g. unreadable changes files) - if not self.changes.has_key("distribution") or not \ + if "distribution" not in self.changes or not \ isinstance(self.changes["distribution"], dict): self.changes["distribution"] = {} @@ -113,15 +113,15 @@ class Changes(object): override_summary = "" for name, entry in sorted(self.files.items()): - if entry.has_key("byhand"): + if "byhand" in entry: byhand = True summary += name + " byhand\n" - elif entry.has_key("new"): + elif "new" in entry: new = True summary += "(new) %s %s %s\n" % (name, entry["priority"], entry["section"]) - if entry.has_key("othercomponents"): + if "othercomponents" in entry: summary += "WARNING: Already present in %s distribution.\n" % (entry["othercomponents"]) if entry["type"] == "deb": @@ -134,7 +134,7 @@ class Changes(object): destination = entry["pool name"] + name summary += name + "\n to " + destination + "\n" - if not entry.has_key("type"): + if "type" not in entry: entry["type"] = "unknown" if entry["type"] in ["deb", "udeb", "dsc"]: @@ -157,11 +157,11 @@ class Changes(object): summary = "" # Abandon the check if it's a non-sourceful upload - if not self.changes["architecture"].has_key("source"): + if "source" not in self.changes["architecture"]: return summary for name, entry in sorted(self.files.items()): - if not entry.has_key("new") and entry["type"] == "deb": + if "new" not in entry and entry["type"] == "deb": if entry["section"] != "-": if entry["section"].lower() != entry["override section"].lower(): summary += "%s: package says section is %s, override says %s.\n" % (name, @@ -183,13 +183,13 @@ class Changes(object): def mark_missing_fields(self): """add "missing" in fields which we will require for the known_changes table""" for key in ['urgency', 'maintainer', 'fingerprint', 'changed-by' ]: - if (not self.changes.has_key(key)) or (not self.changes[key]): + if (key not in self.changes) or (not self.changes[key]): self.changes[key]='missing' def __get_file_from_pool(self, filename, entry, session, logger): cnf = Config() - if cnf.has_key("Dinstall::SuiteSuffix"): + if "Dinstall::SuiteSuffix" in cnf: component = cnf["Dinstall::SuiteSuffix"] + entry["component"] else: component = entry["component"] @@ -262,13 +262,13 @@ class Changes(object): cpf.size = entry['size'] cpf.md5sum = entry['md5sum'] - if entry.has_key('sha1sum'): + if 'sha1sum' in entry: cpf.sha1sum = entry['sha1sum'] else: f.seek(0) cpf.sha1sum = apt_pkg.sha1sum(f) - if entry.has_key('sha256sum'): + if 'sha256sum' in entry: cpf.sha256sum = entry['sha256sum'] else: f.seek(0) @@ -288,7 +288,7 @@ class Changes(object): # Add files referenced in .dsc, but not included in .changes for name, entry in self.dsc_files.items(): - if self.files.has_key(name): + if name in self.files: continue entry['source'] = self.changes['source'] @@ -322,7 +322,7 @@ class Changes(object): for name, entry in self.files.items(): r.append(" %s:" % (name)) for i in CHANGESFIELDS_FILES: - if entry.has_key(i): + if i in entry: r.append(" %s: %s" % (i.capitalize(), entry[i])) xfields = self.unknown_files_fields(name) if len(xfields) > 0: @@ -341,7 +341,7 @@ class Changes(object): r.append(' %s: %s' % (i.capitalize(), val)) for i in CHANGESFIELDS_OPTIONAL: - if self.changes.has_key(i): + if i in self.changes: r.append(' %s: %s' % (i.capitalize(), self.changes[i])) xfields = self.unknown_changes_fields() @@ -353,7 +353,7 @@ class Changes(object): def str_dsc(self): r = [] for i in CHANGESFIELDS_DSC: - if self.dsc.has_key(i): + if i in self.dsc: r.append(' %s: %s' % (i.capitalize(), self.dsc[i])) xfields = self.unknown_dsc_fields() @@ -369,7 +369,7 @@ class Changes(object): for i in CHANGESFIELDS_DSCFILES_MANDATORY: r.append(" %s: %s" % (i.capitalize(), entry[i])) for i in CHANGESFIELDS_DSCFILES_OPTIONAL: - if entry.has_key(i): + if i in entry: r.append(" %s: %s" % (i.capitalize(), entry[i])) xfields = self.unknown_dsc_files_fields(name) if len(xfields) > 0: diff --git a/daklib/dbconn.py b/daklib/dbconn.py index 55ba21a58114a06062f9d7df428037349f28819b..90bd7b7f0f36c6d8128bcfb646ec692c73c9f664 100755 --- a/daklib/dbconn.py +++ b/daklib/dbconn.py @@ -2142,7 +2142,7 @@ class DBConn(object): if not getattr(self, 'initialised', False): self.initialised = True - self.debug = kwargs.has_key('debug') + self.debug = 'debug' in kwargs self.__createconn() def __setuptables(self): @@ -2495,24 +2495,24 @@ class DBConn(object): def __createconn(self): from config import Config cnf = Config() - if cnf.has_key("DB::Service"): + if "DB::Service" in cnf: connstr = "postgresql://service=%s" % cnf["DB::Service"] - elif cnf.has_key("DB::Host"): + elif "DB::Host" in cnf: # TCP/IP connstr = "postgresql://%s" % cnf["DB::Host"] - if cnf.has_key("DB::Port") and cnf["DB::Port"] != "-1": + if "DB::Port" in cnf and cnf["DB::Port"] != "-1": connstr += ":%s" % cnf["DB::Port"] connstr += "/%s" % cnf["DB::Name"] else: # Unix Socket connstr = "postgresql:///%s" % cnf["DB::Name"] - if cnf.has_key("DB::Port") and cnf["DB::Port"] != "-1": + if "DB::Port" in cnf and cnf["DB::Port"] != "-1": connstr += "?port=%s" % cnf["DB::Port"] engine_args = { 'echo': self.debug } - if cnf.has_key('DB::PoolSize'): + if 'DB::PoolSize' in cnf: engine_args['pool_size'] = int(cnf['DB::PoolSize']) - if cnf.has_key('DB::MaxOverflow'): + if 'DB::MaxOverflow' in cnf: engine_args['max_overflow'] = int(cnf['DB::MaxOverflow']) if cnf.get('DB::Unicode') == 'false': engine_args['use_native_unicode'] = False diff --git a/daklib/queue.py b/daklib/queue.py index 8751920b74f2e26737571ed6e7aaf348b4e109d3..92e9df1c84874397bdb3002e524a8c6c77369009 100644 --- a/daklib/queue.py +++ b/daklib/queue.py @@ -214,12 +214,12 @@ class Upload(object): cnf = Config() # If 'dak process-unchecked' crashed out in the right place, architecture may still be a string. - if not self.pkg.changes.has_key("architecture") or not \ + if "architecture" not in self.pkg.changes or not \ isinstance(self.pkg.changes["architecture"], dict): self.pkg.changes["architecture"] = { "Unknown" : "" } # and maintainer2047 may not exist. - if not self.pkg.changes.has_key("maintainer2047"): + if "maintainer2047" not in self.pkg.changes: self.pkg.changes["maintainer2047"] = cnf["Dinstall::MyEmailAddress"] self.Subst["__ARCHITECTURE__"] = " ".join(self.pkg.changes["architecture"].keys()) @@ -227,7 +227,7 @@ class Upload(object): self.Subst["__FILE_CONTENTS__"] = self.pkg.changes.get("filecontents", "") # For source uploads the Changed-By field wins; otherwise Maintainer wins. - if self.pkg.changes["architecture"].has_key("source") and \ + if "source" in self.pkg.changes["architecture"] and \ self.pkg.changes["changedby822"] != "" and \ (self.pkg.changes["changedby822"] != self.pkg.changes["maintainer822"]): @@ -244,15 +244,15 @@ class Upload(object): # the package into PU-NEW, but the fingerprint has gone away from the keyring in # the meantime so the package will be remarked as rejectable. Urgh. # TODO: Fix this properly - if self.pkg.changes.has_key('fingerprint'): + if 'fingerprint' in self.pkg.changes: session = DBConn().session() fpr = get_fingerprint(self.pkg.changes['fingerprint'], session) if fpr and self.check_if_upload_is_sponsored("%s@debian.org" % fpr.uid.uid, fpr.uid.name): - if self.pkg.changes.has_key("sponsoremail"): + if "sponsoremail" in self.pkg.changes: self.Subst["__MAINTAINER_TO__"] += ", %s" % self.pkg.changes["sponsoremail"] session.close() - if cnf.has_key("Dinstall::PackagesServer") and self.pkg.changes.has_key("source"): + if "Dinstall::PackagesServer" in cnf and "source" in self.pkg.changes: self.Subst["__MAINTAINER_TO__"] += "\nBcc: %s@%s" % (self.pkg.changes["source"], cnf["Dinstall::PackagesServer"]) # Apply any global override of the Maintainer field @@ -269,7 +269,7 @@ class Upload(object): def check_if_upload_is_sponsored(self, uid_email, uid_name): for key in "maintaineremail", "changedbyemail", "maintainername", "changedbyname": - if not self.pkg.changes.has_key(key): + if key not in self.pkg.changes: return False uid_email = '@'.join(uid_email.split('@')[:2]) if uid_email in [self.pkg.changes["maintaineremail"], self.pkg.changes["changedbyemail"]]: @@ -314,12 +314,12 @@ class Upload(object): cnf = Config() # Skip all of this if not sending mail to avoid confusing people - if cnf.has_key("Dinstall::Options::No-Mail") and cnf["Dinstall::Options::No-Mail"]: + if "Dinstall::Options::No-Mail" in cnf and cnf["Dinstall::Options::No-Mail"]: return "" # Only do announcements for source uploads with a recent dpkg-dev installed - if float(self.pkg.changes.get("format", 0)) < 1.6 or not \ - self.pkg.changes["architecture"].has_key("source"): + if float(self.pkg.changes.get("format", 0)) < 1.6 or \ + "source" not in self.pkg.changes["architecture"]: return "" announcetemplate = os.path.join(cnf["Dir::Templates"], 'process-unchecked.announce') @@ -343,7 +343,7 @@ class Upload(object): self.update_subst() self.Subst["__ANNOUNCE_LIST_ADDRESS__"] = announce_list if cnf.get("Dinstall::PackagesServer") and \ - self.pkg.changes["architecture"].has_key("source"): + "source" in self.pkg.changes["architecture"]: trackingsendto = "Bcc: %s@%s" % (self.pkg.changes["source"], cnf["Dinstall::PackagesServer"]) self.Subst["__ANNOUNCE_LIST_ADDRESS__"] += "\n" + trackingsendto @@ -352,7 +352,7 @@ class Upload(object): del self.Subst["__ANNOUNCE_LIST_ADDRESS__"] - if cnf.find_b("Dinstall::CloseBugs") and cnf.has_key("Dinstall::BugServer"): + if cnf.find_b("Dinstall::CloseBugs") and "Dinstall::BugServer" in cnf: summary = self.close_bugs(summary, action) del self.Subst["__SHORT_SUMMARY__"] diff --git a/daklib/urgencylog.py b/daklib/urgencylog.py index a47974dd11f006ad7bd9e4f3b226301826ce46dd..2cb1c461e28f15d10e17f6e145e5b0fe2aa9cd5f 100644 --- a/daklib/urgencylog.py +++ b/daklib/urgencylog.py @@ -48,7 +48,7 @@ class UrgencyLog(object): self.timestamp = time.strftime("%Y%m%d%H%M%S") cnf = Config() - if cnf.has_key("Dir::UrgencyLog"): + if "Dir::UrgencyLog" in cnf: # Create the log directory if it doesn't exist self.log_dir = cnf["Dir::UrgencyLog"] diff --git a/daklib/utils.py b/daklib/utils.py index bbb8c027ce4057cc306f21e7a881610fb3892fca..5253533f552d1b77eca548a2c8f96dc7d151d085 100644 --- a/daklib/utils.py +++ b/daklib/utils.py @@ -216,7 +216,7 @@ def parse_deb822(armored_contents, signing_rules=0, keyrings=None, session=None) changes["filecontents"] = armored_contents - if changes.has_key("source"): + if "source" in changes: # Strip the source version in brackets from the source field, # put it in the "source-version" field instead. srcver = re_srchasver.search(changes["source"]) @@ -269,7 +269,7 @@ def parse_changes(filename, signing_rules=0, dsc_file=0, keyrings=None): missingfields=[] for keyword in must_keywords: - if not changes.has_key(keyword.lower()): + if keyword.lower() not in changes: missingfields.append(keyword) if len(missingfields): @@ -366,7 +366,7 @@ def build_file_list(changes, is_a_dsc=0, field="files", hashname="md5sum"): files = {} # Make sure we have a Files: field to parse... - if not changes.has_key(field): + if field not in changes: raise NoFilesFieldError # Validate .changes Format: field @@ -423,7 +423,7 @@ def send_mail (message, filename="", whitelists=None): print >>fh, message, # Check whether we're supposed to be sending mail - if Cnf.has_key("Dinstall::Options::No-Mail") and Cnf["Dinstall::Options::No-Mail"]: + if "Dinstall::Options::No-Mail" in Cnf and Cnf["Dinstall::Options::No-Mail"]: return # If we've been passed a string dump it into a temporary file @@ -476,10 +476,10 @@ def send_mail (message, filename="", whitelists=None): message_raw.replace_header(field, ', '.join(match)) # Change message fields in order if we don't have a To header - if not message_raw.has_key("To"): + if "To" not in message_raw: fields.reverse() for field in fields: - if message_raw.has_key(field): + if field in message_raw: message_raw[fields[-1]] = message_raw[field] del message_raw[field] break @@ -1183,7 +1183,7 @@ def check_reverse_depends(removals, suite, arches=None, session=None, cruft=Fals for virtual_pkg in provides.split(","): virtual_pkg = virtual_pkg.strip() if virtual_pkg == package: continue - if not virtual_packages.has_key(virtual_pkg): + if virtual_pkg not in virtual_packages: virtual_packages[virtual_pkg] = 0 if package not in removals: virtual_packages[virtual_pkg] += 1 diff --git a/scripts/debian/insert_missing_changedby.py b/scripts/debian/insert_missing_changedby.py index 570b5471eefbd30d949c39113bd12dbba1020a00..443bbd7f9ffd757a3820c5b112bbbeaa1bd84d38 100644 --- a/scripts/debian/insert_missing_changedby.py +++ b/scripts/debian/insert_missing_changedby.py @@ -52,7 +52,7 @@ maintainer_id_cache={} def get_or_set_maintainer_id (maintainer): global maintainer_id_cache - if maintainer_id_cache.has_key(maintainer): + if maintainer in maintainer_id_cache: return maintainer_id_cache[maintainer] if isinstance(maintainer, basestring): diff --git a/tools/queue_rss.py b/tools/queue_rss.py index fab7cb83f16b4ac1508b99906b9b386d4b47846c..d2327caf5f0bd1775999d189cf1fb744948c666b 100755 --- a/tools/queue_rss.py +++ b/tools/queue_rss.py @@ -124,7 +124,7 @@ def add_rss_item(status, msg, direction): pubdate = msg['Date'] elif direction == "out": feed = status.feed_out - if msg.has_key('Leave-Reason'): + if 'Leave-Reason' in msg: title = "%s %s left NEW (%s)" % (msg['Source'], msg['Version'], msg['Leave-Reason'][0]) else: @@ -143,7 +143,7 @@ def add_rss_item(status, msg, direction): (msg['Source'], msg['Version']) guid = msg['Checksums-Sha256'][0]['sha256'] - if msg.has_key('Processed-By'): + if 'Processed-By' in msg: author = msg['Processed-By'] else: changedby = parseaddr(msg['Changed-By']) @@ -169,16 +169,16 @@ def update_feeds(curqueue, status, settings): reason_log = os.path.join(settings.logdir, time.strftime("%Y-%m")) for (name, parsed) in curqueue.items(): - if not status.queue.has_key(name): + if name not in status.queue: # new package add_rss_item(status, parsed, "in") for (name, parsed) in status.queue.items(): - if not curqueue.has_key(name): + if name not in curqueue: # removed package, try to find out why if leave_reason is None: leave_reason = parse_leave_reason(reason_log) - if leave_reason and leave_reason.has_key(name): + if leave_reason and name in leave_reason: parsed['Leave-Reason'] = leave_reason[name][0] parsed['Processed-By'] = leave_reason[name][1] + "@debian.org" add_rss_item(status, parsed, "out")