提交 84bb4881 编写于 作者: C Chris Lamb 提交者: Joerg Jaspert

Replace instances of ``if x.has_key(y)`` with ``if y in x``.

上级 c724c0a2
......@@ -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')
......
......@@ -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)
......
......@@ -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")
......
......@@ -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")
......
......@@ -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)
......
......@@ -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)
......
......@@ -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")
......
......@@ -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"),
......
......@@ -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'),
......
......@@ -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)
......
......@@ -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
......
......@@ -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")
......
......@@ -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] = ""
......
......@@ -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()
......
......@@ -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")
......
......@@ -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')
......
......@@ -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)
......
......@@ -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):
......
......@@ -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'),
......
......@@ -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"
......
......@@ -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)
......
......@@ -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"]:
......
......@@ -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()
......
......@@ -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")
......
......@@ -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')
......
......@@ -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")
......
......@@ -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"]:
......
......@@ -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"),
......
......@@ -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"),
......
......@@ -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")]
......
......@@ -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)
......
......@@ -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"
......
......@@ -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()
......
......@@ -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)
......
......@@ -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")
......
......@@ -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()
################################################################################
......
......@@ -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)
......
......@@ -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 '<h1>Currently no deferred uploads to Debian</h1>'
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:
......
......@@ -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")
......
......@@ -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)
......
......@@ -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'))
......
......@@ -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)
......
......@@ -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:
......
......@@ -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
......
......@@ -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__"]
......
......@@ -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"]
......
......@@ -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
......
......@@ -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):
......
......@@ -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")
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册