Merge ~cjwatson/launchpad:six-dict-iter into launchpad:master
- Git
- lp:~cjwatson/launchpad
- six-dict-iter
- Merge into master
Status: | Merged |
---|---|
Approved by: | Colin Watson |
Approved revision: | 41b7c40b4fb1d1e98de3754b3cd7f38c34eaf8c2 |
Merge reported by: | Otto Co-Pilot |
Merged at revision: | not available |
Proposed branch: | ~cjwatson/launchpad:six-dict-iter |
Merge into: | launchpad:master |
Diff against target: |
2251 lines (+249/-155) 90 files modified
brzplugins/lpserve/__init__.py (+3/-2) brzplugins/lpserve/test_lpserve.py (+4/-3) database/schema/security.py (+10/-8) lib/contrib/oauth.py (+7/-4) lib/lp/app/browser/launchpadform.py (+2/-1) lib/lp/app/browser/tales.py (+3/-2) lib/lp/archivepublisher/domination.py (+3/-2) lib/lp/archivepublisher/model/ftparchive.py (+4/-3) lib/lp/archivepublisher/publishing.py (+2/-1) lib/lp/archivepublisher/scripts/publish_ftpmaster.py (+12/-11) lib/lp/archivepublisher/tests/test_dominator.py (+3/-2) lib/lp/archivepublisher/tests/test_publish_ftpmaster.py (+3/-4) lib/lp/archiveuploader/dscfile.py (+1/-1) lib/lp/archiveuploader/nascentuploadfile.py (+3/-2) lib/lp/archiveuploader/utils.py (+3/-1) lib/lp/bugs/browser/bugalsoaffects.py (+3/-2) lib/lp/bugs/browser/bugtarget.py (+2/-1) lib/lp/bugs/interfaces/bugtaskfilter.py (+3/-1) lib/lp/bugs/model/bugtask.py (+2/-1) lib/lp/bugs/model/structuralsubscription.py (+3/-2) lib/lp/bugs/model/tests/test_bugsubscriptioninfo.py (+3/-2) lib/lp/bugs/scripts/bugsummaryrebuild.py (+7/-5) lib/lp/bugs/scripts/bugtasktargetnamecaches.py (+2/-1) lib/lp/bugs/scripts/bzremotecomponentfinder.py (+2/-1) lib/lp/bugs/tests/externalbugtracker.py (+2/-1) lib/lp/buildmaster/browser/builder.py (+2/-1) lib/lp/buildmaster/manager.py (+2/-1) lib/lp/buildmaster/model/builder.py (+2/-1) lib/lp/buildmaster/queuedepth.py (+2/-1) lib/lp/buildmaster/tests/test_queuedepth.py (+2/-1) lib/lp/code/browser/branch.py (+3/-2) lib/lp/code/browser/branchlisting.py (+3/-2) lib/lp/code/browser/branchmergeproposal.py (+2/-1) lib/lp/code/browser/gitrepository.py (+3/-3) lib/lp/code/model/branchcollection.py (+2/-1) lib/lp/code/model/branchjob.py (+1/-1) lib/lp/code/model/codereviewinlinecomment.py (+2/-1) lib/lp/code/model/revision.py (+3/-2) lib/lp/codehosting/inmemory.py (+1/-1) lib/lp/codehosting/scanner/buglinks.py (+2/-1) lib/lp/codehosting/sshserver/session.py (+2/-1) lib/lp/codehosting/vfs/branchfsclient.py (+2/-1) lib/lp/registry/model/distroseriesdifference.py (+5/-4) lib/lp/registry/scripts/tests/test_populate_distroseriesdiff.py (+3/-1) lib/lp/registry/services/sharingservice.py (+2/-1) lib/lp/scripts/utilities/warninghandler.py (+3/-1) lib/lp/services/command_spawner.py (+1/-1) lib/lp/services/config/__init__.py (+2/-1) lib/lp/services/database/bulk.py (+2/-1) lib/lp/services/features/testing.py (+2/-1) lib/lp/services/librarianserver/testing/fake.py (+3/-2) lib/lp/services/mail/basemailer.py (+2/-1) lib/lp/services/messaging/tests/test_rabbit.py (+2/-1) lib/lp/services/osutils.py (+3/-1) lib/lp/services/testing/customresult.py (+2/-1) lib/lp/services/utils.py (+2/-1) lib/lp/services/webapp/escaping.py (+2/-1) lib/lp/services/webapp/login.py (+1/-1) lib/lp/services/webapp/servers.py (+1/-1) lib/lp/services/webhooks/interfaces.py (+2/-1) lib/lp/soyuz/browser/tests/archive-views.txt (+3/-1) lib/lp/soyuz/model/packagediff.py (+2/-1) lib/lp/soyuz/model/publishing.py (+2/-1) lib/lp/soyuz/scripts/custom_uploads_copier.py (+3/-1) lib/lp/soyuz/scripts/gina/handlers.py (+2/-1) lib/lp/soyuz/scripts/gina/runner.py (+2/-2) lib/lp/testing/__init__.py (+4/-3) lib/lp/testing/swift/fakeswift.py (+2/-1) lib/lp/translations/browser/translationlinksaggregator.py (+4/-2) lib/lp/translations/browser/translationmessage.py (+3/-2) lib/lp/translations/doc/translationimportqueue.txt (+3/-1) lib/lp/translations/model/potemplate.py (+2/-1) lib/lp/translations/model/potmsgset.py (+4/-3) lib/lp/translations/model/translationimportqueue.py (+3/-1) lib/lp/translations/model/translationsharingjob.py (+2/-2) lib/lp/translations/scripts/po_import.py (+2/-1) lib/lp/translations/scripts/tests/test_reupload_translations.py (+3/-2) lib/lp/translations/scripts/tests/test_translations_to_branch.py (+4/-3) lib/lp/translations/stories/webservice/xx-translationimportqueue.txt (+1/-1) lib/lp/translations/tests/test_potemplate.py (+3/-2) lib/lp/translations/tests/test_side.py (+3/-2) lib/lp/translations/utilities/gettext_po_parser.py (+3/-2) lib/lp/translations/utilities/pluralforms.py (+3/-1) lib/lp/translations/utilities/tests/test_translation_importer.py (+2/-1) lib/lp/translations/utilities/translation_import.py (+3/-2) lib/lp/translations/utilities/translationmerger.py (+3/-3) lib/lp/translations/utilities/validate.py (+2/-1) utilities/findimports.py (+3/-1) utilities/generate-external-bug-status-docs (+3/-1) utilities/list-pages (+2/-1) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Thiago F. Pappacena (community) | Approve | ||
Review via email: mp+383369@code.launchpad.net |
Commit message
Use six for dict iteration
Description of the change
`dict.iterkeys()` can just be replaced with `dict` if the result is being iterated over, since `iter(dict)` iterates over its keys. Otherwise, `dict.iter{
Thiago F. Pappacena (pappacena) wrote : | # |
Colin Watson (cjwatson) wrote : | # |
Well, but that last isn't true; on Python 2, six.itervalues(
Mainly I wanted to use a reasonably obvious mechanical transformation that didn't require me to reason about whether there might be a real performance implication in any of the >130 cases here. A secondary benefit was that it means that we don't lose information as part of this commit: we can still look at the existing calls to dict.values and consider whether those might need to take a copy (I've certainly run across some that do, for example because the loop body deletes items from the dict). Doing that across the whole tree is a large chunk of work that I haven't tackled yet.
So, it's true it's not strictly necessary to use six.iter*, but I did think that it was worthwhile and better than reverting to bare .values() etc. in a systematic way.
Thiago F. Pappacena (pappacena) wrote : | # |
Fair enough. In that case, LGTM.
Preview Diff
1 | diff --git a/brzplugins/lpserve/__init__.py b/brzplugins/lpserve/__init__.py | |||
2 | index b956568..3ce2081 100644 | |||
3 | --- a/brzplugins/lpserve/__init__.py | |||
4 | +++ b/brzplugins/lpserve/__init__.py | |||
5 | @@ -48,6 +48,7 @@ from breezy.transport import ( | |||
6 | 48 | get_transport, | 48 | get_transport, |
7 | 49 | transport_server_registry, | 49 | transport_server_registry, |
8 | 50 | ) | 50 | ) |
9 | 51 | import six | ||
10 | 51 | 52 | ||
11 | 52 | 53 | ||
12 | 53 | class cmd_launchpad_server(Command): | 54 | class cmd_launchpad_server(Command): |
13 | @@ -591,7 +592,7 @@ class LPForkingService(object): | |||
14 | 591 | pid = os.getpid() | 592 | pid = os.getpid() |
15 | 592 | trace.mutter('%d spawned' % (pid,)) | 593 | trace.mutter('%d spawned' % (pid,)) |
16 | 593 | self._server_socket.close() | 594 | self._server_socket.close() |
18 | 594 | for env_var, value in env.iteritems(): | 595 | for env_var, value in six.iteritems(env): |
19 | 595 | osutils.set_or_unset_env(env_var, value) | 596 | osutils.set_or_unset_env(env_var, value) |
20 | 596 | # See [Decision #3] | 597 | # See [Decision #3] |
21 | 597 | self._create_child_file_descriptors(temp_name) | 598 | self._create_child_file_descriptors(temp_name) |
22 | @@ -769,7 +770,7 @@ class LPForkingService(object): | |||
23 | 769 | # We sent the SIGKILL signal, see if they exited | 770 | # We sent the SIGKILL signal, see if they exited |
24 | 770 | self._wait_for_children(self.SLEEP_FOR_CHILDREN_TIMEOUT) | 771 | self._wait_for_children(self.SLEEP_FOR_CHILDREN_TIMEOUT) |
25 | 771 | if self._child_processes: | 772 | if self._child_processes: |
27 | 772 | for c_id, (c_path, sock) in self._child_processes.iteritems(): | 773 | for c_id, (c_path, sock) in six.iteritems(self._child_processes): |
28 | 773 | # TODO: We should probably put something into this message? | 774 | # TODO: We should probably put something into this message? |
29 | 774 | # However, the likelyhood is very small that this isn't | 775 | # However, the likelyhood is very small that this isn't |
30 | 775 | # already closed because of SIGKILL + _wait_for_children | 776 | # already closed because of SIGKILL + _wait_for_children |
31 | diff --git a/brzplugins/lpserve/test_lpserve.py b/brzplugins/lpserve/test_lpserve.py | |||
32 | index 3801df4..1420ed7 100644 | |||
33 | --- a/brzplugins/lpserve/test_lpserve.py | |||
34 | +++ b/brzplugins/lpserve/test_lpserve.py | |||
35 | @@ -18,6 +18,7 @@ from breezy import ( | |||
36 | 18 | trace, | 18 | trace, |
37 | 19 | ) | 19 | ) |
38 | 20 | from breezy.plugins import lpserve | 20 | from breezy.plugins import lpserve |
39 | 21 | import six | ||
40 | 21 | from testtools import content | 22 | from testtools import content |
41 | 22 | 23 | ||
42 | 23 | from lp.codehosting import ( | 24 | from lp.codehosting import ( |
43 | @@ -336,11 +337,11 @@ class TestCaseWithSubprocess(tests.TestCaseWithTransport): | |||
44 | 336 | old_env = {} | 337 | old_env = {} |
45 | 337 | 338 | ||
46 | 338 | def cleanup_environment(): | 339 | def cleanup_environment(): |
48 | 339 | for env_var, value in env_changes.iteritems(): | 340 | for env_var, value in six.iteritems(env_changes): |
49 | 340 | old_env[env_var] = osutils.set_or_unset_env(env_var, value) | 341 | old_env[env_var] = osutils.set_or_unset_env(env_var, value) |
50 | 341 | 342 | ||
51 | 342 | def restore_environment(): | 343 | def restore_environment(): |
53 | 343 | for env_var, value in old_env.iteritems(): | 344 | for env_var, value in six.iteritems(old_env): |
54 | 344 | osutils.set_or_unset_env(env_var, value) | 345 | osutils.set_or_unset_env(env_var, value) |
55 | 345 | 346 | ||
56 | 346 | cwd = None | 347 | cwd = None |
57 | @@ -406,7 +407,7 @@ class TestCaseWithLPForkingServiceSubprocess(TestCaseWithSubprocess): | |||
58 | 406 | def send_fork_request(self, command, env=None): | 407 | def send_fork_request(self, command, env=None): |
59 | 407 | if env is not None: | 408 | if env is not None: |
60 | 408 | request_lines = ['fork-env %s\n' % (command,)] | 409 | request_lines = ['fork-env %s\n' % (command,)] |
62 | 409 | for key, value in env.iteritems(): | 410 | for key, value in six.iteritems(env): |
63 | 410 | request_lines.append('%s: %s\n' % (key, value)) | 411 | request_lines.append('%s: %s\n' % (key, value)) |
64 | 411 | request_lines.append('end\n') | 412 | request_lines.append('end\n') |
65 | 412 | request = ''.join(request_lines) | 413 | request = ''.join(request_lines) |
66 | diff --git a/database/schema/security.py b/database/schema/security.py | |||
67 | index 1c53659..274bb03 100755 | |||
68 | --- a/database/schema/security.py | |||
69 | +++ b/database/schema/security.py | |||
70 | @@ -13,6 +13,8 @@ import os | |||
71 | 13 | import re | 13 | import re |
72 | 14 | import sys | 14 | import sys |
73 | 15 | 15 | ||
74 | 16 | import six | ||
75 | 17 | |||
76 | 16 | from fti import quote_identifier | 18 | from fti import quote_identifier |
77 | 17 | from lp.services.compat import SafeConfigParser | 19 | from lp.services.compat import SafeConfigParser |
78 | 18 | from lp.services.database.sqlbase import connect | 20 | from lp.services.database.sqlbase import connect |
79 | @@ -302,8 +304,8 @@ class PermissionGatherer: | |||
80 | 302 | to grant or revoke for. Each is a string. | 304 | to grant or revoke for. Each is a string. |
81 | 303 | """ | 305 | """ |
82 | 304 | result = [] | 306 | result = [] |
85 | 305 | for permission, parties in self.permissions.iteritems(): | 307 | for permission, parties in six.iteritems(self.permissions): |
86 | 306 | for principal, entities in parties.iteritems(): | 308 | for principal, entities in six.iteritems(parties): |
87 | 307 | result.append( | 309 | result.append( |
88 | 308 | (permission, ", ".join(entities), principal)) | 310 | (permission, ", ".join(entities), principal)) |
89 | 309 | return result | 311 | return result |
90 | @@ -315,8 +317,8 @@ class PermissionGatherer: | |||
91 | 315 | def countEntities(self): | 317 | def countEntities(self): |
92 | 316 | """Count the number of different entities.""" | 318 | """Count the number of different entities.""" |
93 | 317 | entities = set() | 319 | entities = set() |
96 | 318 | for entities_and_entities in self.permissions.itervalues(): | 320 | for entities_and_entities in six.itervalues(self.permissions): |
97 | 319 | for extra_entities in entities_and_entities.itervalues(): | 321 | for extra_entities in six.itervalues(entities_and_entities): |
98 | 320 | entities.update(extra_entities) | 322 | entities.update(extra_entities) |
99 | 321 | return len(entities) | 323 | return len(entities) |
100 | 322 | 324 | ||
101 | @@ -324,7 +326,7 @@ class PermissionGatherer: | |||
102 | 324 | """Count the number of different principals.""" | 326 | """Count the number of different principals.""" |
103 | 325 | return len(set(sum([ | 327 | return len(set(sum([ |
104 | 326 | principals.keys() | 328 | principals.keys() |
106 | 327 | for principals in self.permissions.itervalues()], []))) | 329 | for principals in six.itervalues(self.permissions)], []))) |
107 | 328 | 330 | ||
108 | 329 | def grant(self, cur): | 331 | def grant(self, cur): |
109 | 330 | """Grant all gathered permissions. | 332 | """Grant all gathered permissions. |
110 | @@ -480,7 +482,7 @@ def reset_permissions(con, config, options): | |||
111 | 480 | 482 | ||
112 | 481 | log.debug('Updating group memberships') | 483 | log.debug('Updating group memberships') |
113 | 482 | existing_memberships = list_role_members(cur, memberships.keys()) | 484 | existing_memberships = list_role_members(cur, memberships.keys()) |
115 | 483 | for group, users in memberships.iteritems(): | 485 | for group, users in six.iteritems(memberships): |
116 | 484 | cur_users = managed_roles.intersection(existing_memberships[group]) | 486 | cur_users = managed_roles.intersection(existing_memberships[group]) |
117 | 485 | to_grant = users - cur_users | 487 | to_grant = users - cur_users |
118 | 486 | if to_grant: | 488 | if to_grant: |
119 | @@ -517,7 +519,7 @@ def reset_permissions(con, config, options): | |||
120 | 517 | # Set permissions as per config file | 519 | # Set permissions as per config file |
121 | 518 | desired_permissions = defaultdict(lambda: defaultdict(set)) | 520 | desired_permissions = defaultdict(lambda: defaultdict(set)) |
122 | 519 | 521 | ||
124 | 520 | valid_objs = set(schema.iterkeys()) | 522 | valid_objs = set(schema) |
125 | 521 | 523 | ||
126 | 522 | # Any object with permissions granted is accessible to the 'read' | 524 | # Any object with permissions granted is accessible to the 'read' |
127 | 523 | # role. Some (eg. the lp_* replicated tables and internal or trigger | 525 | # role. Some (eg. the lp_* replicated tables and internal or trigger |
128 | @@ -618,7 +620,7 @@ def reset_permissions(con, config, options): | |||
129 | 618 | new = desired_permissions[obj][role] | 620 | new = desired_permissions[obj][role] |
130 | 619 | old_privs = obj.acl.get(role, {}) | 621 | old_privs = obj.acl.get(role, {}) |
131 | 620 | old = set(old_privs) | 622 | old = set(old_privs) |
133 | 621 | if any(old_privs.itervalues()): | 623 | if any(six.itervalues(old_privs)): |
134 | 622 | log.warning("%s has grant option on %s", role, obj.fullname) | 624 | log.warning("%s has grant option on %s", role, obj.fullname) |
135 | 623 | if new == old: | 625 | if new == old: |
136 | 624 | continue | 626 | continue |
137 | diff --git a/lib/contrib/oauth.py b/lib/contrib/oauth.py | |||
138 | index 47a821d..2d11e6c 100644 | |||
139 | --- a/lib/contrib/oauth.py | |||
140 | +++ b/lib/contrib/oauth.py | |||
141 | @@ -3,6 +3,7 @@ import hmac | |||
142 | 3 | import random | 3 | import random |
143 | 4 | import time | 4 | import time |
144 | 5 | 5 | ||
145 | 6 | import six | ||
146 | 6 | from six.moves.urllib.parse import ( | 7 | from six.moves.urllib.parse import ( |
147 | 7 | parse_qs, | 8 | parse_qs, |
148 | 8 | quote, | 9 | quote, |
149 | @@ -118,7 +119,7 @@ class OAuthRequest(object): | |||
150 | 118 | # get any non-oauth parameters | 119 | # get any non-oauth parameters |
151 | 119 | def get_nonoauth_parameters(self): | 120 | def get_nonoauth_parameters(self): |
152 | 120 | parameters = {} | 121 | parameters = {} |
154 | 121 | for k, v in self.parameters.iteritems(): | 122 | for k, v in six.iteritems(self.parameters): |
155 | 122 | # ignore oauth parameters | 123 | # ignore oauth parameters |
156 | 123 | if k.find('oauth_') < 0: | 124 | if k.find('oauth_') < 0: |
157 | 124 | parameters[k] = v | 125 | parameters[k] = v |
158 | @@ -129,13 +130,15 @@ class OAuthRequest(object): | |||
159 | 129 | auth_header = 'OAuth realm="%s"' % realm | 130 | auth_header = 'OAuth realm="%s"' % realm |
160 | 130 | # add the oauth parameters | 131 | # add the oauth parameters |
161 | 131 | if self.parameters: | 132 | if self.parameters: |
163 | 132 | for k, v in self.parameters.iteritems(): | 133 | for k, v in six.iteritems(self.parameters): |
164 | 133 | auth_header += ', %s="%s"' % (k, v) | 134 | auth_header += ', %s="%s"' % (k, v) |
165 | 134 | return {'Authorization': auth_header} | 135 | return {'Authorization': auth_header} |
166 | 135 | 136 | ||
167 | 136 | # serialize as post data for a POST request | 137 | # serialize as post data for a POST request |
168 | 137 | def to_postdata(self): | 138 | def to_postdata(self): |
170 | 138 | return '&'.join('%s=%s' % (escape(str(k)), escape(str(v))) for k, v in self.parameters.iteritems()) | 139 | return '&'.join( |
171 | 140 | '%s=%s' % (escape(str(k)), escape(str(v))) | ||
172 | 141 | for k, v in six.iteritems(self.parameters)) | ||
173 | 139 | 142 | ||
174 | 140 | # serialize as a url for a GET request | 143 | # serialize as a url for a GET request |
175 | 141 | def to_url(self): | 144 | def to_url(self): |
176 | @@ -269,7 +272,7 @@ class OAuthRequest(object): | |||
177 | 269 | @staticmethod | 272 | @staticmethod |
178 | 270 | def _split_url_string(param_str): | 273 | def _split_url_string(param_str): |
179 | 271 | parameters = parse_qs(param_str, keep_blank_values=False) | 274 | parameters = parse_qs(param_str, keep_blank_values=False) |
181 | 272 | for k, v in parameters.iteritems(): | 275 | for k, v in six.iteritems(parameters): |
182 | 273 | parameters[k] = unquote(v[0]) | 276 | parameters[k] = unquote(v[0]) |
183 | 274 | return parameters | 277 | return parameters |
184 | 275 | 278 | ||
185 | diff --git a/lib/lp/app/browser/launchpadform.py b/lib/lp/app/browser/launchpadform.py | |||
186 | index ac6dd15..8899cbd 100644 | |||
187 | --- a/lib/lp/app/browser/launchpadform.py | |||
188 | +++ b/lib/lp/app/browser/launchpadform.py | |||
189 | @@ -19,6 +19,7 @@ __all__ = [ | |||
190 | 19 | from lazr.lifecycle.event import ObjectModifiedEvent | 19 | from lazr.lifecycle.event import ObjectModifiedEvent |
191 | 20 | from lazr.lifecycle.snapshot import Snapshot | 20 | from lazr.lifecycle.snapshot import Snapshot |
192 | 21 | import simplejson | 21 | import simplejson |
193 | 22 | import six | ||
194 | 22 | import transaction | 23 | import transaction |
195 | 23 | from zope.event import notify | 24 | from zope.event import notify |
196 | 24 | from zope.formlib import form | 25 | from zope.formlib import form |
197 | @@ -213,7 +214,7 @@ class LaunchpadFormView(LaunchpadView): | |||
198 | 213 | self.form_fields, self.prefix, context, self.request, | 214 | self.form_fields, self.prefix, context, self.request, |
199 | 214 | data=self.initial_values, adapters=self.adapters, | 215 | data=self.initial_values, adapters=self.adapters, |
200 | 215 | ignore_request=False) | 216 | ignore_request=False) |
202 | 216 | for field_name, help_link in self.help_links.iteritems(): | 217 | for field_name, help_link in six.iteritems(self.help_links): |
203 | 217 | self.widgets[field_name].help_link = help_link | 218 | self.widgets[field_name].help_link = help_link |
204 | 218 | 219 | ||
205 | 219 | @property | 220 | @property |
206 | diff --git a/lib/lp/app/browser/tales.py b/lib/lp/app/browser/tales.py | |||
207 | index df20fcb..8e4921e 100644 | |||
208 | --- a/lib/lp/app/browser/tales.py | |||
209 | +++ b/lib/lp/app/browser/tales.py | |||
210 | @@ -23,6 +23,7 @@ from lazr.enum import enumerated_type_registry | |||
211 | 23 | from lazr.restful.utils import get_current_browser_request | 23 | from lazr.restful.utils import get_current_browser_request |
212 | 24 | from lazr.uri import URI | 24 | from lazr.uri import URI |
213 | 25 | import pytz | 25 | import pytz |
214 | 26 | import six | ||
215 | 26 | from six.moves.urllib.parse import quote | 27 | from six.moves.urllib.parse import quote |
216 | 27 | from zope.browserpage import ViewPageTemplateFile | 28 | from zope.browserpage import ViewPageTemplateFile |
217 | 28 | from zope.component import ( | 29 | from zope.component import ( |
218 | @@ -1418,7 +1419,7 @@ class CustomizableFormatter(ObjectFormatterAPI): | |||
219 | 1418 | """ | 1419 | """ |
220 | 1419 | values = dict( | 1420 | values = dict( |
221 | 1420 | (k, v if v is not None else '') | 1421 | (k, v if v is not None else '') |
223 | 1421 | for k, v in self._link_summary_values().iteritems()) | 1422 | for k, v in six.iteritems(self._link_summary_values())) |
224 | 1422 | return structured(self._link_summary_template, **values).escapedtext | 1423 | return structured(self._link_summary_template, **values).escapedtext |
225 | 1423 | 1424 | ||
226 | 1424 | def _title_values(self): | 1425 | def _title_values(self): |
227 | @@ -1440,7 +1441,7 @@ class CustomizableFormatter(ObjectFormatterAPI): | |||
228 | 1440 | return None | 1441 | return None |
229 | 1441 | values = dict( | 1442 | values = dict( |
230 | 1442 | (k, v if v is not None else '') | 1443 | (k, v if v is not None else '') |
232 | 1443 | for k, v in self._title_values().iteritems()) | 1444 | for k, v in six.iteritems(self._title_values())) |
233 | 1444 | return structured(title_template, **values).escapedtext | 1445 | return structured(title_template, **values).escapedtext |
234 | 1445 | 1446 | ||
235 | 1446 | def sprite_css(self): | 1447 | def sprite_css(self): |
236 | diff --git a/lib/lp/archivepublisher/domination.py b/lib/lp/archivepublisher/domination.py | |||
237 | index a02fd78..356a2ee 100644 | |||
238 | --- a/lib/lp/archivepublisher/domination.py | |||
239 | +++ b/lib/lp/archivepublisher/domination.py | |||
240 | @@ -60,6 +60,7 @@ from operator import ( | |||
241 | 60 | ) | 60 | ) |
242 | 61 | 61 | ||
243 | 62 | import apt_pkg | 62 | import apt_pkg |
244 | 63 | import six | ||
245 | 63 | from six.moves import ( | 64 | from six.moves import ( |
246 | 64 | filter as ifilter, | 65 | filter as ifilter, |
247 | 65 | filterfalse as ifilterfalse, | 66 | filterfalse as ifilterfalse, |
248 | @@ -669,7 +670,7 @@ class Dominator: | |||
249 | 669 | bins = self.findBinariesForDomination(distroarchseries, pocket) | 670 | bins = self.findBinariesForDomination(distroarchseries, pocket) |
250 | 670 | sorted_packages = self._sortPackages(bins, generalization) | 671 | sorted_packages = self._sortPackages(bins, generalization) |
251 | 671 | self.logger.info("Planning domination of binaries...") | 672 | self.logger.info("Planning domination of binaries...") |
253 | 672 | for name, pubs in sorted_packages.iteritems(): | 673 | for name, pubs in six.iteritems(sorted_packages): |
254 | 673 | self.logger.debug("Planning domination of %s" % name) | 674 | self.logger.debug("Planning domination of %s" % name) |
255 | 674 | assert len(pubs) > 0, "Dominating zero binaries!" | 675 | assert len(pubs) > 0, "Dominating zero binaries!" |
256 | 675 | live_versions = find_live_binary_versions_pass_1(pubs) | 676 | live_versions = find_live_binary_versions_pass_1(pubs) |
257 | @@ -774,7 +775,7 @@ class Dominator: | |||
258 | 774 | delete = [] | 775 | delete = [] |
259 | 775 | 776 | ||
260 | 776 | self.logger.debug("Dominating sources...") | 777 | self.logger.debug("Dominating sources...") |
262 | 777 | for name, pubs in sorted_packages.iteritems(): | 778 | for name, pubs in six.iteritems(sorted_packages): |
263 | 778 | self.logger.debug("Dominating %s" % name) | 779 | self.logger.debug("Dominating %s" % name) |
264 | 779 | assert len(pubs) > 0, "Dominating zero sources!" | 780 | assert len(pubs) > 0, "Dominating zero sources!" |
265 | 780 | live_versions = find_live_source_versions(pubs) | 781 | live_versions = find_live_source_versions(pubs) |
266 | diff --git a/lib/lp/archivepublisher/model/ftparchive.py b/lib/lp/archivepublisher/model/ftparchive.py | |||
267 | index 39e7d40..6fe3c3c 100644 | |||
268 | --- a/lib/lp/archivepublisher/model/ftparchive.py | |||
269 | +++ b/lib/lp/archivepublisher/model/ftparchive.py | |||
270 | @@ -8,6 +8,7 @@ from StringIO import StringIO | |||
271 | 8 | import time | 8 | import time |
272 | 9 | 9 | ||
273 | 10 | import scandir | 10 | import scandir |
274 | 11 | import six | ||
275 | 11 | from storm.expr import ( | 12 | from storm.expr import ( |
276 | 12 | Desc, | 13 | Desc, |
277 | 13 | Join, | 14 | Join, |
278 | @@ -201,7 +202,7 @@ class FTPArchiveHandler: | |||
279 | 201 | stderr_handler.finalize() | 202 | stderr_handler.finalize() |
280 | 202 | failures = sorted([ | 203 | failures = sorted([ |
281 | 203 | (tag, receiver.returncode) | 204 | (tag, receiver.returncode) |
283 | 204 | for tag, receiver in returncodes.iteritems() | 205 | for tag, receiver in six.iteritems(returncodes) |
284 | 205 | if receiver.returncode != 0]) | 206 | if receiver.returncode != 0]) |
285 | 206 | if len(failures) > 0: | 207 | if len(failures) > 0: |
286 | 207 | by_arch = ["%s (returned %d)" % failure for failure in failures] | 208 | by_arch = ["%s (returned %d)" % failure for failure in failures] |
287 | @@ -694,8 +695,8 @@ class FTPArchiveHandler: | |||
288 | 694 | 695 | ||
289 | 695 | self.log.debug("Writing file lists for %s" % suite) | 696 | self.log.debug("Writing file lists for %s" % suite) |
290 | 696 | series, pocket = self.distro.getDistroSeriesAndPocket(suite) | 697 | series, pocket = self.distro.getDistroSeriesAndPocket(suite) |
293 | 697 | for component, architectures in filelist.iteritems(): | 698 | for component, architectures in six.iteritems(filelist): |
294 | 698 | for architecture, file_names in architectures.iteritems(): | 699 | for architecture, file_names in six.iteritems(architectures): |
295 | 699 | # XXX wgrant 2010-10-06: There must be a better place to do | 700 | # XXX wgrant 2010-10-06: There must be a better place to do |
296 | 700 | # this. | 701 | # this. |
297 | 701 | if architecture == "source": | 702 | if architecture == "source": |
298 | diff --git a/lib/lp/archivepublisher/publishing.py b/lib/lp/archivepublisher/publishing.py | |||
299 | index cd19ed8..f6246b0 100644 | |||
300 | --- a/lib/lp/archivepublisher/publishing.py | |||
301 | +++ b/lib/lp/archivepublisher/publishing.py | |||
302 | @@ -36,6 +36,7 @@ from debian.deb822 import ( | |||
303 | 36 | Release, | 36 | Release, |
304 | 37 | ) | 37 | ) |
305 | 38 | import scandir | 38 | import scandir |
306 | 39 | import six | ||
307 | 39 | from storm.expr import Desc | 40 | from storm.expr import Desc |
308 | 40 | from zope.component import getUtility | 41 | from zope.component import getUtility |
309 | 41 | from zope.interface import ( | 42 | from zope.interface import ( |
310 | @@ -984,7 +985,7 @@ class Publisher(object): | |||
311 | 984 | translation_stanza.makeOutput().encode('utf-8') | 985 | translation_stanza.makeOutput().encode('utf-8') |
312 | 985 | + '\n\n') | 986 | + '\n\n') |
313 | 986 | 987 | ||
315 | 987 | for index in indices.itervalues(): | 988 | for index in six.itervalues(indices): |
316 | 988 | index.close() | 989 | index.close() |
317 | 989 | 990 | ||
318 | 990 | if separate_long_descriptions: | 991 | if separate_long_descriptions: |
319 | diff --git a/lib/lp/archivepublisher/scripts/publish_ftpmaster.py b/lib/lp/archivepublisher/scripts/publish_ftpmaster.py | |||
320 | index 5fcd7d3..c307846 100644 | |||
321 | --- a/lib/lp/archivepublisher/scripts/publish_ftpmaster.py | |||
322 | +++ b/lib/lp/archivepublisher/scripts/publish_ftpmaster.py | |||
323 | @@ -15,6 +15,7 @@ import shutil | |||
324 | 15 | 15 | ||
325 | 16 | from pytz import utc | 16 | from pytz import utc |
326 | 17 | import scandir | 17 | import scandir |
327 | 18 | import six | ||
328 | 18 | from zope.component import getUtility | 19 | from zope.component import getUtility |
329 | 19 | 20 | ||
330 | 20 | from lp.archivepublisher.config import getPubConfig | 21 | from lp.archivepublisher.config import getPubConfig |
331 | @@ -224,9 +225,7 @@ class PublishFTPMaster(LaunchpadCronScript): | |||
332 | 224 | return [] | 225 | return [] |
333 | 225 | 226 | ||
334 | 226 | # May need indexes for this series. | 227 | # May need indexes for this series. |
338 | 227 | suites = [ | 228 | suites = [distroseries.getSuite(pocket) for pocket in pocketsuffix] |
336 | 228 | distroseries.getSuite(pocket) | ||
337 | 229 | for pocket in pocketsuffix.iterkeys()] | ||
339 | 230 | return [ | 229 | return [ |
340 | 231 | suite for suite in suites | 230 | suite for suite in suites |
341 | 232 | if not file_exists(self.locateIndexesMarker(distro, suite))] | 231 | if not file_exists(self.locateIndexesMarker(distro, suite))] |
342 | @@ -289,7 +288,8 @@ class PublishFTPMaster(LaunchpadCronScript): | |||
343 | 289 | 288 | ||
344 | 290 | :param archive_purpose: The (purpose of the) archive to copy. | 289 | :param archive_purpose: The (purpose of the) archive to copy. |
345 | 291 | """ | 290 | """ |
347 | 292 | for purpose, archive_config in self.configs[distribution].iteritems(): | 291 | for purpose, archive_config in ( |
348 | 292 | six.iteritems(self.configs[distribution])): | ||
349 | 293 | dists = get_dists(archive_config) | 293 | dists = get_dists(archive_config) |
350 | 294 | backup_dists = get_backup_dists(archive_config) | 294 | backup_dists = get_backup_dists(archive_config) |
351 | 295 | execute_subprocess( | 295 | execute_subprocess( |
352 | @@ -319,14 +319,15 @@ class PublishFTPMaster(LaunchpadCronScript): | |||
353 | 319 | run died while in this state, restore the directory to its | 319 | run died while in this state, restore the directory to its |
354 | 320 | permanent location. | 320 | permanent location. |
355 | 321 | """ | 321 | """ |
358 | 322 | for distro_configs in self.configs.itervalues(): | 322 | for distro_configs in six.itervalues(self.configs): |
359 | 323 | for archive_config in distro_configs.itervalues(): | 323 | for archive_config in six.itervalues(distro_configs): |
360 | 324 | self.recoverArchiveWorkingDir(archive_config) | 324 | self.recoverArchiveWorkingDir(archive_config) |
361 | 325 | 325 | ||
362 | 326 | def setUpDirs(self): | 326 | def setUpDirs(self): |
363 | 327 | """Create archive roots and such if they did not yet exist.""" | 327 | """Create archive roots and such if they did not yet exist.""" |
366 | 328 | for distro_configs in self.configs.itervalues(): | 328 | for distro_configs in six.itervalues(self.configs): |
367 | 329 | for archive_purpose, archive_config in distro_configs.iteritems(): | 329 | for archive_purpose, archive_config in ( |
368 | 330 | six.iteritems(distro_configs)): | ||
369 | 330 | archiveroot = archive_config.archiveroot | 331 | archiveroot = archive_config.archiveroot |
370 | 331 | if not file_exists(archiveroot): | 332 | if not file_exists(archiveroot): |
371 | 332 | self.logger.debug( | 333 | self.logger.debug( |
372 | @@ -407,7 +408,7 @@ class PublishFTPMaster(LaunchpadCronScript): | |||
373 | 407 | backup dists directory around. | 408 | backup dists directory around. |
374 | 408 | """ | 409 | """ |
375 | 409 | self.logger.debug("Moving the new dists into place...") | 410 | self.logger.debug("Moving the new dists into place...") |
377 | 410 | for archive_config in self.configs[distribution].itervalues(): | 411 | for archive_config in six.itervalues(self.configs[distribution]): |
378 | 411 | # Use the dists "working location" as a temporary place to | 412 | # Use the dists "working location" as a temporary place to |
379 | 412 | # move the current dists out of the way for the switch. If | 413 | # move the current dists out of the way for the switch. If |
380 | 413 | # we die in this state, the next run will know to move the | 414 | # we die in this state, the next run will know to move the |
381 | @@ -422,7 +423,7 @@ class PublishFTPMaster(LaunchpadCronScript): | |||
382 | 422 | 423 | ||
383 | 423 | def clearEmptyDirs(self, distribution): | 424 | def clearEmptyDirs(self, distribution): |
384 | 424 | """Clear out any redundant empty directories.""" | 425 | """Clear out any redundant empty directories.""" |
386 | 425 | for archive_config in self.configs[distribution].itervalues(): | 426 | for archive_config in six.itervalues(self.configs[distribution]): |
387 | 426 | execute_subprocess( | 427 | execute_subprocess( |
388 | 427 | ["find", archive_config.archiveroot, "-type", "d", "-empty", | 428 | ["find", archive_config.archiveroot, "-type", "d", "-empty", |
389 | 428 | "-delete"], | 429 | "-delete"], |
390 | @@ -432,7 +433,7 @@ class PublishFTPMaster(LaunchpadCronScript): | |||
391 | 432 | """Run the finalize.d parts to finalize publication.""" | 433 | """Run the finalize.d parts to finalize publication.""" |
392 | 433 | archive_roots = ' '.join([ | 434 | archive_roots = ' '.join([ |
393 | 434 | archive_config.archiveroot | 435 | archive_config.archiveroot |
395 | 435 | for archive_config in self.configs[distribution].itervalues()]) | 436 | for archive_config in six.itervalues(self.configs[distribution])]) |
396 | 436 | 437 | ||
397 | 437 | env = { | 438 | env = { |
398 | 438 | 'SECURITY_UPLOAD_ONLY': 'yes' if security_only else 'no', | 439 | 'SECURITY_UPLOAD_ONLY': 'yes' if security_only else 'no', |
399 | diff --git a/lib/lp/archivepublisher/tests/test_dominator.py b/lib/lp/archivepublisher/tests/test_dominator.py | |||
400 | index b88da56..4d073e0 100755 | |||
401 | --- a/lib/lp/archivepublisher/tests/test_dominator.py | |||
402 | +++ b/lib/lp/archivepublisher/tests/test_dominator.py | |||
403 | @@ -11,6 +11,7 @@ import datetime | |||
404 | 11 | from operator import attrgetter | 11 | from operator import attrgetter |
405 | 12 | 12 | ||
406 | 13 | import apt_pkg | 13 | import apt_pkg |
407 | 14 | import six | ||
408 | 14 | from testtools.matchers import ( | 15 | from testtools.matchers import ( |
409 | 15 | GreaterThan, | 16 | GreaterThan, |
410 | 16 | LessThan, | 17 | LessThan, |
411 | @@ -813,14 +814,14 @@ class TestDominatorMethods(TestCaseWithFactory): | |||
412 | 813 | # Actually the "oldest to newest" order on the publications only | 814 | # Actually the "oldest to newest" order on the publications only |
413 | 814 | # applies to their creation dates. Their creation orders are | 815 | # applies to their creation dates. Their creation orders are |
414 | 815 | # irrelevant. | 816 | # irrelevant. |
416 | 816 | for pubs_list in pubs_by_version.itervalues(): | 817 | for pubs_list in six.itervalues(pubs_by_version): |
417 | 817 | alter_creation_dates(pubs_list, ages) | 818 | alter_creation_dates(pubs_list, ages) |
418 | 818 | pubs_list.sort(key=attrgetter('datecreated')) | 819 | pubs_list.sort(key=attrgetter('datecreated')) |
419 | 819 | 820 | ||
420 | 820 | live_versions = ["1.1", "1.2"] | 821 | live_versions = ["1.1", "1.2"] |
421 | 821 | last_version_alive = sorted(live_versions)[-1] | 822 | last_version_alive = sorted(live_versions)[-1] |
422 | 822 | 823 | ||
424 | 823 | all_pubs = sum(pubs_by_version.itervalues(), []) | 824 | all_pubs = sum(six.itervalues(pubs_by_version), []) |
425 | 824 | dominator = Dominator(DevNullLogger(), series.main_archive) | 825 | dominator = Dominator(DevNullLogger(), series.main_archive) |
426 | 825 | supersede, _, delete = dominator.planPackageDomination( | 826 | supersede, _, delete = dominator.planPackageDomination( |
427 | 826 | generalization.sortPublications(all_pubs), live_versions, | 827 | generalization.sortPublications(all_pubs), live_versions, |
428 | diff --git a/lib/lp/archivepublisher/tests/test_publish_ftpmaster.py b/lib/lp/archivepublisher/tests/test_publish_ftpmaster.py | |||
429 | index 8c99b73..450da11 100644 | |||
430 | --- a/lib/lp/archivepublisher/tests/test_publish_ftpmaster.py | |||
431 | +++ b/lib/lp/archivepublisher/tests/test_publish_ftpmaster.py | |||
432 | @@ -121,8 +121,7 @@ def get_a_suite(distroseries): | |||
433 | 121 | 121 | ||
434 | 122 | def get_marker_files(script, distroseries): | 122 | def get_marker_files(script, distroseries): |
435 | 123 | """Return filesystem paths for all indexes markers for `distroseries`.""" | 123 | """Return filesystem paths for all indexes markers for `distroseries`.""" |
438 | 124 | suites = [ | 124 | suites = [distroseries.getSuite(pocket) for pocket in pocketsuffix] |
437 | 125 | distroseries.getSuite(pocket) for pocket in pocketsuffix.iterkeys()] | ||
439 | 126 | distro = distroseries.distribution | 125 | distro = distroseries.distribution |
440 | 127 | return [script.locateIndexesMarker(distro, suite) for suite in suites] | 126 | return [script.locateIndexesMarker(distro, suite) for suite in suites] |
441 | 128 | 127 | ||
442 | @@ -998,7 +997,7 @@ class TestCreateDistroSeriesIndexes(TestCaseWithFactory, HelpersMixin): | |||
443 | 998 | script = self.makeScript(series.distribution) | 997 | script = self.makeScript(series.distribution) |
444 | 999 | script.setUp() | 998 | script.setUp() |
445 | 1000 | self.assertContentEqual( | 999 | self.assertContentEqual( |
447 | 1001 | [series.getSuite(pocket) for pocket in pocketsuffix.iterkeys()], | 1000 | [series.getSuite(pocket) for pocket in pocketsuffix], |
448 | 1002 | script.listSuitesNeedingIndexes(series)) | 1001 | script.listSuitesNeedingIndexes(series)) |
449 | 1003 | 1002 | ||
450 | 1004 | def test_listSuitesNeedingIndexes_is_empty_for_nonfrozen_series(self): | 1003 | def test_listSuitesNeedingIndexes_is_empty_for_nonfrozen_series(self): |
451 | @@ -1133,7 +1132,7 @@ class TestCreateDistroSeriesIndexes(TestCaseWithFactory, HelpersMixin): | |||
452 | 1133 | [((given_distro, given_suites), kwargs)] = script.createIndexes.calls | 1132 | [((given_distro, given_suites), kwargs)] = script.createIndexes.calls |
453 | 1134 | self.assertEqual(distro, given_distro) | 1133 | self.assertEqual(distro, given_distro) |
454 | 1135 | self.assertContentEqual( | 1134 | self.assertContentEqual( |
456 | 1136 | [series.getSuite(pocket) for pocket in pocketsuffix.iterkeys()], | 1135 | [series.getSuite(pocket) for pocket in pocketsuffix], |
457 | 1137 | given_suites) | 1136 | given_suites) |
458 | 1138 | 1137 | ||
459 | 1139 | def test_createIndexes_ignores_other_series(self): | 1138 | def test_createIndexes_ignores_other_series(self): |
460 | diff --git a/lib/lp/archiveuploader/dscfile.py b/lib/lp/archiveuploader/dscfile.py | |||
461 | index 604193c..fbe1e25 100644 | |||
462 | --- a/lib/lp/archiveuploader/dscfile.py | |||
463 | +++ b/lib/lp/archiveuploader/dscfile.py | |||
464 | @@ -684,7 +684,7 @@ class DSCFile(SourceUploadFile, SignableTagFile): | |||
465 | 684 | ISourcePackageNameSet).getOrCreateByName(self.source) | 684 | ISourcePackageNameSet).getOrCreateByName(self.source) |
466 | 685 | 685 | ||
467 | 686 | user_defined_fields = self.extractUserDefinedFields([ | 686 | user_defined_fields = self.extractUserDefinedFields([ |
469 | 687 | (field, encoded[field]) for field in self._dict.iterkeys()]) | 687 | (field, encoded[field]) for field in self._dict]) |
470 | 688 | 688 | ||
471 | 689 | if self.changes.buildinfo is not None: | 689 | if self.changes.buildinfo is not None: |
472 | 690 | buildinfo_lfa = self.changes.buildinfo.storeInDatabase() | 690 | buildinfo_lfa = self.changes.buildinfo.storeInDatabase() |
473 | diff --git a/lib/lp/archiveuploader/nascentuploadfile.py b/lib/lp/archiveuploader/nascentuploadfile.py | |||
474 | index f28e43e..0791141 100644 | |||
475 | --- a/lib/lp/archiveuploader/nascentuploadfile.py | |||
476 | +++ b/lib/lp/archiveuploader/nascentuploadfile.py | |||
477 | @@ -26,6 +26,7 @@ import time | |||
478 | 26 | import apt_inst | 26 | import apt_inst |
479 | 27 | import apt_pkg | 27 | import apt_pkg |
480 | 28 | from debian.deb822 import Deb822Dict | 28 | from debian.deb822 import Deb822Dict |
481 | 29 | import six | ||
482 | 29 | from zope.component import getUtility | 30 | from zope.component import getUtility |
483 | 30 | 31 | ||
484 | 31 | from lp.app.errors import NotFoundError | 32 | from lp.app.errors import NotFoundError |
485 | @@ -218,7 +219,7 @@ class NascentUploadFile: | |||
486 | 218 | ckfile = open(self.filepath, "r") | 219 | ckfile = open(self.filepath, "r") |
487 | 219 | size = 0 | 220 | size = 0 |
488 | 220 | for chunk in filechunks(ckfile): | 221 | for chunk in filechunks(ckfile): |
490 | 221 | for digester in digesters.itervalues(): | 222 | for digester in six.itervalues(digesters): |
491 | 222 | digester.update(chunk) | 223 | digester.update(chunk) |
492 | 223 | size += len(chunk) | 224 | size += len(chunk) |
493 | 224 | ckfile.close() | 225 | ckfile.close() |
494 | @@ -905,7 +906,7 @@ class BaseBinaryUploadFile(PackageUploadFile): | |||
495 | 905 | debug_package = None | 906 | debug_package = None |
496 | 906 | 907 | ||
497 | 907 | user_defined_fields = self.extractUserDefinedFields( | 908 | user_defined_fields = self.extractUserDefinedFields( |
499 | 908 | [(field, encoded[field]) for field in self.control.iterkeys()]) | 909 | [(field, encoded[field]) for field in self.control]) |
500 | 909 | 910 | ||
501 | 910 | binary = build.createBinaryPackageRelease( | 911 | binary = build.createBinaryPackageRelease( |
502 | 911 | binarypackagename=binary_name, | 912 | binarypackagename=binary_name, |
503 | diff --git a/lib/lp/archiveuploader/utils.py b/lib/lp/archiveuploader/utils.py | |||
504 | index ac8057d..67a009f 100644 | |||
505 | --- a/lib/lp/archiveuploader/utils.py | |||
506 | +++ b/lib/lp/archiveuploader/utils.py | |||
507 | @@ -39,6 +39,8 @@ import re | |||
508 | 39 | import signal | 39 | import signal |
509 | 40 | import subprocess | 40 | import subprocess |
510 | 41 | 41 | ||
511 | 42 | import six | ||
512 | 43 | |||
513 | 42 | from lp.services.encoding import guess as guess_encoding | 44 | from lp.services.encoding import guess as guess_encoding |
514 | 43 | from lp.soyuz.enums import BinaryPackageFileType | 45 | from lp.soyuz.enums import BinaryPackageFileType |
515 | 44 | 46 | ||
516 | @@ -333,7 +335,7 @@ def merge_file_lists(files, checksums_sha1, checksums_sha256, changes=True): | |||
517 | 333 | (filename, file_hashes[filename], size)) | 335 | (filename, file_hashes[filename], size)) |
518 | 334 | 336 | ||
519 | 335 | # Ensure that each filename was only listed in Files once. | 337 | # Ensure that each filename was only listed in Files once. |
521 | 336 | if set(file_counter.itervalues()) - set([1]): | 338 | if set(six.itervalues(file_counter)) - set([1]): |
522 | 337 | raise UploadError("Duplicate filenames in Files field.") | 339 | raise UploadError("Duplicate filenames in Files field.") |
523 | 338 | 340 | ||
524 | 339 | # Ensure that the Checksums-Sha1 and Checksums-Sha256 fields, if | 341 | # Ensure that the Checksums-Sha1 and Checksums-Sha256 fields, if |
525 | diff --git a/lib/lp/bugs/browser/bugalsoaffects.py b/lib/lp/bugs/browser/bugalsoaffects.py | |||
526 | index 4fa3421..b4f5ea5 100644 | |||
527 | --- a/lib/lp/bugs/browser/bugalsoaffects.py | |||
528 | +++ b/lib/lp/bugs/browser/bugalsoaffects.py | |||
529 | @@ -16,6 +16,7 @@ from lazr.enum import ( | |||
530 | 16 | Item, | 16 | Item, |
531 | 17 | ) | 17 | ) |
532 | 18 | from lazr.lifecycle.event import ObjectCreatedEvent | 18 | from lazr.lifecycle.event import ObjectCreatedEvent |
533 | 19 | import six | ||
534 | 19 | from zope.browserpage import ViewPageTemplateFile | 20 | from zope.browserpage import ViewPageTemplateFile |
535 | 20 | from zope.component import getUtility | 21 | from zope.component import getUtility |
536 | 21 | from zope.event import notify | 22 | from zope.event import notify |
537 | @@ -605,7 +606,7 @@ class ProductBugTaskCreationStep(BugTaskCreationStep): | |||
538 | 605 | 606 | ||
539 | 606 | # Don't request validation for text widgets that are not | 607 | # Don't request validation for text widgets that are not |
540 | 607 | # related to the current radio selection. | 608 | # related to the current radio selection. |
542 | 608 | for option, name in link_upstream_options.iteritems(): | 609 | for option, name in six.iteritems(link_upstream_options): |
543 | 609 | if link_upstream_how != option: | 610 | if link_upstream_how != option: |
544 | 610 | names.discard(name) | 611 | names.discard(name) |
545 | 611 | elif self.widgets[name].hasValidInput(): | 612 | elif self.widgets[name].hasValidInput(): |
546 | @@ -619,7 +620,7 @@ class ProductBugTaskCreationStep(BugTaskCreationStep): | |||
547 | 619 | else: | 620 | else: |
548 | 620 | # Don't validate these widgets when we don't yet know how | 621 | # Don't validate these widgets when we don't yet know how |
549 | 621 | # we intend to link upstream. | 622 | # we intend to link upstream. |
551 | 622 | names.difference_update(link_upstream_options.itervalues()) | 623 | names.difference_update(six.itervalues(link_upstream_options)) |
552 | 623 | 624 | ||
553 | 624 | return super(ProductBugTaskCreationStep, | 625 | return super(ProductBugTaskCreationStep, |
554 | 625 | self).validate_widgets(data, names) | 626 | self).validate_widgets(data, names) |
555 | diff --git a/lib/lp/bugs/browser/bugtarget.py b/lib/lp/bugs/browser/bugtarget.py | |||
556 | index 5755c1b..01b323d 100644 | |||
557 | --- a/lib/lp/bugs/browser/bugtarget.py | |||
558 | +++ b/lib/lp/bugs/browser/bugtarget.py | |||
559 | @@ -28,6 +28,7 @@ from lazr.restful.interface import copy_field | |||
560 | 28 | from lazr.restful.interfaces import IJSONRequestCache | 28 | from lazr.restful.interfaces import IJSONRequestCache |
561 | 29 | from pytz import timezone | 29 | from pytz import timezone |
562 | 30 | from simplejson import dumps | 30 | from simplejson import dumps |
563 | 31 | import six | ||
564 | 31 | from six.moves import http_client | 32 | from six.moves import http_client |
565 | 32 | from six.moves.urllib.parse import ( | 33 | from six.moves.urllib.parse import ( |
566 | 33 | quote, | 34 | quote, |
567 | @@ -1235,7 +1236,7 @@ class BugTargetBugTagsView(LaunchpadView): | |||
568 | 1235 | count=count, | 1236 | count=count, |
569 | 1236 | url=self._getSearchURL(tag), | 1237 | url=self._getSearchURL(tag), |
570 | 1237 | ) | 1238 | ) |
572 | 1238 | for (tag, count) in tags.iteritems()], | 1239 | for (tag, count) in six.iteritems(tags)], |
573 | 1239 | key=itemgetter('count'), reverse=True) | 1240 | key=itemgetter('count'), reverse=True) |
574 | 1240 | 1241 | ||
575 | 1241 | @property | 1242 | @property |
576 | diff --git a/lib/lp/bugs/interfaces/bugtaskfilter.py b/lib/lp/bugs/interfaces/bugtaskfilter.py | |||
577 | index e3407ed..898c955 100644 | |||
578 | --- a/lib/lp/bugs/interfaces/bugtaskfilter.py | |||
579 | +++ b/lib/lp/bugs/interfaces/bugtaskfilter.py | |||
580 | @@ -17,6 +17,8 @@ from collections import ( | |||
581 | 17 | ) | 17 | ) |
582 | 18 | from operator import attrgetter | 18 | from operator import attrgetter |
583 | 19 | 19 | ||
584 | 20 | import six | ||
585 | 21 | |||
586 | 20 | from lp.bugs.interfaces.bugtarget import IHasBugs | 22 | from lp.bugs.interfaces.bugtarget import IHasBugs |
587 | 21 | 23 | ||
588 | 22 | 24 | ||
589 | @@ -67,5 +69,5 @@ def filter_bugtasks_by_context(context, bugtasks): | |||
590 | 67 | for task in bugtasks: | 69 | for task in bugtasks: |
591 | 68 | bug_mapping[task.bugID].append(weight_calculator(task)) | 70 | bug_mapping[task.bugID].append(weight_calculator(task)) |
592 | 69 | 71 | ||
594 | 70 | filtered = [sorted(tasks)[0].task for tasks in bug_mapping.itervalues()] | 72 | filtered = [sorted(tasks)[0].task for tasks in six.itervalues(bug_mapping)] |
595 | 71 | return sorted(filtered, key=attrgetter('bugID')) | 73 | return sorted(filtered, key=attrgetter('bugID')) |
596 | diff --git a/lib/lp/bugs/model/bugtask.py b/lib/lp/bugs/model/bugtask.py | |||
597 | index 2c3b6ef..fe7d366 100644 | |||
598 | --- a/lib/lp/bugs/model/bugtask.py | |||
599 | +++ b/lib/lp/bugs/model/bugtask.py | |||
600 | @@ -32,6 +32,7 @@ import re | |||
601 | 32 | 32 | ||
602 | 33 | from lazr.lifecycle.event import ObjectDeletedEvent | 33 | from lazr.lifecycle.event import ObjectDeletedEvent |
603 | 34 | import pytz | 34 | import pytz |
604 | 35 | import six | ||
605 | 35 | from sqlobject import ( | 36 | from sqlobject import ( |
606 | 36 | ForeignKey, | 37 | ForeignKey, |
607 | 37 | SQLObjectNotFound, | 38 | SQLObjectNotFound, |
608 | @@ -1138,7 +1139,7 @@ class BugTask(SQLBase): | |||
609 | 1138 | new_key['sourcepackagename'] != self.sourcepackagename): | 1139 | new_key['sourcepackagename'] != self.sourcepackagename): |
610 | 1139 | self._syncSourcePackages(new_key['sourcepackagename'], user) | 1140 | self._syncSourcePackages(new_key['sourcepackagename'], user) |
611 | 1140 | 1141 | ||
613 | 1141 | for name, value in new_key.iteritems(): | 1142 | for name, value in six.iteritems(new_key): |
614 | 1142 | setattr(self, name, value) | 1143 | setattr(self, name, value) |
615 | 1143 | self.updateTargetNameCache() | 1144 | self.updateTargetNameCache() |
616 | 1144 | self.bug._reconcileAccess() | 1145 | self.bug._reconcileAccess() |
617 | diff --git a/lib/lp/bugs/model/structuralsubscription.py b/lib/lp/bugs/model/structuralsubscription.py | |||
618 | index aec76a8..c2834e3 100644 | |||
619 | --- a/lib/lp/bugs/model/structuralsubscription.py | |||
620 | +++ b/lib/lp/bugs/model/structuralsubscription.py | |||
621 | @@ -15,6 +15,7 @@ __all__ = [ | |||
622 | 15 | from collections import defaultdict | 15 | from collections import defaultdict |
623 | 16 | 16 | ||
624 | 17 | import pytz | 17 | import pytz |
625 | 18 | import six | ||
626 | 18 | from storm.base import Storm | 19 | from storm.base import Storm |
627 | 19 | from storm.expr import ( | 20 | from storm.expr import ( |
628 | 20 | And, | 21 | And, |
629 | @@ -137,7 +138,7 @@ class StructuralSubscription(Storm): | |||
630 | 137 | def __init__(self, subscriber, subscribed_by, **kwargs): | 138 | def __init__(self, subscriber, subscribed_by, **kwargs): |
631 | 138 | self.subscriber = subscriber | 139 | self.subscriber = subscriber |
632 | 139 | self.subscribed_by = subscribed_by | 140 | self.subscribed_by = subscribed_by |
634 | 140 | for arg, value in kwargs.iteritems(): | 141 | for arg, value in six.iteritems(kwargs): |
635 | 141 | setattr(self, arg, value) | 142 | setattr(self, arg, value) |
636 | 142 | 143 | ||
637 | 143 | @property | 144 | @property |
638 | @@ -463,7 +464,7 @@ class StructuralSubscriptionTargetMixin: | |||
639 | 463 | """See `IStructuralSubscriptionTarget`.""" | 464 | """See `IStructuralSubscriptionTarget`.""" |
640 | 464 | from lp.registry.model.person import Person | 465 | from lp.registry.model.person import Person |
641 | 465 | clauses = [StructuralSubscription.subscriberID == Person.id] | 466 | clauses = [StructuralSubscription.subscriberID == Person.id] |
643 | 466 | for key, value in self._target_args.iteritems(): | 467 | for key, value in six.iteritems(self._target_args): |
644 | 467 | clauses.append( | 468 | clauses.append( |
645 | 468 | getattr(StructuralSubscription, key) == value) | 469 | getattr(StructuralSubscription, key) == value) |
646 | 469 | 470 | ||
647 | diff --git a/lib/lp/bugs/model/tests/test_bugsubscriptioninfo.py b/lib/lp/bugs/model/tests/test_bugsubscriptioninfo.py | |||
648 | index 89c5c0f..f261fcb 100644 | |||
649 | --- a/lib/lp/bugs/model/tests/test_bugsubscriptioninfo.py | |||
650 | +++ b/lib/lp/bugs/model/tests/test_bugsubscriptioninfo.py | |||
651 | @@ -7,6 +7,7 @@ __metaclass__ = type | |||
652 | 7 | 7 | ||
653 | 8 | from contextlib import contextmanager | 8 | from contextlib import contextmanager |
654 | 9 | 9 | ||
655 | 10 | import six | ||
656 | 10 | from storm.store import Store | 11 | from storm.store import Store |
657 | 11 | from testtools.matchers import Equals | 12 | from testtools.matchers import Equals |
658 | 12 | from zope.component import queryAdapter | 13 | from zope.component import queryAdapter |
659 | @@ -64,7 +65,7 @@ class TestSubscriptionRelatedSets(TestCaseWithFactory): | |||
660 | 64 | subscribers = dict( | 65 | subscribers = dict( |
661 | 65 | (name_pair, make_person(*name_pair)) | 66 | (name_pair, make_person(*name_pair)) |
662 | 66 | for name_pair in self.name_pairs) | 67 | for name_pair in self.name_pairs) |
664 | 67 | self.subscribers_set = frozenset(subscribers.itervalues()) | 68 | self.subscribers_set = frozenset(six.itervalues(subscribers)) |
665 | 68 | self.subscribers_sorted = tuple( | 69 | self.subscribers_sorted = tuple( |
666 | 69 | subscribers[name_pair] for name_pair in self.name_pairs_sorted) | 70 | subscribers[name_pair] for name_pair in self.name_pairs_sorted) |
667 | 70 | 71 | ||
668 | @@ -428,7 +429,7 @@ class TestBugSubscriptionInfoPermissions(TestCaseWithFactory): | |||
669 | 428 | self.assertEqual({}, checker.set_permissions) | 429 | self.assertEqual({}, checker.set_permissions) |
670 | 429 | 430 | ||
671 | 430 | # All attributes require launchpad.View. | 431 | # All attributes require launchpad.View. |
673 | 431 | permissions = set(checker.get_permissions.itervalues()) | 432 | permissions = set(six.itervalues(checker.get_permissions)) |
674 | 432 | self.assertContentEqual(["launchpad.View"], permissions) | 433 | self.assertContentEqual(["launchpad.View"], permissions) |
675 | 433 | 434 | ||
676 | 434 | # The security adapter for launchpad.View lets anyone reference the | 435 | # The security adapter for launchpad.View lets anyone reference the |
677 | diff --git a/lib/lp/bugs/scripts/bugsummaryrebuild.py b/lib/lp/bugs/scripts/bugsummaryrebuild.py | |||
678 | index f41d8c2..f000905 100644 | |||
679 | --- a/lib/lp/bugs/scripts/bugsummaryrebuild.py | |||
680 | +++ b/lib/lp/bugs/scripts/bugsummaryrebuild.py | |||
681 | @@ -3,6 +3,7 @@ | |||
682 | 3 | 3 | ||
683 | 4 | __metaclass__ = type | 4 | __metaclass__ = type |
684 | 5 | 5 | ||
685 | 6 | import six | ||
686 | 6 | from storm.expr import ( | 7 | from storm.expr import ( |
687 | 7 | Alias, | 8 | Alias, |
688 | 8 | And, | 9 | And, |
689 | @@ -116,7 +117,7 @@ def get_bugsummary_constraint(target, cls=RawBugSummary): | |||
690 | 116 | # Map to ID columns to work around Storm bug #682989. | 117 | # Map to ID columns to work around Storm bug #682989. |
691 | 117 | return [ | 118 | return [ |
692 | 118 | getattr(cls, k) == v | 119 | getattr(cls, k) == v |
694 | 119 | for (k, v) in _get_bugsummary_constraint_bits(target).iteritems()] | 120 | for (k, v) in six.iteritems(_get_bugsummary_constraint_bits(target))] |
695 | 120 | 121 | ||
696 | 121 | 122 | ||
697 | 122 | def get_bugtaskflat_constraint(target): | 123 | def get_bugtaskflat_constraint(target): |
698 | @@ -161,8 +162,8 @@ def calculate_bugsummary_changes(old, new): | |||
699 | 161 | from the old one. | 162 | from the old one. |
700 | 162 | """ | 163 | """ |
701 | 163 | keys = set() | 164 | keys = set() |
704 | 164 | keys.update(old.iterkeys()) | 165 | keys.update(six.iterkeys(old)) |
705 | 165 | keys.update(new.iterkeys()) | 166 | keys.update(six.iterkeys(new)) |
706 | 166 | added = {} | 167 | added = {} |
707 | 167 | updated = {} | 168 | updated = {} |
708 | 168 | removed = [] | 169 | removed = [] |
709 | @@ -198,7 +199,7 @@ def apply_bugsummary_changes(target, added, updated, removed): | |||
710 | 198 | RawBugSummary.access_policy_id) | 199 | RawBugSummary.access_policy_id) |
711 | 199 | 200 | ||
712 | 200 | # Postgres doesn't do bulk updates, so do a delete+add. | 201 | # Postgres doesn't do bulk updates, so do a delete+add. |
714 | 201 | for key, count in updated.iteritems(): | 202 | for key, count in six.iteritems(updated): |
715 | 202 | removed.append(key) | 203 | removed.append(key) |
716 | 203 | added[key] = count | 204 | added[key] = count |
717 | 204 | 205 | ||
718 | @@ -219,7 +220,8 @@ def apply_bugsummary_changes(target, added, updated, removed): | |||
719 | 219 | if added: | 220 | if added: |
720 | 220 | create( | 221 | create( |
721 | 221 | target_cols + key_cols + (RawBugSummary.count,), | 222 | target_cols + key_cols + (RawBugSummary.count,), |
723 | 222 | [target_key + key + (count,) for key, count in added.iteritems()]) | 223 | [target_key + key + (count,) |
724 | 224 | for key, count in six.iteritems(added)]) | ||
725 | 223 | 225 | ||
726 | 224 | 226 | ||
727 | 225 | def rebuild_bugsummary_for_target(target, log): | 227 | def rebuild_bugsummary_for_target(target, log): |
728 | diff --git a/lib/lp/bugs/scripts/bugtasktargetnamecaches.py b/lib/lp/bugs/scripts/bugtasktargetnamecaches.py | |||
729 | index 5d14052..429ff49 100644 | |||
730 | --- a/lib/lp/bugs/scripts/bugtasktargetnamecaches.py | |||
731 | +++ b/lib/lp/bugs/scripts/bugtasktargetnamecaches.py | |||
732 | @@ -8,6 +8,7 @@ __all__ = ['BugTaskTargetNameCacheUpdater'] | |||
733 | 8 | 8 | ||
734 | 9 | from collections import defaultdict | 9 | from collections import defaultdict |
735 | 10 | 10 | ||
736 | 11 | import six | ||
737 | 11 | from zope.interface import implementer | 12 | from zope.interface import implementer |
738 | 12 | 13 | ||
739 | 13 | from lp.bugs.model.bugtask import ( | 14 | from lp.bugs.model.bugtask import ( |
740 | @@ -65,7 +66,7 @@ class BugTaskTargetNameCachesTunableLoop(object): | |||
741 | 65 | candidates = defaultdict(set) | 66 | candidates = defaultdict(set) |
742 | 66 | for candidate in candidate_set: | 67 | for candidate in candidate_set: |
743 | 67 | candidates[candidate[:-1]].add(candidate[-1]) | 68 | candidates[candidate[:-1]].add(candidate[-1]) |
745 | 68 | return list(candidates.iteritems()) | 69 | return list(six.iteritems(candidates)) |
746 | 69 | 70 | ||
747 | 70 | def isDone(self): | 71 | def isDone(self): |
748 | 71 | """See `ITunableLoop`.""" | 72 | """See `ITunableLoop`.""" |
749 | diff --git a/lib/lp/bugs/scripts/bzremotecomponentfinder.py b/lib/lp/bugs/scripts/bzremotecomponentfinder.py | |||
750 | index 4dcb6cb..cf4246e 100644 | |||
751 | --- a/lib/lp/bugs/scripts/bzremotecomponentfinder.py | |||
752 | +++ b/lib/lp/bugs/scripts/bzremotecomponentfinder.py | |||
753 | @@ -12,6 +12,7 @@ __all__ = [ | |||
754 | 12 | import re | 12 | import re |
755 | 13 | 13 | ||
756 | 14 | import requests | 14 | import requests |
757 | 15 | import six | ||
758 | 15 | import transaction | 16 | import transaction |
759 | 16 | from zope.component import getUtility | 17 | from zope.component import getUtility |
760 | 17 | 18 | ||
761 | @@ -163,7 +164,7 @@ class BugzillaRemoteComponentFinder: | |||
762 | 163 | def storeRemoteProductsAndComponents(self, bz_bugtracker, lp_bugtracker): | 164 | def storeRemoteProductsAndComponents(self, bz_bugtracker, lp_bugtracker): |
763 | 164 | """Stores parsed product/component data from bz_bugtracker""" | 165 | """Stores parsed product/component data from bz_bugtracker""" |
764 | 165 | components_to_add = [] | 166 | components_to_add = [] |
766 | 166 | for product in bz_bugtracker.products.itervalues(): | 167 | for product in six.itervalues(bz_bugtracker.products): |
767 | 167 | # Look up the component group id from Launchpad for the product | 168 | # Look up the component group id from Launchpad for the product |
768 | 168 | # if it already exists. Otherwise, add it. | 169 | # if it already exists. Otherwise, add it. |
769 | 169 | lp_component_group = lp_bugtracker.getRemoteComponentGroup( | 170 | lp_component_group = lp_bugtracker.getRemoteComponentGroup( |
770 | diff --git a/lib/lp/bugs/tests/externalbugtracker.py b/lib/lp/bugs/tests/externalbugtracker.py | |||
771 | index b8a5b9d..afb1d81 100644 | |||
772 | --- a/lib/lp/bugs/tests/externalbugtracker.py | |||
773 | +++ b/lib/lp/bugs/tests/externalbugtracker.py | |||
774 | @@ -17,6 +17,7 @@ import re | |||
775 | 17 | import time | 17 | import time |
776 | 18 | 18 | ||
777 | 19 | import responses | 19 | import responses |
778 | 20 | import six | ||
779 | 20 | from six.moves import xmlrpc_client | 21 | from six.moves import xmlrpc_client |
780 | 21 | from six.moves.urllib_parse import ( | 22 | from six.moves.urllib_parse import ( |
781 | 22 | parse_qs, | 23 | parse_qs, |
782 | @@ -720,7 +721,7 @@ class TestBugzillaXMLRPCTransport(RequestsTransport): | |||
783 | 720 | def _copy_comment(self, comment, fields_to_return=None): | 721 | def _copy_comment(self, comment, fields_to_return=None): |
784 | 721 | # Copy wanted fields. | 722 | # Copy wanted fields. |
785 | 722 | return dict( | 723 | return dict( |
787 | 723 | (key, value) for (key, value) in comment.iteritems() | 724 | (key, value) for (key, value) in six.iteritems(comment) |
788 | 724 | if fields_to_return is None or key in fields_to_return) | 725 | if fields_to_return is None or key in fields_to_return) |
789 | 725 | 726 | ||
790 | 726 | def comments(self, arguments): | 727 | def comments(self, arguments): |
791 | diff --git a/lib/lp/buildmaster/browser/builder.py b/lib/lp/buildmaster/browser/builder.py | |||
792 | index 0c5d05a..b378ea3 100644 | |||
793 | --- a/lib/lp/buildmaster/browser/builder.py | |||
794 | +++ b/lib/lp/buildmaster/browser/builder.py | |||
795 | @@ -20,6 +20,7 @@ from itertools import groupby | |||
796 | 20 | import operator | 20 | import operator |
797 | 21 | 21 | ||
798 | 22 | from lazr.restful.utils import smartquote | 22 | from lazr.restful.utils import smartquote |
799 | 23 | import six | ||
800 | 23 | from zope.component import getUtility | 24 | from zope.component import getUtility |
801 | 24 | from zope.event import notify | 25 | from zope.event import notify |
802 | 25 | from zope.formlib.widget import CustomWidgetFactory | 26 | from zope.formlib.widget import CustomWidgetFactory |
803 | @@ -273,7 +274,7 @@ class BuilderCategory: | |||
804 | 273 | else: | 274 | else: |
805 | 274 | grouped_builders[processor] = [builder] | 275 | grouped_builders[processor] = [builder] |
806 | 275 | 276 | ||
808 | 276 | for processor, builders in grouped_builders.iteritems(): | 277 | for processor, builders in six.iteritems(grouped_builders): |
809 | 277 | virt_str = 'virt' if self.virtualized else 'nonvirt' | 278 | virt_str = 'virt' if self.virtualized else 'nonvirt' |
810 | 278 | processor_name = processor.name if processor else None | 279 | processor_name = processor.name if processor else None |
811 | 279 | queue_size, duration = build_queue_sizes[virt_str].get( | 280 | queue_size, duration = build_queue_sizes[virt_str].get( |
812 | diff --git a/lib/lp/buildmaster/manager.py b/lib/lp/buildmaster/manager.py | |||
813 | index ea29ff2..3c80622 100644 | |||
814 | --- a/lib/lp/buildmaster/manager.py | |||
815 | +++ b/lib/lp/buildmaster/manager.py | |||
816 | @@ -15,6 +15,7 @@ import datetime | |||
817 | 15 | import functools | 15 | import functools |
818 | 16 | import logging | 16 | import logging |
819 | 17 | 17 | ||
820 | 18 | import six | ||
821 | 18 | from storm.expr import LeftJoin | 19 | from storm.expr import LeftJoin |
822 | 19 | import transaction | 20 | import transaction |
823 | 20 | from twisted.application import service | 21 | from twisted.application import service |
824 | @@ -139,7 +140,7 @@ class PrefetchedBuilderFactory: | |||
825 | 139 | 140 | ||
826 | 140 | def iterVitals(self): | 141 | def iterVitals(self): |
827 | 141 | """See `BuilderFactory`.""" | 142 | """See `BuilderFactory`.""" |
829 | 142 | return (b for n, b in sorted(self.vitals_map.iteritems())) | 143 | return (b for n, b in sorted(six.iteritems(self.vitals_map))) |
830 | 143 | 144 | ||
831 | 144 | 145 | ||
832 | 145 | def judge_failure(builder_count, job_count, exc, retry=True): | 146 | def judge_failure(builder_count, job_count, exc, retry=True): |
833 | diff --git a/lib/lp/buildmaster/model/builder.py b/lib/lp/buildmaster/model/builder.py | |||
834 | index 4d32dcf..a44e7fc 100644 | |||
835 | --- a/lib/lp/buildmaster/model/builder.py | |||
836 | +++ b/lib/lp/buildmaster/model/builder.py | |||
837 | @@ -11,6 +11,7 @@ __all__ = [ | |||
838 | 11 | 11 | ||
839 | 12 | import logging | 12 | import logging |
840 | 13 | 13 | ||
841 | 14 | import six | ||
842 | 14 | from sqlobject import ( | 15 | from sqlobject import ( |
843 | 15 | BoolCol, | 16 | BoolCol, |
844 | 16 | ForeignKey, | 17 | ForeignKey, |
845 | @@ -243,7 +244,7 @@ class Builder(SQLBase): | |||
846 | 243 | 244 | ||
847 | 244 | job_type_conditions = [] | 245 | job_type_conditions = [] |
848 | 245 | job_sources = specific_build_farm_job_sources() | 246 | job_sources = specific_build_farm_job_sources() |
850 | 246 | for job_type, job_source in job_sources.iteritems(): | 247 | for job_type, job_source in six.iteritems(job_sources): |
851 | 247 | query = job_source.addCandidateSelectionCriteria( | 248 | query = job_source.addCandidateSelectionCriteria( |
852 | 248 | self.processor, self.virtualized) | 249 | self.processor, self.virtualized) |
853 | 249 | if query: | 250 | if query: |
854 | diff --git a/lib/lp/buildmaster/queuedepth.py b/lib/lp/buildmaster/queuedepth.py | |||
855 | index 1fdb151..66f1986 100644 | |||
856 | --- a/lib/lp/buildmaster/queuedepth.py | |||
857 | +++ b/lib/lp/buildmaster/queuedepth.py | |||
858 | @@ -14,6 +14,7 @@ from datetime import ( | |||
859 | 14 | ) | 14 | ) |
860 | 15 | 15 | ||
861 | 16 | from pytz import utc | 16 | from pytz import utc |
862 | 17 | import six | ||
863 | 17 | from storm.expr import Count | 18 | from storm.expr import Count |
864 | 18 | 19 | ||
865 | 19 | from lp.buildmaster.enums import BuildQueueStatus | 20 | from lp.buildmaster.enums import BuildQueueStatus |
866 | @@ -275,7 +276,7 @@ def estimate_job_delay(bq, builder_stats): | |||
867 | 275 | 276 | ||
868 | 276 | sum_of_delays = 0 | 277 | sum_of_delays = 0 |
869 | 277 | # Now devide the delays based on a jobs/builders comparison. | 278 | # Now devide the delays based on a jobs/builders comparison. |
871 | 278 | for platform, duration in delays.iteritems(): | 279 | for platform, duration in six.iteritems(delays): |
872 | 279 | jobs = job_counts[platform] | 280 | jobs = job_counts[platform] |
873 | 280 | builders = builder_stats[platform] | 281 | builders = builder_stats[platform] |
874 | 281 | # If there are less jobs than builders that can take them on, | 282 | # If there are less jobs than builders that can take them on, |
875 | diff --git a/lib/lp/buildmaster/tests/test_queuedepth.py b/lib/lp/buildmaster/tests/test_queuedepth.py | |||
876 | index 090fd11..b9198e1 100644 | |||
877 | --- a/lib/lp/buildmaster/tests/test_queuedepth.py | |||
878 | +++ b/lib/lp/buildmaster/tests/test_queuedepth.py | |||
879 | @@ -10,6 +10,7 @@ from datetime import ( | |||
880 | 10 | ) | 10 | ) |
881 | 11 | 11 | ||
882 | 12 | from pytz import utc | 12 | from pytz import utc |
883 | 13 | import six | ||
884 | 13 | from zope.component import getUtility | 14 | from zope.component import getUtility |
885 | 14 | from zope.security.proxy import removeSecurityProxy | 15 | from zope.security.proxy import removeSecurityProxy |
886 | 15 | 16 | ||
887 | @@ -698,7 +699,7 @@ class TestMinTimeToNextBuilderMulti(MultiArchBuildsBase): | |||
888 | 698 | check_mintime_to_builder(self, job, 0) | 699 | check_mintime_to_builder(self, job, 0) |
889 | 699 | 700 | ||
890 | 700 | # Let's disable all builders. | 701 | # Let's disable all builders. |
892 | 701 | for builders in self.builders.itervalues(): | 702 | for builders in six.itervalues(self.builders): |
893 | 702 | for builder in builders: | 703 | for builder in builders: |
894 | 703 | builder.builderok = False | 704 | builder.builderok = False |
895 | 704 | 705 | ||
896 | diff --git a/lib/lp/code/browser/branch.py b/lib/lp/code/browser/branch.py | |||
897 | index 404c272..6ea17ac 100644 | |||
898 | --- a/lib/lp/code/browser/branch.py | |||
899 | +++ b/lib/lp/code/browser/branch.py | |||
900 | @@ -36,6 +36,7 @@ from lazr.restful.interface import ( | |||
901 | 36 | from lazr.uri import URI | 36 | from lazr.uri import URI |
902 | 37 | import pytz | 37 | import pytz |
903 | 38 | import simplejson | 38 | import simplejson |
904 | 39 | import six | ||
905 | 39 | from zope.component import getUtility | 40 | from zope.component import getUtility |
906 | 40 | from zope.event import notify | 41 | from zope.event import notify |
907 | 41 | from zope.formlib import form | 42 | from zope.formlib import form |
908 | @@ -954,8 +955,8 @@ class BranchDeletionView(LaunchpadFormView): | |||
909 | 954 | :return: A list of tuples of (item, action, reason, allowed) | 955 | :return: A list of tuples of (item, action, reason, allowed) |
910 | 955 | """ | 956 | """ |
911 | 956 | reqs = [] | 957 | reqs = [] |
914 | 957 | for item, (action, reason) in ( | 958 | for item, (action, reason) in six.iteritems( |
915 | 958 | self.context.deletionRequirements(eager_load=True).iteritems()): | 959 | self.context.deletionRequirements(eager_load=True)): |
916 | 959 | allowed = check_permission('launchpad.Edit', item) | 960 | allowed = check_permission('launchpad.Edit', item) |
917 | 960 | reqs.append((item, action, reason, allowed)) | 961 | reqs.append((item, action, reason, allowed)) |
918 | 961 | return reqs | 962 | return reqs |
919 | diff --git a/lib/lp/code/browser/branchlisting.py b/lib/lp/code/browser/branchlisting.py | |||
920 | index f472ef0..23a1e9c 100644 | |||
921 | --- a/lib/lp/code/browser/branchlisting.py | |||
922 | +++ b/lib/lp/code/browser/branchlisting.py | |||
923 | @@ -33,6 +33,7 @@ from lazr.enum import ( | |||
924 | 33 | EnumeratedType, | 33 | EnumeratedType, |
925 | 34 | Item, | 34 | Item, |
926 | 35 | ) | 35 | ) |
927 | 36 | import six | ||
928 | 36 | from six.moves.urllib.parse import parse_qs | 37 | from six.moves.urllib.parse import parse_qs |
929 | 37 | from storm.expr import Desc | 38 | from storm.expr import Desc |
930 | 38 | from zope.browserpage import ViewPageTemplateFile | 39 | from zope.browserpage import ViewPageTemplateFile |
931 | @@ -1306,7 +1307,7 @@ class GroupedDistributionSourcePackageBranchesView(LaunchpadView, | |||
932 | 1306 | # For each distro series, we only want the "best" pocket if one branch | 1307 | # For each distro series, we only want the "best" pocket if one branch |
933 | 1307 | # is linked to more than one pocket. Best here means smaller value. | 1308 | # is linked to more than one pocket. Best here means smaller value. |
934 | 1308 | official_branches = {} | 1309 | official_branches = {} |
936 | 1309 | for key, value in distro_links.iteritems(): | 1310 | for key, value in six.iteritems(distro_links): |
937 | 1310 | ordered = sorted(value, key=attrgetter('pocket')) | 1311 | ordered = sorted(value, key=attrgetter('pocket')) |
938 | 1311 | seen_branches = set() | 1312 | seen_branches = set() |
939 | 1312 | branches = [] | 1313 | branches = [] |
940 | @@ -1363,7 +1364,7 @@ class GroupedDistributionSourcePackageBranchesView(LaunchpadView, | |||
941 | 1363 | and merge proposal links for badges. | 1364 | and merge proposal links for badges. |
942 | 1364 | """ | 1365 | """ |
943 | 1365 | visible_branches = [] | 1366 | visible_branches = [] |
945 | 1366 | for branches, count in self.series_branches_map.itervalues(): | 1367 | for branches, count in six.itervalues(self.series_branches_map): |
946 | 1367 | visible_branches.extend(branches) | 1368 | visible_branches.extend(branches) |
947 | 1368 | return visible_branches | 1369 | return visible_branches |
948 | 1369 | 1370 | ||
949 | diff --git a/lib/lp/code/browser/branchmergeproposal.py b/lib/lp/code/browser/branchmergeproposal.py | |||
950 | index a1b41fb..6d33f97 100644 | |||
951 | --- a/lib/lp/code/browser/branchmergeproposal.py | |||
952 | +++ b/lib/lp/code/browser/branchmergeproposal.py | |||
953 | @@ -35,6 +35,7 @@ from lazr.restful.interfaces import ( | |||
954 | 35 | IWebServiceClientRequest, | 35 | IWebServiceClientRequest, |
955 | 36 | ) | 36 | ) |
956 | 37 | import simplejson | 37 | import simplejson |
957 | 38 | import six | ||
958 | 38 | from zope.component import ( | 39 | from zope.component import ( |
959 | 39 | adapter, | 40 | adapter, |
960 | 40 | getMultiAdapter, | 41 | getMultiAdapter, |
961 | @@ -145,7 +146,7 @@ def latest_proposals_for_each_branch(proposals): | |||
962 | 145 | targets[target] = (proposal, date_created) | 146 | targets[target] = (proposal, date_created) |
963 | 146 | 147 | ||
964 | 147 | return sorted( | 148 | return sorted( |
966 | 148 | [proposal for proposal, date_created in targets.itervalues()], | 149 | [proposal for proposal, date_created in six.itervalues(targets)], |
967 | 149 | key=operator.attrgetter('date_created'), reverse=True) | 150 | key=operator.attrgetter('date_created'), reverse=True) |
968 | 150 | 151 | ||
969 | 151 | 152 | ||
970 | diff --git a/lib/lp/code/browser/gitrepository.py b/lib/lp/code/browser/gitrepository.py | |||
971 | index c05dcc1..4f38702 100644 | |||
972 | --- a/lib/lp/code/browser/gitrepository.py | |||
973 | +++ b/lib/lp/code/browser/gitrepository.py | |||
974 | @@ -31,6 +31,7 @@ from lazr.restful.interface import ( | |||
975 | 31 | copy_field, | 31 | copy_field, |
976 | 32 | use_template, | 32 | use_template, |
977 | 33 | ) | 33 | ) |
978 | 34 | import six | ||
979 | 34 | from six.moves.urllib_parse import ( | 35 | from six.moves.urllib_parse import ( |
980 | 35 | urlsplit, | 36 | urlsplit, |
981 | 36 | urlunsplit, | 37 | urlunsplit, |
982 | @@ -1273,9 +1274,8 @@ class GitRepositoryDeletionView(LaunchpadFormView): | |||
983 | 1273 | :return: A list of tuples of (item, action, reason, allowed) | 1274 | :return: A list of tuples of (item, action, reason, allowed) |
984 | 1274 | """ | 1275 | """ |
985 | 1275 | reqs = [] | 1276 | reqs = [] |
989 | 1276 | for item, (action, reason) in ( | 1277 | for item, (action, reason) in six.iteritems( |
990 | 1277 | self.context.getDeletionRequirements( | 1278 | self.context.getDeletionRequirements(eager_load=True)): |
988 | 1278 | eager_load=True).iteritems()): | ||
991 | 1279 | allowed = check_permission("launchpad.Edit", item) | 1279 | allowed = check_permission("launchpad.Edit", item) |
992 | 1280 | reqs.append((item, action, reason, allowed)) | 1280 | reqs.append((item, action, reason, allowed)) |
993 | 1281 | return reqs | 1281 | return reqs |
994 | diff --git a/lib/lp/code/model/branchcollection.py b/lib/lp/code/model/branchcollection.py | |||
995 | index 79411cc..9c0b097 100644 | |||
996 | --- a/lib/lp/code/model/branchcollection.py | |||
997 | +++ b/lib/lp/code/model/branchcollection.py | |||
998 | @@ -16,6 +16,7 @@ from lazr.uri import ( | |||
999 | 16 | InvalidURIError, | 16 | InvalidURIError, |
1000 | 17 | URI, | 17 | URI, |
1001 | 18 | ) | 18 | ) |
1002 | 19 | import six | ||
1003 | 19 | from storm.expr import ( | 20 | from storm.expr import ( |
1004 | 20 | And, | 21 | And, |
1005 | 21 | Asc, | 22 | Asc, |
1006 | @@ -562,7 +563,7 @@ class GenericBranchCollection: | |||
1007 | 562 | bugtasks_for_branch[bugbranch.branch].append(bugtask) | 563 | bugtasks_for_branch[bugbranch.branch].append(bugtask) |
1008 | 563 | 564 | ||
1009 | 564 | # Now filter those down to one bugtask per branch | 565 | # Now filter those down to one bugtask per branch |
1011 | 565 | for branch, tasks in bugtasks_for_branch.iteritems(): | 566 | for branch, tasks in six.iteritems(bugtasks_for_branch): |
1012 | 566 | linked_bugtasks[branch.id].extend( | 567 | linked_bugtasks[branch.id].extend( |
1013 | 567 | filter_bugtasks_by_context(branch.target.context, tasks)) | 568 | filter_bugtasks_by_context(branch.target.context, tasks)) |
1014 | 568 | 569 | ||
1015 | diff --git a/lib/lp/code/model/branchjob.py b/lib/lp/code/model/branchjob.py | |||
1016 | index a26c47b..7067f8a 100644 | |||
1017 | --- a/lib/lp/code/model/branchjob.py | |||
1018 | +++ b/lib/lp/code/model/branchjob.py | |||
1019 | @@ -684,7 +684,7 @@ class RevisionsAddedJob(BranchJobDerived): | |||
1020 | 684 | proposals[source_id] = (proposal, date_created) | 684 | proposals[source_id] = (proposal, date_created) |
1021 | 685 | 685 | ||
1022 | 686 | return sorted( | 686 | return sorted( |
1024 | 687 | [proposal for proposal, date_created in proposals.itervalues()], | 687 | [proposal for proposal, date_created in six.itervalues(proposals)], |
1025 | 688 | key=operator.attrgetter('date_created'), reverse=True) | 688 | key=operator.attrgetter('date_created'), reverse=True) |
1026 | 689 | 689 | ||
1027 | 690 | def getRevisionMessage(self, revision_id, revno): | 690 | def getRevisionMessage(self, revision_id, revno): |
1028 | diff --git a/lib/lp/code/model/codereviewinlinecomment.py b/lib/lp/code/model/codereviewinlinecomment.py | |||
1029 | index 580eb44..2ac74b0 100644 | |||
1030 | --- a/lib/lp/code/model/codereviewinlinecomment.py | |||
1031 | +++ b/lib/lp/code/model/codereviewinlinecomment.py | |||
1032 | @@ -10,6 +10,7 @@ __all__ = [ | |||
1033 | 10 | 'CodeReviewInlineCommentSet', | 10 | 'CodeReviewInlineCommentSet', |
1034 | 11 | ] | 11 | ] |
1035 | 12 | 12 | ||
1036 | 13 | import six | ||
1037 | 13 | from storm.expr import LeftJoin | 14 | from storm.expr import LeftJoin |
1038 | 14 | from storm.locals import ( | 15 | from storm.locals import ( |
1039 | 15 | Int, | 16 | Int, |
1040 | @@ -113,7 +114,7 @@ class CodeReviewInlineCommentSet: | |||
1041 | 113 | list(crics), key=lambda c: c.comment.date_created) | 114 | list(crics), key=lambda c: c.comment.date_created) |
1042 | 114 | inline_comments = [] | 115 | inline_comments = [] |
1043 | 115 | for cric in sorted_crics: | 116 | for cric in sorted_crics: |
1045 | 116 | for line_number, text in cric.comments.iteritems(): | 117 | for line_number, text in six.iteritems(cric.comments): |
1046 | 117 | comment = { | 118 | comment = { |
1047 | 118 | 'line_number': line_number, | 119 | 'line_number': line_number, |
1048 | 119 | 'person': cric.person, | 120 | 'person': cric.person, |
1049 | diff --git a/lib/lp/code/model/revision.py b/lib/lp/code/model/revision.py | |||
1050 | index 4895ebb..a979c74 100644 | |||
1051 | --- a/lib/lp/code/model/revision.py | |||
1052 | +++ b/lib/lp/code/model/revision.py | |||
1053 | @@ -18,6 +18,7 @@ import email | |||
1054 | 18 | 18 | ||
1055 | 19 | from breezy.revision import NULL_REVISION | 19 | from breezy.revision import NULL_REVISION |
1056 | 20 | import pytz | 20 | import pytz |
1057 | 21 | import six | ||
1058 | 21 | from sqlobject import ( | 22 | from sqlobject import ( |
1059 | 22 | BoolCol, | 23 | BoolCol, |
1060 | 23 | ForeignKey, | 24 | ForeignKey, |
1061 | @@ -287,7 +288,7 @@ class RevisionSet: | |||
1062 | 287 | parent_id=parent_id) | 288 | parent_id=parent_id) |
1063 | 288 | 289 | ||
1064 | 289 | # Create revision properties. | 290 | # Create revision properties. |
1066 | 290 | for name, value in properties.iteritems(): | 291 | for name, value in six.iteritems(properties): |
1067 | 291 | RevisionProperty(revision=revision, name=name, value=value) | 292 | RevisionProperty(revision=revision, name=name, value=value) |
1068 | 292 | 293 | ||
1069 | 293 | return revision | 294 | return revision |
1070 | @@ -378,7 +379,7 @@ class RevisionSet: | |||
1071 | 378 | for bzr_revision in revisions: | 379 | for bzr_revision in revisions: |
1072 | 379 | db_id = revision_db_id[bzr_revision.revision_id] | 380 | db_id = revision_db_id[bzr_revision.revision_id] |
1073 | 380 | # Property data: revision DB id, name, value. | 381 | # Property data: revision DB id, name, value. |
1075 | 381 | for name, value in bzr_revision.properties.iteritems(): | 382 | for name, value in six.iteritems(bzr_revision.properties): |
1076 | 382 | # pristine-tar properties can be huge, and storing them | 383 | # pristine-tar properties can be huge, and storing them |
1077 | 383 | # in the database provides no value. Exclude them. | 384 | # in the database provides no value. Exclude them. |
1078 | 384 | if name.startswith('deb-pristine-delta'): | 385 | if name.startswith('deb-pristine-delta'): |
1079 | diff --git a/lib/lp/codehosting/inmemory.py b/lib/lp/codehosting/inmemory.py | |||
1080 | index a2a7103..2b704fd 100644 | |||
1081 | --- a/lib/lp/codehosting/inmemory.py | |||
1082 | +++ b/lib/lp/codehosting/inmemory.py | |||
1083 | @@ -131,7 +131,7 @@ class ObjectSet: | |||
1084 | 131 | del self._objects[db_object.id] | 131 | del self._objects[db_object.id] |
1085 | 132 | 132 | ||
1086 | 133 | def __iter__(self): | 133 | def __iter__(self): |
1088 | 134 | return self._objects.itervalues() | 134 | return six.itervalues(self._objects) |
1089 | 135 | 135 | ||
1090 | 136 | def _find(self, **kwargs): | 136 | def _find(self, **kwargs): |
1091 | 137 | [(key, value)] = kwargs.items() | 137 | [(key, value)] = kwargs.items() |
1092 | diff --git a/lib/lp/codehosting/scanner/buglinks.py b/lib/lp/codehosting/scanner/buglinks.py | |||
1093 | index f9609c3..116fb90 100644 | |||
1094 | --- a/lib/lp/codehosting/scanner/buglinks.py | |||
1095 | +++ b/lib/lp/codehosting/scanner/buglinks.py | |||
1096 | @@ -9,6 +9,7 @@ __all__ = [ | |||
1097 | 9 | ] | 9 | ] |
1098 | 10 | 10 | ||
1099 | 11 | from breezy.bugtracker import InvalidBugStatus | 11 | from breezy.bugtracker import InvalidBugStatus |
1100 | 12 | import six | ||
1101 | 12 | from six.moves.urllib.parse import urlsplit | 13 | from six.moves.urllib.parse import urlsplit |
1102 | 13 | from zope.component import getUtility | 14 | from zope.component import getUtility |
1103 | 14 | 15 | ||
1104 | @@ -77,7 +78,7 @@ class BugBranchLinker: | |||
1105 | 77 | except InvalidBugStatus: | 78 | except InvalidBugStatus: |
1106 | 78 | return | 79 | return |
1107 | 79 | bug_set = getUtility(IBugSet) | 80 | bug_set = getUtility(IBugSet) |
1109 | 80 | for bug_id, status in bug_info.iteritems(): | 81 | for bug_id, status in six.iteritems(bug_info): |
1110 | 81 | try: | 82 | try: |
1111 | 82 | bug = bug_set.get(bug_id) | 83 | bug = bug_set.get(bug_id) |
1112 | 83 | except NotFoundError: | 84 | except NotFoundError: |
1113 | diff --git a/lib/lp/codehosting/sshserver/session.py b/lib/lp/codehosting/sshserver/session.py | |||
1114 | index 38bea68..a77855b 100644 | |||
1115 | --- a/lib/lp/codehosting/sshserver/session.py | |||
1116 | +++ b/lib/lp/codehosting/sshserver/session.py | |||
1117 | @@ -15,6 +15,7 @@ import sys | |||
1118 | 15 | 15 | ||
1119 | 16 | from lazr.sshserver.events import AvatarEvent | 16 | from lazr.sshserver.events import AvatarEvent |
1120 | 17 | from lazr.sshserver.session import DoNothingSession | 17 | from lazr.sshserver.session import DoNothingSession |
1121 | 18 | import six | ||
1122 | 18 | from six import reraise | 19 | from six import reraise |
1123 | 19 | from six.moves.urllib.parse import urlparse | 20 | from six.moves.urllib.parse import urlparse |
1124 | 20 | from twisted.internet import ( | 21 | from twisted.internet import ( |
1125 | @@ -144,7 +145,7 @@ class ForkedProcessTransport(process.BaseProcess): | |||
1126 | 144 | assert executable == 'brz', executable # Maybe .endswith() | 145 | assert executable == 'brz', executable # Maybe .endswith() |
1127 | 145 | assert args[0] == 'brz', args[0] | 146 | assert args[0] == 'brz', args[0] |
1128 | 146 | message = ['fork-env %s\n' % (' '.join(args[1:]),)] | 147 | message = ['fork-env %s\n' % (' '.join(args[1:]),)] |
1130 | 147 | for key, value in environment.iteritems(): | 148 | for key, value in six.iteritems(environment): |
1131 | 148 | # XXX: Currently we only pass BRZ_EMAIL, should we be passing | 149 | # XXX: Currently we only pass BRZ_EMAIL, should we be passing |
1132 | 149 | # everything else? Note that many won't be handled properly, | 150 | # everything else? Note that many won't be handled properly, |
1133 | 150 | # since the process is already running. | 151 | # since the process is already running. |
1134 | diff --git a/lib/lp/codehosting/vfs/branchfsclient.py b/lib/lp/codehosting/vfs/branchfsclient.py | |||
1135 | index b96d780..3307830 100644 | |||
1136 | --- a/lib/lp/codehosting/vfs/branchfsclient.py | |||
1137 | +++ b/lib/lp/codehosting/vfs/branchfsclient.py | |||
1138 | @@ -14,6 +14,7 @@ __all__ = [ | |||
1139 | 14 | 14 | ||
1140 | 15 | import time | 15 | import time |
1141 | 16 | 16 | ||
1142 | 17 | import six | ||
1143 | 17 | from twisted.internet import defer | 18 | from twisted.internet import defer |
1144 | 18 | 19 | ||
1145 | 19 | from lp.code.interfaces.codehosting import BRANCH_TRANSPORT | 20 | from lp.code.interfaces.codehosting import BRANCH_TRANSPORT |
1146 | @@ -84,7 +85,7 @@ class BranchFileSystemClient: | |||
1147 | 84 | def _getFromCache(self, path): | 85 | def _getFromCache(self, path): |
1148 | 85 | """Get the cached 'transport_tuple' for 'path'.""" | 86 | """Get the cached 'transport_tuple' for 'path'.""" |
1149 | 86 | split_path = path.strip('/').split('/') | 87 | split_path = path.strip('/').split('/') |
1151 | 87 | for object_path, value in self._cache.iteritems(): | 88 | for object_path, value in six.iteritems(self._cache): |
1152 | 88 | transport_type, data, inserted_time = value | 89 | transport_type, data, inserted_time = value |
1153 | 89 | split_object_path = object_path.strip('/').split('/') | 90 | split_object_path = object_path.strip('/').split('/') |
1154 | 90 | # Do a segment-by-segment comparison. Python sucks, lists should | 91 | # Do a segment-by-segment comparison. Python sucks, lists should |
1155 | diff --git a/lib/lp/registry/model/distroseriesdifference.py b/lib/lp/registry/model/distroseriesdifference.py | |||
1156 | index e0ee875..0672584 100644 | |||
1157 | --- a/lib/lp/registry/model/distroseriesdifference.py | |||
1158 | +++ b/lib/lp/registry/model/distroseriesdifference.py | |||
1159 | @@ -19,6 +19,7 @@ from debian.changelog import ( | |||
1160 | 19 | Version, | 19 | Version, |
1161 | 20 | ) | 20 | ) |
1162 | 21 | from lazr.enum import DBItem | 21 | from lazr.enum import DBItem |
1163 | 22 | import six | ||
1164 | 22 | from sqlobject import StringCol | 23 | from sqlobject import StringCol |
1165 | 23 | from storm.expr import ( | 24 | from storm.expr import ( |
1166 | 24 | And, | 25 | And, |
1167 | @@ -279,10 +280,10 @@ def eager_load_dsds(dsds): | |||
1168 | 279 | # referred to. | 280 | # referred to. |
1169 | 280 | sprs = bulk.load_related( | 281 | sprs = bulk.load_related( |
1170 | 281 | SourcePackageRelease, chain( | 282 | SourcePackageRelease, chain( |
1175 | 282 | source_pubs.itervalues(), | 283 | six.itervalues(source_pubs), |
1176 | 283 | parent_source_pubs.itervalues(), | 284 | six.itervalues(parent_source_pubs), |
1177 | 284 | source_pubs_for_release.itervalues(), | 285 | six.itervalues(source_pubs_for_release), |
1178 | 285 | parent_source_pubs_for_release.itervalues()), | 286 | six.itervalues(parent_source_pubs_for_release)), |
1179 | 286 | ("sourcepackagereleaseID",)) | 287 | ("sourcepackagereleaseID",)) |
1180 | 287 | 288 | ||
1181 | 288 | # Get packagesets and parent_packagesets for each DSD. | 289 | # Get packagesets and parent_packagesets for each DSD. |
1182 | diff --git a/lib/lp/registry/scripts/tests/test_populate_distroseriesdiff.py b/lib/lp/registry/scripts/tests/test_populate_distroseriesdiff.py | |||
1183 | index a8acf8a..84f9f74 100644 | |||
1184 | --- a/lib/lp/registry/scripts/tests/test_populate_distroseriesdiff.py | |||
1185 | +++ b/lib/lp/registry/scripts/tests/test_populate_distroseriesdiff.py | |||
1186 | @@ -5,6 +5,7 @@ | |||
1187 | 5 | 5 | ||
1188 | 6 | __metaclass__ = type | 6 | __metaclass__ = type |
1189 | 7 | 7 | ||
1190 | 8 | import six | ||
1191 | 8 | from storm.store import Store | 9 | from storm.store import Store |
1192 | 9 | import transaction | 10 | import transaction |
1193 | 10 | from zope.security.proxy import removeSecurityProxy | 11 | from zope.security.proxy import removeSecurityProxy |
1194 | @@ -171,7 +172,8 @@ class TestFindLatestSourcePackageReleases(TestCaseWithFactory, FactoryHelper): | |||
1195 | 171 | for status in active_publishing_status) | 172 | for status in active_publishing_status) |
1196 | 172 | query = compose_sql_find_latest_source_package_releases(distroseries) | 173 | query = compose_sql_find_latest_source_package_releases(distroseries) |
1197 | 173 | self.assertContentEqual( | 174 | self.assertContentEqual( |
1199 | 174 | [self.getExpectedResultFor(spph) for spph in spphs.itervalues()], | 175 | [self.getExpectedResultFor(spph) |
1200 | 176 | for spph in six.itervalues(spphs)], | ||
1201 | 175 | Store.of(distroseries).execute(query)) | 177 | Store.of(distroseries).execute(query)) |
1202 | 176 | 178 | ||
1203 | 177 | def test_does_not_find_inactive_publication(self): | 179 | def test_does_not_find_inactive_publication(self): |
1204 | diff --git a/lib/lp/registry/services/sharingservice.py b/lib/lp/registry/services/sharingservice.py | |||
1205 | index 68e33c3..09744ee 100644 | |||
1206 | --- a/lib/lp/registry/services/sharingservice.py | |||
1207 | +++ b/lib/lp/registry/services/sharingservice.py | |||
1208 | @@ -13,6 +13,7 @@ from operator import attrgetter | |||
1209 | 13 | 13 | ||
1210 | 14 | from lazr.restful.interfaces import IWebBrowserOriginatingRequest | 14 | from lazr.restful.interfaces import IWebBrowserOriginatingRequest |
1211 | 15 | from lazr.restful.utils import get_current_web_service_request | 15 | from lazr.restful.utils import get_current_web_service_request |
1212 | 16 | import six | ||
1213 | 16 | from storm.expr import ( | 17 | from storm.expr import ( |
1214 | 17 | And, | 18 | And, |
1215 | 18 | Count, | 19 | Count, |
1216 | @@ -608,7 +609,7 @@ class SharingService: | |||
1217 | 608 | for (grantee, permissions, shared_artifact_types) in grant_permissions: | 609 | for (grantee, permissions, shared_artifact_types) in grant_permissions: |
1218 | 609 | some_things_shared = len(shared_artifact_types) > 0 | 610 | some_things_shared = len(shared_artifact_types) > 0 |
1219 | 610 | grantee_permissions = {} | 611 | grantee_permissions = {} |
1221 | 611 | for (policy, permission) in permissions.iteritems(): | 612 | for (policy, permission) in six.iteritems(permissions): |
1222 | 612 | grantee_permissions[policy.type.name] = permission.name | 613 | grantee_permissions[policy.type.name] = permission.name |
1223 | 613 | shared_artifact_type_names = [ | 614 | shared_artifact_type_names = [ |
1224 | 614 | info_type.name for info_type in shared_artifact_types] | 615 | info_type.name for info_type in shared_artifact_types] |
1225 | diff --git a/lib/lp/scripts/utilities/warninghandler.py b/lib/lp/scripts/utilities/warninghandler.py | |||
1226 | index 46b8a73..cb0c4ff 100644 | |||
1227 | --- a/lib/lp/scripts/utilities/warninghandler.py | |||
1228 | +++ b/lib/lp/scripts/utilities/warninghandler.py | |||
1229 | @@ -12,6 +12,8 @@ import StringIO | |||
1230 | 12 | import sys | 12 | import sys |
1231 | 13 | import warnings | 13 | import warnings |
1232 | 14 | 14 | ||
1233 | 15 | import six | ||
1234 | 16 | |||
1235 | 15 | 17 | ||
1236 | 16 | class WarningReport: | 18 | class WarningReport: |
1237 | 17 | 19 | ||
1238 | @@ -211,7 +213,7 @@ def report_other_warnings(): | |||
1239 | 211 | if other_warnings: | 213 | if other_warnings: |
1240 | 212 | print(file=sys.stderr) | 214 | print(file=sys.stderr) |
1241 | 213 | print("General warnings.", file=sys.stderr) | 215 | print("General warnings.", file=sys.stderr) |
1243 | 214 | for warninginfo in other_warnings.itervalues(): | 216 | for warninginfo in six.itervalues(other_warnings): |
1244 | 215 | print(file=sys.stderr) | 217 | print(file=sys.stderr) |
1245 | 216 | print(warninginfo, file=sys.stderr) | 218 | print(warninginfo, file=sys.stderr) |
1246 | 217 | 219 | ||
1247 | diff --git a/lib/lp/services/command_spawner.py b/lib/lp/services/command_spawner.py | |||
1248 | index dcca28f..539a3fb 100644 | |||
1249 | --- a/lib/lp/services/command_spawner.py | |||
1250 | +++ b/lib/lp/services/command_spawner.py | |||
1251 | @@ -151,7 +151,7 @@ class CommandSpawner: | |||
1252 | 151 | processes are cleaned up. Until then, they will stay around as | 151 | processes are cleaned up. Until then, they will stay around as |
1253 | 152 | zombies. | 152 | zombies. |
1254 | 153 | """ | 153 | """ |
1256 | 154 | for process in self.running_processes.iterkeys(): | 154 | for process in self.running_processes: |
1257 | 155 | process.terminate() | 155 | process.terminate() |
1258 | 156 | 156 | ||
1259 | 157 | def _spawn(self, command): | 157 | def _spawn(self, command): |
1260 | diff --git a/lib/lp/services/config/__init__.py b/lib/lp/services/config/__init__.py | |||
1261 | index 3c6ad51..ebe9ebf 100644 | |||
1262 | --- a/lib/lp/services/config/__init__.py | |||
1263 | +++ b/lib/lp/services/config/__init__.py | |||
1264 | @@ -22,6 +22,7 @@ import sys | |||
1265 | 22 | 22 | ||
1266 | 23 | from lazr.config import ImplicitTypeSchema | 23 | from lazr.config import ImplicitTypeSchema |
1267 | 24 | from lazr.config.interfaces import ConfigErrors | 24 | from lazr.config.interfaces import ConfigErrors |
1268 | 25 | import six | ||
1269 | 25 | from six.moves.urllib.parse import ( | 26 | from six.moves.urllib.parse import ( |
1270 | 26 | urlparse, | 27 | urlparse, |
1271 | 27 | urlunparse, | 28 | urlunparse, |
1272 | @@ -459,7 +460,7 @@ class DatabaseConfig: | |||
1273 | 459 | 460 | ||
1274 | 460 | Overriding a value to None removes the override. | 461 | Overriding a value to None removes the override. |
1275 | 461 | """ | 462 | """ |
1277 | 462 | for attr, value in kwargs.iteritems(): | 463 | for attr, value in six.iteritems(kwargs): |
1278 | 463 | assert attr in self._db_config_attrs, ( | 464 | assert attr in self._db_config_attrs, ( |
1279 | 464 | "%s cannot be overridden" % attr) | 465 | "%s cannot be overridden" % attr) |
1280 | 465 | if value is None: | 466 | if value is None: |
1281 | diff --git a/lib/lp/services/database/bulk.py b/lib/lp/services/database/bulk.py | |||
1282 | index f73bbf8..840e402 100644 | |||
1283 | --- a/lib/lp/services/database/bulk.py | |||
1284 | +++ b/lib/lp/services/database/bulk.py | |||
1285 | @@ -25,6 +25,7 @@ from operator import ( | |||
1286 | 25 | itemgetter, | 25 | itemgetter, |
1287 | 26 | ) | 26 | ) |
1288 | 27 | 27 | ||
1289 | 28 | import six | ||
1290 | 28 | from storm.databases.postgres import Returning | 29 | from storm.databases.postgres import Returning |
1291 | 29 | from storm.expr import ( | 30 | from storm.expr import ( |
1292 | 30 | And, | 31 | And, |
1293 | @@ -52,7 +53,7 @@ def collate(things, key): | |||
1294 | 52 | collection = defaultdict(list) | 53 | collection = defaultdict(list) |
1295 | 53 | for thing in things: | 54 | for thing in things: |
1296 | 54 | collection[key(thing)].append(thing) | 55 | collection[key(thing)].append(thing) |
1298 | 55 | return collection.iteritems() | 56 | return six.iteritems(collection) |
1299 | 56 | 57 | ||
1300 | 57 | 58 | ||
1301 | 58 | def get_type(thing): | 59 | def get_type(thing): |
1302 | diff --git a/lib/lp/services/features/testing.py b/lib/lp/services/features/testing.py | |||
1303 | index 998138d..3a2d69b 100644 | |||
1304 | --- a/lib/lp/services/features/testing.py | |||
1305 | +++ b/lib/lp/services/features/testing.py | |||
1306 | @@ -13,6 +13,7 @@ __all__ = [ | |||
1307 | 13 | from fixtures import Fixture | 13 | from fixtures import Fixture |
1308 | 14 | from lazr.restful.utils import get_current_browser_request | 14 | from lazr.restful.utils import get_current_browser_request |
1309 | 15 | import psycopg2 | 15 | import psycopg2 |
1310 | 16 | import six | ||
1311 | 16 | 17 | ||
1312 | 17 | from lp.services.features import ( | 18 | from lp.services.features import ( |
1313 | 18 | get_relevant_feature_controller, | 19 | get_relevant_feature_controller, |
1314 | @@ -91,7 +92,7 @@ class FeatureFixtureMixin: | |||
1315 | 91 | scope='default', | 92 | scope='default', |
1316 | 92 | priority=999, | 93 | priority=999, |
1317 | 93 | value=unicode(value)) | 94 | value=unicode(value)) |
1319 | 94 | for flag_name, value in self.desired_features.iteritems() | 95 | for flag_name, value in six.iteritems(self.desired_features) |
1320 | 95 | if value is not None] | 96 | if value is not None] |
1321 | 96 | 97 | ||
1322 | 97 | if self.full_feature_rules is not None: | 98 | if self.full_feature_rules is not None: |
1323 | diff --git a/lib/lp/services/librarianserver/testing/fake.py b/lib/lp/services/librarianserver/testing/fake.py | |||
1324 | index 37d6bb6..e1e1f5e 100644 | |||
1325 | --- a/lib/lp/services/librarianserver/testing/fake.py | |||
1326 | +++ b/lib/lp/services/librarianserver/testing/fake.py | |||
1327 | @@ -19,6 +19,7 @@ import hashlib | |||
1328 | 19 | from StringIO import StringIO | 19 | from StringIO import StringIO |
1329 | 20 | 20 | ||
1330 | 21 | from fixtures import Fixture | 21 | from fixtures import Fixture |
1331 | 22 | import six | ||
1332 | 22 | from six.moves.urllib.parse import urljoin | 23 | from six.moves.urllib.parse import urljoin |
1333 | 23 | import transaction | 24 | import transaction |
1334 | 24 | from transaction.interfaces import ISynchronizer | 25 | from transaction.interfaces import ISynchronizer |
1335 | @@ -138,7 +139,7 @@ class FakeLibrarian(Fixture): | |||
1336 | 138 | database transaction. | 139 | database transaction. |
1337 | 139 | """ | 140 | """ |
1338 | 140 | # Note that all files have been committed to storage. | 141 | # Note that all files have been committed to storage. |
1340 | 141 | for alias in self.aliases.itervalues(): | 142 | for alias in six.itervalues(self.aliases): |
1341 | 142 | alias.file_committed = True | 143 | alias.file_committed = True |
1342 | 143 | 144 | ||
1343 | 144 | def _makeAlias(self, file_id, name, content, content_type): | 145 | def _makeAlias(self, file_id, name, content, content_type): |
1344 | @@ -175,7 +176,7 @@ class FakeLibrarian(Fixture): | |||
1345 | 175 | 176 | ||
1346 | 176 | def findBySHA256(self, sha256): | 177 | def findBySHA256(self, sha256): |
1347 | 177 | "See `ILibraryFileAliasSet`.""" | 178 | "See `ILibraryFileAliasSet`.""" |
1349 | 178 | for alias in self.aliases.itervalues(): | 179 | for alias in six.itervalues(self.aliases): |
1350 | 179 | if alias.content.sha256 == sha256: | 180 | if alias.content.sha256 == sha256: |
1351 | 180 | return alias | 181 | return alias |
1352 | 181 | 182 | ||
1353 | diff --git a/lib/lp/services/mail/basemailer.py b/lib/lp/services/mail/basemailer.py | |||
1354 | index a2f8a40..280ab78 100644 | |||
1355 | --- a/lib/lp/services/mail/basemailer.py | |||
1356 | +++ b/lib/lp/services/mail/basemailer.py | |||
1357 | @@ -12,6 +12,7 @@ import logging | |||
1358 | 12 | from smtplib import SMTPException | 12 | from smtplib import SMTPException |
1359 | 13 | import sys | 13 | import sys |
1360 | 14 | 14 | ||
1361 | 15 | import six | ||
1362 | 15 | from zope.component import getUtility | 16 | from zope.component import getUtility |
1363 | 16 | from zope.error.interfaces import IErrorReportingUtility | 17 | from zope.error.interfaces import IErrorReportingUtility |
1364 | 17 | from zope.security.management import getSecurityPolicy | 18 | from zope.security.management import getSecurityPolicy |
1365 | @@ -79,7 +80,7 @@ class BaseMailer: | |||
1366 | 79 | self._subject_template = subject | 80 | self._subject_template = subject |
1367 | 80 | self._template_name = template_name | 81 | self._template_name = template_name |
1368 | 81 | self._recipients = NotificationRecipientSet() | 82 | self._recipients = NotificationRecipientSet() |
1370 | 82 | for recipient, reason in recipients.iteritems(): | 83 | for recipient, reason in six.iteritems(recipients): |
1371 | 83 | self._recipients.add(recipient, reason, reason.mail_header) | 84 | self._recipients.add(recipient, reason, reason.mail_header) |
1372 | 84 | self.from_address = from_address | 85 | self.from_address = from_address |
1373 | 85 | self.delta = delta | 86 | self.delta = delta |
1374 | diff --git a/lib/lp/services/messaging/tests/test_rabbit.py b/lib/lp/services/messaging/tests/test_rabbit.py | |||
1375 | index 6cd9f99..dfd48af 100644 | |||
1376 | --- a/lib/lp/services/messaging/tests/test_rabbit.py | |||
1377 | +++ b/lib/lp/services/messaging/tests/test_rabbit.py | |||
1378 | @@ -9,6 +9,7 @@ from functools import partial | |||
1379 | 9 | from itertools import count | 9 | from itertools import count |
1380 | 10 | import socket | 10 | import socket |
1381 | 11 | 11 | ||
1382 | 12 | import six | ||
1383 | 12 | from testtools.testcase import ExpectedException | 13 | from testtools.testcase import ExpectedException |
1384 | 13 | import transaction | 14 | import transaction |
1385 | 14 | from transaction._transaction import Status as TransactionStatus | 15 | from transaction._transaction import Status as TransactionStatus |
1386 | @@ -396,7 +397,7 @@ class TestRabbit(RabbitTestCase): | |||
1387 | 396 | return set() | 397 | return set() |
1388 | 397 | else: | 398 | else: |
1389 | 398 | return set( | 399 | return set( |
1391 | 399 | sync.session for sync in syncs_set.data.itervalues() | 400 | sync.session for sync in six.itervalues(syncs_set.data) |
1392 | 400 | if isinstance(sync, RabbitSessionTransactionSync)) | 401 | if isinstance(sync, RabbitSessionTransactionSync)) |
1393 | 401 | 402 | ||
1394 | 402 | def test_global_session(self): | 403 | def test_global_session(self): |
1395 | diff --git a/lib/lp/services/osutils.py b/lib/lp/services/osutils.py | |||
1396 | index b487165..7eafc40 100644 | |||
1397 | --- a/lib/lp/services/osutils.py | |||
1398 | +++ b/lib/lp/services/osutils.py | |||
1399 | @@ -28,6 +28,8 @@ from signal import ( | |||
1400 | 28 | ) | 28 | ) |
1401 | 29 | import time | 29 | import time |
1402 | 30 | 30 | ||
1403 | 31 | import six | ||
1404 | 32 | |||
1405 | 31 | 33 | ||
1406 | 32 | def remove_tree(path): | 34 | def remove_tree(path): |
1407 | 33 | """Remove the tree at 'path' from disk.""" | 35 | """Remove the tree at 'path' from disk.""" |
1408 | @@ -41,7 +43,7 @@ def set_environ(new_values): | |||
1409 | 41 | :return: a dict of the old values | 43 | :return: a dict of the old values |
1410 | 42 | """ | 44 | """ |
1411 | 43 | old_values = {} | 45 | old_values = {} |
1413 | 44 | for name, value in new_values.iteritems(): | 46 | for name, value in six.iteritems(new_values): |
1414 | 45 | old_values[name] = os.environ.get(name) | 47 | old_values[name] = os.environ.get(name) |
1415 | 46 | if value is None: | 48 | if value is None: |
1416 | 47 | if old_values[name] is not None: | 49 | if old_values[name] is not None: |
1417 | diff --git a/lib/lp/services/testing/customresult.py b/lib/lp/services/testing/customresult.py | |||
1418 | index 2164f3d..5862f84 100644 | |||
1419 | --- a/lib/lp/services/testing/customresult.py | |||
1420 | +++ b/lib/lp/services/testing/customresult.py | |||
1421 | @@ -11,6 +11,7 @@ __all__ = [ | |||
1422 | 11 | 11 | ||
1423 | 12 | from unittest import TestSuite | 12 | from unittest import TestSuite |
1424 | 13 | 13 | ||
1425 | 14 | import six | ||
1426 | 14 | from zope.testrunner import find | 15 | from zope.testrunner import find |
1427 | 15 | 16 | ||
1428 | 16 | 17 | ||
1429 | @@ -65,7 +66,7 @@ def filter_tests(list_name, reorder_tests=False): | |||
1430 | 65 | test_lookup = {} | 66 | test_lookup = {} |
1431 | 66 | # Multiple unique testcases can be represented by a single id and they | 67 | # Multiple unique testcases can be represented by a single id and they |
1432 | 67 | # must be tracked separately. | 68 | # must be tracked separately. |
1434 | 68 | for layer_name, suite in tests_by_layer_name.iteritems(): | 69 | for layer_name, suite in six.iteritems(tests_by_layer_name): |
1435 | 69 | for testcase in suite: | 70 | for testcase in suite: |
1436 | 70 | layer_to_tests = test_lookup.setdefault( | 71 | layer_to_tests = test_lookup.setdefault( |
1437 | 71 | testcase.id(), {}) | 72 | testcase.id(), {}) |
1438 | diff --git a/lib/lp/services/utils.py b/lib/lp/services/utils.py | |||
1439 | index beda118..ea661c5 100644 | |||
1440 | --- a/lib/lp/services/utils.py | |||
1441 | +++ b/lib/lp/services/utils.py | |||
1442 | @@ -52,6 +52,7 @@ from fixtures import ( | |||
1443 | 52 | ) | 52 | ) |
1444 | 53 | from lazr.enum import BaseItem | 53 | from lazr.enum import BaseItem |
1445 | 54 | import pytz | 54 | import pytz |
1446 | 55 | import six | ||
1447 | 55 | from six.moves import cPickle as pickle | 56 | from six.moves import cPickle as pickle |
1448 | 56 | from twisted.python.util import mergeFunctionMetadata | 57 | from twisted.python.util import mergeFunctionMetadata |
1449 | 57 | from zope.security.proxy import isinstance as zope_isinstance | 58 | from zope.security.proxy import isinstance as zope_isinstance |
1450 | @@ -388,7 +389,7 @@ def obfuscate_structure(o): | |||
1451 | 388 | elif isinstance(o, (dict)): | 389 | elif isinstance(o, (dict)): |
1452 | 389 | return dict( | 390 | return dict( |
1453 | 390 | (obfuscate_structure(key), obfuscate_structure(value)) | 391 | (obfuscate_structure(key), obfuscate_structure(value)) |
1455 | 391 | for key, value in o.iteritems()) | 392 | for key, value in six.iteritems(o)) |
1456 | 392 | else: | 393 | else: |
1457 | 393 | return o | 394 | return o |
1458 | 394 | 395 | ||
1459 | diff --git a/lib/lp/services/webapp/escaping.py b/lib/lp/services/webapp/escaping.py | |||
1460 | index 8c4d965..bce499e 100644 | |||
1461 | --- a/lib/lp/services/webapp/escaping.py | |||
1462 | +++ b/lib/lp/services/webapp/escaping.py | |||
1463 | @@ -9,6 +9,7 @@ __all__ = [ | |||
1464 | 9 | ] | 9 | ] |
1465 | 10 | 10 | ||
1466 | 11 | from lazr.restful.utils import get_current_browser_request | 11 | from lazr.restful.utils import get_current_browser_request |
1467 | 12 | import six | ||
1468 | 12 | from zope.i18n import ( | 13 | from zope.i18n import ( |
1469 | 13 | Message, | 14 | Message, |
1470 | 14 | translate, | 15 | translate, |
1471 | @@ -95,7 +96,7 @@ class structured: | |||
1472 | 95 | self.escapedtext = text % tuple(html_escape(rep) for rep in reps) | 96 | self.escapedtext = text % tuple(html_escape(rep) for rep in reps) |
1473 | 96 | elif kwreps: | 97 | elif kwreps: |
1474 | 97 | self.escapedtext = text % dict( | 98 | self.escapedtext = text % dict( |
1476 | 98 | (k, html_escape(v)) for k, v in kwreps.iteritems()) | 99 | (k, html_escape(v)) for k, v in six.iteritems(kwreps)) |
1477 | 99 | else: | 100 | else: |
1478 | 100 | self.escapedtext = text | 101 | self.escapedtext = text |
1479 | 101 | 102 | ||
1480 | diff --git a/lib/lp/services/webapp/login.py b/lib/lp/services/webapp/login.py | |||
1481 | index 43eb478..fdbd079 100644 | |||
1482 | --- a/lib/lp/services/webapp/login.py | |||
1483 | +++ b/lib/lp/services/webapp/login.py | |||
1484 | @@ -290,7 +290,7 @@ class OpenIDCallbackView(OpenIDLogin): | |||
1485 | 290 | 290 | ||
1486 | 291 | def _gather_params(self, request): | 291 | def _gather_params(self, request): |
1487 | 292 | params = dict(request.form) | 292 | params = dict(request.form) |
1489 | 293 | for key, value in request.query_string_params.iteritems(): | 293 | for key, value in six.iteritems(request.query_string_params): |
1490 | 294 | if len(value) > 1: | 294 | if len(value) > 1: |
1491 | 295 | raise ValueError( | 295 | raise ValueError( |
1492 | 296 | 'Did not expect multi-valued fields.') | 296 | 'Did not expect multi-valued fields.') |
1493 | diff --git a/lib/lp/services/webapp/servers.py b/lib/lp/services/webapp/servers.py | |||
1494 | index 8b85df8..1f77b76 100644 | |||
1495 | --- a/lib/lp/services/webapp/servers.py | |||
1496 | +++ b/lib/lp/services/webapp/servers.py | |||
1497 | @@ -529,7 +529,7 @@ def get_query_string_params(request): | |||
1498 | 529 | parsed_qs = parse_qs(query_string, keep_blank_values=True) | 529 | parsed_qs = parse_qs(query_string, keep_blank_values=True) |
1499 | 530 | # Use BrowserRequest._decode() for decoding the received parameters. | 530 | # Use BrowserRequest._decode() for decoding the received parameters. |
1500 | 531 | decoded_qs = {} | 531 | decoded_qs = {} |
1502 | 532 | for key, values in parsed_qs.iteritems(): | 532 | for key, values in six.iteritems(parsed_qs): |
1503 | 533 | decoded_qs[key] = [ | 533 | decoded_qs[key] = [ |
1504 | 534 | request._decode(value) for value in values] | 534 | request._decode(value) for value in values] |
1505 | 535 | return decoded_qs | 535 | return decoded_qs |
1506 | diff --git a/lib/lp/services/webhooks/interfaces.py b/lib/lp/services/webhooks/interfaces.py | |||
1507 | index d4d20e3..ad01625 100644 | |||
1508 | --- a/lib/lp/services/webhooks/interfaces.py | |||
1509 | +++ b/lib/lp/services/webhooks/interfaces.py | |||
1510 | @@ -40,6 +40,7 @@ from lazr.restful.fields import ( | |||
1511 | 40 | Reference, | 40 | Reference, |
1512 | 41 | ) | 41 | ) |
1513 | 42 | from lazr.restful.interface import copy_field | 42 | from lazr.restful.interface import copy_field |
1514 | 43 | import six | ||
1515 | 43 | from six.moves import http_client | 44 | from six.moves import http_client |
1516 | 44 | from zope.interface import ( | 45 | from zope.interface import ( |
1517 | 45 | Attribute, | 46 | Attribute, |
1518 | @@ -105,7 +106,7 @@ class AnyWebhookEventTypeVocabulary(SimpleVocabulary): | |||
1519 | 105 | def __init__(self, context): | 106 | def __init__(self, context): |
1520 | 106 | terms = [ | 107 | terms = [ |
1521 | 107 | self.createTerm(key, key, value) | 108 | self.createTerm(key, key, value) |
1523 | 108 | for key, value in WEBHOOK_EVENT_TYPES.iteritems()] | 109 | for key, value in six.iteritems(WEBHOOK_EVENT_TYPES)] |
1524 | 109 | super(AnyWebhookEventTypeVocabulary, self).__init__(terms) | 110 | super(AnyWebhookEventTypeVocabulary, self).__init__(terms) |
1525 | 110 | 111 | ||
1526 | 111 | 112 | ||
1527 | diff --git a/lib/lp/soyuz/browser/tests/archive-views.txt b/lib/lp/soyuz/browser/tests/archive-views.txt | |||
1528 | index 8f440d7..72c1392 100644 | |||
1529 | --- a/lib/lp/soyuz/browser/tests/archive-views.txt | |||
1530 | +++ b/lib/lp/soyuz/browser/tests/archive-views.txt | |||
1531 | @@ -105,8 +105,10 @@ usage details in a dictionary containing: | |||
1532 | 105 | We will use a helper function for printing the returned dictionary | 105 | We will use a helper function for printing the returned dictionary |
1533 | 106 | contents. | 106 | contents. |
1534 | 107 | 107 | ||
1535 | 108 | >>> import six | ||
1536 | 109 | |||
1537 | 108 | >>> def print_repository_usage(repository_usage): | 110 | >>> def print_repository_usage(repository_usage): |
1539 | 109 | ... for key, value in sorted(repository_usage.iteritems()): | 111 | ... for key, value in sorted(six.iteritems(repository_usage)): |
1540 | 110 | ... print('%s: %s' % (key, value)) | 112 | ... print('%s: %s' % (key, value)) |
1541 | 111 | 113 | ||
1542 | 112 | Celso PPA has some packages, but still below the quota. | 114 | Celso PPA has some packages, but still below the quota. |
1543 | diff --git a/lib/lp/soyuz/model/packagediff.py b/lib/lp/soyuz/model/packagediff.py | |||
1544 | index 6933c31..12437cd 100644 | |||
1545 | --- a/lib/lp/soyuz/model/packagediff.py | |||
1546 | +++ b/lib/lp/soyuz/model/packagediff.py | |||
1547 | @@ -16,6 +16,7 @@ import shutil | |||
1548 | 16 | import subprocess | 16 | import subprocess |
1549 | 17 | import tempfile | 17 | import tempfile |
1550 | 18 | 18 | ||
1551 | 19 | import six | ||
1552 | 19 | from sqlobject import ForeignKey | 20 | from sqlobject import ForeignKey |
1553 | 20 | from storm.expr import Desc | 21 | from storm.expr import Desc |
1554 | 21 | from storm.store import EmptyResultSet | 22 | from storm.store import EmptyResultSet |
1555 | @@ -215,7 +216,7 @@ class PackageDiff(SQLBase): | |||
1556 | 215 | zip(directions, (self.from_source, self.to_source))) | 216 | zip(directions, (self.from_source, self.to_source))) |
1557 | 216 | 217 | ||
1558 | 217 | # Iterate over the packages to be diff'ed. | 218 | # Iterate over the packages to be diff'ed. |
1560 | 218 | for direction, package in packages.iteritems(): | 219 | for direction, package in six.iteritems(packages): |
1561 | 219 | # Create distinct directory locations for | 220 | # Create distinct directory locations for |
1562 | 220 | # 'from' and 'to' files. | 221 | # 'from' and 'to' files. |
1563 | 221 | absolute_path = os.path.join(tmp_dir, direction) | 222 | absolute_path = os.path.join(tmp_dir, direction) |
1564 | diff --git a/lib/lp/soyuz/model/publishing.py b/lib/lp/soyuz/model/publishing.py | |||
1565 | index fafd7f9..1c5d384 100644 | |||
1566 | --- a/lib/lp/soyuz/model/publishing.py | |||
1567 | +++ b/lib/lp/soyuz/model/publishing.py | |||
1568 | @@ -22,6 +22,7 @@ import os | |||
1569 | 22 | import sys | 22 | import sys |
1570 | 23 | 23 | ||
1571 | 24 | import pytz | 24 | import pytz |
1572 | 25 | import six | ||
1573 | 25 | from sqlobject import ( | 26 | from sqlobject import ( |
1574 | 26 | ForeignKey, | 27 | ForeignKey, |
1575 | 27 | IntCol, | 28 | IntCol, |
1576 | @@ -1012,7 +1013,7 @@ def expand_binary_requests(distroseries, binaries): | |||
1577 | 1012 | arch_map = dict((arch.architecturetag, arch) for arch in archs) | 1013 | arch_map = dict((arch.architecturetag, arch) for arch in archs) |
1578 | 1013 | 1014 | ||
1579 | 1014 | expanded = [] | 1015 | expanded = [] |
1581 | 1015 | for bpr, overrides in binaries.iteritems(): | 1016 | for bpr, overrides in six.iteritems(binaries): |
1582 | 1016 | if bpr.architecturespecific: | 1017 | if bpr.architecturespecific: |
1583 | 1017 | # Find the DAS in this series corresponding to the original | 1018 | # Find the DAS in this series corresponding to the original |
1584 | 1018 | # build arch tag. If it does not exist or is disabled, we should | 1019 | # build arch tag. If it does not exist or is disabled, we should |
1585 | diff --git a/lib/lp/soyuz/scripts/custom_uploads_copier.py b/lib/lp/soyuz/scripts/custom_uploads_copier.py | |||
1586 | index e6f7e83..21cc1f2 100644 | |||
1587 | --- a/lib/lp/soyuz/scripts/custom_uploads_copier.py | |||
1588 | +++ b/lib/lp/soyuz/scripts/custom_uploads_copier.py | |||
1589 | @@ -14,6 +14,8 @@ __all__ = [ | |||
1590 | 14 | 14 | ||
1591 | 15 | from operator import attrgetter | 15 | from operator import attrgetter |
1592 | 16 | 16 | ||
1593 | 17 | import six | ||
1594 | 18 | |||
1595 | 17 | from lp.archivepublisher.ddtp_tarball import DdtpTarballUpload | 19 | from lp.archivepublisher.ddtp_tarball import DdtpTarballUpload |
1596 | 18 | from lp.archivepublisher.debian_installer import DebianInstallerUpload | 20 | from lp.archivepublisher.debian_installer import DebianInstallerUpload |
1597 | 19 | from lp.archivepublisher.dist_upgrader import DistUpgraderUpload | 21 | from lp.archivepublisher.dist_upgrader import DistUpgraderUpload |
1598 | @@ -163,7 +165,7 @@ class CustomUploadsCopier: | |||
1599 | 163 | self.target_series, source_pocket=self.target_pocket) | 165 | self.target_series, source_pocket=self.target_pocket) |
1600 | 164 | source_uploads = self.getLatestUploads( | 166 | source_uploads = self.getLatestUploads( |
1601 | 165 | source_series, source_pocket=source_pocket) | 167 | source_series, source_pocket=source_pocket) |
1603 | 166 | for upload in source_uploads.itervalues(): | 168 | for upload in six.itervalues(source_uploads): |
1604 | 167 | if (not self.isObsolete(upload, target_uploads) and | 169 | if (not self.isObsolete(upload, target_uploads) and |
1605 | 168 | self.isForValidDAS(upload)): | 170 | self.isForValidDAS(upload)): |
1606 | 169 | self.copyUpload(upload) | 171 | self.copyUpload(upload) |
1607 | diff --git a/lib/lp/soyuz/scripts/gina/handlers.py b/lib/lp/soyuz/scripts/gina/handlers.py | |||
1608 | index 54539a4..597e5aa 100644 | |||
1609 | --- a/lib/lp/soyuz/scripts/gina/handlers.py | |||
1610 | +++ b/lib/lp/soyuz/scripts/gina/handlers.py | |||
1611 | @@ -24,6 +24,7 @@ from cStringIO import StringIO | |||
1612 | 24 | import os | 24 | import os |
1613 | 25 | import re | 25 | import re |
1614 | 26 | 26 | ||
1615 | 27 | import six | ||
1616 | 27 | from sqlobject import ( | 28 | from sqlobject import ( |
1617 | 28 | SQLObjectMoreThanOneResultError, | 29 | SQLObjectMoreThanOneResultError, |
1618 | 29 | SQLObjectNotFound, | 30 | SQLObjectNotFound, |
1619 | @@ -504,7 +505,7 @@ class SourcePackageHandler: | |||
1620 | 504 | dsc_contents = parse_tagfile(dsc_path) | 505 | dsc_contents = parse_tagfile(dsc_path) |
1621 | 505 | dsc_contents = dict([ | 506 | dsc_contents = dict([ |
1622 | 506 | (name.lower(), value) for | 507 | (name.lower(), value) for |
1624 | 507 | (name, value) in dsc_contents.iteritems()]) | 508 | (name, value) in six.iteritems(dsc_contents)]) |
1625 | 508 | 509 | ||
1626 | 509 | # Since the dsc doesn't know, we add in the directory, package | 510 | # Since the dsc doesn't know, we add in the directory, package |
1627 | 510 | # component and section | 511 | # component and section |
1628 | diff --git a/lib/lp/soyuz/scripts/gina/runner.py b/lib/lp/soyuz/scripts/gina/runner.py | |||
1629 | index d9edd1f..631323f 100644 | |||
1630 | --- a/lib/lp/soyuz/scripts/gina/runner.py | |||
1631 | +++ b/lib/lp/soyuz/scripts/gina/runner.py | |||
1632 | @@ -157,7 +157,7 @@ def import_sourcepackages(distro, packages_map, package_root, | |||
1633 | 157 | npacks = len(packages_map.src_map) | 157 | npacks = len(packages_map.src_map) |
1634 | 158 | log.info('%i Source Packages to be imported', npacks) | 158 | log.info('%i Source Packages to be imported', npacks) |
1635 | 159 | 159 | ||
1637 | 160 | for package in sorted(packages_map.src_map.iterkeys()): | 160 | for package in sorted(packages_map.src_map): |
1638 | 161 | for source in packages_map.src_map[package]: | 161 | for source in packages_map.src_map[package]: |
1639 | 162 | attempt_source_package_import( | 162 | attempt_source_package_import( |
1640 | 163 | distro, source, package_root, importer_handler) | 163 | distro, source, package_root, importer_handler) |
1641 | @@ -193,7 +193,7 @@ def import_binarypackages(distro, packages_map, package_root, | |||
1642 | 193 | log.info( | 193 | log.info( |
1643 | 194 | '%i Binary Packages to be imported for %s', npacks, archtag) | 194 | '%i Binary Packages to be imported for %s', npacks, archtag) |
1644 | 195 | # Go over binarypackages importing them for this architecture | 195 | # Go over binarypackages importing them for this architecture |
1646 | 196 | for package_name in sorted(packages_map.bin_map[archtag].iterkeys()): | 196 | for package_name in sorted(packages_map.bin_map[archtag]): |
1647 | 197 | binary = packages_map.bin_map[archtag][package_name] | 197 | binary = packages_map.bin_map[archtag][package_name] |
1648 | 198 | try: | 198 | try: |
1649 | 199 | try: | 199 | try: |
1650 | diff --git a/lib/lp/testing/__init__.py b/lib/lp/testing/__init__.py | |||
1651 | index 20a50d9..81e86f1 100644 | |||
1652 | --- a/lib/lp/testing/__init__.py | |||
1653 | +++ b/lib/lp/testing/__init__.py | |||
1654 | @@ -96,6 +96,7 @@ import oops_datedir_repo.serializer_rfc822 | |||
1655 | 96 | import pytz | 96 | import pytz |
1656 | 97 | import scandir | 97 | import scandir |
1657 | 98 | import simplejson | 98 | import simplejson |
1658 | 99 | import six | ||
1659 | 99 | from storm.store import Store | 100 | from storm.store import Store |
1660 | 100 | import subunit | 101 | import subunit |
1661 | 101 | import testtools | 102 | import testtools |
1662 | @@ -697,7 +698,7 @@ class TestCase(testtools.TestCase, fixtures.TestWithFixtures): | |||
1663 | 697 | The config values will be restored during test tearDown. | 698 | The config values will be restored during test tearDown. |
1664 | 698 | """ | 699 | """ |
1665 | 699 | name = self.factory.getUniqueString() | 700 | name = self.factory.getUniqueString() |
1667 | 700 | body = '\n'.join("%s: %s" % (k, v) for k, v in kwargs.iteritems()) | 701 | body = '\n'.join("%s: %s" % (k, v) for k, v in six.iteritems(kwargs)) |
1668 | 701 | config.push(name, "\n[%s]\n%s\n" % (section, body)) | 702 | config.push(name, "\n[%s]\n%s\n" % (section, body)) |
1669 | 702 | self.addCleanup(config.pop, name) | 703 | self.addCleanup(config.pop, name) |
1670 | 703 | 704 | ||
1671 | @@ -1527,13 +1528,13 @@ def monkey_patch(context, **kwargs): | |||
1672 | 1527 | """ | 1528 | """ |
1673 | 1528 | old_values = {} | 1529 | old_values = {} |
1674 | 1529 | not_set = object() | 1530 | not_set = object() |
1676 | 1530 | for name, value in kwargs.iteritems(): | 1531 | for name, value in six.iteritems(kwargs): |
1677 | 1531 | old_values[name] = getattr(context, name, not_set) | 1532 | old_values[name] = getattr(context, name, not_set) |
1678 | 1532 | setattr(context, name, value) | 1533 | setattr(context, name, value) |
1679 | 1533 | try: | 1534 | try: |
1680 | 1534 | yield | 1535 | yield |
1681 | 1535 | finally: | 1536 | finally: |
1683 | 1536 | for name, value in old_values.iteritems(): | 1537 | for name, value in six.iteritems(old_values): |
1684 | 1537 | if value is not_set: | 1538 | if value is not_set: |
1685 | 1538 | delattr(context, name) | 1539 | delattr(context, name) |
1686 | 1539 | else: | 1540 | else: |
1687 | diff --git a/lib/lp/testing/swift/fakeswift.py b/lib/lp/testing/swift/fakeswift.py | |||
1688 | index 0712e7a..c90dc0d 100644 | |||
1689 | --- a/lib/lp/testing/swift/fakeswift.py | |||
1690 | +++ b/lib/lp/testing/swift/fakeswift.py | |||
1691 | @@ -22,6 +22,7 @@ import sys | |||
1692 | 22 | import time | 22 | import time |
1693 | 23 | import uuid | 23 | import uuid |
1694 | 24 | 24 | ||
1695 | 25 | import six | ||
1696 | 25 | from twisted.web import ( | 26 | from twisted.web import ( |
1697 | 26 | http, | 27 | http, |
1698 | 27 | resource, | 28 | resource, |
1699 | @@ -77,7 +78,7 @@ class FakeKeystone(resource.Resource): | |||
1700 | 77 | if self._isValidToken(token, tenant_name): | 78 | if self._isValidToken(token, tenant_name): |
1701 | 78 | return token | 79 | return token |
1702 | 79 | else: | 80 | else: |
1704 | 80 | for id, token in self.tokens.iteritems(): | 81 | for id, token in six.iteritems(self.tokens): |
1705 | 81 | if self._isValidToken(token, tenant_name): | 82 | if self._isValidToken(token, tenant_name): |
1706 | 82 | return token | 83 | return token |
1707 | 83 | 84 | ||
1708 | diff --git a/lib/lp/translations/browser/translationlinksaggregator.py b/lib/lp/translations/browser/translationlinksaggregator.py | |||
1709 | index 3f196bc..4b06509 100644 | |||
1710 | --- a/lib/lp/translations/browser/translationlinksaggregator.py | |||
1711 | +++ b/lib/lp/translations/browser/translationlinksaggregator.py | |||
1712 | @@ -7,6 +7,8 @@ __all__ = [ | |||
1713 | 7 | 'TranslationLinksAggregator', | 7 | 'TranslationLinksAggregator', |
1714 | 8 | ] | 8 | ] |
1715 | 9 | 9 | ||
1716 | 10 | import six | ||
1717 | 11 | |||
1718 | 10 | from lp.services.webapp import canonical_url | 12 | from lp.services.webapp import canonical_url |
1719 | 11 | from lp.translations.interfaces.pofile import IPOFile | 13 | from lp.translations.interfaces.pofile import IPOFile |
1720 | 12 | from lp.translations.model.productserieslanguage import ProductSeriesLanguage | 14 | from lp.translations.model.productserieslanguage import ProductSeriesLanguage |
1721 | @@ -177,10 +179,10 @@ class TranslationLinksAggregator: | |||
1722 | 177 | returns for the sensible chunks. | 179 | returns for the sensible chunks. |
1723 | 178 | """ | 180 | """ |
1724 | 179 | links = [] | 181 | links = [] |
1726 | 180 | for target, sheets in self._bundle(sheets).iteritems(): | 182 | for target, sheets in six.iteritems(self._bundle(sheets)): |
1727 | 181 | assert sheets, "Translation target has no POFiles or templates." | 183 | assert sheets, "Translation target has no POFiles or templates." |
1728 | 182 | links_and_sheets = self._circumscribe(sheets) | 184 | links_and_sheets = self._circumscribe(sheets) |
1730 | 183 | for link, covered_sheets in links_and_sheets.iteritems(): | 185 | for link, covered_sheets in six.iteritems(links_and_sheets): |
1731 | 184 | links.append(self.describe(target, link, covered_sheets)) | 186 | links.append(self.describe(target, link, covered_sheets)) |
1732 | 185 | 187 | ||
1733 | 186 | return links | 188 | return links |
1734 | diff --git a/lib/lp/translations/browser/translationmessage.py b/lib/lp/translations/browser/translationmessage.py | |||
1735 | index ef75f6c..dbdf1d1 100644 | |||
1736 | --- a/lib/lp/translations/browser/translationmessage.py | |||
1737 | +++ b/lib/lp/translations/browser/translationmessage.py | |||
1738 | @@ -23,6 +23,7 @@ import operator | |||
1739 | 23 | import re | 23 | import re |
1740 | 24 | 24 | ||
1741 | 25 | import pytz | 25 | import pytz |
1742 | 26 | import six | ||
1743 | 26 | from six.moves.urllib.parse import ( | 27 | from six.moves.urllib.parse import ( |
1744 | 27 | parse_qsl, | 28 | parse_qsl, |
1745 | 28 | urlencode, | 29 | urlencode, |
1746 | @@ -96,7 +97,7 @@ def revert_unselected_translations(translations, current_message, | |||
1747 | 96 | original_translations = dict(enumerate(current_message.translations)) | 97 | original_translations = dict(enumerate(current_message.translations)) |
1748 | 97 | 98 | ||
1749 | 98 | output = {} | 99 | output = {} |
1751 | 99 | for plural_form, translation in translations.iteritems(): | 100 | for plural_form, translation in six.iteritems(translations): |
1752 | 100 | if plural_form in plural_indices_to_store: | 101 | if plural_form in plural_indices_to_store: |
1753 | 101 | output[plural_form] = translation | 102 | output[plural_form] = translation |
1754 | 102 | elif original_translations.get(plural_form) is None: | 103 | elif original_translations.get(plural_form) is None: |
1755 | @@ -113,7 +114,7 @@ def contains_translations(translations): | |||
1756 | 113 | :param translations: a dict mapping plural forms to their respective | 114 | :param translations: a dict mapping plural forms to their respective |
1757 | 114 | translation strings. | 115 | translation strings. |
1758 | 115 | """ | 116 | """ |
1760 | 116 | for text in translations.itervalues(): | 117 | for text in six.itervalues(translations): |
1761 | 117 | if text is not None and len(text) != 0: | 118 | if text is not None and len(text) != 0: |
1762 | 118 | return True | 119 | return True |
1763 | 119 | return False | 120 | return False |
1764 | diff --git a/lib/lp/translations/doc/translationimportqueue.txt b/lib/lp/translations/doc/translationimportqueue.txt | |||
1765 | index 9f7d8c9..c62423b 100644 | |||
1766 | --- a/lib/lp/translations/doc/translationimportqueue.txt | |||
1767 | +++ b/lib/lp/translations/doc/translationimportqueue.txt | |||
1768 | @@ -1223,9 +1223,11 @@ bug 138650 for an example). | |||
1769 | 1223 | If such bad requests do end up on the import queue, the import queue code will | 1223 | If such bad requests do end up on the import queue, the import queue code will |
1770 | 1224 | raise errors about them. | 1224 | raise errors about them. |
1771 | 1225 | 1225 | ||
1772 | 1226 | >>> import six | ||
1773 | 1227 | |||
1774 | 1226 | >>> def print_import_failures(import_script): | 1228 | >>> def print_import_failures(import_script): |
1775 | 1227 | ... """List failures recorded in an import script instance.""" | 1229 | ... """List failures recorded in an import script instance.""" |
1777 | 1228 | ... for reason, entries in script.failures.iteritems(): | 1230 | ... for reason, entries in six.iteritems(script.failures): |
1778 | 1229 | ... print(reason) | 1231 | ... print(reason) |
1779 | 1230 | ... for entry in entries: | 1232 | ... for entry in entries: |
1780 | 1231 | ... print("-> " + entry) | 1233 | ... print("-> " + entry) |
1781 | diff --git a/lib/lp/translations/model/potemplate.py b/lib/lp/translations/model/potemplate.py | |||
1782 | index ba0a632..70dedd2 100644 | |||
1783 | --- a/lib/lp/translations/model/potemplate.py | |||
1784 | +++ b/lib/lp/translations/model/potemplate.py | |||
1785 | @@ -19,6 +19,7 @@ import operator | |||
1786 | 19 | import os | 19 | import os |
1787 | 20 | 20 | ||
1788 | 21 | from psycopg2.extensions import TransactionRollbackError | 21 | from psycopg2.extensions import TransactionRollbackError |
1789 | 22 | import six | ||
1790 | 22 | from sqlobject import ( | 23 | from sqlobject import ( |
1791 | 23 | BoolCol, | 24 | BoolCol, |
1792 | 24 | ForeignKey, | 25 | ForeignKey, |
1793 | @@ -1560,7 +1561,7 @@ class POTemplateSharingSubset(object): | |||
1794 | 1560 | equivalents[key] = [] | 1561 | equivalents[key] = [] |
1795 | 1561 | equivalents[key].append(template) | 1562 | equivalents[key].append(template) |
1796 | 1562 | 1563 | ||
1798 | 1563 | for equivalence_list in equivalents.itervalues(): | 1564 | for equivalence_list in six.itervalues(equivalents): |
1799 | 1564 | # Sort potemplates from "most representative" to "least | 1565 | # Sort potemplates from "most representative" to "least |
1800 | 1565 | # representative." | 1566 | # representative." |
1801 | 1566 | equivalence_list.sort(key=POTemplate.sharingKey, reverse=True) | 1567 | equivalence_list.sort(key=POTemplate.sharingKey, reverse=True) |
1802 | diff --git a/lib/lp/translations/model/potmsgset.py b/lib/lp/translations/model/potmsgset.py | |||
1803 | index 12f9f05..f256384 100644 | |||
1804 | --- a/lib/lp/translations/model/potmsgset.py | |||
1805 | +++ b/lib/lp/translations/model/potmsgset.py | |||
1806 | @@ -14,6 +14,7 @@ from collections import ( | |||
1807 | 14 | import logging | 14 | import logging |
1808 | 15 | import re | 15 | import re |
1809 | 16 | 16 | ||
1810 | 17 | import six | ||
1811 | 17 | from sqlobject import ( | 18 | from sqlobject import ( |
1812 | 18 | ForeignKey, | 19 | ForeignKey, |
1813 | 19 | SQLObjectNotFound, | 20 | SQLObjectNotFound, |
1814 | @@ -122,7 +123,7 @@ def dictify_translations(translations): | |||
1815 | 122 | # Filter out None values. | 123 | # Filter out None values. |
1816 | 123 | return dict( | 124 | return dict( |
1817 | 124 | (form, translation) | 125 | (form, translation) |
1819 | 125 | for form, translation in translations.iteritems() | 126 | for form, translation in six.iteritems(translations) |
1820 | 126 | if translation is not None) | 127 | if translation is not None) |
1821 | 127 | 128 | ||
1822 | 128 | 129 | ||
1823 | @@ -611,7 +612,7 @@ class POTMsgSet(SQLBase): | |||
1824 | 611 | 612 | ||
1825 | 612 | forms = dict( | 613 | forms = dict( |
1826 | 613 | ('msgstr%d' % form, potranslation) | 614 | ('msgstr%d' % form, potranslation) |
1828 | 614 | for form, potranslation in potranslations.iteritems()) | 615 | for form, potranslation in six.iteritems(potranslations)) |
1829 | 615 | 616 | ||
1830 | 616 | if from_import: | 617 | if from_import: |
1831 | 617 | origin = RosettaTranslationOrigin.SCM | 618 | origin = RosettaTranslationOrigin.SCM |
1832 | @@ -748,7 +749,7 @@ class POTMsgSet(SQLBase): | |||
1833 | 748 | 749 | ||
1834 | 749 | translation_args = dict( | 750 | translation_args = dict( |
1835 | 750 | ('msgstr%d' % form, translation) | 751 | ('msgstr%d' % form, translation) |
1837 | 751 | for form, translation in translations.iteritems()) | 752 | for form, translation in six.iteritems(translations)) |
1838 | 752 | 753 | ||
1839 | 753 | return TranslationMessage( | 754 | return TranslationMessage( |
1840 | 754 | potmsgset=self, | 755 | potmsgset=self, |
1841 | diff --git a/lib/lp/translations/model/translationimportqueue.py b/lib/lp/translations/model/translationimportqueue.py | |||
1842 | index 3ded490..483a4c3 100644 | |||
1843 | --- a/lib/lp/translations/model/translationimportqueue.py | |||
1844 | +++ b/lib/lp/translations/model/translationimportqueue.py | |||
1845 | @@ -19,6 +19,7 @@ from textwrap import dedent | |||
1846 | 19 | 19 | ||
1847 | 20 | import posixpath | 20 | import posixpath |
1848 | 21 | import pytz | 21 | import pytz |
1849 | 22 | import six | ||
1850 | 22 | from sqlobject import ( | 23 | from sqlobject import ( |
1851 | 23 | BoolCol, | 24 | BoolCol, |
1852 | 24 | ForeignKey, | 25 | ForeignKey, |
1853 | @@ -1457,7 +1458,8 @@ class TranslationImportQueue: | |||
1854 | 1457 | """ | 1458 | """ |
1855 | 1458 | now = datetime.datetime.now(pytz.UTC) | 1459 | now = datetime.datetime.now(pytz.UTC) |
1856 | 1459 | deletion_clauses = [] | 1460 | deletion_clauses = [] |
1858 | 1460 | for status, max_age in translation_import_queue_entry_age.iteritems(): | 1461 | for status, max_age in six.iteritems( |
1859 | 1462 | translation_import_queue_entry_age): | ||
1860 | 1461 | cutoff = now - max_age | 1463 | cutoff = now - max_age |
1861 | 1462 | deletion_clauses.append(And( | 1464 | deletion_clauses.append(And( |
1862 | 1463 | TranslationImportQueueEntry.status == status, | 1465 | TranslationImportQueueEntry.status == status, |
1863 | diff --git a/lib/lp/translations/model/translationsharingjob.py b/lib/lp/translations/model/translationsharingjob.py | |||
1864 | index 8a60008..313e8db 100644 | |||
1865 | --- a/lib/lp/translations/model/translationsharingjob.py | |||
1866 | +++ b/lib/lp/translations/model/translationsharingjob.py | |||
1867 | @@ -170,7 +170,7 @@ class TranslationSharingJobDerived( | |||
1868 | 170 | for. | 170 | for. |
1869 | 171 | :param event: The event itself. | 171 | :param event: The event itself. |
1870 | 172 | """ | 172 | """ |
1872 | 173 | for event_type, job_classes in cls._event_types.iteritems(): | 173 | for event_type, job_classes in six.iteritems(cls._event_types): |
1873 | 174 | if not event_type.providedBy(event): | 174 | if not event_type.providedBy(event): |
1874 | 175 | continue | 175 | continue |
1875 | 176 | for job_class in job_classes: | 176 | for job_class in job_classes: |
1876 | @@ -191,7 +191,7 @@ class TranslationSharingJobDerived( | |||
1877 | 191 | # Ignore changes to POTemplates that are neither renames, | 191 | # Ignore changes to POTemplates that are neither renames, |
1878 | 192 | # nor moves to a different package/project. | 192 | # nor moves to a different package/project. |
1879 | 193 | return | 193 | return |
1881 | 194 | for event_type, job_classes in cls._event_types.iteritems(): | 194 | for event_type, job_classes in six.iteritems(cls._event_types): |
1882 | 195 | if not event_type.providedBy(event): | 195 | if not event_type.providedBy(event): |
1883 | 196 | continue | 196 | continue |
1884 | 197 | for job_class in job_classes: | 197 | for job_class in job_classes: |
1885 | diff --git a/lib/lp/translations/scripts/po_import.py b/lib/lp/translations/scripts/po_import.py | |||
1886 | index 3e97f8c..9c9779e 100644 | |||
1887 | --- a/lib/lp/translations/scripts/po_import.py | |||
1888 | +++ b/lib/lp/translations/scripts/po_import.py | |||
1889 | @@ -17,6 +17,7 @@ from datetime import ( | |||
1890 | 17 | import sys | 17 | import sys |
1891 | 18 | 18 | ||
1892 | 19 | import pytz | 19 | import pytz |
1893 | 20 | import six | ||
1894 | 20 | from zope.component import getUtility | 21 | from zope.component import getUtility |
1895 | 21 | 22 | ||
1896 | 22 | from lp.app.interfaces.launchpad import ILaunchpadCelebrities | 23 | from lp.app.interfaces.launchpad import ILaunchpadCelebrities |
1897 | @@ -212,5 +213,5 @@ class TranslationsImport(LaunchpadCronScript): | |||
1898 | 212 | 213 | ||
1899 | 213 | def _reportFailures(self): | 214 | def _reportFailures(self): |
1900 | 214 | """Bulk-report deferred failures as oopses.""" | 215 | """Bulk-report deferred failures as oopses.""" |
1902 | 215 | for reason, entries in self.failures.iteritems(): | 216 | for reason, entries in six.iteritems(self.failures): |
1903 | 216 | self._reportOops(reason, entries) | 217 | self._reportOops(reason, entries) |
1904 | diff --git a/lib/lp/translations/scripts/tests/test_reupload_translations.py b/lib/lp/translations/scripts/tests/test_reupload_translations.py | |||
1905 | index f2a449f..2ec0cee 100644 | |||
1906 | --- a/lib/lp/translations/scripts/tests/test_reupload_translations.py | |||
1907 | +++ b/lib/lp/translations/scripts/tests/test_reupload_translations.py | |||
1908 | @@ -11,6 +11,7 @@ import re | |||
1909 | 11 | from StringIO import StringIO | 11 | from StringIO import StringIO |
1910 | 12 | import tarfile | 12 | import tarfile |
1911 | 13 | 13 | ||
1912 | 14 | import six | ||
1913 | 14 | import transaction | 15 | import transaction |
1914 | 15 | from zope.security.proxy import removeSecurityProxy | 16 | from zope.security.proxy import removeSecurityProxy |
1915 | 16 | 17 | ||
1916 | @@ -61,7 +62,7 @@ def upload_tarball(translation_files): | |||
1917 | 61 | """ | 62 | """ |
1918 | 62 | buf = StringIO() | 63 | buf = StringIO() |
1919 | 63 | tarball = tarfile.open('', 'w:gz', buf) | 64 | tarball = tarfile.open('', 'w:gz', buf) |
1921 | 64 | for name, contents in translation_files.iteritems(): | 65 | for name, contents in six.iteritems(translation_files): |
1922 | 65 | pseudofile = StringIO(contents) | 66 | pseudofile = StringIO(contents) |
1923 | 66 | tarinfo = tarfile.TarInfo() | 67 | tarinfo = tarfile.TarInfo() |
1924 | 67 | tarinfo.name = name | 68 | tarinfo.name = name |
1925 | @@ -93,7 +94,7 @@ def filter_paths(files_dict): | |||
1926 | 93 | applied to each file's path, and non-Ubuntu files left out. | 94 | applied to each file's path, and non-Ubuntu files left out. |
1927 | 94 | """ | 95 | """ |
1928 | 95 | filtered_dict = {} | 96 | filtered_dict = {} |
1930 | 96 | for original_path, content in files_dict.iteritems(): | 97 | for original_path, content in six.iteritems(files_dict): |
1931 | 97 | new_path = _filter_ubuntu_translation_file(original_path) | 98 | new_path = _filter_ubuntu_translation_file(original_path) |
1932 | 98 | if new_path: | 99 | if new_path: |
1933 | 99 | filtered_dict[new_path] = content | 100 | filtered_dict[new_path] = content |
1934 | diff --git a/lib/lp/translations/scripts/tests/test_translations_to_branch.py b/lib/lp/translations/scripts/tests/test_translations_to_branch.py | |||
1935 | index 248b2e0..0cd058a 100644 | |||
1936 | --- a/lib/lp/translations/scripts/tests/test_translations_to_branch.py | |||
1937 | +++ b/lib/lp/translations/scripts/tests/test_translations_to_branch.py | |||
1938 | @@ -9,6 +9,7 @@ from textwrap import dedent | |||
1939 | 9 | 9 | ||
1940 | 10 | from breezy.errors import NotBranchError | 10 | from breezy.errors import NotBranchError |
1941 | 11 | import pytz | 11 | import pytz |
1942 | 12 | import six | ||
1943 | 12 | from testtools.matchers import MatchesRegex | 13 | from testtools.matchers import MatchesRegex |
1944 | 13 | import transaction | 14 | import transaction |
1945 | 14 | from zope.component import getUtility | 15 | from zope.component import getUtility |
1946 | @@ -116,8 +117,8 @@ class TestExportTranslationsToBranch(TestCaseWithFactory): | |||
1947 | 116 | msgstr "Hallo Wereld"\n""", | 117 | msgstr "Hallo Wereld"\n""", |
1948 | 117 | } | 118 | } |
1949 | 118 | 119 | ||
1952 | 119 | branch_filenames = set(branch_contents.iterkeys()) | 120 | branch_filenames = set(branch_contents) |
1953 | 120 | expected_filenames = set(expected_contents.iterkeys()) | 121 | expected_filenames = set(expected_contents) |
1954 | 121 | 122 | ||
1955 | 122 | unexpected_filenames = branch_filenames - expected_filenames | 123 | unexpected_filenames = branch_filenames - expected_filenames |
1956 | 123 | self.assertEqual(set(), unexpected_filenames) | 124 | self.assertEqual(set(), unexpected_filenames) |
1957 | @@ -125,7 +126,7 @@ class TestExportTranslationsToBranch(TestCaseWithFactory): | |||
1958 | 125 | missing_filenames = expected_filenames - branch_filenames | 126 | missing_filenames = expected_filenames - branch_filenames |
1959 | 126 | self.assertEqual(set(), missing_filenames) | 127 | self.assertEqual(set(), missing_filenames) |
1960 | 127 | 128 | ||
1962 | 128 | for filename, expected in expected_contents.iteritems(): | 129 | for filename, expected in six.iteritems(expected_contents): |
1963 | 129 | contents = branch_contents[filename].lstrip('\n') | 130 | contents = branch_contents[filename].lstrip('\n') |
1964 | 130 | pattern = dedent(expected.lstrip('\n')) | 131 | pattern = dedent(expected.lstrip('\n')) |
1965 | 131 | if not re.match(pattern, contents, re.MULTILINE): | 132 | if not re.match(pattern, contents, re.MULTILINE): |
1966 | diff --git a/lib/lp/translations/stories/webservice/xx-translationimportqueue.txt b/lib/lp/translations/stories/webservice/xx-translationimportqueue.txt | |||
1967 | index ca3f633..4b668ed 100644 | |||
1968 | --- a/lib/lp/translations/stories/webservice/xx-translationimportqueue.txt | |||
1969 | +++ b/lib/lp/translations/stories/webservice/xx-translationimportqueue.txt | |||
1970 | @@ -29,7 +29,7 @@ to be cleaned up. | |||
1971 | 29 | ... shown. If omitted, all keys are shown. | 29 | ... shown. If omitted, all keys are shown. |
1972 | 30 | ... """ | 30 | ... """ |
1973 | 31 | ... print('Entry:') | 31 | ... print('Entry:') |
1975 | 32 | ... for key in sorted(a_dict.iterkeys()): | 32 | ... for key in sorted(a_dict): |
1976 | 33 | ... if shown_keys is None or key in shown_keys: | 33 | ... if shown_keys is None or key in shown_keys: |
1977 | 34 | ... print('', key, a_dict[key]) | 34 | ... print('', key, a_dict[key]) |
1978 | 35 | 35 | ||
1979 | diff --git a/lib/lp/translations/tests/test_potemplate.py b/lib/lp/translations/tests/test_potemplate.py | |||
1980 | index 4ebb735..d08826e 100644 | |||
1981 | --- a/lib/lp/translations/tests/test_potemplate.py | |||
1982 | +++ b/lib/lp/translations/tests/test_potemplate.py | |||
1983 | @@ -5,6 +5,7 @@ __metaclass__ = type | |||
1984 | 5 | 5 | ||
1985 | 6 | from operator import methodcaller | 6 | from operator import methodcaller |
1986 | 7 | 7 | ||
1987 | 8 | import six | ||
1988 | 8 | from zope.component import getUtility | 9 | from zope.component import getUtility |
1989 | 9 | from zope.security.proxy import removeSecurityProxy | 10 | from zope.security.proxy import removeSecurityProxy |
1990 | 10 | 11 | ||
1991 | @@ -193,8 +194,8 @@ class EquivalenceClassTestMixin: | |||
1992 | 193 | This ignores the ordering of templates in an equivalence class. | 194 | This ignores the ordering of templates in an equivalence class. |
1993 | 194 | A separate test looks at ordering. | 195 | A separate test looks at ordering. |
1994 | 195 | """ | 196 | """ |
1997 | 196 | self.assertEqual(set(actual.iterkeys()), set(expected.iterkeys())) | 197 | self.assertEqual(set(actual), set(expected)) |
1998 | 197 | for key, value in actual.iteritems(): | 198 | for key, value in six.iteritems(actual): |
1999 | 198 | self.assertEqual(set(value), set(expected[key])) | 199 | self.assertEqual(set(value), set(expected[key])) |
2000 | 199 | 200 | ||
2001 | 200 | 201 | ||
2002 | diff --git a/lib/lp/translations/tests/test_side.py b/lib/lp/translations/tests/test_side.py | |||
2003 | index f5807d0..c7ab892 100644 | |||
2004 | --- a/lib/lp/translations/tests/test_side.py | |||
2005 | +++ b/lib/lp/translations/tests/test_side.py | |||
2006 | @@ -5,6 +5,7 @@ | |||
2007 | 5 | 5 | ||
2008 | 6 | __metaclass__ = type | 6 | __metaclass__ = type |
2009 | 7 | 7 | ||
2010 | 8 | import six | ||
2011 | 8 | from zope.component import getUtility | 9 | from zope.component import getUtility |
2012 | 9 | from zope.interface.verify import verifyObject | 10 | from zope.interface.verify import verifyObject |
2013 | 10 | 11 | ||
2014 | @@ -23,7 +24,7 @@ class TestTranslationSideTraitsSet(TestCaseWithFactory): | |||
2015 | 23 | def test_baseline(self): | 24 | def test_baseline(self): |
2016 | 24 | utility = getUtility(ITranslationSideTraitsSet) | 25 | utility = getUtility(ITranslationSideTraitsSet) |
2017 | 25 | self.assertTrue(verifyObject(ITranslationSideTraitsSet, utility)) | 26 | self.assertTrue(verifyObject(ITranslationSideTraitsSet, utility)) |
2019 | 26 | for traits in utility.getAllTraits().itervalues(): | 27 | for traits in six.itervalues(utility.getAllTraits()): |
2020 | 27 | self.assertTrue(verifyObject(ITranslationSideTraits, traits)) | 28 | self.assertTrue(verifyObject(ITranslationSideTraits, traits)) |
2021 | 28 | 29 | ||
2022 | 29 | def test_other_sides(self): | 30 | def test_other_sides(self): |
2023 | @@ -64,7 +65,7 @@ class TestTranslationSideTraitsSet(TestCaseWithFactory): | |||
2024 | 64 | [TranslationSide.UPSTREAM, TranslationSide.UBUNTU], | 65 | [TranslationSide.UPSTREAM, TranslationSide.UBUNTU], |
2025 | 65 | traits_dict.keys()) | 66 | traits_dict.keys()) |
2026 | 66 | 67 | ||
2028 | 67 | for side, traits in traits_dict.iteritems(): | 68 | for side, traits in six.iteritems(traits_dict): |
2029 | 68 | self.assertEqual(side, traits.side) | 69 | self.assertEqual(side, traits.side) |
2030 | 69 | self.assertEqual(traits, utility.getTraits(side)) | 70 | self.assertEqual(traits, utility.getTraits(side)) |
2031 | 70 | 71 | ||
2032 | diff --git a/lib/lp/translations/utilities/gettext_po_parser.py b/lib/lp/translations/utilities/gettext_po_parser.py | |||
2033 | index c087ef9..78de456 100644 | |||
2034 | --- a/lib/lp/translations/utilities/gettext_po_parser.py | |||
2035 | +++ b/lib/lp/translations/utilities/gettext_po_parser.py | |||
2036 | @@ -20,6 +20,7 @@ import logging | |||
2037 | 20 | import re | 20 | import re |
2038 | 21 | 21 | ||
2039 | 22 | import pytz | 22 | import pytz |
2040 | 23 | import six | ||
2041 | 23 | from zope import datetime as zope_datetime | 24 | from zope import datetime as zope_datetime |
2042 | 24 | from zope.interface import implementer | 25 | from zope.interface import implementer |
2043 | 25 | 26 | ||
2044 | @@ -230,7 +231,7 @@ class POHeader: | |||
2045 | 230 | 231 | ||
2046 | 231 | def _parseHeaderFields(self): | 232 | def _parseHeaderFields(self): |
2047 | 232 | """Return plural form values based on the parsed header.""" | 233 | """Return plural form values based on the parsed header.""" |
2049 | 233 | for key, value in self._header_dictionary.iteritems(): | 234 | for key, value in six.iteritems(self._header_dictionary): |
2050 | 234 | if key == 'plural-forms': | 235 | if key == 'plural-forms': |
2051 | 235 | parts = self._parseAssignments(value) | 236 | parts = self._parseAssignments(value) |
2052 | 236 | nplurals = parts.get('nplurals') | 237 | nplurals = parts.get('nplurals') |
2053 | @@ -362,7 +363,7 @@ class POHeader: | |||
2054 | 362 | raise AssertionError('key %s is not being handled!' % value) | 363 | raise AssertionError('key %s is not being handled!' % value) |
2055 | 363 | 364 | ||
2056 | 364 | # Now, we copy any other header information in the original .po file. | 365 | # Now, we copy any other header information in the original .po file. |
2058 | 365 | for key, value in self._header_dictionary.iteritems(): | 366 | for key, value in six.iteritems(self._header_dictionary): |
2059 | 366 | if key in self._handled_keys_mapping: | 367 | if key in self._handled_keys_mapping: |
2060 | 367 | # It's already handled, skip it. | 368 | # It's already handled, skip it. |
2061 | 368 | continue | 369 | continue |
2062 | diff --git a/lib/lp/translations/utilities/pluralforms.py b/lib/lp/translations/utilities/pluralforms.py | |||
2063 | index 680ba14..8a82685 100644 | |||
2064 | --- a/lib/lp/translations/utilities/pluralforms.py | |||
2065 | +++ b/lib/lp/translations/utilities/pluralforms.py | |||
2066 | @@ -12,6 +12,8 @@ __all__ = [ | |||
2067 | 12 | import gettext | 12 | import gettext |
2068 | 13 | import re | 13 | import re |
2069 | 14 | 14 | ||
2070 | 15 | import six | ||
2071 | 16 | |||
2072 | 15 | from lp.translations.interfaces.translations import TranslationConstants | 17 | from lp.translations.interfaces.translations import TranslationConstants |
2073 | 16 | 18 | ||
2074 | 17 | 19 | ||
2075 | @@ -47,7 +49,7 @@ def make_friendly_plural_forms(expression, expected_forms): | |||
2076 | 47 | 49 | ||
2077 | 48 | return [ | 50 | return [ |
2078 | 49 | {'form': form, 'examples': examples} | 51 | {'form': form, 'examples': examples} |
2080 | 50 | for (form, examples) in forms.iteritems() | 52 | for (form, examples) in six.iteritems(forms) |
2081 | 51 | ] | 53 | ] |
2082 | 52 | 54 | ||
2083 | 53 | 55 | ||
2084 | diff --git a/lib/lp/translations/utilities/tests/test_translation_importer.py b/lib/lp/translations/utilities/tests/test_translation_importer.py | |||
2085 | index dcf203b..2d47d01 100644 | |||
2086 | --- a/lib/lp/translations/utilities/tests/test_translation_importer.py | |||
2087 | +++ b/lib/lp/translations/utilities/tests/test_translation_importer.py | |||
2088 | @@ -7,6 +7,7 @@ __metaclass__ = type | |||
2089 | 7 | 7 | ||
2090 | 8 | from io import BytesIO | 8 | from io import BytesIO |
2091 | 9 | 9 | ||
2092 | 10 | import six | ||
2093 | 10 | import transaction | 11 | import transaction |
2094 | 11 | 12 | ||
2095 | 12 | from lp.services.log.logger import DevNullLogger | 13 | from lp.services.log.logger import DevNullLogger |
2096 | @@ -96,7 +97,7 @@ class TranslationImporterTestCase(TestCaseWithFactory): | |||
2097 | 96 | exactly the same priority.""" | 97 | exactly the same priority.""" |
2098 | 97 | for file_extension in TranslationImporter().supported_file_extensions: | 98 | for file_extension in TranslationImporter().supported_file_extensions: |
2099 | 98 | priorities = [] | 99 | priorities = [] |
2101 | 99 | for format, importer in importers.iteritems(): | 100 | for format, importer in six.iteritems(importers): |
2102 | 100 | if file_extension in importer.file_extensions: | 101 | if file_extension in importer.file_extensions: |
2103 | 101 | self.assertNotIn(importer.priority, priorities) | 102 | self.assertNotIn(importer.priority, priorities) |
2104 | 102 | priorities.append(importer.priority) | 103 | priorities.append(importer.priority) |
2105 | diff --git a/lib/lp/translations/utilities/translation_import.py b/lib/lp/translations/utilities/translation_import.py | |||
2106 | index 197153d..f9af932 100644 | |||
2107 | --- a/lib/lp/translations/utilities/translation_import.py | |||
2108 | +++ b/lib/lp/translations/utilities/translation_import.py | |||
2109 | @@ -14,6 +14,7 @@ from operator import attrgetter | |||
2110 | 14 | 14 | ||
2111 | 15 | import posixpath | 15 | import posixpath |
2112 | 16 | import pytz | 16 | import pytz |
2113 | 17 | import six | ||
2114 | 17 | from storm.exceptions import TimeoutError | 18 | from storm.exceptions import TimeoutError |
2115 | 18 | import transaction | 19 | import transaction |
2116 | 19 | from zope.component import getUtility | 20 | from zope.component import getUtility |
2117 | @@ -274,7 +275,7 @@ class TranslationImporter: | |||
2118 | 274 | """See `ITranslationImporter`.""" | 275 | """See `ITranslationImporter`.""" |
2119 | 275 | file_extensions = [] | 276 | file_extensions = [] |
2120 | 276 | 277 | ||
2122 | 277 | for importer in importers.itervalues(): | 278 | for importer in six.itervalues(importers): |
2123 | 278 | file_extensions.extend(importer.file_extensions) | 279 | file_extensions.extend(importer.file_extensions) |
2124 | 279 | 280 | ||
2125 | 280 | return sorted(set(file_extensions)) | 281 | return sorted(set(file_extensions)) |
2126 | @@ -290,7 +291,7 @@ class TranslationImporter: | |||
2127 | 290 | 291 | ||
2128 | 291 | def isTemplateName(self, path): | 292 | def isTemplateName(self, path): |
2129 | 292 | """See `ITranslationImporter`.""" | 293 | """See `ITranslationImporter`.""" |
2131 | 293 | for importer in importers.itervalues(): | 294 | for importer in six.itervalues(importers): |
2132 | 294 | if path.endswith(importer.template_suffix): | 295 | if path.endswith(importer.template_suffix): |
2133 | 295 | return True | 296 | return True |
2134 | 296 | return False | 297 | return False |
2135 | diff --git a/lib/lp/translations/utilities/translationmerger.py b/lib/lp/translations/utilities/translationmerger.py | |||
2136 | index 044d058..b507fb6 100644 | |||
2137 | --- a/lib/lp/translations/utilities/translationmerger.py | |||
2138 | +++ b/lib/lp/translations/utilities/translationmerger.py | |||
2139 | @@ -283,7 +283,7 @@ class MessageSharingMerge(LaunchpadScript): | |||
2140 | 283 | log.info("Merging %d template equivalence classes." % class_count) | 283 | log.info("Merging %d template equivalence classes." % class_count) |
2141 | 284 | 284 | ||
2142 | 285 | tm = TransactionManager(self.txn, self.options.dry_run) | 285 | tm = TransactionManager(self.txn, self.options.dry_run) |
2144 | 286 | for number, name in enumerate(sorted(equivalence_classes.iterkeys())): | 286 | for number, name in enumerate(sorted(equivalence_classes)): |
2145 | 287 | templates = equivalence_classes[name] | 287 | templates = equivalence_classes[name] |
2146 | 288 | log.info( | 288 | log.info( |
2147 | 289 | "Merging equivalence class '%s': %d template(s) (%d / %d)" % ( | 289 | "Merging equivalence class '%s': %d template(s) (%d / %d)" % ( |
2148 | @@ -429,7 +429,7 @@ class TranslationMerger: | |||
2149 | 429 | 429 | ||
2150 | 430 | self.tm.endTransaction(intermediate=True) | 430 | self.tm.endTransaction(intermediate=True) |
2151 | 431 | 431 | ||
2153 | 432 | for representative_id in representatives.itervalues(): | 432 | for representative_id in six.itervalues(representatives): |
2154 | 433 | representative = POTMsgSet.get(representative_id) | 433 | representative = POTMsgSet.get(representative_id) |
2155 | 434 | self._scrubPOTMsgSetTranslations(representative) | 434 | self._scrubPOTMsgSetTranslations(representative) |
2156 | 435 | self.tm.endTransaction(intermediate=True) | 435 | self.tm.endTransaction(intermediate=True) |
2157 | @@ -484,7 +484,7 @@ class TranslationMerger: | |||
2158 | 484 | num_representatives = len(subordinates) | 484 | num_representatives = len(subordinates) |
2159 | 485 | representative_num = 0 | 485 | representative_num = 0 |
2160 | 486 | 486 | ||
2162 | 487 | for representative, potmsgsets in subordinates.iteritems(): | 487 | for representative, potmsgsets in six.iteritems(subordinates): |
2163 | 488 | representative_num += 1 | 488 | representative_num += 1 |
2164 | 489 | log.debug("Message %d/%d: %d subordinate(s)." % ( | 489 | log.debug("Message %d/%d: %d subordinate(s)." % ( |
2165 | 490 | representative_num, num_representatives, len(potmsgsets))) | 490 | representative_num, num_representatives, len(potmsgsets))) |
2166 | diff --git a/lib/lp/translations/utilities/validate.py b/lib/lp/translations/utilities/validate.py | |||
2167 | index 0b9e8df..371a060 100644 | |||
2168 | --- a/lib/lp/translations/utilities/validate.py | |||
2169 | +++ b/lib/lp/translations/utilities/validate.py | |||
2170 | @@ -9,6 +9,7 @@ __all__ = [ | |||
2171 | 9 | ] | 9 | ] |
2172 | 10 | 10 | ||
2173 | 11 | import gettextpo | 11 | import gettextpo |
2174 | 12 | import six | ||
2175 | 12 | 13 | ||
2176 | 13 | 14 | ||
2177 | 14 | class GettextValidationError(ValueError): | 15 | class GettextValidationError(ValueError): |
2178 | @@ -37,7 +38,7 @@ def validate_translation(original_singular, original_plural, | |||
2179 | 37 | else: | 38 | else: |
2180 | 38 | # Message with plural forms. | 39 | # Message with plural forms. |
2181 | 39 | msg.set_msgid_plural(original_plural) | 40 | msg.set_msgid_plural(original_plural) |
2183 | 40 | for form, translation in translations.iteritems(): | 41 | for form, translation in six.iteritems(translations): |
2184 | 41 | msg.set_msgstr_plural(form, translation) | 42 | msg.set_msgstr_plural(form, translation) |
2185 | 42 | 43 | ||
2186 | 43 | for flag in flags: | 44 | for flag in flags: |
2187 | diff --git a/utilities/findimports.py b/utilities/findimports.py | |||
2188 | index b5615a8..09e0cf1 100755 | |||
2189 | --- a/utilities/findimports.py | |||
2190 | +++ b/utilities/findimports.py | |||
2191 | @@ -46,6 +46,8 @@ import linecache | |||
2192 | 46 | import os | 46 | import os |
2193 | 47 | import sys | 47 | import sys |
2194 | 48 | 48 | ||
2195 | 49 | import six | ||
2196 | 50 | |||
2197 | 49 | 51 | ||
2198 | 50 | class ImportFinder(ASTVisitor): | 52 | class ImportFinder(ASTVisitor): |
2199 | 51 | """AST visitor that collects all imported names in its imports attribute. | 53 | """AST visitor that collects all imported names in its imports attribute. |
2200 | @@ -285,7 +287,7 @@ class ModuleGraph(object): | |||
2201 | 285 | def printUnusedImports(self): | 287 | def printUnusedImports(self): |
2202 | 286 | for module in self.listModules(): | 288 | for module in self.listModules(): |
2203 | 287 | names = [(unused.lineno, unused.name) | 289 | names = [(unused.lineno, unused.name) |
2205 | 288 | for unused in module.unused_names.itervalues()] | 290 | for unused in six.itervalues(module.unused_names)] |
2206 | 289 | names.sort() | 291 | names.sort() |
2207 | 290 | for lineno, name in names: | 292 | for lineno, name in names: |
2208 | 291 | if not self.all_unused: | 293 | if not self.all_unused: |
2209 | diff --git a/utilities/generate-external-bug-status-docs b/utilities/generate-external-bug-status-docs | |||
2210 | index a2d28e8..43e0263 100755 | |||
2211 | --- a/utilities/generate-external-bug-status-docs | |||
2212 | +++ b/utilities/generate-external-bug-status-docs | |||
2213 | @@ -26,6 +26,8 @@ from itertools import chain | |||
2214 | 26 | from optparse import OptionParser | 26 | from optparse import OptionParser |
2215 | 27 | import sys | 27 | import sys |
2216 | 28 | 28 | ||
2217 | 29 | import six | ||
2218 | 30 | |||
2219 | 29 | from lp.bugs.externalbugtracker import BUG_TRACKER_CLASSES | 31 | from lp.bugs.externalbugtracker import BUG_TRACKER_CLASSES |
2220 | 30 | 32 | ||
2221 | 31 | 33 | ||
2222 | @@ -85,7 +87,7 @@ def generate_table(typ, cls): | |||
2223 | 85 | 87 | ||
2224 | 86 | def generate_documentable_classes(): | 88 | def generate_documentable_classes(): |
2225 | 87 | """Yield each class that has a mapping table defined.""" | 89 | """Yield each class that has a mapping table defined.""" |
2227 | 88 | for typ, cls in BUG_TRACKER_CLASSES.iteritems(): | 90 | for typ, cls in six.iteritems(BUG_TRACKER_CLASSES): |
2228 | 89 | if getattr(cls, '_status_lookup', None) is not None: | 91 | if getattr(cls, '_status_lookup', None) is not None: |
2229 | 90 | yield typ, cls | 92 | yield typ, cls |
2230 | 91 | 93 | ||
2231 | diff --git a/utilities/list-pages b/utilities/list-pages | |||
2232 | index 9989cf6..bf08d0a 100755 | |||
2233 | --- a/utilities/list-pages | |||
2234 | +++ b/utilities/list-pages | |||
2235 | @@ -49,6 +49,7 @@ import _pythonpath | |||
2236 | 49 | from inspect import getmro | 49 | from inspect import getmro |
2237 | 50 | import os | 50 | import os |
2238 | 51 | 51 | ||
2239 | 52 | import six | ||
2240 | 52 | from zope.app.wsgi.testlayer import BrowserLayer | 53 | from zope.app.wsgi.testlayer import BrowserLayer |
2241 | 53 | from zope.browserpage.simpleviewclass import simple | 54 | from zope.browserpage.simpleviewclass import simple |
2242 | 54 | from zope.component import adapter, getGlobalSiteManager | 55 | from zope.component import adapter, getGlobalSiteManager |
2243 | @@ -191,7 +192,7 @@ class Whatever(object): | |||
2244 | 191 | 192 | ||
2245 | 192 | def __call__(self, *args, **kwargs): | 193 | def __call__(self, *args, **kwargs): |
2246 | 193 | args = map(repr, args) | 194 | args = map(repr, args) |
2248 | 194 | args.extend('%s=%r' % (k, v) for k, v in kwargs.iteritems()) | 195 | args.extend('%s=%r' % (k, v) for k, v in six.iteritems(kwargs)) |
2249 | 195 | # If we're being called with no args, assume this is part of crazy | 196 | # If we're being called with no args, assume this is part of crazy |
2250 | 196 | # TALES stuff: | 197 | # TALES stuff: |
2251 | 197 | # webapp/metazcml.py(365)path() | 198 | # webapp/metazcml.py(365)path() |
I totally agree with iterating over the dict instead of doing dict.iterkeys(), but is it really necessary to use `six.iter{ keys,values, items}` ?
I mean, under the hood six's methods are basically `return iter(dict. values( ))` (for values, keys and items), and `keys.values()` works fine both on python2 and python3.
The only downside of using directly `dict.values` on Python2 that I can spot is the overhead of creating a copy list of all values, but that's exactly what six does anyway.