Merge ~cjwatson/launchpad:pyupgrade-py3-remaining into launchpad: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)
Reviewer Review Type Date Requested Status
Ioana Lasc 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.
Revision history for this message
Ioana Lasc (ilasc) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index a64bbd3..80c13da 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -32,36 +32,14 @@ repos:
32 rev: v2.31.032 rev: v2.31.0
33 hooks:33 hooks:
34 - id: pyupgrade34 - id: pyupgrade
35 args: [--keep-percent-format]
36 exclude: ^lib/contrib/
37 - id: pyupgrade
38 alias: pyupgrade-py3
39 name: pyupgrade (--py3-plus)
40 args: [--keep-percent-format, --py3-plus]35 args: [--keep-percent-format, --py3-plus]
41 files: |36 exclude: |
42 (?x)^lib/lp/(37 (?x)^(
43 answers38 lib/contrib/.*
44 |app39 |lib/devscripts/.*
45 |archivepublisher40 |utilities/community-contributions\.py
46 |archiveuploader41 |utilities/update-sourcecode
47 |blueprints42 )$
48 |bugs
49 |buildmaster
50 |charms
51 |code
52 |codehosting
53 |coop
54 |oci
55 |registry
56 |scripts
57 |services
58 |snappy
59 |soyuz
60 |testing
61 |testopenid
62 |tests
63 |translations
64 )/
65- repo: https://github.com/PyCQA/isort43- repo: https://github.com/PyCQA/isort
66 rev: 5.9.244 rev: 5.9.2
67 hooks:45 hooks:
diff --git a/brzplugins/lpserve/__init__.py b/brzplugins/lpserve/__init__.py
index 52ce8ac..6b47fde 100644
--- a/brzplugins/lpserve/__init__.py
+++ b/brzplugins/lpserve/__init__.py
@@ -29,7 +29,6 @@ from breezy.transport import (
29 get_transport,29 get_transport,
30 transport_server_registry,30 transport_server_registry,
31 )31 )
32import six
3332
3433
35class cmd_launchpad_server(Command):34class cmd_launchpad_server(Command):
@@ -56,7 +55,7 @@ class cmd_launchpad_server(Command):
56 help=(55 help=(
57 "upload branches to this directory. Defaults to "56 "upload branches to this directory. Defaults to "
58 "config.codehosting.hosted_branches_root."),57 "config.codehosting.hosted_branches_root."),
59 type=six.text_type),58 type=str),
60 Option(59 Option(
61 'mirror-directory',60 'mirror-directory',
62 help=(61 help=(
@@ -67,7 +66,7 @@ class cmd_launchpad_server(Command):
67 help=(66 help=(
68 "the url of the internal XML-RPC server. Defaults to "67 "the url of the internal XML-RPC server. Defaults to "
69 "config.codehosting.codehosting_endpoint."),68 "config.codehosting.codehosting_endpoint."),
70 type=six.text_type),69 type=str),
71 RegistryOption(70 RegistryOption(
72 'protocol', help="Protocol to serve.",71 'protocol', help="Protocol to serve.",
73 lazy_registry=('breezy.transport', 'transport_server_registry'),72 lazy_registry=('breezy.transport', 'transport_server_registry'),
diff --git a/brzplugins/lpserve/test_lpserve.py b/brzplugins/lpserve/test_lpserve.py
index a9563ec..1ce8641 100644
--- a/brzplugins/lpserve/test_lpserve.py
+++ b/brzplugins/lpserve/test_lpserve.py
@@ -8,7 +8,6 @@ from breezy import (
8 osutils,8 osutils,
9 tests,9 tests,
10 )10 )
11import six
1211
13from lp.codehosting import (12from lp.codehosting import (
14 get_brz_path,13 get_brz_path,
@@ -43,11 +42,11 @@ class TestCaseWithSubprocess(tests.TestCaseWithTransport):
43 old_env = {}42 old_env = {}
4443
45 def cleanup_environment():44 def cleanup_environment():
46 for env_var, value in six.iteritems(env_changes):45 for env_var, value in env_changes.items():
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)
4847
49 def restore_environment():48 def restore_environment():
50 for env_var, value in six.iteritems(old_env):49 for env_var, value in old_env.items():
51 osutils.set_or_unset_env(env_var, value)50 osutils.set_or_unset_env(env_var, value)
5251
53 cwd = None52 cwd = None
diff --git a/cronscripts/librarian-feed-swift.py b/cronscripts/librarian-feed-swift.py
index 1cb1374..8921ece 100755
--- a/cronscripts/librarian-feed-swift.py
+++ b/cronscripts/librarian-feed-swift.py
@@ -9,8 +9,6 @@ import _pythonpath # noqa: F401
99
10import os10import os
1111
12import six
13
14from lp.services.database.interfaces import IStandbyStore12from lp.services.database.interfaces import IStandbyStore
15from lp.services.librarian.model import LibraryFileContent13from lp.services.librarian.model import LibraryFileContent
16from lp.services.librarianserver import swift14from lp.services.librarianserver import swift
@@ -79,14 +77,14 @@ class LibrarianFeedSwift(LaunchpadCronScript):
79 SELECT MAX(id) FROM LibraryFileContent77 SELECT MAX(id) FROM LibraryFileContent
80 WHERE datecreated < current_timestamp at time zone 'UTC'78 WHERE datecreated < current_timestamp at time zone 'UTC'
81 - CAST(%s AS INTERVAL)79 - CAST(%s AS INTERVAL)
82 """, (six.text_type(self.options.start_since),)).get_one()[0]80 """, (str(self.options.start_since),)).get_one()[0]
8381
84 if self.options.end_at:82 if self.options.end_at:
85 self.options.end = IStandbyStore(LibraryFileContent).execute("""83 self.options.end = IStandbyStore(LibraryFileContent).execute("""
86 SELECT MAX(id) FROM LibraryFileContent84 SELECT MAX(id) FROM LibraryFileContent
87 WHERE datecreated < current_timestamp at time zone 'UTC'85 WHERE datecreated < current_timestamp at time zone 'UTC'
88 - CAST(%s AS INTERVAL)86 - CAST(%s AS INTERVAL)
89 """, (six.text_type(self.options.end_at),)).get_one()[0]87 """, (str(self.options.end_at),)).get_one()[0]
9088
91 if ((self.options.instance_id is None) !=89 if ((self.options.instance_id is None) !=
92 (self.options.num_instances is None)):90 (self.options.num_instances is None)):
diff --git a/database/schema/security.py b/database/schema/security.py
index 06bdc23..7281678 100755
--- a/database/schema/security.py
+++ b/database/schema/security.py
@@ -12,8 +12,6 @@ import os
12import re12import re
13import sys13import sys
1414
15import six
16
17from fti import quote_identifier15from fti import quote_identifier
18from lp.services.database.sqlbase import connect16from lp.services.database.sqlbase import connect
19from lp.services.scripts import (17from lp.services.scripts import (
@@ -117,7 +115,7 @@ def list_role_members(cur, roles):
117 return members115 return members
118116
119117
120class DbObject(object):118class DbObject:
121119
122 def __init__(120 def __init__(
123 self, schema, name, type_, owner, acl, arguments=None, language=None):121 self, schema, name, type_, owner, acl, arguments=None, language=None):
@@ -151,7 +149,7 @@ class DbObject(object):
151149
152class DbSchema(dict):150class DbSchema(dict):
153 def __init__(self, con):151 def __init__(self, con):
154 super(DbSchema, self).__init__()152 super().__init__()
155 cur = con.cursor()153 cur = con.cursor()
156 log.debug("Getting relation metadata")154 log.debug("Getting relation metadata")
157 cur.execute('''155 cur.execute('''
@@ -223,7 +221,7 @@ class DbSchema(dict):
223 for r in cur.fetchall()}221 for r in cur.fetchall()}
224222
225223
226class CursorWrapper(object):224class CursorWrapper:
227225
228 def __init__(self, cursor):226 def __init__(self, cursor):
229 self.__dict__['_cursor'] = cursor227 self.__dict__['_cursor'] = cursor
@@ -306,8 +304,8 @@ class PermissionGatherer:
306 to grant or revoke for. Each is a string.304 to grant or revoke for. Each is a string.
307 """305 """
308 result = []306 result = []
309 for permission, parties in six.iteritems(self.permissions):307 for permission, parties in self.permissions.items():
310 for principal, entities in six.iteritems(parties):308 for principal, entities in parties.items():
311 result.append(309 result.append(
312 (permission, ", ".join(entities), principal))310 (permission, ", ".join(entities), principal))
313 return result311 return result
@@ -319,8 +317,8 @@ class PermissionGatherer:
319 def countEntities(self):317 def countEntities(self):
320 """Count the number of different entities."""318 """Count the number of different entities."""
321 entities = set()319 entities = set()
322 for entities_and_entities in six.itervalues(self.permissions):320 for entities_and_entities in self.permissions.values():
323 for extra_entities in six.itervalues(entities_and_entities):321 for extra_entities in entities_and_entities.values():
324 entities.update(extra_entities)322 entities.update(extra_entities)
325 return len(entities)323 return len(entities)
326324
@@ -328,7 +326,7 @@ class PermissionGatherer:
328 """Count the number of different principals."""326 """Count the number of different principals."""
329 return len(set(sum((327 return len(set(sum((
330 list(principals)328 list(principals)
331 for principals in six.itervalues(self.permissions)), [])))329 for principals in self.permissions.values()), [])))
332330
333 def grant(self, cur):331 def grant(self, cur):
334 """Grant all gathered permissions.332 """Grant all gathered permissions.
@@ -484,7 +482,7 @@ def reset_permissions(con, config, options):
484482
485 log.debug('Updating group memberships')483 log.debug('Updating group memberships')
486 existing_memberships = list_role_members(cur, list(memberships))484 existing_memberships = list_role_members(cur, list(memberships))
487 for group, users in six.iteritems(memberships):485 for group, users in memberships.items():
488 cur_users = managed_roles.intersection(existing_memberships[group])486 cur_users = managed_roles.intersection(existing_memberships[group])
489 to_grant = users - cur_users487 to_grant = users - cur_users
490 if to_grant:488 if to_grant:
@@ -622,7 +620,7 @@ def reset_permissions(con, config, options):
622 new = desired_permissions[obj][role]620 new = desired_permissions[obj][role]
623 old_privs = obj.acl.get(role, {})621 old_privs = obj.acl.get(role, {})
624 old = set(old_privs)622 old = set(old_privs)
625 if any(six.itervalues(old_privs)):623 if any(old_privs.values()):
626 log.warning("%s has grant option on %s", role, obj.fullname)624 log.warning("%s has grant option on %s", role, obj.fullname)
627 if new == old:625 if new == old:
628 continue626 continue
diff --git a/database/schema/upgrade.py b/database/schema/upgrade.py
index bab20e3..3b579ff 100755
--- a/database/schema/upgrade.py
+++ b/database/schema/upgrade.py
@@ -180,7 +180,7 @@ def get_patchlist(con):
180 log.fatal('Invalid patch filename %s' % repr(patch_file))180 log.fatal('Invalid patch filename %s' % repr(patch_file))
181 raise SystemExit(1)181 raise SystemExit(1)
182182
183 major, minor, patch = [int(i) for i in m.groups()]183 major, minor, patch = (int(i) for i in m.groups())
184 if (major, minor, patch) in dbpatches:184 if (major, minor, patch) in dbpatches:
185 continue # This patch has already been applied185 continue # This patch has already been applied
186 log.debug("Found patch %d.%d.%d -- %s" % (186 log.debug("Found patch %d.%d.%d -- %s" % (
diff --git a/lib/launchpad_loggerhead/app.py b/lib/launchpad_loggerhead/app.py
index aa58d54..7ada98a 100644
--- a/lib/launchpad_loggerhead/app.py
+++ b/lib/launchpad_loggerhead/app.py
@@ -120,8 +120,7 @@ class RootApp:
120 """120 """
121 openid_request = self._make_consumer(environ).begin(121 openid_request = self._make_consumer(environ).begin(
122 config.launchpad.openid_provider_root)122 config.launchpad.openid_provider_root)
123 openid_request.addExtension(123 openid_request.addExtension(SRegRequest(required=['nickname']))
124 SRegRequest(required=[u'nickname']))
125 back_to = construct_url(environ)124 back_to = construct_url(environ)
126 raise HTTPMovedPermanently(openid_request.redirectURL(125 raise HTTPMovedPermanently(openid_request.redirectURL(
127 config.codehosting.secure_codebrowse_root,126 config.codehosting.secure_codebrowse_root,
diff --git a/lib/launchpad_loggerhead/session.py b/lib/launchpad_loggerhead/session.py
index 2adb69c..ce214f7 100644
--- a/lib/launchpad_loggerhead/session.py
+++ b/lib/launchpad_loggerhead/session.py
@@ -21,7 +21,7 @@ class LaunchpadSecureCookie(SecureCookie):
21 hash_method = staticmethod(hashlib.sha256)21 hash_method = staticmethod(hashlib.sha256)
2222
23 # The OpenID consumer stores non-JSON-encodable objects in the session.23 # The OpenID consumer stores non-JSON-encodable objects in the session.
24 class serialization_method(object):24 class serialization_method:
2525
26 @classmethod26 @classmethod
27 def dumps(cls, value):27 def dumps(cls, value):
@@ -33,7 +33,7 @@ class LaunchpadSecureCookie(SecureCookie):
33 return pickle.loads(value)33 return pickle.loads(value)
3434
3535
36class SessionHandler(object):36class SessionHandler:
37 """Middleware that provides a cookie-based session.37 """Middleware that provides a cookie-based session.
3838
39 The session dict is stored, pickled (and HMACed), in a cookie, so don't39 The session dict is stored, pickled (and HMACed), in a cookie, so don't
diff --git a/lib/launchpad_loggerhead/tests.py b/lib/launchpad_loggerhead/tests.py
index 1c78b51..cad2ec3 100644
--- a/lib/launchpad_loggerhead/tests.py
+++ b/lib/launchpad_loggerhead/tests.py
@@ -128,7 +128,7 @@ class TestWSGI(TestCaseWithFactory):
128 layer = AppServerLayer128 layer = AppServerLayer
129129
130 def setUp(self):130 def setUp(self):
131 super(TestWSGI, self).setUp()131 super().setUp()
132 self.useBzrBranches()132 self.useBzrBranches()
133 loggerhead_fixture = self.useFixture(LoggerheadFixture())133 loggerhead_fixture = self.useFixture(LoggerheadFixture())
134134
@@ -136,7 +136,7 @@ class TestWSGI(TestCaseWithFactory):
136 try:136 try:
137 with open(loggerhead_fixture.logfile, "rb") as logfile:137 with open(loggerhead_fixture.logfile, "rb") as logfile:
138 return [logfile.read()]138 return [logfile.read()]
139 except IOError:139 except OSError:
140 return [b""]140 return [b""]
141141
142 self.addDetail(142 self.addDetail(
diff --git a/lib/launchpad_loggerhead/wsgi.py b/lib/launchpad_loggerhead/wsgi.py
index 633fb7c..eefe119 100644
--- a/lib/launchpad_loggerhead/wsgi.py
+++ b/lib/launchpad_loggerhead/wsgi.py
@@ -92,7 +92,7 @@ def log_request_start_and_stop(app):
92class LoggerheadLogger(Logger):92class LoggerheadLogger(Logger):
9393
94 def setup(self, cfg):94 def setup(self, cfg):
95 super(LoggerheadLogger, self).setup(cfg)95 super().setup(cfg)
96 formatter = LaunchpadFormatter(datefmt=None)96 formatter = LaunchpadFormatter(datefmt=None)
97 for handler in self.error_log.handlers:97 for handler in self.error_log.handlers:
98 handler.setFormatter(formatter)98 handler.setFormatter(formatter)
@@ -120,7 +120,7 @@ class LoggerheadApplication(Application):
120120
121 def __init__(self, **kwargs):121 def __init__(self, **kwargs):
122 self.options = kwargs122 self.options = kwargs
123 super(LoggerheadApplication, self).__init__()123 super().__init__()
124124
125 def init(self, parser, opts, args):125 def init(self, parser, opts, args):
126 top = os.path.abspath(os.path.join(126 top = os.path.abspath(os.path.join(
diff --git a/lib/lp/security.py b/lib/lp/security.py
index 044e197..37d52d3 100644
--- a/lib/lp/security.py
+++ b/lib/lp/security.py
@@ -468,7 +468,7 @@ class ViewAccount(EditAccountBySelfOrAdmin):
468 def checkAuthenticated(self, user):468 def checkAuthenticated(self, user):
469 """Extend permission to registry experts."""469 """Extend permission to registry experts."""
470 return (470 return (
471 super(ViewAccount, self).checkAuthenticated(user)471 super().checkAuthenticated(user)
472 or user.in_registry_experts)472 or user.in_registry_experts)
473473
474474
@@ -544,7 +544,7 @@ class LimitedViewProduct(ViewProduct):
544544
545 def checkAuthenticated(self, user):545 def checkAuthenticated(self, user):
546 return (546 return (
547 super(LimitedViewProduct, self).checkAuthenticated(user) or547 super().checkAuthenticated(user) or
548 self.obj.userCanLimitedView(user))548 self.obj.userCanLimitedView(user))
549549
550550
@@ -554,7 +554,7 @@ class EditProduct(EditByOwnersOrAdmins):
554 def checkAuthenticated(self, user):554 def checkAuthenticated(self, user):
555 # Commercial admins may help setup commercial projects.555 # Commercial admins may help setup commercial projects.
556 return (556 return (
557 super(EditProduct, self).checkAuthenticated(user)557 super().checkAuthenticated(user)
558 or is_commercial_case(self.obj, user)558 or is_commercial_case(self.obj, user)
559 or False)559 or False)
560560
@@ -580,8 +580,7 @@ class ViewTimelineProductSeries(DelegatedAuthorization):
580 usedfor = ITimelineProductSeries580 usedfor = ITimelineProductSeries
581581
582 def __init__(self, obj):582 def __init__(self, obj):
583 super(ViewTimelineProductSeries, self).__init__(583 super().__init__(obj, obj.product, 'launchpad.View')
584 obj, obj.product, 'launchpad.View')
585584
586585
587class ViewProductReleaseFile(AnonymousAuthorization):586class ViewProductReleaseFile(AnonymousAuthorization):
@@ -798,7 +797,7 @@ class ModerateSprint(ModerateByRegistryExpertsOrAdmins):
798797
799 def checkAuthenticated(self, user):798 def checkAuthenticated(self, user):
800 return (799 return (
801 super(ModerateSprint, self).checkAuthenticated(user) or800 super().checkAuthenticated(user) or
802 user.isOwner(self.obj))801 user.isOwner(self.obj))
803802
804803
@@ -867,8 +866,7 @@ class ViewProjectMilestone(DelegatedAuthorization):
867 usedfor = IProjectGroupMilestone866 usedfor = IProjectGroupMilestone
868867
869 def __init__(self, obj):868 def __init__(self, obj):
870 super(ViewProjectMilestone, self).__init__(869 super().__init__(obj, obj.product, 'launchpad.View')
871 obj, obj.product, 'launchpad.View')
872870
873871
874class EditProjectMilestoneNever(AuthorizationBase):872class EditProjectMilestoneNever(AuthorizationBase):
@@ -885,8 +883,7 @@ class LimitedViewMilestone(DelegatedAuthorization):
885 usedfor = IMilestone883 usedfor = IMilestone
886884
887 def __init__(self, obj):885 def __init__(self, obj):
888 super(LimitedViewMilestone, self).__init__(886 super().__init__(obj, obj.target, 'launchpad.LimitedView')
889 obj, obj.target, 'launchpad.LimitedView')
890887
891888
892class ViewMilestone(AuthorizationBase):889class ViewMilestone(AuthorizationBase):
@@ -963,7 +960,7 @@ class ModerateTeam(ModerateByRegistryExpertsOrAdmins):
963 registry experts, team admins, or the team owners.960 registry experts, team admins, or the team owners.
964 """961 """
965 return (962 return (
966 super(ModerateTeam, self).checkAuthenticated(user)963 super().checkAuthenticated(user)
967 or can_edit_team(self.obj, user))964 or can_edit_team(self.obj, user))
968965
969966
@@ -1003,8 +1000,7 @@ class AdminByCommercialTeamOrAdminsOrPerson(AdminByCommercialTeamOrAdmins):
10031000
1004 def checkAuthenticated(self, user):1001 def checkAuthenticated(self, user):
1005 """Users can manage their commericial data and admins can help."""1002 """Users can manage their commericial data and admins can help."""
1006 base = super(AdminByCommercialTeamOrAdminsOrPerson, self)1003 return self.obj.id == user.id or super().checkAuthenticated(user)
1007 return self.obj.id == user.id or base.checkAuthenticated(user)
10081004
10091005
1010class EditPersonBySelfOrAdmins(AuthorizationBase):1006class EditPersonBySelfOrAdmins(AuthorizationBase):
@@ -1451,7 +1447,7 @@ class EditDistroSeriesDifference(DelegatedAuthorization):
1451 usedfor = IDistroSeriesDifferenceEdit1447 usedfor = IDistroSeriesDifferenceEdit
14521448
1453 def __init__(self, obj):1449 def __init__(self, obj):
1454 super(EditDistroSeriesDifference, self).__init__(1450 super().__init__(
1455 obj, obj.derived_series.distribution, 'launchpad.View')1451 obj, obj.derived_series.distribution, 'launchpad.View')
14561452
1457 def checkUnauthenticated(self):1453 def checkUnauthenticated(self):
@@ -1479,7 +1475,7 @@ class DriveProduct(SeriesDrivers):
1479 def checkAuthenticated(self, user):1475 def checkAuthenticated(self, user):
1480 # Commercial admins may help setup commercial projects.1476 # Commercial admins may help setup commercial projects.
1481 return (1477 return (
1482 super(DriveProduct, self).checkAuthenticated(user)1478 super().checkAuthenticated(user)
1483 or is_commercial_case(self.obj, user)1479 or is_commercial_case(self.obj, user)
1484 or False)1480 or False)
14851481
@@ -1489,8 +1485,7 @@ class LimitedViewProductSeries(DelegatedAuthorization):
1489 usedfor = IProductSeriesLimitedView1485 usedfor = IProductSeriesLimitedView
14901486
1491 def __init__(self, obj):1487 def __init__(self, obj):
1492 super(LimitedViewProductSeries, self).__init__(1488 super().__init__(obj, obj.product, 'launchpad.LimitedView')
1493 obj, obj.product, 'launchpad.LimitedView')
14941489
14951490
1496class ViewProductSeries(AuthorizationBase):1491class ViewProductSeries(AuthorizationBase):
@@ -1541,8 +1536,7 @@ class ViewDistroArchSeriesFilter(DelegatedAuthorization):
1541 usedfor = IDistroArchSeriesFilter1536 usedfor = IDistroArchSeriesFilter
15421537
1543 def __init__(self, obj):1538 def __init__(self, obj):
1544 super(ViewDistroArchSeriesFilter, self).__init__(1539 super().__init__(obj, obj.distroarchseries, 'launchpad.View')
1545 obj, obj.distroarchseries, 'launchpad.View')
15461540
15471541
1548class EditDistroArchSeriesFilter(DelegatedAuthorization):1542class EditDistroArchSeriesFilter(DelegatedAuthorization):
@@ -1550,8 +1544,7 @@ class EditDistroArchSeriesFilter(DelegatedAuthorization):
1550 usedfor = IDistroArchSeriesFilter1544 usedfor = IDistroArchSeriesFilter
15511545
1552 def __init__(self, obj):1546 def __init__(self, obj):
1553 super(EditDistroArchSeriesFilter, self).__init__(1547 super().__init__(obj, obj.distroarchseries, 'launchpad.Moderate')
1554 obj, obj.distroarchseries, 'launchpad.Moderate')
15551548
15561549
1557class ViewAnnouncement(AuthorizationBase):1550class ViewAnnouncement(AuthorizationBase):
@@ -1888,8 +1881,7 @@ class ViewProductRelease(DelegatedAuthorization):
1888 usedfor = IProductRelease1881 usedfor = IProductRelease
18891882
1890 def __init__(self, obj):1883 def __init__(self, obj):
1891 super(ViewProductRelease, self).__init__(1884 super().__init__(obj, obj.milestone, 'launchpad.View')
1892 obj, obj.milestone, 'launchpad.View')
18931885
18941886
1895class AdminTranslationImportQueueEntry(AuthorizationBase):1887class AdminTranslationImportQueueEntry(AuthorizationBase):
@@ -2002,7 +1994,7 @@ class ViewPackageUploadLog(DelegatedAuthorization):
2002 usedfor = IPackageUploadLog1994 usedfor = IPackageUploadLog
20031995
2004 def __init__(self, obj):1996 def __init__(self, obj):
2005 super(ViewPackageUploadLog, self).__init__(obj, obj.package_upload)1997 super().__init__(obj, obj.package_upload)
20061998
20071999
2008class EditPackageUpload(AdminByAdminsTeam):2000class EditPackageUpload(AdminByAdminsTeam):
@@ -2046,7 +2038,7 @@ class ModerateBuilder(EditBuilder):
20462038
2047 def checkAuthenticated(self, user):2039 def checkAuthenticated(self, user):
2048 return (user.in_registry_experts or2040 return (user.in_registry_experts or
2049 super(ModerateBuilder, self).checkAuthenticated(user))2041 super().checkAuthenticated(user))
20502042
20512043
2052class AdminBuildRecord(AdminByBuilddAdmin):2044class AdminBuildRecord(AdminByBuilddAdmin):
@@ -2154,8 +2146,7 @@ class ModerateBinaryPackageBuild(ViewBinaryPackageBuild):
2154 # administer the archive can already achieve the same effect by2146 # administer the archive can already achieve the same effect by
2155 # setting Archive.external_dependencies.)2147 # setting Archive.external_dependencies.)
2156 return (2148 return (
2157 super(ModerateBinaryPackageBuild, self).checkAuthenticated(2149 super().checkAuthenticated(user) and
2158 user) and
2159 AdminArchive(self.obj.archive).checkAuthenticated(user))2150 AdminArchive(self.obj.archive).checkAuthenticated(user))
21602151
2161 def checkUnauthenticated(self, user):2152 def checkUnauthenticated(self, user):
@@ -2171,7 +2162,7 @@ class ViewTranslationTemplatesBuild(DelegatedAuthorization):
2171 usedfor = ITranslationTemplatesBuild2162 usedfor = ITranslationTemplatesBuild
21722163
2173 def __init__(self, obj):2164 def __init__(self, obj):
2174 super(ViewTranslationTemplatesBuild, self).__init__(obj, obj.branch)2165 super().__init__(obj, obj.branch)
21752166
21762167
2177class AdminQuestion(AuthorizationBase):2168class AdminQuestion(AuthorizationBase):
@@ -2389,7 +2380,7 @@ class ModerateBranch(EditBranch):
2389 permission = 'launchpad.Moderate'2380 permission = 'launchpad.Moderate'
23902381
2391 def checkAuthenticated(self, user):2382 def checkAuthenticated(self, user):
2392 if super(ModerateBranch, self).checkAuthenticated(user):2383 if super().checkAuthenticated(user):
2393 return True2384 return True
2394 branch = self.obj2385 branch = self.obj
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):
@@ -2464,7 +2455,7 @@ class ModerateGitRepository(EditGitRepository):
2464 permission = 'launchpad.Moderate'2455 permission = 'launchpad.Moderate'
24652456
2466 def checkAuthenticated(self, user):2457 def checkAuthenticated(self, user):
2467 if super(ModerateGitRepository, self).checkAuthenticated(user):2458 if super().checkAuthenticated(user):
2468 return True2459 return True
2469 target = self.obj.target2460 target = self.obj.target
2470 if (target is not None and IProduct.providedBy(target) and2461 if (target is not None and IProduct.providedBy(target) and
@@ -2484,17 +2475,17 @@ class ViewGitRef(DelegatedAuthorization):
2484 usedfor = IGitRef2475 usedfor = IGitRef
24852476
2486 def __init__(self, obj):2477 def __init__(self, obj):
2487 super(ViewGitRef, self).__init__(obj, obj.repository)2478 super().__init__(obj, obj.repository)
24882479
2489 def checkAuthenticated(self, user):2480 def checkAuthenticated(self, user):
2490 if self.obj.repository is not None:2481 if self.obj.repository is not None:
2491 return super(ViewGitRef, self).checkAuthenticated(user)2482 return super().checkAuthenticated(user)
2492 else:2483 else:
2493 return True2484 return True
24942485
2495 def checkUnauthenticated(self):2486 def checkUnauthenticated(self):
2496 if self.obj.repository is not None:2487 if self.obj.repository is not None:
2497 return super(ViewGitRef, self).checkUnauthenticated()2488 return super().checkUnauthenticated()
2498 else:2489 else:
2499 return True2490 return True
25002491
@@ -2505,7 +2496,7 @@ class EditGitRef(DelegatedAuthorization):
2505 usedfor = IGitRef2496 usedfor = IGitRef
25062497
2507 def __init__(self, obj):2498 def __init__(self, obj):
2508 super(EditGitRef, self).__init__(obj, obj.repository)2499 super().__init__(obj, obj.repository)
25092500
25102501
2511class ViewGitRule(DelegatedAuthorization):2502class ViewGitRule(DelegatedAuthorization):
@@ -2514,7 +2505,7 @@ class ViewGitRule(DelegatedAuthorization):
2514 usedfor = IGitRule2505 usedfor = IGitRule
25152506
2516 def __init__(self, obj):2507 def __init__(self, obj):
2517 super(ViewGitRule, self).__init__(obj, obj.repository)2508 super().__init__(obj, obj.repository)
25182509
25192510
2520class EditGitRule(DelegatedAuthorization):2511class EditGitRule(DelegatedAuthorization):
@@ -2523,7 +2514,7 @@ class EditGitRule(DelegatedAuthorization):
2523 usedfor = IGitRule2514 usedfor = IGitRule
25242515
2525 def __init__(self, obj):2516 def __init__(self, obj):
2526 super(EditGitRule, self).__init__(obj, obj.repository)2517 super().__init__(obj, obj.repository)
25272518
25282519
2529class ViewGitRuleGrant(DelegatedAuthorization):2520class ViewGitRuleGrant(DelegatedAuthorization):
@@ -2532,7 +2523,7 @@ class ViewGitRuleGrant(DelegatedAuthorization):
2532 usedfor = IGitRuleGrant2523 usedfor = IGitRuleGrant
25332524
2534 def __init__(self, obj):2525 def __init__(self, obj):
2535 super(ViewGitRuleGrant, self).__init__(obj, obj.repository)2526 super().__init__(obj, obj.repository)
25362527
25372528
2538class EditGitRuleGrant(DelegatedAuthorization):2529class EditGitRuleGrant(DelegatedAuthorization):
@@ -2541,7 +2532,7 @@ class EditGitRuleGrant(DelegatedAuthorization):
2541 usedfor = IGitRuleGrant2532 usedfor = IGitRuleGrant
25422533
2543 def __init__(self, obj):2534 def __init__(self, obj):
2544 super(EditGitRuleGrant, self).__init__(obj, obj.repository)2535 super().__init__(obj, obj.repository)
25452536
25462537
2547class ViewGitActivity(DelegatedAuthorization):2538class ViewGitActivity(DelegatedAuthorization):
@@ -2550,7 +2541,7 @@ class ViewGitActivity(DelegatedAuthorization):
2550 usedfor = IGitActivity2541 usedfor = IGitActivity
25512542
2552 def __init__(self, obj):2543 def __init__(self, obj):
2553 super(ViewGitActivity, self).__init__(obj, obj.repository)2544 super().__init__(obj, obj.repository)
25542545
25552546
2556class AdminDistroSeriesTranslations(AuthorizationBase):2547class AdminDistroSeriesTranslations(AuthorizationBase):
@@ -2573,8 +2564,7 @@ class AdminDistributionSourcePackageTranslations(DelegatedAuthorization):
2573 usedfor = IDistributionSourcePackage2564 usedfor = IDistributionSourcePackage
25742565
2575 def __init__(self, obj):2566 def __init__(self, obj):
2576 super(AdminDistributionSourcePackageTranslations, self).__init__(2567 super().__init__(obj, obj.distribution)
2577 obj, obj.distribution)
25782568
25792569
2580class AdminProductSeriesTranslations(AuthorizationBase):2570class AdminProductSeriesTranslations(AuthorizationBase):
@@ -2643,7 +2633,7 @@ class PreviewDiffView(DelegatedAuthorization):
2643 usedfor = IPreviewDiff2633 usedfor = IPreviewDiff
26442634
2645 def __init__(self, obj):2635 def __init__(self, obj):
2646 super(PreviewDiffView, self).__init__(obj, obj.branch_merge_proposal)2636 super().__init__(obj, obj.branch_merge_proposal)
26472637
26482638
2649class CodeReviewVoteReferenceView(DelegatedAuthorization):2639class CodeReviewVoteReferenceView(DelegatedAuthorization):
@@ -2651,8 +2641,7 @@ class CodeReviewVoteReferenceView(DelegatedAuthorization):
2651 usedfor = ICodeReviewVoteReference2641 usedfor = ICodeReviewVoteReference
26522642
2653 def __init__(self, obj):2643 def __init__(self, obj):
2654 super(CodeReviewVoteReferenceView, self).__init__(2644 super().__init__(obj, obj.branch_merge_proposal)
2655 obj, obj.branch_merge_proposal)
26562645
26572646
2658class CodeReviewVoteReferenceEdit(DelegatedAuthorization):2647class CodeReviewVoteReferenceEdit(DelegatedAuthorization):
@@ -2660,8 +2649,7 @@ class CodeReviewVoteReferenceEdit(DelegatedAuthorization):
2660 usedfor = ICodeReviewVoteReference2649 usedfor = ICodeReviewVoteReference
26612650
2662 def __init__(self, obj):2651 def __init__(self, obj):
2663 super(CodeReviewVoteReferenceEdit, self).__init__(2652 super().__init__(obj, obj.branch_merge_proposal.target_branch)
2664 obj, obj.branch_merge_proposal.target_branch)
26652653
2666 def checkAuthenticated(self, user):2654 def checkAuthenticated(self, user):
2667 """Only the affected teams may change the review request.2655 """Only the affected teams may change the review request.
@@ -2675,8 +2663,7 @@ class CodeReviewVoteReferenceEdit(DelegatedAuthorization):
2675 """2663 """
2676 return (user.inTeam(self.obj.reviewer) or2664 return (user.inTeam(self.obj.reviewer) or
2677 user.inTeam(self.obj.registrant) or2665 user.inTeam(self.obj.registrant) or
2678 super(CodeReviewVoteReferenceEdit, self).checkAuthenticated(2666 super().checkAuthenticated(user))
2679 user))
26802667
26812668
2682class CodeReviewCommentView(DelegatedAuthorization):2669class CodeReviewCommentView(DelegatedAuthorization):
@@ -2684,8 +2671,7 @@ class CodeReviewCommentView(DelegatedAuthorization):
2684 usedfor = ICodeReviewComment2671 usedfor = ICodeReviewComment
26852672
2686 def __init__(self, obj):2673 def __init__(self, obj):
2687 super(CodeReviewCommentView, self).__init__(2674 super().__init__(obj, obj.branch_merge_proposal)
2688 obj, obj.branch_merge_proposal)
26892675
26902676
2691class CodeReviewCommentOwner(AuthorizationBase):2677class CodeReviewCommentOwner(AuthorizationBase):
@@ -2702,8 +2688,7 @@ class CodeReviewCommentDelete(DelegatedAuthorization):
2702 usedfor = ICodeReviewCommentDeletion2688 usedfor = ICodeReviewCommentDeletion
27032689
2704 def __init__(self, obj):2690 def __init__(self, obj):
2705 super(CodeReviewCommentDelete, self).__init__(2691 super().__init__(obj, obj.branch_merge_proposal)
2706 obj, obj.branch_merge_proposal)
27072692
27082693
2709class BranchMergeProposalEdit(AuthorizationBase):2694class BranchMergeProposalEdit(AuthorizationBase):
@@ -2804,7 +2789,7 @@ class SubscriberViewArchive(ViewArchive):
2804 def checkAuthenticated(self, user):2789 def checkAuthenticated(self, user):
2805 if user.person in self.obj._known_subscribers:2790 if user.person in self.obj._known_subscribers:
2806 return True2791 return True
2807 if super(SubscriberViewArchive, self).checkAuthenticated(user):2792 if super().checkAuthenticated(user):
2808 return True2793 return True
2809 filter = get_enabled_archive_filter(2794 filter = get_enabled_archive_filter(
2810 user.person, include_subscribed=True)2795 user.person, include_subscribed=True)
@@ -2854,7 +2839,7 @@ class DeleteArchive(EditArchive):
28542839
2855 def checkAuthenticated(self, user):2840 def checkAuthenticated(self, user):
2856 return (2841 return (
2857 super(DeleteArchive, self).checkAuthenticated(user) or2842 super().checkAuthenticated(user) or
2858 (not self.obj.is_main and user.in_registry_experts))2843 (not self.obj.is_main and user.in_registry_experts))
28592844
28602845
@@ -2943,12 +2928,11 @@ class EditArchiveAuthToken(DelegatedAuthorization):
2943 usedfor = IArchiveAuthToken2928 usedfor = IArchiveAuthToken
29442929
2945 def __init__(self, obj):2930 def __init__(self, obj):
2946 super(EditArchiveAuthToken, self).__init__(2931 super().__init__(obj, obj.archive, 'launchpad.Append')
2947 obj, obj.archive, 'launchpad.Append')
29482932
2949 def checkAuthenticated(self, user):2933 def checkAuthenticated(self, user):
2950 return (user.in_admin or2934 return (user.in_admin or
2951 super(EditArchiveAuthToken, self).checkAuthenticated(user))2935 super().checkAuthenticated(user))
29522936
29532937
2954class ViewPersonalArchiveSubscription(DelegatedAuthorization):2938class ViewPersonalArchiveSubscription(DelegatedAuthorization):
@@ -2961,14 +2945,12 @@ class ViewPersonalArchiveSubscription(DelegatedAuthorization):
2961 usedfor = IPersonalArchiveSubscription2945 usedfor = IPersonalArchiveSubscription
29622946
2963 def __init__(self, obj):2947 def __init__(self, obj):
2964 super(ViewPersonalArchiveSubscription, self).__init__(2948 super().__init__(obj, obj.archive, 'launchpad.Append')
2965 obj, obj.archive, 'launchpad.Append')
29662949
2967 def checkAuthenticated(self, user):2950 def checkAuthenticated(self, user):
2968 if user.person == self.obj.subscriber or user.in_admin:2951 if user.person == self.obj.subscriber or user.in_admin:
2969 return True2952 return True
2970 return super(2953 return super().checkAuthenticated(user)
2971 ViewPersonalArchiveSubscription, self).checkAuthenticated(user)
29722954
29732955
2974class ViewArchiveSubscriber(DelegatedAuthorization):2956class ViewArchiveSubscriber(DelegatedAuthorization):
@@ -2981,13 +2963,12 @@ class ViewArchiveSubscriber(DelegatedAuthorization):
2981 usedfor = IArchiveSubscriber2963 usedfor = IArchiveSubscriber
29822964
2983 def __init__(self, obj):2965 def __init__(self, obj):
2984 super(ViewArchiveSubscriber, self).__init__(2966 super().__init__(obj, obj, 'launchpad.Edit')
2985 obj, obj, 'launchpad.Edit')
29862967
2987 def checkAuthenticated(self, user):2968 def checkAuthenticated(self, user):
2988 return (user.inTeam(self.obj.subscriber) or2969 return (user.inTeam(self.obj.subscriber) or
2989 user.in_commercial_admin or2970 user.in_commercial_admin or
2990 super(ViewArchiveSubscriber, self).checkAuthenticated(user))2971 super().checkAuthenticated(user))
29912972
29922973
2993class EditArchiveSubscriber(DelegatedAuthorization):2974class EditArchiveSubscriber(DelegatedAuthorization):
@@ -2999,13 +2980,12 @@ class EditArchiveSubscriber(DelegatedAuthorization):
2999 usedfor = IArchiveSubscriber2980 usedfor = IArchiveSubscriber
30002981
3001 def __init__(self, obj):2982 def __init__(self, obj):
3002 super(EditArchiveSubscriber, self).__init__(2983 super().__init__(obj, obj.archive, 'launchpad.Append')
3003 obj, obj.archive, 'launchpad.Append')
30042984
3005 def checkAuthenticated(self, user):2985 def checkAuthenticated(self, user):
3006 return (user.in_admin or2986 return (user.in_admin or
3007 user.in_commercial_admin or2987 user.in_commercial_admin or
3008 super(EditArchiveSubscriber, self).checkAuthenticated(user))2988 super().checkAuthenticated(user))
30092989
30102990
3011class AdminArchiveSubscriberSet(AdminByCommercialTeamOrAdmins):2991class AdminArchiveSubscriberSet(AdminByCommercialTeamOrAdmins):
@@ -3062,8 +3042,7 @@ class EditPublishing(DelegatedAuthorization):
3062 usedfor = IPublishingEdit3042 usedfor = IPublishingEdit
30633043
3064 def __init__(self, obj):3044 def __init__(self, obj):
3065 super(EditPublishing, self).__init__(3045 super().__init__(obj, obj.archive, 'launchpad.Append')
3066 obj, obj.archive, 'launchpad.Append')
30673046
30683047
3069class ViewBinaryPackagePublishingHistory(ViewSourcePackagePublishingHistory):3048class ViewBinaryPackagePublishingHistory(ViewSourcePackagePublishingHistory):
@@ -3148,7 +3127,7 @@ class EditEmailAddress(EditByOwnersOrAdmins):
3148 # Always allow users to see their own email addresses.3127 # Always allow users to see their own email addresses.
3149 if self.obj.person == user:3128 if self.obj.person == user:
3150 return True3129 return True
3151 return super(EditEmailAddress, self).checkAuthenticated(user)3130 return super().checkAuthenticated(user)
31523131
31533132
3154class ViewGPGKey(AnonymousAuthorization):3133class ViewGPGKey(AnonymousAuthorization):
@@ -3258,8 +3237,7 @@ class EditMessageRevision(DelegatedAuthorization):
3258 usedfor = IMessageRevision3237 usedfor = IMessageRevision
32593238
3260 def __init__(self, obj):3239 def __init__(self, obj):
3261 super(EditMessageRevision, self).__init__(3240 super().__init__(obj, obj.message, 'launchpad.Edit')
3262 obj, obj.message, 'launchpad.Edit')
32633241
32643242
3265class ViewPublisherConfig(AdminByAdminsTeam):3243class ViewPublisherConfig(AdminByAdminsTeam):
@@ -3287,7 +3265,7 @@ class ViewLiveFS(DelegatedAuthorization):
3287 usedfor = ILiveFS3265 usedfor = ILiveFS
32883266
3289 def __init__(self, obj):3267 def __init__(self, obj):
3290 super(ViewLiveFS, self).__init__(obj, obj.owner, 'launchpad.View')3268 super().__init__(obj, obj.owner, 'launchpad.View')
32913269
32923270
3293class EditLiveFS(AuthorizationBase):3271class EditLiveFS(AuthorizationBase):
@@ -3346,7 +3324,7 @@ class EditLiveFSBuild(AdminByBuilddAdmin):
3346 auth_livefs = EditLiveFS(self.obj.livefs)3324 auth_livefs = EditLiveFS(self.obj.livefs)
3347 if auth_livefs.checkAuthenticated(user):3325 if auth_livefs.checkAuthenticated(user):
3348 return True3326 return True
3349 return super(EditLiveFSBuild, self).checkAuthenticated(user)3327 return super().checkAuthenticated(user)
33503328
33513329
3352class AdminLiveFSBuild(AdminByBuilddAdmin):3330class AdminLiveFSBuild(AdminByBuilddAdmin):
@@ -3371,8 +3349,7 @@ class ViewWebhookDeliveryJob(DelegatedAuthorization):
3371 usedfor = IWebhookDeliveryJob3349 usedfor = IWebhookDeliveryJob
33723350
3373 def __init__(self, obj):3351 def __init__(self, obj):
3374 super(ViewWebhookDeliveryJob, self).__init__(3352 super().__init__(obj, obj.webhook, 'launchpad.View')
3375 obj, obj.webhook, 'launchpad.View')
33763353
33773354
3378class ViewSnap(AuthorizationBase):3355class ViewSnap(AuthorizationBase):
@@ -3451,8 +3428,7 @@ class ViewSnapBuildRequest(DelegatedAuthorization):
3451 usedfor = ISnapBuildRequest3428 usedfor = ISnapBuildRequest
34523429
3453 def __init__(self, obj):3430 def __init__(self, obj):
3454 super(ViewSnapBuildRequest, self).__init__(3431 super().__init__(obj, obj.snap, 'launchpad.View')
3455 obj, obj.snap, 'launchpad.View')
34563432
34573433
3458class ViewSnapBuild(DelegatedAuthorization):3434class ViewSnapBuild(DelegatedAuthorization):
@@ -3478,7 +3454,7 @@ class EditSnapBuild(AdminByBuilddAdmin):
3478 auth_snap = EditSnap(self.obj.snap)3454 auth_snap = EditSnap(self.obj.snap)
3479 if auth_snap.checkAuthenticated(user):3455 if auth_snap.checkAuthenticated(user):
3480 return True3456 return True
3481 return super(EditSnapBuild, self).checkAuthenticated(user)3457 return super().checkAuthenticated(user)
34823458
34833459
3484class AdminSnapBuild(AdminByBuilddAdmin):3460class AdminSnapBuild(AdminByBuilddAdmin):
@@ -3532,7 +3508,7 @@ class EditOCIProjectSeries(DelegatedAuthorization):
3532 usedfor = IOCIProjectSeries3508 usedfor = IOCIProjectSeries
35333509
3534 def __init__(self, obj):3510 def __init__(self, obj):
3535 super(EditOCIProjectSeries, self).__init__(obj, obj.oci_project)3511 super().__init__(obj, obj.oci_project)
35363512
35373513
3538class ViewOCIRecipeBuildRequest(DelegatedAuthorization):3514class ViewOCIRecipeBuildRequest(DelegatedAuthorization):
@@ -3540,8 +3516,7 @@ class ViewOCIRecipeBuildRequest(DelegatedAuthorization):
3540 usedfor = IOCIRecipeBuildRequest3516 usedfor = IOCIRecipeBuildRequest
35413517
3542 def __init__(self, obj):3518 def __init__(self, obj):
3543 super(ViewOCIRecipeBuildRequest, self).__init__(3519 super().__init__(obj, obj.recipe, 'launchpad.View')
3544 obj, obj.recipe, 'launchpad.View')
35453520
35463521
3547class ViewOCIRecipe(AnonymousAuthorization):3522class ViewOCIRecipe(AnonymousAuthorization):
@@ -3638,7 +3613,7 @@ class EditOCIRecipeBuild(AdminByBuilddAdmin):
3638 auth_recipe = EditOCIRecipe(self.obj.recipe)3613 auth_recipe = EditOCIRecipe(self.obj.recipe)
3639 if auth_recipe.checkAuthenticated(user):3614 if auth_recipe.checkAuthenticated(user):
3640 return True3615 return True
3641 return super(EditOCIRecipeBuild, self).checkAuthenticated(user)3616 return super().checkAuthenticated(user)
36423617
36433618
3644class AdminOCIRecipeBuild(AdminByBuilddAdmin):3619class AdminOCIRecipeBuild(AdminByBuilddAdmin):
@@ -3717,8 +3692,7 @@ class ViewCharmRecipeBuildRequest(DelegatedAuthorization):
3717 usedfor = ICharmRecipeBuildRequest3692 usedfor = ICharmRecipeBuildRequest
37183693
3719 def __init__(self, obj):3694 def __init__(self, obj):
3720 super(ViewCharmRecipeBuildRequest, self).__init__(3695 super().__init__(obj, obj.recipe, 'launchpad.View')
3721 obj, obj.recipe, 'launchpad.View')
37223696
37233697
3724class ViewCharmRecipeBuild(DelegatedAuthorization):3698class ViewCharmRecipeBuild(DelegatedAuthorization):
@@ -3743,7 +3717,7 @@ class EditCharmRecipeBuild(AdminByBuilddAdmin):
3743 auth_recipe = EditCharmRecipe(self.obj.recipe)3717 auth_recipe = EditCharmRecipe(self.obj.recipe)
3744 if auth_recipe.checkAuthenticated(user):3718 if auth_recipe.checkAuthenticated(user):
3745 return True3719 return True
3746 return super(EditCharmRecipeBuild, self).checkAuthenticated(user)3720 return super().checkAuthenticated(user)
37473721
37483722
3749class AdminCharmRecipeBuild(AdminByBuilddAdmin):3723class AdminCharmRecipeBuild(AdminByBuilddAdmin):
diff --git a/lib/lp/systemhomes.py b/lib/lp/systemhomes.py
index f9d0fd9..9df2372 100644
--- a/lib/lp/systemhomes.py
+++ b/lib/lp/systemhomes.py
@@ -315,7 +315,7 @@ class WebServiceApplication(ServiceRootResource):
315 if self.__class__.cached_wadl is None:315 if self.__class__.cached_wadl is None:
316 # The cache has been disabled for testing316 # The cache has been disabled for testing
317 # purposes. Generate the WADL.317 # purposes. Generate the WADL.
318 return super(WebServiceApplication, self).toWADL()318 return super().toWADL()
319 if version not in self.__class__.cached_wadl:319 if version not in self.__class__.cached_wadl:
320 # It's not cached. Look for it on disk.320 # It's not cached. Look for it on disk.
321 _wadl_filename = self.cachedWADLPath(321 _wadl_filename = self.cachedWADLPath(
@@ -327,9 +327,9 @@ class WebServiceApplication(ServiceRootResource):
327 wadl = _wadl_fd.read()327 wadl = _wadl_fd.read()
328 finally:328 finally:
329 _wadl_fd.close()329 _wadl_fd.close()
330 except IOError:330 except OSError:
331 # It's not on disk; generate it.331 # It's not on disk; generate it.
332 wadl = super(WebServiceApplication, self).toWADL()332 wadl = super().toWADL()
333 del _wadl_fd333 del _wadl_fd
334 self.__class__.cached_wadl[version] = wadl334 self.__class__.cached_wadl[version] = wadl
335 return self.__class__.cached_wadl[version]335 return self.__class__.cached_wadl[version]
diff --git a/lib/lp/xmlrpc/application.py b/lib/lp/xmlrpc/application.py
index 1b23765..d7b5edb 100644
--- a/lib/lp/xmlrpc/application.py
+++ b/lib/lp/xmlrpc/application.py
@@ -109,7 +109,7 @@ class SelfTest(LaunchpadXMLRPCView):
109109
110 def concatenate(self, string1, string2):110 def concatenate(self, string1, string2):
111 """Return the concatenation of the two given strings."""111 """Return the concatenation of the two given strings."""
112 return u'%s %s' % (string1, string2)112 return '%s %s' % (string1, string2)
113113
114 def hello(self):114 def hello(self):
115 """Return a greeting to the logged in user."""115 """Return a greeting to the logged in user."""
diff --git a/lib/lp/xmlrpc/tests/test_xmlrpc_selftest.py b/lib/lp/xmlrpc/tests/test_xmlrpc_selftest.py
index 9f0d528..d4fa40f 100644
--- a/lib/lp/xmlrpc/tests/test_xmlrpc_selftest.py
+++ b/lib/lp/xmlrpc/tests/test_xmlrpc_selftest.py
@@ -42,7 +42,7 @@ class TestXMLRPCSelfTest(TestCaseWithFactory):
42 """42 """
43 selftestview = SelfTest('somecontext', 'somerequest')43 selftestview = SelfTest('somecontext', 'somerequest')
44 self.assertTrue(verifyObject(ISelfTest, selftestview))44 self.assertTrue(verifyObject(ISelfTest, selftestview))
45 self.assertEqual(u'foo bar', selftestview.concatenate('foo', 'bar'))45 self.assertEqual('foo bar', selftestview.concatenate('foo', 'bar'))
46 fault = selftestview.make_fault()46 fault = selftestview.make_fault()
47 self.assertEqual("<Fault 666: 'Yoghurt and spanners.'>", str(fault))47 self.assertEqual("<Fault 666: 'Yoghurt and spanners.'>", str(fault))
4848
diff --git a/scripts/generate-access-token.py b/scripts/generate-access-token.py
index 961d715..e494888 100755
--- a/scripts/generate-access-token.py
+++ b/scripts/generate-access-token.py
@@ -47,7 +47,7 @@ class AccessTokenGenerator(LaunchpadScript):
47 username = self.args[0]47 username = self.args[0]
4848
49 key = six.ensure_text(self.options.consumer_name)49 key = six.ensure_text(self.options.consumer_name)
50 consumer = getUtility(IOAuthConsumerSet).new(key, u'')50 consumer = getUtility(IOAuthConsumerSet).new(key, '')
51 request_token, _ = consumer.newRequestToken()51 request_token, _ = consumer.newRequestToken()
5252
53 # review by username53 # review by username
diff --git a/scripts/gina.py b/scripts/gina.py
index b679bf8..e8fb3ed 100755
--- a/scripts/gina.py
+++ b/scripts/gina.py
@@ -26,7 +26,7 @@ from lp.soyuz.scripts.gina.runner import run_gina
26class Gina(LaunchpadCronScript):26class Gina(LaunchpadCronScript):
2727
28 def __init__(self):28 def __init__(self):
29 super(Gina, self).__init__(name='gina', dbuser=config.gina.dbuser)29 super().__init__(name='gina', dbuser=config.gina.dbuser)
3030
31 @property31 @property
32 def usage(self):32 def usage(self):
diff --git a/scripts/mlist-import.py b/scripts/mlist-import.py
index b7bf8b7..b418b5c 100755
--- a/scripts/mlist-import.py
+++ b/scripts/mlist-import.py
@@ -40,7 +40,7 @@ class MailingListImport(LaunchpadScript):
4040
41 def __init__(self, name, dbuser=None):41 def __init__(self, name, dbuser=None):
42 self.usage = textwrap.dedent(self.__doc__)42 self.usage = textwrap.dedent(self.__doc__)
43 super(MailingListImport, self).__init__(name, dbuser)43 super().__init__(name, dbuser)
4444
45 def add_my_options(self):45 def add_my_options(self):
46 """See `LaunchpadScript`."""46 """See `LaunchpadScript`."""
diff --git a/scripts/update-stacked-on.py b/scripts/update-stacked-on.py
index 7b6bb64..d8351d6 100755
--- a/scripts/update-stacked-on.py
+++ b/scripts/update-stacked-on.py
@@ -56,7 +56,7 @@ class UpdateStackedBranches(LaunchpadScript):
56 """Update stacked branches so their stacked_on_location matches the db."""56 """Update stacked branches so their stacked_on_location matches the db."""
5757
58 def __init__(self):58 def __init__(self):
59 super(UpdateStackedBranches, self).__init__('update-stacked-on')59 super().__init__('update-stacked-on')
6060
61 def add_my_options(self):61 def add_my_options(self):
62 self.parser.add_option(62 self.parser.add_option(
diff --git a/scripts/upload2librarian.py b/scripts/upload2librarian.py
index f211095..4c89bad 100755
--- a/scripts/upload2librarian.py
+++ b/scripts/upload2librarian.py
@@ -53,7 +53,7 @@ class LibrarianUploader(LaunchpadScript):
53 """53 """
54 try:54 try:
55 file = open(filepath)55 file = open(filepath)
56 except IOError:56 except OSError:
57 raise LaunchpadScriptFailure('Could not open: %s' % filepath)57 raise LaunchpadScriptFailure('Could not open: %s' % filepath)
5858
59 flen = os.stat(filepath).st_size59 flen = os.stat(filepath).st_size
diff --git a/setup.py b/setup.py
index ee010f0..88f502c 100644
--- a/setup.py
+++ b/setup.py
@@ -51,8 +51,7 @@ class LPScriptWriter(ScriptWriter):
51 "module_name": ep.module_name,51 "module_name": ep.module_name,
52 })52 })
53 args = cls._get_script_args("console", name, header, script_text)53 args = cls._get_script_args("console", name, header, script_text)
54 for res in args:54 yield from args
55 yield res
5655
5756
58class lp_develop(develop):57class lp_develop(develop):
diff --git a/utilities/generate-external-bug-status-docs b/utilities/generate-external-bug-status-docs
index 63a98b6..94ad229 100755
--- a/utilities/generate-external-bug-status-docs
+++ b/utilities/generate-external-bug-status-docs
@@ -26,8 +26,6 @@ from itertools import chain
26from optparse import OptionParser26from optparse import OptionParser
27import sys27import sys
2828
29import six
30
31from lp.bugs.externalbugtracker import BUG_TRACKER_CLASSES29from lp.bugs.externalbugtracker import BUG_TRACKER_CLASSES
3230
3331
@@ -87,7 +85,7 @@ def generate_table(typ, cls):
8785
88def generate_documentable_classes():86def generate_documentable_classes():
89 """Yield each class that has a mapping table defined."""87 """Yield each class that has a mapping table defined."""
90 for typ, cls in six.iteritems(BUG_TRACKER_CLASSES):88 for typ, cls in BUG_TRACKER_CLASSES.items():
91 if getattr(cls, '_status_lookup', None) is not None:89 if getattr(cls, '_status_lookup', None) is not None:
92 yield typ, cls90 yield typ, cls
9391
diff --git a/utilities/list-pages b/utilities/list-pages
index 2f584ab..3dd9314 100755
--- a/utilities/list-pages
+++ b/utilities/list-pages
@@ -47,7 +47,6 @@ import _pythonpath # noqa: F401
47from inspect import getmro47from inspect import getmro
48import os48import os
4949
50import six
51from zope.app.wsgi.testlayer import BrowserLayer50from zope.app.wsgi.testlayer import BrowserLayer
52from zope.browserpage.simpleviewclass import simple51from zope.browserpage.simpleviewclass import simple
53from zope.component import (52from zope.component import (
@@ -177,7 +176,7 @@ def format_page_adapter(a):
177_BLACKLIST = [176_BLACKLIST = [
178 '__conform__',177 '__conform__',
179 ]178 ]
180class Whatever(object):179class Whatever:
181180
182 def __init__(self, name, interface=None):181 def __init__(self, name, interface=None):
183 self._name = name182 self._name = name
@@ -196,7 +195,7 @@ class Whatever(object):
196195
197 def __call__(self, *args, **kwargs):196 def __call__(self, *args, **kwargs):
198 args = map(repr, args)197 args = map(repr, args)
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())
200 # If we're being called with no args, assume this is part of crazy199 # If we're being called with no args, assume this is part of crazy
201 # TALES stuff:200 # TALES stuff:
202 # webapp/metazcml.py(365)path()201 # webapp/metazcml.py(365)path()
@@ -224,7 +223,7 @@ class Whatever(object):
224223
225@implementer(ICanonicalUrlData)224@implementer(ICanonicalUrlData)
226@adapter(object)225@adapter(object)
227class DefaultCanonicalUrlData(object):226class DefaultCanonicalUrlData:
228 def __init__(self, name):227 def __init__(self, name):
229 self.path = '[[%s]]' % (name,)228 self.path = '[[%s]]' % (name,)
230 self.rootsite = None229 self.rootsite = None
diff --git a/utilities/make-lp-user b/utilities/make-lp-user
index ee792d1..6278075 100755
--- a/utilities/make-lp-user
+++ b/utilities/make-lp-user
@@ -103,12 +103,12 @@ def add_ssh_public_keys(person):
103 key_set = getUtility(ISSHKeySet)103 key_set = getUtility(ISSHKeySet)
104 for filename in ('id_rsa.pub', 'id_dsa.pub'):104 for filename in ('id_rsa.pub', 'id_dsa.pub'):
105 try:105 try:
106 public_key_file = open(os.path.join(ssh_dir, filename), 'r')106 public_key_file = open(os.path.join(ssh_dir, filename))
107 try:107 try:
108 public_key = public_key_file.read()108 public_key = public_key_file.read()
109 finally:109 finally:
110 public_key_file.close()110 public_key_file.close()
111 except (OSError, IOError):111 except OSError:
112 continue112 continue
113 key_set.new(person, public_key)113 key_set.new(person, public_key)
114 print('Registered SSH key: %s' % (filename,))114 print('Registered SSH key: %s' % (filename,))
diff --git a/utilities/massage-bug-import-xml b/utilities/massage-bug-import-xml
index 997e3dd..7e43831 100755
--- a/utilities/massage-bug-import-xml
+++ b/utilities/massage-bug-import-xml
@@ -14,7 +14,7 @@ NS = "https://launchpad.net/xmlns/2006/bugs"
14def norm_text(elem):14def norm_text(elem):
15 if elem is not None:15 if elem is not None:
16 if elem.text is None:16 if elem.text is None:
17 elem.text = u""17 elem.text = ""
18 else:18 else:
19 elem.text = elem.text.strip()19 elem.text = elem.text.strip()
2020
@@ -26,7 +26,7 @@ def truncate(text, message=None):
26 message = "[Truncated]"26 message = "[Truncated]"
27 else:27 else:
28 message = "[Truncated; %s]" % message28 message = "[Truncated; %s]" % message
29 return u"%s...\n\n%s" % (29 return "%s...\n\n%s" % (
30 "\n".join(lines[:30]).strip(), message)30 "\n".join(lines[:30]).strip(), message)
31 else:31 else:
32 return text32 return text
@@ -97,7 +97,7 @@ def massage(root, project_name, fix_nickname, tag_nickname):
9797
98 # Change the nickname.98 # Change the nickname.
99 if nickname.text is None or fix_nickname:99 if nickname.text is None or fix_nickname:
100 nickname.text = u"%s-%s" % (project_name, bug.get('id'))100 nickname.text = "%s-%s" % (project_name, bug.get('id'))
101101
102 # Resolve duplicateof, if it exists.102 # Resolve duplicateof, if it exists.
103 if bug.get("id") in duplicates:103 if bug.get("id") in duplicates:
@@ -117,11 +117,11 @@ def massage(root, project_name, fix_nickname, tag_nickname):
117 if first_comment_text is None:117 if first_comment_text is None:
118 problem_detail("No comments!")118 problem_detail("No comments!")
119 problem_resolution("Setting description to '-'.")119 problem_resolution("Setting description to '-'.")
120 description.text = u'-'120 description.text = '-'
121 elif len(first_comment_text.text) == 0:121 elif len(first_comment_text.text) == 0:
122 problem_detail("First comment has no text!")122 problem_detail("First comment has no text!")
123 problem_resolution("Setting description to '-'.")123 problem_resolution("Setting description to '-'.")
124 description.text = u'-'124 description.text = '-'
125 else:125 else:
126 problem_detail("First comment has text.")126 problem_detail("First comment has text.")
127 problem_resolution("Removing description.")127 problem_resolution("Removing description.")
@@ -159,7 +159,7 @@ def massage(root, project_name, fix_nickname, tag_nickname):
159 problem(159 problem(
160 "Bug %s's first comment has no text." % bug.get('id'))160 "Bug %s's first comment has no text." % bug.get('id'))
161 problem_resolution("Setting comment text to '-'.")161 problem_resolution("Setting comment text to '-'.")
162 first_comment_text.text = u'-'162 first_comment_text.text = '-'
163 problem_resolved()163 problem_resolved()
164 elif len(first_comment_text.text) > 50000:164 elif len(first_comment_text.text) > 50000:
165 problem(165 problem(
@@ -170,12 +170,12 @@ def massage(root, project_name, fix_nickname, tag_nickname):
170 attachment = etree.SubElement(170 attachment = etree.SubElement(
171 first_comment, '{%s}attachment' % NS)171 first_comment, '{%s}attachment' % NS)
172 etree.SubElement(attachment, '{%s}filename' % NS).text = (172 etree.SubElement(attachment, '{%s}filename' % NS).text = (
173 u"%s-bug-%s-full-description.txt" % (173 "%s-bug-%s-full-description.txt" % (
174 project_name, bug.get('id')))174 project_name, bug.get('id')))
175 etree.SubElement(attachment, '{%s}title' % NS).text = (175 etree.SubElement(attachment, '{%s}title' % NS).text = (
176 u"Full description (text/plain, utf-8)")176 "Full description (text/plain, utf-8)")
177 etree.SubElement(attachment, '{%s}mimetype' % NS).text = (177 etree.SubElement(attachment, '{%s}mimetype' % NS).text = (
178 u"text/plain")178 "text/plain")
179 etree.SubElement(attachment, '{%s}contents' % NS).text = (179 etree.SubElement(attachment, '{%s}contents' % NS).text = (
180 standard_b64encode(180 standard_b64encode(
181 first_comment_text.text.encode('utf-8')181 first_comment_text.text.encode('utf-8')
diff --git a/utilities/pglogwatch.py b/utilities/pglogwatch.py
index 52eee17..8d61ed1 100755
--- a/utilities/pglogwatch.py
+++ b/utilities/pglogwatch.py
@@ -38,7 +38,7 @@ def generate_loglines(logfile):
38 raise RuntimeError("tail returned %d" % cmd.returncode)38 raise RuntimeError("tail returned %d" % cmd.returncode)
3939
4040
41class Process(object):41class Process:
42 statement = None42 statement = None
43 duration = None43 duration = None
44 connection = None44 connection = None
@@ -48,7 +48,7 @@ class Process(object):
48 self.pid = pid48 self.pid = pid
4949
5050
51class Watcher(object):51class Watcher:
52 _line_re = re.compile(r"""52 _line_re = re.compile(r"""
53 ^\d{4}-\d\d-\d\d \s \d\d:\d\d:\d\d \s53 ^\d{4}-\d\d-\d\d \s \d\d:\d\d:\d\d \s
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>.*)$
diff --git a/utilities/soyuz-sampledata-setup.py b/utilities/soyuz-sampledata-setup.py
index cde53e9..7a6e4f1 100755
--- a/utilities/soyuz-sampledata-setup.py
+++ b/utilities/soyuz-sampledata-setup.py
@@ -322,7 +322,7 @@ def sign_code_of_conduct(person, log):
322 fake_gpg_key = LaunchpadObjectFactory().makeGPGKey(person)322 fake_gpg_key = LaunchpadObjectFactory().makeGPGKey(person)
323 Store.of(person).add(SignedCodeOfConduct(323 Store.of(person).add(SignedCodeOfConduct(
324 owner=person, signing_key_fingerprint=fake_gpg_key.fingerprint,324 owner=person, signing_key_fingerprint=fake_gpg_key.fingerprint,
325 signedcode=u"Normally a signed CoC would go here.", active=True))325 signedcode="Normally a signed CoC would go here.", active=True))
326326
327327
328def create_ppa_user(username, options, approver, log):328def create_ppa_user(username, options, approver, log):

Subscribers

People subscribed via source and target branches

to status/vote changes: