Merge ~cjwatson/launchpad:pyupgrade-py3-remaining into launchpad:master
- Git
- lp:~cjwatson/launchpad
- pyupgrade-py3-remaining
- Merge into master
Proposed by
Colin Watson
Status: | Merged |
---|---|
Approved by: | Colin Watson |
Approved revision: | 0c99f391d1ba4e2e673e0a2fbe8de860b9fcb234 |
Merge reported by: | Otto Co-Pilot |
Merged at revision: | not available |
Proposed branch: | ~cjwatson/launchpad:pyupgrade-py3-remaining |
Merge into: | launchpad:master |
Diff against target: |
1182 lines (+120/-179) 26 files modified
.pre-commit-config.yaml (+7/-29) brzplugins/lpserve/__init__.py (+2/-3) brzplugins/lpserve/test_lpserve.py (+2/-3) cronscripts/librarian-feed-swift.py (+2/-4) database/schema/security.py (+10/-12) database/schema/upgrade.py (+1/-1) lib/launchpad_loggerhead/app.py (+1/-2) lib/launchpad_loggerhead/session.py (+2/-2) lib/launchpad_loggerhead/tests.py (+2/-2) lib/launchpad_loggerhead/wsgi.py (+2/-2) lib/lp/security.py (+60/-86) lib/lp/systemhomes.py (+3/-3) lib/lp/xmlrpc/application.py (+1/-1) lib/lp/xmlrpc/tests/test_xmlrpc_selftest.py (+1/-1) scripts/generate-access-token.py (+1/-1) scripts/gina.py (+1/-1) scripts/mlist-import.py (+1/-1) scripts/update-stacked-on.py (+1/-1) scripts/upload2librarian.py (+1/-1) setup.py (+1/-2) utilities/generate-external-bug-status-docs (+1/-3) utilities/list-pages (+3/-4) utilities/make-lp-user (+2/-2) utilities/massage-bug-import-xml (+9/-9) utilities/pglogwatch.py (+2/-2) utilities/soyuz-sampledata-setup.py (+1/-1) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ioana Lasc (community) | Approve | ||
Review via email: mp+414243@code.launchpad.net |
Commit message
Apply "pyupgrade --py3-plus" to most remaining files
Description of the change
There are a couple of non-production scripts in `utilities/` and their dependencies that still require Python 2, as well as the code in `lib/contrib/` that's copied from elsewhere pending replacement by dependencies from PyPI and that's better to leave alone. Everything else that `pyupgrade` knows how to deal with now uses Python 3 syntax.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml | |||
2 | index a64bbd3..80c13da 100644 | |||
3 | --- a/.pre-commit-config.yaml | |||
4 | +++ b/.pre-commit-config.yaml | |||
5 | @@ -32,36 +32,14 @@ repos: | |||
6 | 32 | rev: v2.31.0 | 32 | rev: v2.31.0 |
7 | 33 | hooks: | 33 | hooks: |
8 | 34 | - id: pyupgrade | 34 | - id: pyupgrade |
9 | 35 | args: [--keep-percent-format] | ||
10 | 36 | exclude: ^lib/contrib/ | ||
11 | 37 | - id: pyupgrade | ||
12 | 38 | alias: pyupgrade-py3 | ||
13 | 39 | name: pyupgrade (--py3-plus) | ||
14 | 40 | args: [--keep-percent-format, --py3-plus] | 35 | args: [--keep-percent-format, --py3-plus] |
39 | 41 | files: | | 36 | exclude: | |
40 | 42 | (?x)^lib/lp/( | 37 | (?x)^( |
41 | 43 | answers | 38 | lib/contrib/.* |
42 | 44 | |app | 39 | |lib/devscripts/.* |
43 | 45 | |archivepublisher | 40 | |utilities/community-contributions\.py |
44 | 46 | |archiveuploader | 41 | |utilities/update-sourcecode |
45 | 47 | |blueprints | 42 | )$ |
22 | 48 | |bugs | ||
23 | 49 | |buildmaster | ||
24 | 50 | |charms | ||
25 | 51 | |code | ||
26 | 52 | |codehosting | ||
27 | 53 | |coop | ||
28 | 54 | |oci | ||
29 | 55 | |registry | ||
30 | 56 | |scripts | ||
31 | 57 | |services | ||
32 | 58 | |snappy | ||
33 | 59 | |soyuz | ||
34 | 60 | |testing | ||
35 | 61 | |testopenid | ||
36 | 62 | |tests | ||
37 | 63 | |translations | ||
38 | 64 | )/ | ||
46 | 65 | - repo: https://github.com/PyCQA/isort | 43 | - repo: https://github.com/PyCQA/isort |
47 | 66 | rev: 5.9.2 | 44 | rev: 5.9.2 |
48 | 67 | hooks: | 45 | hooks: |
49 | diff --git a/brzplugins/lpserve/__init__.py b/brzplugins/lpserve/__init__.py | |||
50 | index 52ce8ac..6b47fde 100644 | |||
51 | --- a/brzplugins/lpserve/__init__.py | |||
52 | +++ b/brzplugins/lpserve/__init__.py | |||
53 | @@ -29,7 +29,6 @@ from breezy.transport import ( | |||
54 | 29 | get_transport, | 29 | get_transport, |
55 | 30 | transport_server_registry, | 30 | transport_server_registry, |
56 | 31 | ) | 31 | ) |
57 | 32 | import six | ||
58 | 33 | 32 | ||
59 | 34 | 33 | ||
60 | 35 | class cmd_launchpad_server(Command): | 34 | class cmd_launchpad_server(Command): |
61 | @@ -56,7 +55,7 @@ class cmd_launchpad_server(Command): | |||
62 | 56 | help=( | 55 | help=( |
63 | 57 | "upload branches to this directory. Defaults to " | 56 | "upload branches to this directory. Defaults to " |
64 | 58 | "config.codehosting.hosted_branches_root."), | 57 | "config.codehosting.hosted_branches_root."), |
66 | 59 | type=six.text_type), | 58 | type=str), |
67 | 60 | Option( | 59 | Option( |
68 | 61 | 'mirror-directory', | 60 | 'mirror-directory', |
69 | 62 | help=( | 61 | help=( |
70 | @@ -67,7 +66,7 @@ class cmd_launchpad_server(Command): | |||
71 | 67 | help=( | 66 | help=( |
72 | 68 | "the url of the internal XML-RPC server. Defaults to " | 67 | "the url of the internal XML-RPC server. Defaults to " |
73 | 69 | "config.codehosting.codehosting_endpoint."), | 68 | "config.codehosting.codehosting_endpoint."), |
75 | 70 | type=six.text_type), | 69 | type=str), |
76 | 71 | RegistryOption( | 70 | RegistryOption( |
77 | 72 | 'protocol', help="Protocol to serve.", | 71 | 'protocol', help="Protocol to serve.", |
78 | 73 | lazy_registry=('breezy.transport', 'transport_server_registry'), | 72 | lazy_registry=('breezy.transport', 'transport_server_registry'), |
79 | diff --git a/brzplugins/lpserve/test_lpserve.py b/brzplugins/lpserve/test_lpserve.py | |||
80 | index a9563ec..1ce8641 100644 | |||
81 | --- a/brzplugins/lpserve/test_lpserve.py | |||
82 | +++ b/brzplugins/lpserve/test_lpserve.py | |||
83 | @@ -8,7 +8,6 @@ from breezy import ( | |||
84 | 8 | osutils, | 8 | osutils, |
85 | 9 | tests, | 9 | tests, |
86 | 10 | ) | 10 | ) |
87 | 11 | import six | ||
88 | 12 | 11 | ||
89 | 13 | from lp.codehosting import ( | 12 | from lp.codehosting import ( |
90 | 14 | get_brz_path, | 13 | get_brz_path, |
91 | @@ -43,11 +42,11 @@ class TestCaseWithSubprocess(tests.TestCaseWithTransport): | |||
92 | 43 | old_env = {} | 42 | old_env = {} |
93 | 44 | 43 | ||
94 | 45 | def cleanup_environment(): | 44 | def cleanup_environment(): |
96 | 46 | for env_var, value in six.iteritems(env_changes): | 45 | for env_var, value in env_changes.items(): |
97 | 47 | old_env[env_var] = osutils.set_or_unset_env(env_var, value) | 46 | old_env[env_var] = osutils.set_or_unset_env(env_var, value) |
98 | 48 | 47 | ||
99 | 49 | def restore_environment(): | 48 | def restore_environment(): |
101 | 50 | for env_var, value in six.iteritems(old_env): | 49 | for env_var, value in old_env.items(): |
102 | 51 | osutils.set_or_unset_env(env_var, value) | 50 | osutils.set_or_unset_env(env_var, value) |
103 | 52 | 51 | ||
104 | 53 | cwd = None | 52 | cwd = None |
105 | diff --git a/cronscripts/librarian-feed-swift.py b/cronscripts/librarian-feed-swift.py | |||
106 | index 1cb1374..8921ece 100755 | |||
107 | --- a/cronscripts/librarian-feed-swift.py | |||
108 | +++ b/cronscripts/librarian-feed-swift.py | |||
109 | @@ -9,8 +9,6 @@ import _pythonpath # noqa: F401 | |||
110 | 9 | 9 | ||
111 | 10 | import os | 10 | import os |
112 | 11 | 11 | ||
113 | 12 | import six | ||
114 | 13 | |||
115 | 14 | from lp.services.database.interfaces import IStandbyStore | 12 | from lp.services.database.interfaces import IStandbyStore |
116 | 15 | from lp.services.librarian.model import LibraryFileContent | 13 | from lp.services.librarian.model import LibraryFileContent |
117 | 16 | from lp.services.librarianserver import swift | 14 | from lp.services.librarianserver import swift |
118 | @@ -79,14 +77,14 @@ class LibrarianFeedSwift(LaunchpadCronScript): | |||
119 | 79 | SELECT MAX(id) FROM LibraryFileContent | 77 | SELECT MAX(id) FROM LibraryFileContent |
120 | 80 | WHERE datecreated < current_timestamp at time zone 'UTC' | 78 | WHERE datecreated < current_timestamp at time zone 'UTC' |
121 | 81 | - CAST(%s AS INTERVAL) | 79 | - CAST(%s AS INTERVAL) |
123 | 82 | """, (six.text_type(self.options.start_since),)).get_one()[0] | 80 | """, (str(self.options.start_since),)).get_one()[0] |
124 | 83 | 81 | ||
125 | 84 | if self.options.end_at: | 82 | if self.options.end_at: |
126 | 85 | self.options.end = IStandbyStore(LibraryFileContent).execute(""" | 83 | self.options.end = IStandbyStore(LibraryFileContent).execute(""" |
127 | 86 | SELECT MAX(id) FROM LibraryFileContent | 84 | SELECT MAX(id) FROM LibraryFileContent |
128 | 87 | WHERE datecreated < current_timestamp at time zone 'UTC' | 85 | WHERE datecreated < current_timestamp at time zone 'UTC' |
129 | 88 | - CAST(%s AS INTERVAL) | 86 | - CAST(%s AS INTERVAL) |
131 | 89 | """, (six.text_type(self.options.end_at),)).get_one()[0] | 87 | """, (str(self.options.end_at),)).get_one()[0] |
132 | 90 | 88 | ||
133 | 91 | if ((self.options.instance_id is None) != | 89 | if ((self.options.instance_id is None) != |
134 | 92 | (self.options.num_instances is None)): | 90 | (self.options.num_instances is None)): |
135 | diff --git a/database/schema/security.py b/database/schema/security.py | |||
136 | index 06bdc23..7281678 100755 | |||
137 | --- a/database/schema/security.py | |||
138 | +++ b/database/schema/security.py | |||
139 | @@ -12,8 +12,6 @@ import os | |||
140 | 12 | import re | 12 | import re |
141 | 13 | import sys | 13 | import sys |
142 | 14 | 14 | ||
143 | 15 | import six | ||
144 | 16 | |||
145 | 17 | from fti import quote_identifier | 15 | from fti import quote_identifier |
146 | 18 | from lp.services.database.sqlbase import connect | 16 | from lp.services.database.sqlbase import connect |
147 | 19 | from lp.services.scripts import ( | 17 | from lp.services.scripts import ( |
148 | @@ -117,7 +115,7 @@ def list_role_members(cur, roles): | |||
149 | 117 | return members | 115 | return members |
150 | 118 | 116 | ||
151 | 119 | 117 | ||
153 | 120 | class DbObject(object): | 118 | class DbObject: |
154 | 121 | 119 | ||
155 | 122 | def __init__( | 120 | def __init__( |
156 | 123 | self, schema, name, type_, owner, acl, arguments=None, language=None): | 121 | self, schema, name, type_, owner, acl, arguments=None, language=None): |
157 | @@ -151,7 +149,7 @@ class DbObject(object): | |||
158 | 151 | 149 | ||
159 | 152 | class DbSchema(dict): | 150 | class DbSchema(dict): |
160 | 153 | def __init__(self, con): | 151 | def __init__(self, con): |
162 | 154 | super(DbSchema, self).__init__() | 152 | super().__init__() |
163 | 155 | cur = con.cursor() | 153 | cur = con.cursor() |
164 | 156 | log.debug("Getting relation metadata") | 154 | log.debug("Getting relation metadata") |
165 | 157 | cur.execute(''' | 155 | cur.execute(''' |
166 | @@ -223,7 +221,7 @@ class DbSchema(dict): | |||
167 | 223 | for r in cur.fetchall()} | 221 | for r in cur.fetchall()} |
168 | 224 | 222 | ||
169 | 225 | 223 | ||
171 | 226 | class CursorWrapper(object): | 224 | class CursorWrapper: |
172 | 227 | 225 | ||
173 | 228 | def __init__(self, cursor): | 226 | def __init__(self, cursor): |
174 | 229 | self.__dict__['_cursor'] = cursor | 227 | self.__dict__['_cursor'] = cursor |
175 | @@ -306,8 +304,8 @@ class PermissionGatherer: | |||
176 | 306 | to grant or revoke for. Each is a string. | 304 | to grant or revoke for. Each is a string. |
177 | 307 | """ | 305 | """ |
178 | 308 | result = [] | 306 | result = [] |
181 | 309 | for permission, parties in six.iteritems(self.permissions): | 307 | for permission, parties in self.permissions.items(): |
182 | 310 | for principal, entities in six.iteritems(parties): | 308 | for principal, entities in parties.items(): |
183 | 311 | result.append( | 309 | result.append( |
184 | 312 | (permission, ", ".join(entities), principal)) | 310 | (permission, ", ".join(entities), principal)) |
185 | 313 | return result | 311 | return result |
186 | @@ -319,8 +317,8 @@ class PermissionGatherer: | |||
187 | 319 | def countEntities(self): | 317 | def countEntities(self): |
188 | 320 | """Count the number of different entities.""" | 318 | """Count the number of different entities.""" |
189 | 321 | entities = set() | 319 | entities = set() |
192 | 322 | for entities_and_entities in six.itervalues(self.permissions): | 320 | for entities_and_entities in self.permissions.values(): |
193 | 323 | for extra_entities in six.itervalues(entities_and_entities): | 321 | for extra_entities in entities_and_entities.values(): |
194 | 324 | entities.update(extra_entities) | 322 | entities.update(extra_entities) |
195 | 325 | return len(entities) | 323 | return len(entities) |
196 | 326 | 324 | ||
197 | @@ -328,7 +326,7 @@ class PermissionGatherer: | |||
198 | 328 | """Count the number of different principals.""" | 326 | """Count the number of different principals.""" |
199 | 329 | return len(set(sum(( | 327 | return len(set(sum(( |
200 | 330 | list(principals) | 328 | list(principals) |
202 | 331 | for principals in six.itervalues(self.permissions)), []))) | 329 | for principals in self.permissions.values()), []))) |
203 | 332 | 330 | ||
204 | 333 | def grant(self, cur): | 331 | def grant(self, cur): |
205 | 334 | """Grant all gathered permissions. | 332 | """Grant all gathered permissions. |
206 | @@ -484,7 +482,7 @@ def reset_permissions(con, config, options): | |||
207 | 484 | 482 | ||
208 | 485 | log.debug('Updating group memberships') | 483 | log.debug('Updating group memberships') |
209 | 486 | existing_memberships = list_role_members(cur, list(memberships)) | 484 | existing_memberships = list_role_members(cur, list(memberships)) |
211 | 487 | for group, users in six.iteritems(memberships): | 485 | for group, users in memberships.items(): |
212 | 488 | cur_users = managed_roles.intersection(existing_memberships[group]) | 486 | cur_users = managed_roles.intersection(existing_memberships[group]) |
213 | 489 | to_grant = users - cur_users | 487 | to_grant = users - cur_users |
214 | 490 | if to_grant: | 488 | if to_grant: |
215 | @@ -622,7 +620,7 @@ def reset_permissions(con, config, options): | |||
216 | 622 | new = desired_permissions[obj][role] | 620 | new = desired_permissions[obj][role] |
217 | 623 | old_privs = obj.acl.get(role, {}) | 621 | old_privs = obj.acl.get(role, {}) |
218 | 624 | old = set(old_privs) | 622 | old = set(old_privs) |
220 | 625 | if any(six.itervalues(old_privs)): | 623 | if any(old_privs.values()): |
221 | 626 | log.warning("%s has grant option on %s", role, obj.fullname) | 624 | log.warning("%s has grant option on %s", role, obj.fullname) |
222 | 627 | if new == old: | 625 | if new == old: |
223 | 628 | continue | 626 | continue |
224 | diff --git a/database/schema/upgrade.py b/database/schema/upgrade.py | |||
225 | index bab20e3..3b579ff 100755 | |||
226 | --- a/database/schema/upgrade.py | |||
227 | +++ b/database/schema/upgrade.py | |||
228 | @@ -180,7 +180,7 @@ def get_patchlist(con): | |||
229 | 180 | log.fatal('Invalid patch filename %s' % repr(patch_file)) | 180 | log.fatal('Invalid patch filename %s' % repr(patch_file)) |
230 | 181 | raise SystemExit(1) | 181 | raise SystemExit(1) |
231 | 182 | 182 | ||
233 | 183 | major, minor, patch = [int(i) for i in m.groups()] | 183 | major, minor, patch = (int(i) for i in m.groups()) |
234 | 184 | if (major, minor, patch) in dbpatches: | 184 | if (major, minor, patch) in dbpatches: |
235 | 185 | continue # This patch has already been applied | 185 | continue # This patch has already been applied |
236 | 186 | log.debug("Found patch %d.%d.%d -- %s" % ( | 186 | log.debug("Found patch %d.%d.%d -- %s" % ( |
237 | diff --git a/lib/launchpad_loggerhead/app.py b/lib/launchpad_loggerhead/app.py | |||
238 | index aa58d54..7ada98a 100644 | |||
239 | --- a/lib/launchpad_loggerhead/app.py | |||
240 | +++ b/lib/launchpad_loggerhead/app.py | |||
241 | @@ -120,8 +120,7 @@ class RootApp: | |||
242 | 120 | """ | 120 | """ |
243 | 121 | openid_request = self._make_consumer(environ).begin( | 121 | openid_request = self._make_consumer(environ).begin( |
244 | 122 | config.launchpad.openid_provider_root) | 122 | config.launchpad.openid_provider_root) |
247 | 123 | openid_request.addExtension( | 123 | openid_request.addExtension(SRegRequest(required=['nickname'])) |
246 | 124 | SRegRequest(required=[u'nickname'])) | ||
248 | 125 | back_to = construct_url(environ) | 124 | back_to = construct_url(environ) |
249 | 126 | raise HTTPMovedPermanently(openid_request.redirectURL( | 125 | raise HTTPMovedPermanently(openid_request.redirectURL( |
250 | 127 | config.codehosting.secure_codebrowse_root, | 126 | config.codehosting.secure_codebrowse_root, |
251 | diff --git a/lib/launchpad_loggerhead/session.py b/lib/launchpad_loggerhead/session.py | |||
252 | index 2adb69c..ce214f7 100644 | |||
253 | --- a/lib/launchpad_loggerhead/session.py | |||
254 | +++ b/lib/launchpad_loggerhead/session.py | |||
255 | @@ -21,7 +21,7 @@ class LaunchpadSecureCookie(SecureCookie): | |||
256 | 21 | hash_method = staticmethod(hashlib.sha256) | 21 | hash_method = staticmethod(hashlib.sha256) |
257 | 22 | 22 | ||
258 | 23 | # The OpenID consumer stores non-JSON-encodable objects in the session. | 23 | # The OpenID consumer stores non-JSON-encodable objects in the session. |
260 | 24 | class serialization_method(object): | 24 | class serialization_method: |
261 | 25 | 25 | ||
262 | 26 | @classmethod | 26 | @classmethod |
263 | 27 | def dumps(cls, value): | 27 | def dumps(cls, value): |
264 | @@ -33,7 +33,7 @@ class LaunchpadSecureCookie(SecureCookie): | |||
265 | 33 | return pickle.loads(value) | 33 | return pickle.loads(value) |
266 | 34 | 34 | ||
267 | 35 | 35 | ||
269 | 36 | class SessionHandler(object): | 36 | class SessionHandler: |
270 | 37 | """Middleware that provides a cookie-based session. | 37 | """Middleware that provides a cookie-based session. |
271 | 38 | 38 | ||
272 | 39 | The session dict is stored, pickled (and HMACed), in a cookie, so don't | 39 | The session dict is stored, pickled (and HMACed), in a cookie, so don't |
273 | diff --git a/lib/launchpad_loggerhead/tests.py b/lib/launchpad_loggerhead/tests.py | |||
274 | index 1c78b51..cad2ec3 100644 | |||
275 | --- a/lib/launchpad_loggerhead/tests.py | |||
276 | +++ b/lib/launchpad_loggerhead/tests.py | |||
277 | @@ -128,7 +128,7 @@ class TestWSGI(TestCaseWithFactory): | |||
278 | 128 | layer = AppServerLayer | 128 | layer = AppServerLayer |
279 | 129 | 129 | ||
280 | 130 | def setUp(self): | 130 | def setUp(self): |
282 | 131 | super(TestWSGI, self).setUp() | 131 | super().setUp() |
283 | 132 | self.useBzrBranches() | 132 | self.useBzrBranches() |
284 | 133 | loggerhead_fixture = self.useFixture(LoggerheadFixture()) | 133 | loggerhead_fixture = self.useFixture(LoggerheadFixture()) |
285 | 134 | 134 | ||
286 | @@ -136,7 +136,7 @@ class TestWSGI(TestCaseWithFactory): | |||
287 | 136 | try: | 136 | try: |
288 | 137 | with open(loggerhead_fixture.logfile, "rb") as logfile: | 137 | with open(loggerhead_fixture.logfile, "rb") as logfile: |
289 | 138 | return [logfile.read()] | 138 | return [logfile.read()] |
291 | 139 | except IOError: | 139 | except OSError: |
292 | 140 | return [b""] | 140 | return [b""] |
293 | 141 | 141 | ||
294 | 142 | self.addDetail( | 142 | self.addDetail( |
295 | diff --git a/lib/launchpad_loggerhead/wsgi.py b/lib/launchpad_loggerhead/wsgi.py | |||
296 | index 633fb7c..eefe119 100644 | |||
297 | --- a/lib/launchpad_loggerhead/wsgi.py | |||
298 | +++ b/lib/launchpad_loggerhead/wsgi.py | |||
299 | @@ -92,7 +92,7 @@ def log_request_start_and_stop(app): | |||
300 | 92 | class LoggerheadLogger(Logger): | 92 | class LoggerheadLogger(Logger): |
301 | 93 | 93 | ||
302 | 94 | def setup(self, cfg): | 94 | def setup(self, cfg): |
304 | 95 | super(LoggerheadLogger, self).setup(cfg) | 95 | super().setup(cfg) |
305 | 96 | formatter = LaunchpadFormatter(datefmt=None) | 96 | formatter = LaunchpadFormatter(datefmt=None) |
306 | 97 | for handler in self.error_log.handlers: | 97 | for handler in self.error_log.handlers: |
307 | 98 | handler.setFormatter(formatter) | 98 | handler.setFormatter(formatter) |
308 | @@ -120,7 +120,7 @@ class LoggerheadApplication(Application): | |||
309 | 120 | 120 | ||
310 | 121 | def __init__(self, **kwargs): | 121 | def __init__(self, **kwargs): |
311 | 122 | self.options = kwargs | 122 | self.options = kwargs |
313 | 123 | super(LoggerheadApplication, self).__init__() | 123 | super().__init__() |
314 | 124 | 124 | ||
315 | 125 | def init(self, parser, opts, args): | 125 | def init(self, parser, opts, args): |
316 | 126 | top = os.path.abspath(os.path.join( | 126 | top = os.path.abspath(os.path.join( |
317 | diff --git a/lib/lp/security.py b/lib/lp/security.py | |||
318 | index 044e197..37d52d3 100644 | |||
319 | --- a/lib/lp/security.py | |||
320 | +++ b/lib/lp/security.py | |||
321 | @@ -468,7 +468,7 @@ class ViewAccount(EditAccountBySelfOrAdmin): | |||
322 | 468 | def checkAuthenticated(self, user): | 468 | def checkAuthenticated(self, user): |
323 | 469 | """Extend permission to registry experts.""" | 469 | """Extend permission to registry experts.""" |
324 | 470 | return ( | 470 | return ( |
326 | 471 | super(ViewAccount, self).checkAuthenticated(user) | 471 | super().checkAuthenticated(user) |
327 | 472 | or user.in_registry_experts) | 472 | or user.in_registry_experts) |
328 | 473 | 473 | ||
329 | 474 | 474 | ||
330 | @@ -544,7 +544,7 @@ class LimitedViewProduct(ViewProduct): | |||
331 | 544 | 544 | ||
332 | 545 | def checkAuthenticated(self, user): | 545 | def checkAuthenticated(self, user): |
333 | 546 | return ( | 546 | return ( |
335 | 547 | super(LimitedViewProduct, self).checkAuthenticated(user) or | 547 | super().checkAuthenticated(user) or |
336 | 548 | self.obj.userCanLimitedView(user)) | 548 | self.obj.userCanLimitedView(user)) |
337 | 549 | 549 | ||
338 | 550 | 550 | ||
339 | @@ -554,7 +554,7 @@ class EditProduct(EditByOwnersOrAdmins): | |||
340 | 554 | def checkAuthenticated(self, user): | 554 | def checkAuthenticated(self, user): |
341 | 555 | # Commercial admins may help setup commercial projects. | 555 | # Commercial admins may help setup commercial projects. |
342 | 556 | return ( | 556 | return ( |
344 | 557 | super(EditProduct, self).checkAuthenticated(user) | 557 | super().checkAuthenticated(user) |
345 | 558 | or is_commercial_case(self.obj, user) | 558 | or is_commercial_case(self.obj, user) |
346 | 559 | or False) | 559 | or False) |
347 | 560 | 560 | ||
348 | @@ -580,8 +580,7 @@ class ViewTimelineProductSeries(DelegatedAuthorization): | |||
349 | 580 | usedfor = ITimelineProductSeries | 580 | usedfor = ITimelineProductSeries |
350 | 581 | 581 | ||
351 | 582 | def __init__(self, obj): | 582 | def __init__(self, obj): |
354 | 583 | super(ViewTimelineProductSeries, self).__init__( | 583 | super().__init__(obj, obj.product, 'launchpad.View') |
353 | 584 | obj, obj.product, 'launchpad.View') | ||
355 | 585 | 584 | ||
356 | 586 | 585 | ||
357 | 587 | class ViewProductReleaseFile(AnonymousAuthorization): | 586 | class ViewProductReleaseFile(AnonymousAuthorization): |
358 | @@ -798,7 +797,7 @@ class ModerateSprint(ModerateByRegistryExpertsOrAdmins): | |||
359 | 798 | 797 | ||
360 | 799 | def checkAuthenticated(self, user): | 798 | def checkAuthenticated(self, user): |
361 | 800 | return ( | 799 | return ( |
363 | 801 | super(ModerateSprint, self).checkAuthenticated(user) or | 800 | super().checkAuthenticated(user) or |
364 | 802 | user.isOwner(self.obj)) | 801 | user.isOwner(self.obj)) |
365 | 803 | 802 | ||
366 | 804 | 803 | ||
367 | @@ -867,8 +866,7 @@ class ViewProjectMilestone(DelegatedAuthorization): | |||
368 | 867 | usedfor = IProjectGroupMilestone | 866 | usedfor = IProjectGroupMilestone |
369 | 868 | 867 | ||
370 | 869 | def __init__(self, obj): | 868 | def __init__(self, obj): |
373 | 870 | super(ViewProjectMilestone, self).__init__( | 869 | super().__init__(obj, obj.product, 'launchpad.View') |
372 | 871 | obj, obj.product, 'launchpad.View') | ||
374 | 872 | 870 | ||
375 | 873 | 871 | ||
376 | 874 | class EditProjectMilestoneNever(AuthorizationBase): | 872 | class EditProjectMilestoneNever(AuthorizationBase): |
377 | @@ -885,8 +883,7 @@ class LimitedViewMilestone(DelegatedAuthorization): | |||
378 | 885 | usedfor = IMilestone | 883 | usedfor = IMilestone |
379 | 886 | 884 | ||
380 | 887 | def __init__(self, obj): | 885 | def __init__(self, obj): |
383 | 888 | super(LimitedViewMilestone, self).__init__( | 886 | super().__init__(obj, obj.target, 'launchpad.LimitedView') |
382 | 889 | obj, obj.target, 'launchpad.LimitedView') | ||
384 | 890 | 887 | ||
385 | 891 | 888 | ||
386 | 892 | class ViewMilestone(AuthorizationBase): | 889 | class ViewMilestone(AuthorizationBase): |
387 | @@ -963,7 +960,7 @@ class ModerateTeam(ModerateByRegistryExpertsOrAdmins): | |||
388 | 963 | registry experts, team admins, or the team owners. | 960 | registry experts, team admins, or the team owners. |
389 | 964 | """ | 961 | """ |
390 | 965 | return ( | 962 | return ( |
392 | 966 | super(ModerateTeam, self).checkAuthenticated(user) | 963 | super().checkAuthenticated(user) |
393 | 967 | or can_edit_team(self.obj, user)) | 964 | or can_edit_team(self.obj, user)) |
394 | 968 | 965 | ||
395 | 969 | 966 | ||
396 | @@ -1003,8 +1000,7 @@ class AdminByCommercialTeamOrAdminsOrPerson(AdminByCommercialTeamOrAdmins): | |||
397 | 1003 | 1000 | ||
398 | 1004 | def checkAuthenticated(self, user): | 1001 | def checkAuthenticated(self, user): |
399 | 1005 | """Users can manage their commericial data and admins can help.""" | 1002 | """Users can manage their commericial data and admins can help.""" |
402 | 1006 | base = super(AdminByCommercialTeamOrAdminsOrPerson, self) | 1003 | return self.obj.id == user.id or super().checkAuthenticated(user) |
401 | 1007 | return self.obj.id == user.id or base.checkAuthenticated(user) | ||
403 | 1008 | 1004 | ||
404 | 1009 | 1005 | ||
405 | 1010 | class EditPersonBySelfOrAdmins(AuthorizationBase): | 1006 | class EditPersonBySelfOrAdmins(AuthorizationBase): |
406 | @@ -1451,7 +1447,7 @@ class EditDistroSeriesDifference(DelegatedAuthorization): | |||
407 | 1451 | usedfor = IDistroSeriesDifferenceEdit | 1447 | usedfor = IDistroSeriesDifferenceEdit |
408 | 1452 | 1448 | ||
409 | 1453 | def __init__(self, obj): | 1449 | def __init__(self, obj): |
411 | 1454 | super(EditDistroSeriesDifference, self).__init__( | 1450 | super().__init__( |
412 | 1455 | obj, obj.derived_series.distribution, 'launchpad.View') | 1451 | obj, obj.derived_series.distribution, 'launchpad.View') |
413 | 1456 | 1452 | ||
414 | 1457 | def checkUnauthenticated(self): | 1453 | def checkUnauthenticated(self): |
415 | @@ -1479,7 +1475,7 @@ class DriveProduct(SeriesDrivers): | |||
416 | 1479 | def checkAuthenticated(self, user): | 1475 | def checkAuthenticated(self, user): |
417 | 1480 | # Commercial admins may help setup commercial projects. | 1476 | # Commercial admins may help setup commercial projects. |
418 | 1481 | return ( | 1477 | return ( |
420 | 1482 | super(DriveProduct, self).checkAuthenticated(user) | 1478 | super().checkAuthenticated(user) |
421 | 1483 | or is_commercial_case(self.obj, user) | 1479 | or is_commercial_case(self.obj, user) |
422 | 1484 | or False) | 1480 | or False) |
423 | 1485 | 1481 | ||
424 | @@ -1489,8 +1485,7 @@ class LimitedViewProductSeries(DelegatedAuthorization): | |||
425 | 1489 | usedfor = IProductSeriesLimitedView | 1485 | usedfor = IProductSeriesLimitedView |
426 | 1490 | 1486 | ||
427 | 1491 | def __init__(self, obj): | 1487 | def __init__(self, obj): |
430 | 1492 | super(LimitedViewProductSeries, self).__init__( | 1488 | super().__init__(obj, obj.product, 'launchpad.LimitedView') |
429 | 1493 | obj, obj.product, 'launchpad.LimitedView') | ||
431 | 1494 | 1489 | ||
432 | 1495 | 1490 | ||
433 | 1496 | class ViewProductSeries(AuthorizationBase): | 1491 | class ViewProductSeries(AuthorizationBase): |
434 | @@ -1541,8 +1536,7 @@ class ViewDistroArchSeriesFilter(DelegatedAuthorization): | |||
435 | 1541 | usedfor = IDistroArchSeriesFilter | 1536 | usedfor = IDistroArchSeriesFilter |
436 | 1542 | 1537 | ||
437 | 1543 | def __init__(self, obj): | 1538 | def __init__(self, obj): |
440 | 1544 | super(ViewDistroArchSeriesFilter, self).__init__( | 1539 | super().__init__(obj, obj.distroarchseries, 'launchpad.View') |
439 | 1545 | obj, obj.distroarchseries, 'launchpad.View') | ||
441 | 1546 | 1540 | ||
442 | 1547 | 1541 | ||
443 | 1548 | class EditDistroArchSeriesFilter(DelegatedAuthorization): | 1542 | class EditDistroArchSeriesFilter(DelegatedAuthorization): |
444 | @@ -1550,8 +1544,7 @@ class EditDistroArchSeriesFilter(DelegatedAuthorization): | |||
445 | 1550 | usedfor = IDistroArchSeriesFilter | 1544 | usedfor = IDistroArchSeriesFilter |
446 | 1551 | 1545 | ||
447 | 1552 | def __init__(self, obj): | 1546 | def __init__(self, obj): |
450 | 1553 | super(EditDistroArchSeriesFilter, self).__init__( | 1547 | super().__init__(obj, obj.distroarchseries, 'launchpad.Moderate') |
449 | 1554 | obj, obj.distroarchseries, 'launchpad.Moderate') | ||
451 | 1555 | 1548 | ||
452 | 1556 | 1549 | ||
453 | 1557 | class ViewAnnouncement(AuthorizationBase): | 1550 | class ViewAnnouncement(AuthorizationBase): |
454 | @@ -1888,8 +1881,7 @@ class ViewProductRelease(DelegatedAuthorization): | |||
455 | 1888 | usedfor = IProductRelease | 1881 | usedfor = IProductRelease |
456 | 1889 | 1882 | ||
457 | 1890 | def __init__(self, obj): | 1883 | def __init__(self, obj): |
460 | 1891 | super(ViewProductRelease, self).__init__( | 1884 | super().__init__(obj, obj.milestone, 'launchpad.View') |
459 | 1892 | obj, obj.milestone, 'launchpad.View') | ||
461 | 1893 | 1885 | ||
462 | 1894 | 1886 | ||
463 | 1895 | class AdminTranslationImportQueueEntry(AuthorizationBase): | 1887 | class AdminTranslationImportQueueEntry(AuthorizationBase): |
464 | @@ -2002,7 +1994,7 @@ class ViewPackageUploadLog(DelegatedAuthorization): | |||
465 | 2002 | usedfor = IPackageUploadLog | 1994 | usedfor = IPackageUploadLog |
466 | 2003 | 1995 | ||
467 | 2004 | def __init__(self, obj): | 1996 | def __init__(self, obj): |
469 | 2005 | super(ViewPackageUploadLog, self).__init__(obj, obj.package_upload) | 1997 | super().__init__(obj, obj.package_upload) |
470 | 2006 | 1998 | ||
471 | 2007 | 1999 | ||
472 | 2008 | class EditPackageUpload(AdminByAdminsTeam): | 2000 | class EditPackageUpload(AdminByAdminsTeam): |
473 | @@ -2046,7 +2038,7 @@ class ModerateBuilder(EditBuilder): | |||
474 | 2046 | 2038 | ||
475 | 2047 | def checkAuthenticated(self, user): | 2039 | def checkAuthenticated(self, user): |
476 | 2048 | return (user.in_registry_experts or | 2040 | return (user.in_registry_experts or |
478 | 2049 | super(ModerateBuilder, self).checkAuthenticated(user)) | 2041 | super().checkAuthenticated(user)) |
479 | 2050 | 2042 | ||
480 | 2051 | 2043 | ||
481 | 2052 | class AdminBuildRecord(AdminByBuilddAdmin): | 2044 | class AdminBuildRecord(AdminByBuilddAdmin): |
482 | @@ -2154,8 +2146,7 @@ class ModerateBinaryPackageBuild(ViewBinaryPackageBuild): | |||
483 | 2154 | # administer the archive can already achieve the same effect by | 2146 | # administer the archive can already achieve the same effect by |
484 | 2155 | # setting Archive.external_dependencies.) | 2147 | # setting Archive.external_dependencies.) |
485 | 2156 | return ( | 2148 | return ( |
488 | 2157 | super(ModerateBinaryPackageBuild, self).checkAuthenticated( | 2149 | super().checkAuthenticated(user) and |
487 | 2158 | user) and | ||
489 | 2159 | AdminArchive(self.obj.archive).checkAuthenticated(user)) | 2150 | AdminArchive(self.obj.archive).checkAuthenticated(user)) |
490 | 2160 | 2151 | ||
491 | 2161 | def checkUnauthenticated(self, user): | 2152 | def checkUnauthenticated(self, user): |
492 | @@ -2171,7 +2162,7 @@ class ViewTranslationTemplatesBuild(DelegatedAuthorization): | |||
493 | 2171 | usedfor = ITranslationTemplatesBuild | 2162 | usedfor = ITranslationTemplatesBuild |
494 | 2172 | 2163 | ||
495 | 2173 | def __init__(self, obj): | 2164 | def __init__(self, obj): |
497 | 2174 | super(ViewTranslationTemplatesBuild, self).__init__(obj, obj.branch) | 2165 | super().__init__(obj, obj.branch) |
498 | 2175 | 2166 | ||
499 | 2176 | 2167 | ||
500 | 2177 | class AdminQuestion(AuthorizationBase): | 2168 | class AdminQuestion(AuthorizationBase): |
501 | @@ -2389,7 +2380,7 @@ class ModerateBranch(EditBranch): | |||
502 | 2389 | permission = 'launchpad.Moderate' | 2380 | permission = 'launchpad.Moderate' |
503 | 2390 | 2381 | ||
504 | 2391 | def checkAuthenticated(self, user): | 2382 | def checkAuthenticated(self, user): |
506 | 2392 | if super(ModerateBranch, self).checkAuthenticated(user): | 2383 | if super().checkAuthenticated(user): |
507 | 2393 | return True | 2384 | return True |
508 | 2394 | branch = self.obj | 2385 | branch = self.obj |
509 | 2395 | if branch.product is not None and user.inTeam(branch.product.owner): | 2386 | if branch.product is not None and user.inTeam(branch.product.owner): |
510 | @@ -2464,7 +2455,7 @@ class ModerateGitRepository(EditGitRepository): | |||
511 | 2464 | permission = 'launchpad.Moderate' | 2455 | permission = 'launchpad.Moderate' |
512 | 2465 | 2456 | ||
513 | 2466 | def checkAuthenticated(self, user): | 2457 | def checkAuthenticated(self, user): |
515 | 2467 | if super(ModerateGitRepository, self).checkAuthenticated(user): | 2458 | if super().checkAuthenticated(user): |
516 | 2468 | return True | 2459 | return True |
517 | 2469 | target = self.obj.target | 2460 | target = self.obj.target |
518 | 2470 | if (target is not None and IProduct.providedBy(target) and | 2461 | if (target is not None and IProduct.providedBy(target) and |
519 | @@ -2484,17 +2475,17 @@ class ViewGitRef(DelegatedAuthorization): | |||
520 | 2484 | usedfor = IGitRef | 2475 | usedfor = IGitRef |
521 | 2485 | 2476 | ||
522 | 2486 | def __init__(self, obj): | 2477 | def __init__(self, obj): |
524 | 2487 | super(ViewGitRef, self).__init__(obj, obj.repository) | 2478 | super().__init__(obj, obj.repository) |
525 | 2488 | 2479 | ||
526 | 2489 | def checkAuthenticated(self, user): | 2480 | def checkAuthenticated(self, user): |
527 | 2490 | if self.obj.repository is not None: | 2481 | if self.obj.repository is not None: |
529 | 2491 | return super(ViewGitRef, self).checkAuthenticated(user) | 2482 | return super().checkAuthenticated(user) |
530 | 2492 | else: | 2483 | else: |
531 | 2493 | return True | 2484 | return True |
532 | 2494 | 2485 | ||
533 | 2495 | def checkUnauthenticated(self): | 2486 | def checkUnauthenticated(self): |
534 | 2496 | if self.obj.repository is not None: | 2487 | if self.obj.repository is not None: |
536 | 2497 | return super(ViewGitRef, self).checkUnauthenticated() | 2488 | return super().checkUnauthenticated() |
537 | 2498 | else: | 2489 | else: |
538 | 2499 | return True | 2490 | return True |
539 | 2500 | 2491 | ||
540 | @@ -2505,7 +2496,7 @@ class EditGitRef(DelegatedAuthorization): | |||
541 | 2505 | usedfor = IGitRef | 2496 | usedfor = IGitRef |
542 | 2506 | 2497 | ||
543 | 2507 | def __init__(self, obj): | 2498 | def __init__(self, obj): |
545 | 2508 | super(EditGitRef, self).__init__(obj, obj.repository) | 2499 | super().__init__(obj, obj.repository) |
546 | 2509 | 2500 | ||
547 | 2510 | 2501 | ||
548 | 2511 | class ViewGitRule(DelegatedAuthorization): | 2502 | class ViewGitRule(DelegatedAuthorization): |
549 | @@ -2514,7 +2505,7 @@ class ViewGitRule(DelegatedAuthorization): | |||
550 | 2514 | usedfor = IGitRule | 2505 | usedfor = IGitRule |
551 | 2515 | 2506 | ||
552 | 2516 | def __init__(self, obj): | 2507 | def __init__(self, obj): |
554 | 2517 | super(ViewGitRule, self).__init__(obj, obj.repository) | 2508 | super().__init__(obj, obj.repository) |
555 | 2518 | 2509 | ||
556 | 2519 | 2510 | ||
557 | 2520 | class EditGitRule(DelegatedAuthorization): | 2511 | class EditGitRule(DelegatedAuthorization): |
558 | @@ -2523,7 +2514,7 @@ class EditGitRule(DelegatedAuthorization): | |||
559 | 2523 | usedfor = IGitRule | 2514 | usedfor = IGitRule |
560 | 2524 | 2515 | ||
561 | 2525 | def __init__(self, obj): | 2516 | def __init__(self, obj): |
563 | 2526 | super(EditGitRule, self).__init__(obj, obj.repository) | 2517 | super().__init__(obj, obj.repository) |
564 | 2527 | 2518 | ||
565 | 2528 | 2519 | ||
566 | 2529 | class ViewGitRuleGrant(DelegatedAuthorization): | 2520 | class ViewGitRuleGrant(DelegatedAuthorization): |
567 | @@ -2532,7 +2523,7 @@ class ViewGitRuleGrant(DelegatedAuthorization): | |||
568 | 2532 | usedfor = IGitRuleGrant | 2523 | usedfor = IGitRuleGrant |
569 | 2533 | 2524 | ||
570 | 2534 | def __init__(self, obj): | 2525 | def __init__(self, obj): |
572 | 2535 | super(ViewGitRuleGrant, self).__init__(obj, obj.repository) | 2526 | super().__init__(obj, obj.repository) |
573 | 2536 | 2527 | ||
574 | 2537 | 2528 | ||
575 | 2538 | class EditGitRuleGrant(DelegatedAuthorization): | 2529 | class EditGitRuleGrant(DelegatedAuthorization): |
576 | @@ -2541,7 +2532,7 @@ class EditGitRuleGrant(DelegatedAuthorization): | |||
577 | 2541 | usedfor = IGitRuleGrant | 2532 | usedfor = IGitRuleGrant |
578 | 2542 | 2533 | ||
579 | 2543 | def __init__(self, obj): | 2534 | def __init__(self, obj): |
581 | 2544 | super(EditGitRuleGrant, self).__init__(obj, obj.repository) | 2535 | super().__init__(obj, obj.repository) |
582 | 2545 | 2536 | ||
583 | 2546 | 2537 | ||
584 | 2547 | class ViewGitActivity(DelegatedAuthorization): | 2538 | class ViewGitActivity(DelegatedAuthorization): |
585 | @@ -2550,7 +2541,7 @@ class ViewGitActivity(DelegatedAuthorization): | |||
586 | 2550 | usedfor = IGitActivity | 2541 | usedfor = IGitActivity |
587 | 2551 | 2542 | ||
588 | 2552 | def __init__(self, obj): | 2543 | def __init__(self, obj): |
590 | 2553 | super(ViewGitActivity, self).__init__(obj, obj.repository) | 2544 | super().__init__(obj, obj.repository) |
591 | 2554 | 2545 | ||
592 | 2555 | 2546 | ||
593 | 2556 | class AdminDistroSeriesTranslations(AuthorizationBase): | 2547 | class AdminDistroSeriesTranslations(AuthorizationBase): |
594 | @@ -2573,8 +2564,7 @@ class AdminDistributionSourcePackageTranslations(DelegatedAuthorization): | |||
595 | 2573 | usedfor = IDistributionSourcePackage | 2564 | usedfor = IDistributionSourcePackage |
596 | 2574 | 2565 | ||
597 | 2575 | def __init__(self, obj): | 2566 | def __init__(self, obj): |
600 | 2576 | super(AdminDistributionSourcePackageTranslations, self).__init__( | 2567 | super().__init__(obj, obj.distribution) |
599 | 2577 | obj, obj.distribution) | ||
601 | 2578 | 2568 | ||
602 | 2579 | 2569 | ||
603 | 2580 | class AdminProductSeriesTranslations(AuthorizationBase): | 2570 | class AdminProductSeriesTranslations(AuthorizationBase): |
604 | @@ -2643,7 +2633,7 @@ class PreviewDiffView(DelegatedAuthorization): | |||
605 | 2643 | usedfor = IPreviewDiff | 2633 | usedfor = IPreviewDiff |
606 | 2644 | 2634 | ||
607 | 2645 | def __init__(self, obj): | 2635 | def __init__(self, obj): |
609 | 2646 | super(PreviewDiffView, self).__init__(obj, obj.branch_merge_proposal) | 2636 | super().__init__(obj, obj.branch_merge_proposal) |
610 | 2647 | 2637 | ||
611 | 2648 | 2638 | ||
612 | 2649 | class CodeReviewVoteReferenceView(DelegatedAuthorization): | 2639 | class CodeReviewVoteReferenceView(DelegatedAuthorization): |
613 | @@ -2651,8 +2641,7 @@ class CodeReviewVoteReferenceView(DelegatedAuthorization): | |||
614 | 2651 | usedfor = ICodeReviewVoteReference | 2641 | usedfor = ICodeReviewVoteReference |
615 | 2652 | 2642 | ||
616 | 2653 | def __init__(self, obj): | 2643 | def __init__(self, obj): |
619 | 2654 | super(CodeReviewVoteReferenceView, self).__init__( | 2644 | super().__init__(obj, obj.branch_merge_proposal) |
618 | 2655 | obj, obj.branch_merge_proposal) | ||
620 | 2656 | 2645 | ||
621 | 2657 | 2646 | ||
622 | 2658 | class CodeReviewVoteReferenceEdit(DelegatedAuthorization): | 2647 | class CodeReviewVoteReferenceEdit(DelegatedAuthorization): |
623 | @@ -2660,8 +2649,7 @@ class CodeReviewVoteReferenceEdit(DelegatedAuthorization): | |||
624 | 2660 | usedfor = ICodeReviewVoteReference | 2649 | usedfor = ICodeReviewVoteReference |
625 | 2661 | 2650 | ||
626 | 2662 | def __init__(self, obj): | 2651 | def __init__(self, obj): |
629 | 2663 | super(CodeReviewVoteReferenceEdit, self).__init__( | 2652 | super().__init__(obj, obj.branch_merge_proposal.target_branch) |
628 | 2664 | obj, obj.branch_merge_proposal.target_branch) | ||
630 | 2665 | 2653 | ||
631 | 2666 | def checkAuthenticated(self, user): | 2654 | def checkAuthenticated(self, user): |
632 | 2667 | """Only the affected teams may change the review request. | 2655 | """Only the affected teams may change the review request. |
633 | @@ -2675,8 +2663,7 @@ class CodeReviewVoteReferenceEdit(DelegatedAuthorization): | |||
634 | 2675 | """ | 2663 | """ |
635 | 2676 | return (user.inTeam(self.obj.reviewer) or | 2664 | return (user.inTeam(self.obj.reviewer) or |
636 | 2677 | user.inTeam(self.obj.registrant) or | 2665 | user.inTeam(self.obj.registrant) or |
639 | 2678 | super(CodeReviewVoteReferenceEdit, self).checkAuthenticated( | 2666 | super().checkAuthenticated(user)) |
638 | 2679 | user)) | ||
640 | 2680 | 2667 | ||
641 | 2681 | 2668 | ||
642 | 2682 | class CodeReviewCommentView(DelegatedAuthorization): | 2669 | class CodeReviewCommentView(DelegatedAuthorization): |
643 | @@ -2684,8 +2671,7 @@ class CodeReviewCommentView(DelegatedAuthorization): | |||
644 | 2684 | usedfor = ICodeReviewComment | 2671 | usedfor = ICodeReviewComment |
645 | 2685 | 2672 | ||
646 | 2686 | def __init__(self, obj): | 2673 | def __init__(self, obj): |
649 | 2687 | super(CodeReviewCommentView, self).__init__( | 2674 | super().__init__(obj, obj.branch_merge_proposal) |
648 | 2688 | obj, obj.branch_merge_proposal) | ||
650 | 2689 | 2675 | ||
651 | 2690 | 2676 | ||
652 | 2691 | class CodeReviewCommentOwner(AuthorizationBase): | 2677 | class CodeReviewCommentOwner(AuthorizationBase): |
653 | @@ -2702,8 +2688,7 @@ class CodeReviewCommentDelete(DelegatedAuthorization): | |||
654 | 2702 | usedfor = ICodeReviewCommentDeletion | 2688 | usedfor = ICodeReviewCommentDeletion |
655 | 2703 | 2689 | ||
656 | 2704 | def __init__(self, obj): | 2690 | def __init__(self, obj): |
659 | 2705 | super(CodeReviewCommentDelete, self).__init__( | 2691 | super().__init__(obj, obj.branch_merge_proposal) |
658 | 2706 | obj, obj.branch_merge_proposal) | ||
660 | 2707 | 2692 | ||
661 | 2708 | 2693 | ||
662 | 2709 | class BranchMergeProposalEdit(AuthorizationBase): | 2694 | class BranchMergeProposalEdit(AuthorizationBase): |
663 | @@ -2804,7 +2789,7 @@ class SubscriberViewArchive(ViewArchive): | |||
664 | 2804 | def checkAuthenticated(self, user): | 2789 | def checkAuthenticated(self, user): |
665 | 2805 | if user.person in self.obj._known_subscribers: | 2790 | if user.person in self.obj._known_subscribers: |
666 | 2806 | return True | 2791 | return True |
668 | 2807 | if super(SubscriberViewArchive, self).checkAuthenticated(user): | 2792 | if super().checkAuthenticated(user): |
669 | 2808 | return True | 2793 | return True |
670 | 2809 | filter = get_enabled_archive_filter( | 2794 | filter = get_enabled_archive_filter( |
671 | 2810 | user.person, include_subscribed=True) | 2795 | user.person, include_subscribed=True) |
672 | @@ -2854,7 +2839,7 @@ class DeleteArchive(EditArchive): | |||
673 | 2854 | 2839 | ||
674 | 2855 | def checkAuthenticated(self, user): | 2840 | def checkAuthenticated(self, user): |
675 | 2856 | return ( | 2841 | return ( |
677 | 2857 | super(DeleteArchive, self).checkAuthenticated(user) or | 2842 | super().checkAuthenticated(user) or |
678 | 2858 | (not self.obj.is_main and user.in_registry_experts)) | 2843 | (not self.obj.is_main and user.in_registry_experts)) |
679 | 2859 | 2844 | ||
680 | 2860 | 2845 | ||
681 | @@ -2943,12 +2928,11 @@ class EditArchiveAuthToken(DelegatedAuthorization): | |||
682 | 2943 | usedfor = IArchiveAuthToken | 2928 | usedfor = IArchiveAuthToken |
683 | 2944 | 2929 | ||
684 | 2945 | def __init__(self, obj): | 2930 | def __init__(self, obj): |
687 | 2946 | super(EditArchiveAuthToken, self).__init__( | 2931 | super().__init__(obj, obj.archive, 'launchpad.Append') |
686 | 2947 | obj, obj.archive, 'launchpad.Append') | ||
688 | 2948 | 2932 | ||
689 | 2949 | def checkAuthenticated(self, user): | 2933 | def checkAuthenticated(self, user): |
690 | 2950 | return (user.in_admin or | 2934 | return (user.in_admin or |
692 | 2951 | super(EditArchiveAuthToken, self).checkAuthenticated(user)) | 2935 | super().checkAuthenticated(user)) |
693 | 2952 | 2936 | ||
694 | 2953 | 2937 | ||
695 | 2954 | class ViewPersonalArchiveSubscription(DelegatedAuthorization): | 2938 | class ViewPersonalArchiveSubscription(DelegatedAuthorization): |
696 | @@ -2961,14 +2945,12 @@ class ViewPersonalArchiveSubscription(DelegatedAuthorization): | |||
697 | 2961 | usedfor = IPersonalArchiveSubscription | 2945 | usedfor = IPersonalArchiveSubscription |
698 | 2962 | 2946 | ||
699 | 2963 | def __init__(self, obj): | 2947 | def __init__(self, obj): |
702 | 2964 | super(ViewPersonalArchiveSubscription, self).__init__( | 2948 | super().__init__(obj, obj.archive, 'launchpad.Append') |
701 | 2965 | obj, obj.archive, 'launchpad.Append') | ||
703 | 2966 | 2949 | ||
704 | 2967 | def checkAuthenticated(self, user): | 2950 | def checkAuthenticated(self, user): |
705 | 2968 | if user.person == self.obj.subscriber or user.in_admin: | 2951 | if user.person == self.obj.subscriber or user.in_admin: |
706 | 2969 | return True | 2952 | return True |
709 | 2970 | return super( | 2953 | return super().checkAuthenticated(user) |
708 | 2971 | ViewPersonalArchiveSubscription, self).checkAuthenticated(user) | ||
710 | 2972 | 2954 | ||
711 | 2973 | 2955 | ||
712 | 2974 | class ViewArchiveSubscriber(DelegatedAuthorization): | 2956 | class ViewArchiveSubscriber(DelegatedAuthorization): |
713 | @@ -2981,13 +2963,12 @@ class ViewArchiveSubscriber(DelegatedAuthorization): | |||
714 | 2981 | usedfor = IArchiveSubscriber | 2963 | usedfor = IArchiveSubscriber |
715 | 2982 | 2964 | ||
716 | 2983 | def __init__(self, obj): | 2965 | def __init__(self, obj): |
719 | 2984 | super(ViewArchiveSubscriber, self).__init__( | 2966 | super().__init__(obj, obj, 'launchpad.Edit') |
718 | 2985 | obj, obj, 'launchpad.Edit') | ||
720 | 2986 | 2967 | ||
721 | 2987 | def checkAuthenticated(self, user): | 2968 | def checkAuthenticated(self, user): |
722 | 2988 | return (user.inTeam(self.obj.subscriber) or | 2969 | return (user.inTeam(self.obj.subscriber) or |
723 | 2989 | user.in_commercial_admin or | 2970 | user.in_commercial_admin or |
725 | 2990 | super(ViewArchiveSubscriber, self).checkAuthenticated(user)) | 2971 | super().checkAuthenticated(user)) |
726 | 2991 | 2972 | ||
727 | 2992 | 2973 | ||
728 | 2993 | class EditArchiveSubscriber(DelegatedAuthorization): | 2974 | class EditArchiveSubscriber(DelegatedAuthorization): |
729 | @@ -2999,13 +2980,12 @@ class EditArchiveSubscriber(DelegatedAuthorization): | |||
730 | 2999 | usedfor = IArchiveSubscriber | 2980 | usedfor = IArchiveSubscriber |
731 | 3000 | 2981 | ||
732 | 3001 | def __init__(self, obj): | 2982 | def __init__(self, obj): |
735 | 3002 | super(EditArchiveSubscriber, self).__init__( | 2983 | super().__init__(obj, obj.archive, 'launchpad.Append') |
734 | 3003 | obj, obj.archive, 'launchpad.Append') | ||
736 | 3004 | 2984 | ||
737 | 3005 | def checkAuthenticated(self, user): | 2985 | def checkAuthenticated(self, user): |
738 | 3006 | return (user.in_admin or | 2986 | return (user.in_admin or |
739 | 3007 | user.in_commercial_admin or | 2987 | user.in_commercial_admin or |
741 | 3008 | super(EditArchiveSubscriber, self).checkAuthenticated(user)) | 2988 | super().checkAuthenticated(user)) |
742 | 3009 | 2989 | ||
743 | 3010 | 2990 | ||
744 | 3011 | class AdminArchiveSubscriberSet(AdminByCommercialTeamOrAdmins): | 2991 | class AdminArchiveSubscriberSet(AdminByCommercialTeamOrAdmins): |
745 | @@ -3062,8 +3042,7 @@ class EditPublishing(DelegatedAuthorization): | |||
746 | 3062 | usedfor = IPublishingEdit | 3042 | usedfor = IPublishingEdit |
747 | 3063 | 3043 | ||
748 | 3064 | def __init__(self, obj): | 3044 | def __init__(self, obj): |
751 | 3065 | super(EditPublishing, self).__init__( | 3045 | super().__init__(obj, obj.archive, 'launchpad.Append') |
750 | 3066 | obj, obj.archive, 'launchpad.Append') | ||
752 | 3067 | 3046 | ||
753 | 3068 | 3047 | ||
754 | 3069 | class ViewBinaryPackagePublishingHistory(ViewSourcePackagePublishingHistory): | 3048 | class ViewBinaryPackagePublishingHistory(ViewSourcePackagePublishingHistory): |
755 | @@ -3148,7 +3127,7 @@ class EditEmailAddress(EditByOwnersOrAdmins): | |||
756 | 3148 | # Always allow users to see their own email addresses. | 3127 | # Always allow users to see their own email addresses. |
757 | 3149 | if self.obj.person == user: | 3128 | if self.obj.person == user: |
758 | 3150 | return True | 3129 | return True |
760 | 3151 | return super(EditEmailAddress, self).checkAuthenticated(user) | 3130 | return super().checkAuthenticated(user) |
761 | 3152 | 3131 | ||
762 | 3153 | 3132 | ||
763 | 3154 | class ViewGPGKey(AnonymousAuthorization): | 3133 | class ViewGPGKey(AnonymousAuthorization): |
764 | @@ -3258,8 +3237,7 @@ class EditMessageRevision(DelegatedAuthorization): | |||
765 | 3258 | usedfor = IMessageRevision | 3237 | usedfor = IMessageRevision |
766 | 3259 | 3238 | ||
767 | 3260 | def __init__(self, obj): | 3239 | def __init__(self, obj): |
770 | 3261 | super(EditMessageRevision, self).__init__( | 3240 | super().__init__(obj, obj.message, 'launchpad.Edit') |
769 | 3262 | obj, obj.message, 'launchpad.Edit') | ||
771 | 3263 | 3241 | ||
772 | 3264 | 3242 | ||
773 | 3265 | class ViewPublisherConfig(AdminByAdminsTeam): | 3243 | class ViewPublisherConfig(AdminByAdminsTeam): |
774 | @@ -3287,7 +3265,7 @@ class ViewLiveFS(DelegatedAuthorization): | |||
775 | 3287 | usedfor = ILiveFS | 3265 | usedfor = ILiveFS |
776 | 3288 | 3266 | ||
777 | 3289 | def __init__(self, obj): | 3267 | def __init__(self, obj): |
779 | 3290 | super(ViewLiveFS, self).__init__(obj, obj.owner, 'launchpad.View') | 3268 | super().__init__(obj, obj.owner, 'launchpad.View') |
780 | 3291 | 3269 | ||
781 | 3292 | 3270 | ||
782 | 3293 | class EditLiveFS(AuthorizationBase): | 3271 | class EditLiveFS(AuthorizationBase): |
783 | @@ -3346,7 +3324,7 @@ class EditLiveFSBuild(AdminByBuilddAdmin): | |||
784 | 3346 | auth_livefs = EditLiveFS(self.obj.livefs) | 3324 | auth_livefs = EditLiveFS(self.obj.livefs) |
785 | 3347 | if auth_livefs.checkAuthenticated(user): | 3325 | if auth_livefs.checkAuthenticated(user): |
786 | 3348 | return True | 3326 | return True |
788 | 3349 | return super(EditLiveFSBuild, self).checkAuthenticated(user) | 3327 | return super().checkAuthenticated(user) |
789 | 3350 | 3328 | ||
790 | 3351 | 3329 | ||
791 | 3352 | class AdminLiveFSBuild(AdminByBuilddAdmin): | 3330 | class AdminLiveFSBuild(AdminByBuilddAdmin): |
792 | @@ -3371,8 +3349,7 @@ class ViewWebhookDeliveryJob(DelegatedAuthorization): | |||
793 | 3371 | usedfor = IWebhookDeliveryJob | 3349 | usedfor = IWebhookDeliveryJob |
794 | 3372 | 3350 | ||
795 | 3373 | def __init__(self, obj): | 3351 | def __init__(self, obj): |
798 | 3374 | super(ViewWebhookDeliveryJob, self).__init__( | 3352 | super().__init__(obj, obj.webhook, 'launchpad.View') |
797 | 3375 | obj, obj.webhook, 'launchpad.View') | ||
799 | 3376 | 3353 | ||
800 | 3377 | 3354 | ||
801 | 3378 | class ViewSnap(AuthorizationBase): | 3355 | class ViewSnap(AuthorizationBase): |
802 | @@ -3451,8 +3428,7 @@ class ViewSnapBuildRequest(DelegatedAuthorization): | |||
803 | 3451 | usedfor = ISnapBuildRequest | 3428 | usedfor = ISnapBuildRequest |
804 | 3452 | 3429 | ||
805 | 3453 | def __init__(self, obj): | 3430 | def __init__(self, obj): |
808 | 3454 | super(ViewSnapBuildRequest, self).__init__( | 3431 | super().__init__(obj, obj.snap, 'launchpad.View') |
807 | 3455 | obj, obj.snap, 'launchpad.View') | ||
809 | 3456 | 3432 | ||
810 | 3457 | 3433 | ||
811 | 3458 | class ViewSnapBuild(DelegatedAuthorization): | 3434 | class ViewSnapBuild(DelegatedAuthorization): |
812 | @@ -3478,7 +3454,7 @@ class EditSnapBuild(AdminByBuilddAdmin): | |||
813 | 3478 | auth_snap = EditSnap(self.obj.snap) | 3454 | auth_snap = EditSnap(self.obj.snap) |
814 | 3479 | if auth_snap.checkAuthenticated(user): | 3455 | if auth_snap.checkAuthenticated(user): |
815 | 3480 | return True | 3456 | return True |
817 | 3481 | return super(EditSnapBuild, self).checkAuthenticated(user) | 3457 | return super().checkAuthenticated(user) |
818 | 3482 | 3458 | ||
819 | 3483 | 3459 | ||
820 | 3484 | class AdminSnapBuild(AdminByBuilddAdmin): | 3460 | class AdminSnapBuild(AdminByBuilddAdmin): |
821 | @@ -3532,7 +3508,7 @@ class EditOCIProjectSeries(DelegatedAuthorization): | |||
822 | 3532 | usedfor = IOCIProjectSeries | 3508 | usedfor = IOCIProjectSeries |
823 | 3533 | 3509 | ||
824 | 3534 | def __init__(self, obj): | 3510 | def __init__(self, obj): |
826 | 3535 | super(EditOCIProjectSeries, self).__init__(obj, obj.oci_project) | 3511 | super().__init__(obj, obj.oci_project) |
827 | 3536 | 3512 | ||
828 | 3537 | 3513 | ||
829 | 3538 | class ViewOCIRecipeBuildRequest(DelegatedAuthorization): | 3514 | class ViewOCIRecipeBuildRequest(DelegatedAuthorization): |
830 | @@ -3540,8 +3516,7 @@ class ViewOCIRecipeBuildRequest(DelegatedAuthorization): | |||
831 | 3540 | usedfor = IOCIRecipeBuildRequest | 3516 | usedfor = IOCIRecipeBuildRequest |
832 | 3541 | 3517 | ||
833 | 3542 | def __init__(self, obj): | 3518 | def __init__(self, obj): |
836 | 3543 | super(ViewOCIRecipeBuildRequest, self).__init__( | 3519 | super().__init__(obj, obj.recipe, 'launchpad.View') |
835 | 3544 | obj, obj.recipe, 'launchpad.View') | ||
837 | 3545 | 3520 | ||
838 | 3546 | 3521 | ||
839 | 3547 | class ViewOCIRecipe(AnonymousAuthorization): | 3522 | class ViewOCIRecipe(AnonymousAuthorization): |
840 | @@ -3638,7 +3613,7 @@ class EditOCIRecipeBuild(AdminByBuilddAdmin): | |||
841 | 3638 | auth_recipe = EditOCIRecipe(self.obj.recipe) | 3613 | auth_recipe = EditOCIRecipe(self.obj.recipe) |
842 | 3639 | if auth_recipe.checkAuthenticated(user): | 3614 | if auth_recipe.checkAuthenticated(user): |
843 | 3640 | return True | 3615 | return True |
845 | 3641 | return super(EditOCIRecipeBuild, self).checkAuthenticated(user) | 3616 | return super().checkAuthenticated(user) |
846 | 3642 | 3617 | ||
847 | 3643 | 3618 | ||
848 | 3644 | class AdminOCIRecipeBuild(AdminByBuilddAdmin): | 3619 | class AdminOCIRecipeBuild(AdminByBuilddAdmin): |
849 | @@ -3717,8 +3692,7 @@ class ViewCharmRecipeBuildRequest(DelegatedAuthorization): | |||
850 | 3717 | usedfor = ICharmRecipeBuildRequest | 3692 | usedfor = ICharmRecipeBuildRequest |
851 | 3718 | 3693 | ||
852 | 3719 | def __init__(self, obj): | 3694 | def __init__(self, obj): |
855 | 3720 | super(ViewCharmRecipeBuildRequest, self).__init__( | 3695 | super().__init__(obj, obj.recipe, 'launchpad.View') |
854 | 3721 | obj, obj.recipe, 'launchpad.View') | ||
856 | 3722 | 3696 | ||
857 | 3723 | 3697 | ||
858 | 3724 | class ViewCharmRecipeBuild(DelegatedAuthorization): | 3698 | class ViewCharmRecipeBuild(DelegatedAuthorization): |
859 | @@ -3743,7 +3717,7 @@ class EditCharmRecipeBuild(AdminByBuilddAdmin): | |||
860 | 3743 | auth_recipe = EditCharmRecipe(self.obj.recipe) | 3717 | auth_recipe = EditCharmRecipe(self.obj.recipe) |
861 | 3744 | if auth_recipe.checkAuthenticated(user): | 3718 | if auth_recipe.checkAuthenticated(user): |
862 | 3745 | return True | 3719 | return True |
864 | 3746 | return super(EditCharmRecipeBuild, self).checkAuthenticated(user) | 3720 | return super().checkAuthenticated(user) |
865 | 3747 | 3721 | ||
866 | 3748 | 3722 | ||
867 | 3749 | class AdminCharmRecipeBuild(AdminByBuilddAdmin): | 3723 | class AdminCharmRecipeBuild(AdminByBuilddAdmin): |
868 | diff --git a/lib/lp/systemhomes.py b/lib/lp/systemhomes.py | |||
869 | index f9d0fd9..9df2372 100644 | |||
870 | --- a/lib/lp/systemhomes.py | |||
871 | +++ b/lib/lp/systemhomes.py | |||
872 | @@ -315,7 +315,7 @@ class WebServiceApplication(ServiceRootResource): | |||
873 | 315 | if self.__class__.cached_wadl is None: | 315 | if self.__class__.cached_wadl is None: |
874 | 316 | # The cache has been disabled for testing | 316 | # The cache has been disabled for testing |
875 | 317 | # purposes. Generate the WADL. | 317 | # purposes. Generate the WADL. |
877 | 318 | return super(WebServiceApplication, self).toWADL() | 318 | return super().toWADL() |
878 | 319 | if version not in self.__class__.cached_wadl: | 319 | if version not in self.__class__.cached_wadl: |
879 | 320 | # It's not cached. Look for it on disk. | 320 | # It's not cached. Look for it on disk. |
880 | 321 | _wadl_filename = self.cachedWADLPath( | 321 | _wadl_filename = self.cachedWADLPath( |
881 | @@ -327,9 +327,9 @@ class WebServiceApplication(ServiceRootResource): | |||
882 | 327 | wadl = _wadl_fd.read() | 327 | wadl = _wadl_fd.read() |
883 | 328 | finally: | 328 | finally: |
884 | 329 | _wadl_fd.close() | 329 | _wadl_fd.close() |
886 | 330 | except IOError: | 330 | except OSError: |
887 | 331 | # It's not on disk; generate it. | 331 | # It's not on disk; generate it. |
889 | 332 | wadl = super(WebServiceApplication, self).toWADL() | 332 | wadl = super().toWADL() |
890 | 333 | del _wadl_fd | 333 | del _wadl_fd |
891 | 334 | self.__class__.cached_wadl[version] = wadl | 334 | self.__class__.cached_wadl[version] = wadl |
892 | 335 | return self.__class__.cached_wadl[version] | 335 | return self.__class__.cached_wadl[version] |
893 | diff --git a/lib/lp/xmlrpc/application.py b/lib/lp/xmlrpc/application.py | |||
894 | index 1b23765..d7b5edb 100644 | |||
895 | --- a/lib/lp/xmlrpc/application.py | |||
896 | +++ b/lib/lp/xmlrpc/application.py | |||
897 | @@ -109,7 +109,7 @@ class SelfTest(LaunchpadXMLRPCView): | |||
898 | 109 | 109 | ||
899 | 110 | def concatenate(self, string1, string2): | 110 | def concatenate(self, string1, string2): |
900 | 111 | """Return the concatenation of the two given strings.""" | 111 | """Return the concatenation of the two given strings.""" |
902 | 112 | return u'%s %s' % (string1, string2) | 112 | return '%s %s' % (string1, string2) |
903 | 113 | 113 | ||
904 | 114 | def hello(self): | 114 | def hello(self): |
905 | 115 | """Return a greeting to the logged in user.""" | 115 | """Return a greeting to the logged in user.""" |
906 | diff --git a/lib/lp/xmlrpc/tests/test_xmlrpc_selftest.py b/lib/lp/xmlrpc/tests/test_xmlrpc_selftest.py | |||
907 | index 9f0d528..d4fa40f 100644 | |||
908 | --- a/lib/lp/xmlrpc/tests/test_xmlrpc_selftest.py | |||
909 | +++ b/lib/lp/xmlrpc/tests/test_xmlrpc_selftest.py | |||
910 | @@ -42,7 +42,7 @@ class TestXMLRPCSelfTest(TestCaseWithFactory): | |||
911 | 42 | """ | 42 | """ |
912 | 43 | selftestview = SelfTest('somecontext', 'somerequest') | 43 | selftestview = SelfTest('somecontext', 'somerequest') |
913 | 44 | self.assertTrue(verifyObject(ISelfTest, selftestview)) | 44 | self.assertTrue(verifyObject(ISelfTest, selftestview)) |
915 | 45 | self.assertEqual(u'foo bar', selftestview.concatenate('foo', 'bar')) | 45 | self.assertEqual('foo bar', selftestview.concatenate('foo', 'bar')) |
916 | 46 | fault = selftestview.make_fault() | 46 | fault = selftestview.make_fault() |
917 | 47 | self.assertEqual("<Fault 666: 'Yoghurt and spanners.'>", str(fault)) | 47 | self.assertEqual("<Fault 666: 'Yoghurt and spanners.'>", str(fault)) |
918 | 48 | 48 | ||
919 | diff --git a/scripts/generate-access-token.py b/scripts/generate-access-token.py | |||
920 | index 961d715..e494888 100755 | |||
921 | --- a/scripts/generate-access-token.py | |||
922 | +++ b/scripts/generate-access-token.py | |||
923 | @@ -47,7 +47,7 @@ class AccessTokenGenerator(LaunchpadScript): | |||
924 | 47 | username = self.args[0] | 47 | username = self.args[0] |
925 | 48 | 48 | ||
926 | 49 | key = six.ensure_text(self.options.consumer_name) | 49 | key = six.ensure_text(self.options.consumer_name) |
928 | 50 | consumer = getUtility(IOAuthConsumerSet).new(key, u'') | 50 | consumer = getUtility(IOAuthConsumerSet).new(key, '') |
929 | 51 | request_token, _ = consumer.newRequestToken() | 51 | request_token, _ = consumer.newRequestToken() |
930 | 52 | 52 | ||
931 | 53 | # review by username | 53 | # review by username |
932 | diff --git a/scripts/gina.py b/scripts/gina.py | |||
933 | index b679bf8..e8fb3ed 100755 | |||
934 | --- a/scripts/gina.py | |||
935 | +++ b/scripts/gina.py | |||
936 | @@ -26,7 +26,7 @@ from lp.soyuz.scripts.gina.runner import run_gina | |||
937 | 26 | class Gina(LaunchpadCronScript): | 26 | class Gina(LaunchpadCronScript): |
938 | 27 | 27 | ||
939 | 28 | def __init__(self): | 28 | def __init__(self): |
941 | 29 | super(Gina, self).__init__(name='gina', dbuser=config.gina.dbuser) | 29 | super().__init__(name='gina', dbuser=config.gina.dbuser) |
942 | 30 | 30 | ||
943 | 31 | @property | 31 | @property |
944 | 32 | def usage(self): | 32 | def usage(self): |
945 | diff --git a/scripts/mlist-import.py b/scripts/mlist-import.py | |||
946 | index b7bf8b7..b418b5c 100755 | |||
947 | --- a/scripts/mlist-import.py | |||
948 | +++ b/scripts/mlist-import.py | |||
949 | @@ -40,7 +40,7 @@ class MailingListImport(LaunchpadScript): | |||
950 | 40 | 40 | ||
951 | 41 | def __init__(self, name, dbuser=None): | 41 | def __init__(self, name, dbuser=None): |
952 | 42 | self.usage = textwrap.dedent(self.__doc__) | 42 | self.usage = textwrap.dedent(self.__doc__) |
954 | 43 | super(MailingListImport, self).__init__(name, dbuser) | 43 | super().__init__(name, dbuser) |
955 | 44 | 44 | ||
956 | 45 | def add_my_options(self): | 45 | def add_my_options(self): |
957 | 46 | """See `LaunchpadScript`.""" | 46 | """See `LaunchpadScript`.""" |
958 | diff --git a/scripts/update-stacked-on.py b/scripts/update-stacked-on.py | |||
959 | index 7b6bb64..d8351d6 100755 | |||
960 | --- a/scripts/update-stacked-on.py | |||
961 | +++ b/scripts/update-stacked-on.py | |||
962 | @@ -56,7 +56,7 @@ class UpdateStackedBranches(LaunchpadScript): | |||
963 | 56 | """Update stacked branches so their stacked_on_location matches the db.""" | 56 | """Update stacked branches so their stacked_on_location matches the db.""" |
964 | 57 | 57 | ||
965 | 58 | def __init__(self): | 58 | def __init__(self): |
967 | 59 | super(UpdateStackedBranches, self).__init__('update-stacked-on') | 59 | super().__init__('update-stacked-on') |
968 | 60 | 60 | ||
969 | 61 | def add_my_options(self): | 61 | def add_my_options(self): |
970 | 62 | self.parser.add_option( | 62 | self.parser.add_option( |
971 | diff --git a/scripts/upload2librarian.py b/scripts/upload2librarian.py | |||
972 | index f211095..4c89bad 100755 | |||
973 | --- a/scripts/upload2librarian.py | |||
974 | +++ b/scripts/upload2librarian.py | |||
975 | @@ -53,7 +53,7 @@ class LibrarianUploader(LaunchpadScript): | |||
976 | 53 | """ | 53 | """ |
977 | 54 | try: | 54 | try: |
978 | 55 | file = open(filepath) | 55 | file = open(filepath) |
980 | 56 | except IOError: | 56 | except OSError: |
981 | 57 | raise LaunchpadScriptFailure('Could not open: %s' % filepath) | 57 | raise LaunchpadScriptFailure('Could not open: %s' % filepath) |
982 | 58 | 58 | ||
983 | 59 | flen = os.stat(filepath).st_size | 59 | flen = os.stat(filepath).st_size |
984 | diff --git a/setup.py b/setup.py | |||
985 | index ee010f0..88f502c 100644 | |||
986 | --- a/setup.py | |||
987 | +++ b/setup.py | |||
988 | @@ -51,8 +51,7 @@ class LPScriptWriter(ScriptWriter): | |||
989 | 51 | "module_name": ep.module_name, | 51 | "module_name": ep.module_name, |
990 | 52 | }) | 52 | }) |
991 | 53 | args = cls._get_script_args("console", name, header, script_text) | 53 | args = cls._get_script_args("console", name, header, script_text) |
994 | 54 | for res in args: | 54 | yield from args |
993 | 55 | yield res | ||
995 | 56 | 55 | ||
996 | 57 | 56 | ||
997 | 58 | class lp_develop(develop): | 57 | class lp_develop(develop): |
998 | diff --git a/utilities/generate-external-bug-status-docs b/utilities/generate-external-bug-status-docs | |||
999 | index 63a98b6..94ad229 100755 | |||
1000 | --- a/utilities/generate-external-bug-status-docs | |||
1001 | +++ b/utilities/generate-external-bug-status-docs | |||
1002 | @@ -26,8 +26,6 @@ from itertools import chain | |||
1003 | 26 | from optparse import OptionParser | 26 | from optparse import OptionParser |
1004 | 27 | import sys | 27 | import sys |
1005 | 28 | 28 | ||
1006 | 29 | import six | ||
1007 | 30 | |||
1008 | 31 | from lp.bugs.externalbugtracker import BUG_TRACKER_CLASSES | 29 | from lp.bugs.externalbugtracker import BUG_TRACKER_CLASSES |
1009 | 32 | 30 | ||
1010 | 33 | 31 | ||
1011 | @@ -87,7 +85,7 @@ def generate_table(typ, cls): | |||
1012 | 87 | 85 | ||
1013 | 88 | def generate_documentable_classes(): | 86 | def generate_documentable_classes(): |
1014 | 89 | """Yield each class that has a mapping table defined.""" | 87 | """Yield each class that has a mapping table defined.""" |
1016 | 90 | for typ, cls in six.iteritems(BUG_TRACKER_CLASSES): | 88 | for typ, cls in BUG_TRACKER_CLASSES.items(): |
1017 | 91 | if getattr(cls, '_status_lookup', None) is not None: | 89 | if getattr(cls, '_status_lookup', None) is not None: |
1018 | 92 | yield typ, cls | 90 | yield typ, cls |
1019 | 93 | 91 | ||
1020 | diff --git a/utilities/list-pages b/utilities/list-pages | |||
1021 | index 2f584ab..3dd9314 100755 | |||
1022 | --- a/utilities/list-pages | |||
1023 | +++ b/utilities/list-pages | |||
1024 | @@ -47,7 +47,6 @@ import _pythonpath # noqa: F401 | |||
1025 | 47 | from inspect import getmro | 47 | from inspect import getmro |
1026 | 48 | import os | 48 | import os |
1027 | 49 | 49 | ||
1028 | 50 | import six | ||
1029 | 51 | from zope.app.wsgi.testlayer import BrowserLayer | 50 | from zope.app.wsgi.testlayer import BrowserLayer |
1030 | 52 | from zope.browserpage.simpleviewclass import simple | 51 | from zope.browserpage.simpleviewclass import simple |
1031 | 53 | from zope.component import ( | 52 | from zope.component import ( |
1032 | @@ -177,7 +176,7 @@ def format_page_adapter(a): | |||
1033 | 177 | _BLACKLIST = [ | 176 | _BLACKLIST = [ |
1034 | 178 | '__conform__', | 177 | '__conform__', |
1035 | 179 | ] | 178 | ] |
1037 | 180 | class Whatever(object): | 179 | class Whatever: |
1038 | 181 | 180 | ||
1039 | 182 | def __init__(self, name, interface=None): | 181 | def __init__(self, name, interface=None): |
1040 | 183 | self._name = name | 182 | self._name = name |
1041 | @@ -196,7 +195,7 @@ class Whatever(object): | |||
1042 | 196 | 195 | ||
1043 | 197 | def __call__(self, *args, **kwargs): | 196 | def __call__(self, *args, **kwargs): |
1044 | 198 | args = map(repr, args) | 197 | args = map(repr, args) |
1046 | 199 | args.extend('%s=%r' % (k, v) for k, v in six.iteritems(kwargs)) | 198 | args.extend('%s=%r' % (k, v) for k, v in kwargs.items()) |
1047 | 200 | # If we're being called with no args, assume this is part of crazy | 199 | # If we're being called with no args, assume this is part of crazy |
1048 | 201 | # TALES stuff: | 200 | # TALES stuff: |
1049 | 202 | # webapp/metazcml.py(365)path() | 201 | # webapp/metazcml.py(365)path() |
1050 | @@ -224,7 +223,7 @@ class Whatever(object): | |||
1051 | 224 | 223 | ||
1052 | 225 | @implementer(ICanonicalUrlData) | 224 | @implementer(ICanonicalUrlData) |
1053 | 226 | @adapter(object) | 225 | @adapter(object) |
1055 | 227 | class DefaultCanonicalUrlData(object): | 226 | class DefaultCanonicalUrlData: |
1056 | 228 | def __init__(self, name): | 227 | def __init__(self, name): |
1057 | 229 | self.path = '[[%s]]' % (name,) | 228 | self.path = '[[%s]]' % (name,) |
1058 | 230 | self.rootsite = None | 229 | self.rootsite = None |
1059 | diff --git a/utilities/make-lp-user b/utilities/make-lp-user | |||
1060 | index ee792d1..6278075 100755 | |||
1061 | --- a/utilities/make-lp-user | |||
1062 | +++ b/utilities/make-lp-user | |||
1063 | @@ -103,12 +103,12 @@ def add_ssh_public_keys(person): | |||
1064 | 103 | key_set = getUtility(ISSHKeySet) | 103 | key_set = getUtility(ISSHKeySet) |
1065 | 104 | for filename in ('id_rsa.pub', 'id_dsa.pub'): | 104 | for filename in ('id_rsa.pub', 'id_dsa.pub'): |
1066 | 105 | try: | 105 | try: |
1068 | 106 | public_key_file = open(os.path.join(ssh_dir, filename), 'r') | 106 | public_key_file = open(os.path.join(ssh_dir, filename)) |
1069 | 107 | try: | 107 | try: |
1070 | 108 | public_key = public_key_file.read() | 108 | public_key = public_key_file.read() |
1071 | 109 | finally: | 109 | finally: |
1072 | 110 | public_key_file.close() | 110 | public_key_file.close() |
1074 | 111 | except (OSError, IOError): | 111 | except OSError: |
1075 | 112 | continue | 112 | continue |
1076 | 113 | key_set.new(person, public_key) | 113 | key_set.new(person, public_key) |
1077 | 114 | print('Registered SSH key: %s' % (filename,)) | 114 | print('Registered SSH key: %s' % (filename,)) |
1078 | diff --git a/utilities/massage-bug-import-xml b/utilities/massage-bug-import-xml | |||
1079 | index 997e3dd..7e43831 100755 | |||
1080 | --- a/utilities/massage-bug-import-xml | |||
1081 | +++ b/utilities/massage-bug-import-xml | |||
1082 | @@ -14,7 +14,7 @@ NS = "https://launchpad.net/xmlns/2006/bugs" | |||
1083 | 14 | def norm_text(elem): | 14 | def norm_text(elem): |
1084 | 15 | if elem is not None: | 15 | if elem is not None: |
1085 | 16 | if elem.text is None: | 16 | if elem.text is None: |
1087 | 17 | elem.text = u"" | 17 | elem.text = "" |
1088 | 18 | else: | 18 | else: |
1089 | 19 | elem.text = elem.text.strip() | 19 | elem.text = elem.text.strip() |
1090 | 20 | 20 | ||
1091 | @@ -26,7 +26,7 @@ def truncate(text, message=None): | |||
1092 | 26 | message = "[Truncated]" | 26 | message = "[Truncated]" |
1093 | 27 | else: | 27 | else: |
1094 | 28 | message = "[Truncated; %s]" % message | 28 | message = "[Truncated; %s]" % message |
1096 | 29 | return u"%s...\n\n%s" % ( | 29 | return "%s...\n\n%s" % ( |
1097 | 30 | "\n".join(lines[:30]).strip(), message) | 30 | "\n".join(lines[:30]).strip(), message) |
1098 | 31 | else: | 31 | else: |
1099 | 32 | return text | 32 | return text |
1100 | @@ -97,7 +97,7 @@ def massage(root, project_name, fix_nickname, tag_nickname): | |||
1101 | 97 | 97 | ||
1102 | 98 | # Change the nickname. | 98 | # Change the nickname. |
1103 | 99 | if nickname.text is None or fix_nickname: | 99 | if nickname.text is None or fix_nickname: |
1105 | 100 | nickname.text = u"%s-%s" % (project_name, bug.get('id')) | 100 | nickname.text = "%s-%s" % (project_name, bug.get('id')) |
1106 | 101 | 101 | ||
1107 | 102 | # Resolve duplicateof, if it exists. | 102 | # Resolve duplicateof, if it exists. |
1108 | 103 | if bug.get("id") in duplicates: | 103 | if bug.get("id") in duplicates: |
1109 | @@ -117,11 +117,11 @@ def massage(root, project_name, fix_nickname, tag_nickname): | |||
1110 | 117 | if first_comment_text is None: | 117 | if first_comment_text is None: |
1111 | 118 | problem_detail("No comments!") | 118 | problem_detail("No comments!") |
1112 | 119 | problem_resolution("Setting description to '-'.") | 119 | problem_resolution("Setting description to '-'.") |
1114 | 120 | description.text = u'-' | 120 | description.text = '-' |
1115 | 121 | elif len(first_comment_text.text) == 0: | 121 | elif len(first_comment_text.text) == 0: |
1116 | 122 | problem_detail("First comment has no text!") | 122 | problem_detail("First comment has no text!") |
1117 | 123 | problem_resolution("Setting description to '-'.") | 123 | problem_resolution("Setting description to '-'.") |
1119 | 124 | description.text = u'-' | 124 | description.text = '-' |
1120 | 125 | else: | 125 | else: |
1121 | 126 | problem_detail("First comment has text.") | 126 | problem_detail("First comment has text.") |
1122 | 127 | problem_resolution("Removing description.") | 127 | problem_resolution("Removing description.") |
1123 | @@ -159,7 +159,7 @@ def massage(root, project_name, fix_nickname, tag_nickname): | |||
1124 | 159 | problem( | 159 | problem( |
1125 | 160 | "Bug %s's first comment has no text." % bug.get('id')) | 160 | "Bug %s's first comment has no text." % bug.get('id')) |
1126 | 161 | problem_resolution("Setting comment text to '-'.") | 161 | problem_resolution("Setting comment text to '-'.") |
1128 | 162 | first_comment_text.text = u'-' | 162 | first_comment_text.text = '-' |
1129 | 163 | problem_resolved() | 163 | problem_resolved() |
1130 | 164 | elif len(first_comment_text.text) > 50000: | 164 | elif len(first_comment_text.text) > 50000: |
1131 | 165 | problem( | 165 | problem( |
1132 | @@ -170,12 +170,12 @@ def massage(root, project_name, fix_nickname, tag_nickname): | |||
1133 | 170 | attachment = etree.SubElement( | 170 | attachment = etree.SubElement( |
1134 | 171 | first_comment, '{%s}attachment' % NS) | 171 | first_comment, '{%s}attachment' % NS) |
1135 | 172 | etree.SubElement(attachment, '{%s}filename' % NS).text = ( | 172 | etree.SubElement(attachment, '{%s}filename' % NS).text = ( |
1137 | 173 | u"%s-bug-%s-full-description.txt" % ( | 173 | "%s-bug-%s-full-description.txt" % ( |
1138 | 174 | project_name, bug.get('id'))) | 174 | project_name, bug.get('id'))) |
1139 | 175 | etree.SubElement(attachment, '{%s}title' % NS).text = ( | 175 | etree.SubElement(attachment, '{%s}title' % NS).text = ( |
1141 | 176 | u"Full description (text/plain, utf-8)") | 176 | "Full description (text/plain, utf-8)") |
1142 | 177 | etree.SubElement(attachment, '{%s}mimetype' % NS).text = ( | 177 | etree.SubElement(attachment, '{%s}mimetype' % NS).text = ( |
1144 | 178 | u"text/plain") | 178 | "text/plain") |
1145 | 179 | etree.SubElement(attachment, '{%s}contents' % NS).text = ( | 179 | etree.SubElement(attachment, '{%s}contents' % NS).text = ( |
1146 | 180 | standard_b64encode( | 180 | standard_b64encode( |
1147 | 181 | first_comment_text.text.encode('utf-8') | 181 | first_comment_text.text.encode('utf-8') |
1148 | diff --git a/utilities/pglogwatch.py b/utilities/pglogwatch.py | |||
1149 | index 52eee17..8d61ed1 100755 | |||
1150 | --- a/utilities/pglogwatch.py | |||
1151 | +++ b/utilities/pglogwatch.py | |||
1152 | @@ -38,7 +38,7 @@ def generate_loglines(logfile): | |||
1153 | 38 | raise RuntimeError("tail returned %d" % cmd.returncode) | 38 | raise RuntimeError("tail returned %d" % cmd.returncode) |
1154 | 39 | 39 | ||
1155 | 40 | 40 | ||
1157 | 41 | class Process(object): | 41 | class Process: |
1158 | 42 | statement = None | 42 | statement = None |
1159 | 43 | duration = None | 43 | duration = None |
1160 | 44 | connection = None | 44 | connection = None |
1161 | @@ -48,7 +48,7 @@ class Process(object): | |||
1162 | 48 | self.pid = pid | 48 | self.pid = pid |
1163 | 49 | 49 | ||
1164 | 50 | 50 | ||
1166 | 51 | class Watcher(object): | 51 | class Watcher: |
1167 | 52 | _line_re = re.compile(r""" | 52 | _line_re = re.compile(r""" |
1168 | 53 | ^\d{4}-\d\d-\d\d \s \d\d:\d\d:\d\d \s | 53 | ^\d{4}-\d\d-\d\d \s \d\d:\d\d:\d\d \s |
1169 | 54 | \[(?P<pid>\d+)\] \s (?P<type>LOG|ERROR|DETAIL): \s+ (?P<rest>.*)$ | 54 | \[(?P<pid>\d+)\] \s (?P<type>LOG|ERROR|DETAIL): \s+ (?P<rest>.*)$ |
1170 | diff --git a/utilities/soyuz-sampledata-setup.py b/utilities/soyuz-sampledata-setup.py | |||
1171 | index cde53e9..7a6e4f1 100755 | |||
1172 | --- a/utilities/soyuz-sampledata-setup.py | |||
1173 | +++ b/utilities/soyuz-sampledata-setup.py | |||
1174 | @@ -322,7 +322,7 @@ def sign_code_of_conduct(person, log): | |||
1175 | 322 | fake_gpg_key = LaunchpadObjectFactory().makeGPGKey(person) | 322 | fake_gpg_key = LaunchpadObjectFactory().makeGPGKey(person) |
1176 | 323 | Store.of(person).add(SignedCodeOfConduct( | 323 | Store.of(person).add(SignedCodeOfConduct( |
1177 | 324 | owner=person, signing_key_fingerprint=fake_gpg_key.fingerprint, | 324 | owner=person, signing_key_fingerprint=fake_gpg_key.fingerprint, |
1179 | 325 | signedcode=u"Normally a signed CoC would go here.", active=True)) | 325 | signedcode="Normally a signed CoC would go here.", active=True)) |
1180 | 326 | 326 | ||
1181 | 327 | 327 | ||
1182 | 328 | def create_ppa_user(username, options, approver, log): | 328 | def create_ppa_user(username, options, approver, log): |
LGTM