launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #06544
[Merge] lp:~jtv/maas/python-3-lint into lp:maas
Jeroen T. Vermeulen has proposed merging lp:~jtv/maas/python-3-lint into lp:maas.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~jtv/maas/python-3-lint/+merge/95148
Bits that won't work in python 3, which is near EOL. Might as well not have the old habits in our codebase, and I had a few minutes of landing time to kill.
--
https://code.launchpad.net/~jtv/maas/python-3-lint/+merge/95148
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/maas/python-3-lint into lp:maas.
=== modified file 'src/maasserver/api.py'
--- src/maasserver/api.py 2012-02-27 16:52:55 +0000
+++ src/maasserver/api.py 2012-02-29 10:58:19 +0000
@@ -160,19 +160,20 @@
# Compute the list of methods ('GET', 'POST', etc.) that need to be
# overriden.
overriden_methods = set()
- for name, value in vars(cls).iteritems():
+ for name, value in vars(cls).items():
overriden_methods.update(getattr(value, '_api_exported', {}))
# Override the appropriate methods with a 'dispatcher' method.
for method in overriden_methods:
operations = {
- name: value for name, value in vars(cls).iteritems()
+ name: value
+ for name, value in vars(cls).items()
if is_api_exported(value, method)}
cls._available_api_methods = getattr(
cls, "_available_api_methods", {}).copy()
cls._available_api_methods[method] = {
(name if op._api_exported[method] is True
else op._api_exported[method]): op
- for name, op in operations.iteritems()
+ for name, op in operations.items()
if method in op._api_exported}
def dispatcher(self, request, *args, **kwargs):
@@ -186,7 +187,7 @@
"parameter:\n\n" % OP_PARAM)
dispatcher.__doc__ += "\n".join(
"- Operation '%s' (op=%s):\n\t%s" % (name, name, op.__doc__)
- for name, op in cls._available_api_methods[method].iteritems())
+ for name, op in cls._available_api_methods[method].items())
# Add {'create','read','update','delete'} method.
setattr(cls, method_name, dispatcher)
@@ -341,7 +342,7 @@
user=request.user, system_id=system_id)
mac = node.add_mac_address(request.data.get('mac_address', None))
return mac
- except ValidationError, e:
+ except ValidationError as e:
return HttpResponseBadRequest(e.message_dict)
@classmethod
=== modified file 'src/maasserver/forms.py'
--- src/maasserver/forms.py 2012-02-28 13:33:42 +0000
+++ src/maasserver/forms.py 2012-02-29 10:58:19 +0000
@@ -65,7 +65,7 @@
class MultipleMACAddressField(forms.MultiValueField):
def __init__(self, nb_macs=1, *args, **kwargs):
- fields = [MACAddressFormField() for i in xrange(nb_macs)]
+ fields = [MACAddressFormField() for i in range(nb_macs)]
super(MultipleMACAddressField, self).__init__(fields, *args, **kwargs)
def compress(self, data_list):
=== modified file 'src/maasserver/testing/factory.py'
--- src/maasserver/testing/factory.py 2012-02-28 13:33:42 +0000
+++ src/maasserver/testing/factory.py 2012-02-29 10:58:19 +0000
@@ -31,7 +31,7 @@
def getRandomString(self, size=10):
return "".join(
random.choice(string.letters + string.digits)
- for x in xrange(size))
+ for x in range(size))
def getRandomBoolean(self):
random.choice((True, False))
=== modified file 'src/maasserver/tests/test_models.py'
--- src/maasserver/tests/test_models.py 2012-02-21 19:06:52 +0000
+++ src/maasserver/tests/test_models.py 2012-02-29 10:58:19 +0000
@@ -366,7 +366,7 @@
profile = factory.make_user().get_profile()
token_ids = []
consumer_ids = []
- for i in xrange(3):
+ for i in range(3):
token, consumer = profile.create_authorisation_token()
token_ids.append(token.id)
consumer_ids.append(consumer.id)
@@ -381,7 +381,7 @@
self.assertRaises(CannotDeleteUserException, profile.delete)
def test_manager_all_users(self):
- users = set(factory.make_user() for i in xrange(3))
+ users = set(factory.make_user() for i in range(3))
all_users = set(UserProfile.objects.all_users())
self.assertEqual(users, all_users)
=== modified file 'src/maasserver/tests/test_views.py'
--- src/maasserver/tests/test_views.py 2012-02-28 13:33:42 +0000
+++ src/maasserver/tests/test_views.py 2012-02-29 10:58:19 +0000
@@ -56,7 +56,7 @@
# The preferences page displays the API access tokens.
user = self.logged_in_user
# Create a few tokens.
- for i in xrange(3):
+ for i in range(3):
user.get_profile().create_authorisation_token()
response = self.client.get('/account/prefs/')
doc = fromstring(response.content)
=== modified file 'src/provisioningserver/api.py'
--- src/provisioningserver/api.py 2012-02-28 17:26:33 +0000
+++ src/provisioningserver/api.py 2012-02-29 10:58:19 +0000
@@ -34,7 +34,7 @@
"""Apply `function` to each value in `mapping`, returned in a new dict."""
return {
key: function(value)
- for key, value in mapping.iteritems()
+ for key, value in mapping.items()
}
@@ -96,13 +96,13 @@
# or not that happens is undefined (for now).
interfaces = {
name: configuration
- for name, configuration in interfaces.iteritems()
+ for name, configuration in interfaces.items()
if configuration["mac_address"]
}
interface_names_by_mac_address = {
interface["mac_address"]: interface_name
- for interface_name, interface in interfaces.iteritems()
+ for interface_name, interface in interfaces.items()
}
mac_addresses_to_remove = set(
interface_names_by_mac_address).difference(mac_addresses)
@@ -200,17 +200,17 @@
@inlineCallbacks
def modify_distros(self, deltas):
- for name, delta in deltas.iteritems():
+ for name, delta in deltas.items():
yield CobblerDistro(self.session, name).modify(delta)
@inlineCallbacks
def modify_profiles(self, deltas):
- for name, delta in deltas.iteritems():
+ for name, delta in deltas.items():
yield CobblerProfile(self.session, name).modify(delta)
@inlineCallbacks
def modify_nodes(self, deltas):
- for name, delta in deltas.iteritems():
+ for name, delta in deltas.items():
system = CobblerSystem(self.session, name)
if "mac_addresses" in delta:
# This needs to be handled carefully.
=== modified file 'src/provisioningserver/cobblerclient.py'
--- src/provisioningserver/cobblerclient.py 2012-02-17 14:01:13 +0000
+++ src/provisioningserver/cobblerclient.py 2012-02-29 10:58:19 +0000
@@ -66,7 +66,7 @@
elif isinstance(data, list):
return [tilde_to_None(value) for value in data]
elif isinstance(data, dict):
- return {key: tilde_to_None(value) for key, value in data.iteritems()}
+ return {key: tilde_to_None(value) for key, value in data.items()}
else:
return data
@@ -433,7 +433,7 @@
else:
return {
name: value
- for name, value in attributes.iteritems()
+ for name, value in attributes.items()
if name in cls.known_attributes
}
@@ -483,7 +483,7 @@
args = dict(
(cls._normalize_attribute(key), value)
- for key, value in attributes.iteritems())
+ for key, value in attributes.items())
# Overwrite any existing object of the same name. Unfortunately
# this parameter goes into the "attributes," and seems to be
@@ -511,7 +511,7 @@
attributes=self.modification_attributes)
args = {
normalize(key): value
- for key, value in delta.iteritems()
+ for key, value in delta.items()
}
success = yield self.session.call(
'xapi_object_edit', self.object_type, self.name, 'edit', args,
=== modified file 'src/provisioningserver/interfaces.py'
--- src/provisioningserver/interfaces.py 2012-02-28 13:49:34 +0000
+++ src/provisioningserver/interfaces.py 2012-02-29 10:58:19 +0000
@@ -154,7 +154,7 @@
# over-the-wire.
PAPI_XMLRPC_FUNCTIONS = {
"xmlrpc_%s" % name: value
- for name, value in PAPI_FUNCTIONS.iteritems()
+ for name, value in PAPI_FUNCTIONS.items()
}
# Construct an interface containing IProvisioningAPI_Template's functions but
=== modified file 'src/provisioningserver/testing/fakeapi.py'
--- src/provisioningserver/testing/fakeapi.py 2012-02-28 13:49:34 +0000
+++ src/provisioningserver/testing/fakeapi.py 2012-02-29 10:58:19 +0000
@@ -41,7 +41,7 @@
keys = frozenset(keys)
return {
key: value
- for key, value in self.iteritems()
+ for key, value in self.items()
if key in keys
}
@@ -59,7 +59,7 @@
"""
return {
key: value.copy()
- for key, value in self.iteritems()
+ for key, value in self.items()
}
@@ -95,17 +95,17 @@
return name
def modify_distros(self, deltas):
- for name, delta in deltas.iteritems():
+ for name, delta in deltas.items():
distro = self.distros[name]
distro.update(delta)
def modify_profiles(self, deltas):
- for name, delta in deltas.iteritems():
+ for name, delta in deltas.items():
profile = self.profiles[name]
profile.update(delta)
def modify_nodes(self, deltas):
- for name, delta in deltas.iteritems():
+ for name, delta in deltas.items():
node = self.nodes[name]
node.update(delta)
=== modified file 'src/provisioningserver/testing/fakecobbler.py'
--- src/provisioningserver/testing/fakecobbler.py 2012-02-15 20:52:29 +0000
+++ src/provisioningserver/testing/fakecobbler.py 2012-02-29 10:58:19 +0000
@@ -359,7 +359,7 @@
handle = self._api_get_handle(token, object_type, name)
if object_type == "system" and "interface" in attrs:
self._xapi_edit_system_interfaces(token, handle, name, attrs)
- for key, value in attrs.iteritems():
+ for key, value in attrs.items():
self._api_modify_object(token, object_type, handle, key, value)
return self._api_save_object(token, object_type, handle)
else:
=== modified file 'src/provisioningserver/tests/test_api.py'
--- src/provisioningserver/tests/test_api.py 2012-02-28 17:32:40 +0000
+++ src/provisioningserver/tests/test_api.py 2012-02-29 10:58:19 +0000
@@ -362,7 +362,7 @@
self.assertEqual({}, distros)
# Create some distros via the Provisioning API.
expected = {}
- for num in xrange(3):
+ for num in range(3):
initrd = self.getUniqueString()
kernel = self.getUniqueString()
name = self.getUniqueString()
@@ -384,7 +384,7 @@
self.assertEqual({}, profiles)
# Create some profiles via the Provisioning API.
expected = {}
- for num in xrange(3):
+ for num in range(3):
name = self.getUniqueString()
yield papi.add_profile(name, distro)
expected[name] = {u'distro': u'distro', u'name': name}
=== modified file 'utilities/format-imports'
--- utilities/format-imports 2012-01-24 12:44:48 +0000
+++ utilities/format-imports 2012-02-29 10:58:19 +0000
@@ -309,7 +309,7 @@
thirdparty_section = {}
local_section = {}
# Group modules into sections.
- for module, statement in imports.iteritems():
+ for module, statement in imports.items():
module_base = module_base_regex.findall(module)[0]
comment = statement.comment
if module_base == '_pythonpath':