summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Lint
diff options
context:
space:
mode:
authorJonah BrĂ¼chert <jbb@kaidan.im>2024-04-19 23:52:23 +0200
committerJonah BrĂ¼chert <jbb@kaidan.im>2024-04-19 23:52:23 +0200
commit2724e6409534a948b5a2c212ae0a7192326c1b4c (patch)
treefe49421ea9c00298c01d5c5c52d0687c2f4bb9fd /src/lib/Bcfg2/Server/Lint
parent4d140a72fdde0e34060b9fa1ef76e05502245d20 (diff)
downloadbcfg2-2724e6409534a948b5a2c212ae0a7192326c1b4c.tar.gz
bcfg2-2724e6409534a948b5a2c212ae0a7192326c1b4c.tar.bz2
bcfg2-2724e6409534a948b5a2c212ae0a7192326c1b4c.zip
Run 2to3 on the entire project
Diffstat (limited to 'src/lib/Bcfg2/Server/Lint')
-rw-r--r--src/lib/Bcfg2/Server/Lint/Bundler.py6
-rw-r--r--src/lib/Bcfg2/Server/Lint/Cfg.py8
-rw-r--r--src/lib/Bcfg2/Server/Lint/Comments.py20
-rw-r--r--src/lib/Bcfg2/Server/Lint/Genshi.py6
-rw-r--r--src/lib/Bcfg2/Server/Lint/GroupNames.py4
-rw-r--r--src/lib/Bcfg2/Server/Lint/InfoXML.py4
-rw-r--r--src/lib/Bcfg2/Server/Lint/Jinja2.py4
-rw-r--r--src/lib/Bcfg2/Server/Lint/MergeFiles.py4
-rw-r--r--src/lib/Bcfg2/Server/Lint/Metadata.py4
-rw-r--r--src/lib/Bcfg2/Server/Lint/RequiredAttrs.py8
-rw-r--r--src/lib/Bcfg2/Server/Lint/TemplateAbuse.py6
-rw-r--r--src/lib/Bcfg2/Server/Lint/TemplateHelper.py2
-rw-r--r--src/lib/Bcfg2/Server/Lint/Validate.py4
-rw-r--r--src/lib/Bcfg2/Server/Lint/__init__.py14
14 files changed, 47 insertions, 47 deletions
diff --git a/src/lib/Bcfg2/Server/Lint/Bundler.py b/src/lib/Bcfg2/Server/Lint/Bundler.py
index 7b024229b..7bf6f0baa 100644
--- a/src/lib/Bcfg2/Server/Lint/Bundler.py
+++ b/src/lib/Bcfg2/Server/Lint/Bundler.py
@@ -11,7 +11,7 @@ class Bundler(ServerPlugin):
def Run(self):
self.missing_bundles()
- for bundle in self.core.plugins['Bundler'].entries.values():
+ for bundle in list(self.core.plugins['Bundler'].entries.values()):
if self.HandlesFile(bundle.name):
self.bundle_names(bundle)
@@ -32,11 +32,11 @@ class Bundler(ServerPlugin):
ref_bundles = set([b.get("name")
for b in groupdata.findall("//Bundle")])
- for bundle in self.core.plugins['Bundler'].bundles.values():
+ for bundle in list(self.core.plugins['Bundler'].bundles.values()):
ref_bundles |= set([rb.get("name") for rb in
bundle.xdata.findall(".//RequiredBundle")])
- allbundles = self.core.plugins['Bundler'].bundles.keys()
+ allbundles = list(self.core.plugins['Bundler'].bundles.keys())
for bundle in ref_bundles:
if bundle not in allbundles:
self.LintError("bundle-not-found",
diff --git a/src/lib/Bcfg2/Server/Lint/Cfg.py b/src/lib/Bcfg2/Server/Lint/Cfg.py
index 13b04a6b8..e4eba2619 100644
--- a/src/lib/Bcfg2/Server/Lint/Cfg.py
+++ b/src/lib/Bcfg2/Server/Lint/Cfg.py
@@ -29,8 +29,8 @@ class Cfg(ServerPlugin):
""" Check that a single entryset doesn't have multiple
non-specific (i.e., 'all') handlers. """
cfg = self.core.plugins['Cfg']
- for eset in cfg.entries.values():
- alls = [e for e in eset.entries.values()
+ for eset in list(cfg.entries.values()):
+ alls = [e for e in list(eset.entries.values())
if (e.specific.all and
issubclass(e.__class__, CfgGenerator))]
if len(alls) > 1:
@@ -98,9 +98,9 @@ class Cfg(ServerPlugin):
# next, get a list of all files known to Cfg
cfg_files = set()
- for root, eset in cfg.entries.items():
+ for root, eset in list(cfg.entries.items()):
cfg_files.update(os.path.join(cfg.data, root.lstrip("/"), fname)
- for fname in eset.entries.keys())
+ for fname in list(eset.entries.keys()))
# finally, compare the two
unknown_files = all_files - cfg_files
diff --git a/src/lib/Bcfg2/Server/Lint/Comments.py b/src/lib/Bcfg2/Server/Lint/Comments.py
index fbe84de87..7061dee3f 100644
--- a/src/lib/Bcfg2/Server/Lint/Comments.py
+++ b/src/lib/Bcfg2/Server/Lint/Comments.py
@@ -180,7 +180,7 @@ class Comments(Bcfg2.Server.Lint.ServerPlugin):
def check_bundles(self):
""" Check bundle files for required comments. """
if 'Bundler' in self.core.plugins:
- for bundle in self.core.plugins['Bundler'].entries.values():
+ for bundle in list(self.core.plugins['Bundler'].entries.values()):
xdata = None
rtype = ""
try:
@@ -197,7 +197,7 @@ class Comments(Bcfg2.Server.Lint.ServerPlugin):
""" Check Properties files for required comments. """
if 'Properties' in self.core.plugins:
props = self.core.plugins['Properties']
- for propfile, pdata in props.entries.items():
+ for propfile, pdata in list(props.entries.items()):
if os.path.splitext(propfile)[1] == ".xml":
self.check_xml(pdata.name, pdata.xdata, 'properties')
@@ -243,8 +243,8 @@ class Comments(Bcfg2.Server.Lint.ServerPlugin):
""" Check Cfg files and ``info.xml`` files for required
comments. """
if 'Cfg' in self.core.plugins:
- for entryset in self.core.plugins['Cfg'].entries.values():
- for entry in entryset.entries.values():
+ for entryset in list(self.core.plugins['Cfg'].entries.values()):
+ for entry in list(entryset.entries.values()):
rtype = None
if isinstance(entry, CfgGenshiGenerator):
rtype = "genshi"
@@ -265,7 +265,7 @@ class Comments(Bcfg2.Server.Lint.ServerPlugin):
def check_probes(self):
""" Check Probes for required comments """
if 'Probes' in self.core.plugins:
- for probe in self.core.plugins['Probes'].probes.entries.values():
+ for probe in list(self.core.plugins['Probes'].probes.entries.values()):
self.check_plaintext(probe.name, probe.data, "probes")
def check_xml(self, filename, xdata, rtype):
@@ -319,21 +319,21 @@ class Comments(Bcfg2.Server.Lint.ServerPlugin):
for line in lines:
# we check for both '$<keyword>:' and '$<keyword>$' to see
# if the keyword just hasn't been expanded
- for (keyword, status) in found.items():
+ for (keyword, status) in list(found.items()):
if not status:
if '$%s:' % keyword in line:
found[keyword] = True
elif '$%s$' % keyword in line:
found[keyword] = None
- unexpanded = [keyword for (keyword, status) in found.items()
+ unexpanded = [keyword for (keyword, status) in list(found.items())
if status is None]
if unexpanded:
self.LintError("unexpanded-keywords",
"%s: Required keywords(s) found but not "
"expanded: %s" %
(filename, ", ".join(unexpanded)))
- missing = [keyword for (keyword, status) in found.items()
+ missing = [keyword for (keyword, status) in list(found.items())
if status is False]
if missing:
self.LintError("keywords-not-found",
@@ -345,11 +345,11 @@ class Comments(Bcfg2.Server.Lint.ServerPlugin):
found = dict((k, False) for k in self.required_comments(rtype))
for line in lines:
- for (comment, status) in found.items():
+ for (comment, status) in list(found.items()):
if not status:
found[comment] = comment in line
- missing = [comment for (comment, status) in found.items()
+ missing = [comment for (comment, status) in list(found.items())
if status is False]
if missing:
self.LintError("comments-not-found",
diff --git a/src/lib/Bcfg2/Server/Lint/Genshi.py b/src/lib/Bcfg2/Server/Lint/Genshi.py
index a2581e70b..fb12e4254 100644
--- a/src/lib/Bcfg2/Server/Lint/Genshi.py
+++ b/src/lib/Bcfg2/Server/Lint/Genshi.py
@@ -36,8 +36,8 @@ class Genshi(Bcfg2.Server.Lint.ServerPlugin):
def check_cfg(self):
""" Check genshi templates in Cfg for syntax errors. """
- for entryset in self.core.plugins['Cfg'].entries.values():
- for entry in entryset.entries.values():
+ for entryset in list(self.core.plugins['Cfg'].entries.values()):
+ for entry in list(entryset.entries.values()):
if (self.HandlesFile(entry.name) and
isinstance(entry, CfgGenshiGenerator) and
not entry.template):
@@ -47,7 +47,7 @@ class Genshi(Bcfg2.Server.Lint.ServerPlugin):
def check_bundler(self):
""" Check templates in Bundler for syntax errors. """
loader = TemplateLoader()
- for entry in self.core.plugins['Bundler'].entries.values():
+ for entry in list(self.core.plugins['Bundler'].entries.values()):
if (self.HandlesFile(entry.name) and
entry.template is not None):
self.check_template(loader, entry.name, cls=MarkupTemplate)
diff --git a/src/lib/Bcfg2/Server/Lint/GroupNames.py b/src/lib/Bcfg2/Server/Lint/GroupNames.py
index e28080300..3bfb4949f 100644
--- a/src/lib/Bcfg2/Server/Lint/GroupNames.py
+++ b/src/lib/Bcfg2/Server/Lint/GroupNames.py
@@ -34,7 +34,7 @@ class GroupNames(Bcfg2.Server.Lint.ServerPlugin):
def check_rules(self):
""" Check groups used in the Rules plugin for validity. """
- for rules in self.core.plugins['Rules'].entries.values():
+ for rules in list(self.core.plugins['Rules'].entries.values()):
if not self.HandlesFile(rules.name):
continue
xdata = rules.pnode.data
@@ -44,7 +44,7 @@ class GroupNames(Bcfg2.Server.Lint.ServerPlugin):
def check_bundles(self):
""" Check groups used in the Bundler plugin for validity. """
- for bundle in self.core.plugins['Bundler'].entries.values():
+ for bundle in list(self.core.plugins['Bundler'].entries.values()):
if self.HandlesFile(bundle.name) and bundle.template is None:
self.check_entries(bundle.xdata.xpath("//Group"),
bundle.name)
diff --git a/src/lib/Bcfg2/Server/Lint/InfoXML.py b/src/lib/Bcfg2/Server/Lint/InfoXML.py
index 950a86f01..cd21371e7 100644
--- a/src/lib/Bcfg2/Server/Lint/InfoXML.py
+++ b/src/lib/Bcfg2/Server/Lint/InfoXML.py
@@ -29,11 +29,11 @@ class InfoXML(Bcfg2.Server.Lint.ServerPlugin):
if 'Cfg' not in self.core.plugins:
return
- for filename, entryset in self.core.plugins['Cfg'].entries.items():
+ for filename, entryset in list(self.core.plugins['Cfg'].entries.items()):
infoxml_fname = os.path.join(entryset.path, "info.xml")
if self.HandlesFile(infoxml_fname):
found = False
- for entry in entryset.entries.values():
+ for entry in list(entryset.entries.values()):
if isinstance(entry, CfgInfoXML):
self.check_infoxml(infoxml_fname,
entry.infoxml.xdata)
diff --git a/src/lib/Bcfg2/Server/Lint/Jinja2.py b/src/lib/Bcfg2/Server/Lint/Jinja2.py
index 333249cc2..0b177d640 100644
--- a/src/lib/Bcfg2/Server/Lint/Jinja2.py
+++ b/src/lib/Bcfg2/Server/Lint/Jinja2.py
@@ -34,8 +34,8 @@ class Jinja2(Bcfg2.Server.Lint.ServerPlugin):
def check_cfg(self):
""" Check jinja2 templates in Cfg for syntax errors. """
- for entryset in self.core.plugins['Cfg'].entries.values():
- for entry in entryset.entries.values():
+ for entryset in list(self.core.plugins['Cfg'].entries.values()):
+ for entry in list(entryset.entries.values()):
if (self.HandlesFile(entry.name) and
isinstance(entry, CfgJinja2Generator)):
self.check_template(entry)
diff --git a/src/lib/Bcfg2/Server/Lint/MergeFiles.py b/src/lib/Bcfg2/Server/Lint/MergeFiles.py
index 3b89e507a..b1a0fa8ef 100644
--- a/src/lib/Bcfg2/Server/Lint/MergeFiles.py
+++ b/src/lib/Bcfg2/Server/Lint/MergeFiles.py
@@ -48,8 +48,8 @@ class MergeFiles(Bcfg2.Server.Lint.ServerPlugin):
if not hdlr.__specific__:
ignore.extend(hdlr.__basenames__)
- for filename, entryset in self.core.plugins['Cfg'].entries.items():
- candidates = dict([(f, e) for f, e in entryset.entries.items()
+ for filename, entryset in list(self.core.plugins['Cfg'].entries.items()):
+ candidates = dict([(f, e) for f, e in list(entryset.entries.items())
if (isinstance(e, CfgGenerator) and
is_string(e.data,
Bcfg2.Options.setup.encoding) and
diff --git a/src/lib/Bcfg2/Server/Lint/Metadata.py b/src/lib/Bcfg2/Server/Lint/Metadata.py
index e445892d1..3c1d49a45 100644
--- a/src/lib/Bcfg2/Server/Lint/Metadata.py
+++ b/src/lib/Bcfg2/Server/Lint/Metadata.py
@@ -131,7 +131,7 @@ class Metadata(ServerPlugin):
groups[grpname] = grp
else: # group has no options
groups[grpname] = grp
- for grpname, grps in duplicates.items():
+ for grpname, grps in list(duplicates.items()):
self.LintError("duplicate-group",
"Group %s is defined multiple times:\n%s" %
(grpname,
@@ -154,7 +154,7 @@ class Metadata(ServerPlugin):
entries[el.get("name")].append(self.RenderXML(el))
else:
entries[el.get("name")] = [self.RenderXML(el)]
- for ename, els in entries.items():
+ for ename, els in list(entries.items()):
if len(els) > 1:
self.LintError("duplicate-%s" % etype,
"%s %s is defined multiple times:\n%s" %
diff --git a/src/lib/Bcfg2/Server/Lint/RequiredAttrs.py b/src/lib/Bcfg2/Server/Lint/RequiredAttrs.py
index 56b4e7477..6d872bfa5 100644
--- a/src/lib/Bcfg2/Server/Lint/RequiredAttrs.py
+++ b/src/lib/Bcfg2/Server/Lint/RequiredAttrs.py
@@ -230,7 +230,7 @@ class RequiredAttrs(Bcfg2.Server.Lint.ServerPlugin):
if 'Rules' not in self.core.plugins:
return
- for rules in self.core.plugins['Rules'].entries.values():
+ for rules in list(self.core.plugins['Rules'].entries.values()):
xdata = rules.pnode.data
for path in xdata.xpath("//Path"):
self.check_entry(path,
@@ -243,7 +243,7 @@ class RequiredAttrs(Bcfg2.Server.Lint.ServerPlugin):
if 'Bundler' not in self.core.plugins:
return
- for bundle in self.core.plugins['Bundler'].entries.values():
+ for bundle in list(self.core.plugins['Bundler'].entries.values()):
if self.HandlesFile(bundle.name) and bundle.template is None:
for path in bundle.xdata.xpath(
"//*[substring(name(), 1, 5) = 'Bound']"):
@@ -327,7 +327,7 @@ class RequiredAttrs(Bcfg2.Server.Lint.ServerPlugin):
"Text content of %s %s in %s is malformed\n%s" %
(tag, name, filename, self.RenderXML(entry)))
- if not attrs.issuperset(required_attrs.keys()):
+ if not attrs.issuperset(list(required_attrs.keys())):
self.LintError(
"required-attrs-missing",
"The following required attribute(s) are missing for %s "
@@ -338,7 +338,7 @@ class RequiredAttrs(Bcfg2.Server.Lint.ServerPlugin):
set(required_attrs.keys()).difference(attrs)]),
self.RenderXML(entry)))
- for attr, fmt in required_attrs.items():
+ for attr, fmt in list(required_attrs.items()):
if fmt and attr in attrs and not fmt(entry.attrib[attr]):
self.LintError(
"required-attr-format",
diff --git a/src/lib/Bcfg2/Server/Lint/TemplateAbuse.py b/src/lib/Bcfg2/Server/Lint/TemplateAbuse.py
index a437c1318..8ca2ccaed 100644
--- a/src/lib/Bcfg2/Server/Lint/TemplateAbuse.py
+++ b/src/lib/Bcfg2/Server/Lint/TemplateAbuse.py
@@ -26,8 +26,8 @@ class TemplateAbuse(Bcfg2.Server.Lint.ServerPlugin):
def Run(self):
if 'Cfg' in self.core.plugins:
- for entryset in self.core.plugins['Cfg'].entries.values():
- for entry in entryset.entries.values():
+ for entryset in list(self.core.plugins['Cfg'].entries.values()):
+ for entry in list(entryset.entries.values()):
if (self.HandlesFile(entry.name) and
any(isinstance(entry, t) for t in self.templates)):
self.check_template(entryset, entry)
@@ -60,7 +60,7 @@ class TemplateAbuse(Bcfg2.Server.Lint.ServerPlugin):
return
# finally, check for executable permissions in info.xml
- for entry in entryset.entries.values():
+ for entry in list(entryset.entries.values()):
if isinstance(entry, CfgInfoXML):
for pinfo in entry.infoxml.xdata.xpath("//FileInfo/Info"):
try:
diff --git a/src/lib/Bcfg2/Server/Lint/TemplateHelper.py b/src/lib/Bcfg2/Server/Lint/TemplateHelper.py
index 98faa269d..403437bc0 100644
--- a/src/lib/Bcfg2/Server/Lint/TemplateHelper.py
+++ b/src/lib/Bcfg2/Server/Lint/TemplateHelper.py
@@ -31,7 +31,7 @@ class TemplateHelper(ServerPlugin):
self.reserved_defaults = dummy.reserved_defaults
def Run(self):
- for helper in self.core.plugins['TemplateHelper'].entries.values():
+ for helper in list(self.core.plugins['TemplateHelper'].entries.values()):
if self.HandlesFile(helper.name):
self.check_helper(helper.name)
diff --git a/src/lib/Bcfg2/Server/Lint/Validate.py b/src/lib/Bcfg2/Server/Lint/Validate.py
index 146f18b0c..7bccce87c 100644
--- a/src/lib/Bcfg2/Server/Lint/Validate.py
+++ b/src/lib/Bcfg2/Server/Lint/Validate.py
@@ -71,7 +71,7 @@ class Validate(Bcfg2.Server.Lint.ServerlessPlugin):
def Run(self):
- for path, schemaname in self.filesets.items():
+ for path, schemaname in list(self.filesets.items()):
try:
filelist = self.filelists[path]
except KeyError:
@@ -211,7 +211,7 @@ class Validate(Bcfg2.Server.Lint.ServerlessPlugin):
values are lists of the full paths to all files in the Bcfg2
repository (or given with ``bcfg2-lint --stdin``) that match
the glob."""
- for path in self.filesets.keys():
+ for path in list(self.filesets.keys()):
if '/**/' in path:
if self.files is not None:
self.filelists[path] = self.list_matching_files(path)
diff --git a/src/lib/Bcfg2/Server/Lint/__init__.py b/src/lib/Bcfg2/Server/Lint/__init__.py
index 66c8180f4..23ec65a58 100644
--- a/src/lib/Bcfg2/Server/Lint/__init__.py
+++ b/src/lib/Bcfg2/Server/Lint/__init__.py
@@ -188,7 +188,7 @@ class ErrorHandler(object):
#: A dict of registered errors
self.errortypes = dict()
if errors is not None:
- self.RegisterErrors(dict(errors.items()))
+ self.RegisterErrors(dict(list(errors.items())))
def RegisterErrors(self, errors):
""" Register a dict of errors that a plugin may raise. The
@@ -199,7 +199,7 @@ class ErrorHandler(object):
:param errors: The error dict
:type errors: dict
"""
- for err, action in errors.items():
+ for err, action in list(errors.items()):
if err not in self.errortypes:
if "warn" in action:
self.errortypes[err] = self.warn
@@ -400,9 +400,9 @@ class CLI(object):
for plugin in self.serverplugins + self.serverlessplugins:
self.errorhandler.RegisterErrors(getattr(plugin, 'Errors')())
- print("%-35s %-35s" % ("Error name", "Handler"))
- for err, handler in self.errorhandler.errortypes.items():
- print("%-35s %-35s" % (err, handler.__name__))
+ print(("%-35s %-35s" % ("Error name", "Handler")))
+ for err, handler in list(self.errorhandler.errortypes.items()):
+ print(("%-35s %-35s" % (err, handler.__name__)))
return 0
if not self.serverplugins and not self.serverlessplugins:
@@ -429,8 +429,8 @@ class CLI(object):
if (self.errorhandler.errors or
self.errorhandler.warnings or
Bcfg2.Options.setup.verbose):
- print("%d errors" % self.errorhandler.errors)
- print("%d warnings" % self.errorhandler.warnings)
+ print(("%d errors" % self.errorhandler.errors))
+ print(("%d warnings" % self.errorhandler.warnings))
if self.errorhandler.errors:
return 2