Commit 84bb4881 authored by Chris Lamb's avatar Chris Lamb 💬 Committed by Joerg Jaspert

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

parent 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'