Skip to content
This repository was archived by the owner on Jan 14, 2021. It is now read-only.

Commit 88ea5e6

Browse files
committed
More Python3
Signed-off-by: Nils Philippsen <nils@redhat.com>
1 parent 4fa717e commit 88ea5e6

File tree

7 files changed

+42
-40
lines changed

7 files changed

+42
-40
lines changed

pdcupdater/commands.py

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import print_function
2-
31
import logging
42
import logging.config
53
import sys
@@ -79,7 +77,7 @@ def audit():
7977

8078
def _print_audit_report(results, verbose):
8179
fail = False
82-
for key, values in list(results.items()):
80+
for key, values in results.items():
8381
present, absent = values
8482
fail = fail or present or absent
8583

@@ -88,30 +86,33 @@ def _print_audit_report(results, verbose):
8886
else:
8987
print("WARNING - audit script detected something is wrong.")
9088

91-
print("\nSummary")
92-
print("=======\n")
89+
print()
90+
print("Summary")
91+
print("=======")
92+
print()
9393

94-
for key, values in list(results.items()):
94+
for key, values in results.items():
9595
present, absent = values
9696
if not present and not absent:
97-
print(( "- [x]", key))
97+
print(f"- [x] {key}")
9898
else:
99-
print(("- [!]", key))
100-
print((" ", len(present), "extra entries in PDC unaccounted for"))
101-
print((" ", len(absent), "entries absent from PDC"))
99+
print(f"- [!] {key}")
100+
print(f" {len(present)} extra entries in PDC unaccounted for")
101+
print(f" {len(absent)} entries absent from PDC")
102102

103-
print("\nDetails")
103+
print()
104+
print("Details")
104105
print("=======")
105106

106107
limit = 100
107-
for key, values in list(results.items()):
108+
for key, values in results.items():
108109
present, absent = values
109110
if not present and not absent:
110111
continue
111112

112113
print()
113114
print(key)
114-
print(("-" * len(key)))
115+
print("-" * len(key))
115116
print()
116117

117118
if not present:
@@ -121,16 +122,16 @@ def _print_audit_report(results, verbose):
121122
print()
122123
if verbose or len(present) < limit:
123124
for value in present:
124-
print(("-", value))
125+
print(f"- {value}")
125126
if isinstance(present, dict):
126-
print((" ", present[value]))
127+
print(f" {present[value]}")
127128
else:
128129
present = list(present)
129130
for value in present[:limit]:
130-
print(("-", value))
131+
print(f"- {value}")
131132
if isinstance(present, dict):
132-
print((" ", present[value]))
133-
print(("- (plus %i more... truncated.)" % (len(present) - limit)))
133+
print(f" {present[value]}")
134+
print(f"- (plus {len(present) - limit} more... truncated.)")
134135
print()
135136

136137
if not absent:
@@ -140,16 +141,16 @@ def _print_audit_report(results, verbose):
140141
print()
141142
if verbose or len(absent) < limit:
142143
for value in absent:
143-
print("-", value)
144+
print(f"- {value}")
144145
if isinstance(absent, dict):
145-
print(" ", absent[value])
146+
print(f" {absent[value]}")
146147
else:
147148
absent = list(absent)
148149
for value in absent[:limit]:
149-
print("-", value)
150+
print(f"- {value}")
150151
if isinstance(absent, dict):
151-
print(" ", absent[value])
152-
print("- (plus %i more... truncated.)" % (len(absent) - limit))
152+
print(f" {absent[value]}")
153+
print(f"- (plus {len(absent) - limit} more... truncated.)")
153154

154155
if not fail:
155156
return 0

pdcupdater/handlers/__init__.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import abc
1+
from abc import ABCMeta, abstractmethod
22

33
import fedmsg.utils
44

@@ -11,7 +11,7 @@ def load_handlers(config):
1111
yield handler
1212

1313

14-
class BaseHandler(object, metaclass=abc.ABCMeta):
14+
class BaseHandler(object, metaclass=ABCMeta):
1515
""" An abstract base class for handlers to enforce API. """
1616

1717
def __init__(self, config):
@@ -31,21 +31,22 @@ def construct_topics(self, config):
3131
for topic in self.topic_suffixes
3232
]
3333

34-
@abc.abstractproperty
34+
@property
35+
@abstractmethod
3536
def topic_suffixes(self):
3637
pass
3738

38-
@abc.abstractmethod
39+
@abstractmethod
3940
def can_handle(self, pdc, msg):
4041
""" Return True or False if this handler can handle this message. """
4142
pass
4243

43-
@abc.abstractmethod
44+
@abstractmethod
4445
def handle(self, pdc, msg):
4546
""" Handle a fedmsg and update PDC if necessary. """
4647
pass
4748

48-
@abc.abstractmethod
49+
@abstractmethod
4950
def audit(self, pdc):
5051
""" This is intended to be called from a cronjob once every few days
5152
and is meant to (in a read-only fashion) check that what PDC thinks is
@@ -60,7 +61,7 @@ def audit(self, pdc):
6061
"""
6162
pass
6263

63-
@abc.abstractmethod
64+
@abstractmethod
6465
def initialize(self, pdc):
6566
""" This needs to be called only once when pdc-updater is first
6667
installed. It should query the original data source and initialize PDC

pdcupdater/handlers/atomic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def audit(self, pdc):
110110

111111
# Associate the two by release and normalize
112112
present, absent = {}, {}
113-
for release in set(list(git_groups.keys()) + list(pdc_groups.keys())):
113+
for release in set(git_groups) | set(pdc_groups):
114114
# Convert each group to a set
115115
left = set(git_groups.get(release, []))
116116
right = set(pdc_groups.get(release, []))

pdcupdater/handlers/depchain/base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ def _yield_managed_pdc_relationships_from_release(self, pdc, release_id):
114114

115115
# Construct and yield a three-tuple result.
116116
keys = ('name', 'release')
117-
parent = dict(list(zip(keys, [entry['from_component'][key] for key in keys])))
118-
child = dict(list(zip(keys, [entry['to_component'][key] for key in keys])))
117+
parent = {key: entry['from_component'][key] for key in keys}
118+
child = {key: entry['to_component'][key] for key in keys}
119119
yield parent, relationship_type, child
120120

121121
def handle(self, pdc, msg):
@@ -154,7 +154,7 @@ def handle(self, pdc, msg):
154154
by_parent[parent_name].add((relationship, child_name,))
155155

156156
# Finally, iterate over all those, now grouped by parent_name
157-
for parent_name, koji_relationships in list(by_parent.items()):
157+
for parent_name, koji_relationships in by_parent.items():
158158
# TODO -- pass in global_component_name to this function?
159159
parent = pdcupdater.utils.ensure_release_component_exists(
160160
pdc, release_id, parent_name, type=self.parent_type)

pdcupdater/handlers/modules.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ def get_module_rpms(self, pdc, module):
111111
# For SRPM packages, include the hash and branch from which is
112112
# has been built.
113113
if (rpm['arch'] == 'src'
114-
and rpm['name'] in list(mmd.get_rpm_components().keys())
115-
and 'rpms' in list(mmd.get_xmd()['mbs'].keys())
114+
and rpm['name'] in mmd.get_rpm_components()
115+
and 'rpms' in mmd.get_xmd()['mbs']
116116
and rpm['name'] in mmd.get_xmd()['mbs']['rpms']):
117117
mmd_rpm = mmd.get_rpm_components()[rpm['name']]
118118
xmd_rpm = mmd.get_xmd()['mbs']['rpms'][rpm['name']]
@@ -172,11 +172,11 @@ def create_module(self, pdc, body):
172172
runtime_deps = []
173173
build_deps = []
174174
for deps in mmd.get_dependencies():
175-
for dependency, streams in list(deps.get_requires().items()):
175+
for dependency, streams in deps.get_requires().items():
176176
for stream in streams.get():
177177
runtime_deps.append(
178178
{'dependency': dependency, 'stream': stream})
179-
for dependency, streams in list(deps.get_buildrequires().items()):
179+
for dependency, streams in deps.get_buildrequires().items():
180180
for stream in streams.get():
181181
build_deps.append(
182182
{'dependency': dependency, 'stream': stream})

pdcupdater/handlers/rpms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def _gather_koji_rpms(self):
107107
}
108108

109109
# Flatten into a list and augment the koji dict with tag info.
110-
for tag, rpms in list(koji_rpms.items()):
110+
for tag, rpms in koji_rpms.items():
111111
yield [
112112
dict(
113113
name=rpm['name'],

pdcupdater/services.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def koji_yield_rpm_requires(url, nvra):
121121
rpm.RPMSENSE_GREATER: '>',
122122
rpm.RPMSENSE_EQUAL: '=',
123123
}
124-
relevant_flags = reduce(operator.ior, list(header_lookup.keys()))
124+
relevant_flags = reduce(operator.ior, header_lookup)
125125

126126
# Query koji and step over all the deps listed in the raw rpm headers.
127127
deps = session.getRPMDeps(nvra, koji.DEP_REQUIRE)

0 commit comments

Comments
 (0)