You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2020/02/10 22:44:49 UTC

[allura] 18/41: [#8349] python-modernize -n -w --no-diffs -f raise .

This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch db/8349
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 751b5dd26c6775c3a893cccb68a83c9b3be3190f
Author: Dave Brondsema <da...@brondsema.net>
AuthorDate: Mon Feb 10 14:34:40 2020 -0500

    [#8349] python-modernize -n -w --no-diffs -f raise .
---
 Allura/allura/app.py                               |  2 +-
 Allura/allura/config/app_cfg.py                    |  2 +-
 Allura/allura/controllers/base.py                  |  2 +-
 Allura/allura/controllers/basetest_project_root.py |  4 ++--
 Allura/allura/controllers/project.py               |  4 ++--
 Allura/allura/controllers/rest.py                  | 10 +++++-----
 Allura/allura/controllers/search.py                |  2 +-
 Allura/allura/controllers/site_admin.py            |  2 +-
 Allura/allura/ext/admin/admin_main.py              |  8 ++++----
 Allura/allura/lib/base.py                          |  2 +-
 Allura/allura/lib/mail_util.py                     |  8 ++++----
 Allura/allura/lib/repository.py                    |  2 +-
 Allura/allura/model/project.py                     |  2 +-
 ForgeTracker/forgetracker/model/ticket.py          |  6 +++---
 ForgeTracker/forgetracker/tracker_main.py          |  2 +-
 15 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/Allura/allura/app.py b/Allura/allura/app.py
index ad7db0c..99ddc4f 100644
--- a/Allura/allura/app.py
+++ b/Allura/allura/app.py
@@ -1058,4 +1058,4 @@ class WebhooksLookup(BaseController, AdminControllerMixin):
         for hook in self.app._webhooks:
             if hook.type == name and hook.controller:
                 return hook.controller(hook, self.app), remainder
-        raise exc.HTTPNotFound, name
+        raise exc.HTTPNotFound(name)
diff --git a/Allura/allura/config/app_cfg.py b/Allura/allura/config/app_cfg.py
index 9e8d023..9ba1639 100644
--- a/Allura/allura/config/app_cfg.py
+++ b/Allura/allura/config/app_cfg.py
@@ -123,7 +123,7 @@ class JinjaEngine(ew.TemplateEngine):
         try:
             return self._environ.get_template(template_name)
         except jinja2.TemplateNotFound:
-            raise ew.errors.TemplateNotFound, '%s not found' % template_name
+            raise ew.errors.TemplateNotFound('%s not found' % template_name)
 
     def parse(self, template_text, filepath=None):
         return self._environ.from_string(template_text)
diff --git a/Allura/allura/controllers/base.py b/Allura/allura/controllers/base.py
index b47d4c0..a61beab 100644
--- a/Allura/allura/controllers/base.py
+++ b/Allura/allura/controllers/base.py
@@ -35,7 +35,7 @@ class BaseController(object):
     def _lookup(self, name=None, *remainder):
         """Provide explicit default lookup to avoid dispatching backtracking
         and possible loops."""
-        raise exc.HTTPNotFound, name
+        raise exc.HTTPNotFound(name)
 
     def rate_limit(self, artifact_class, message, redir='..'):
         if artifact_class.is_limit_exceeded(c.app.config, user=c.user):
diff --git a/Allura/allura/controllers/basetest_project_root.py b/Allura/allura/controllers/basetest_project_root.py
index 5364cb4..459c95e 100644
--- a/Allura/allura/controllers/basetest_project_root.py
+++ b/Allura/allura/controllers/basetest_project_root.py
@@ -104,10 +104,10 @@ class BasetestProjectRootController(WsgiDispatchController, ProjectController):
             try:
                 c.project.install_app(ep_name, name)
             except KeyError:
-                raise exc.HTTPNotFound, name
+                raise exc.HTTPNotFound(name)
             app = c.project.app_instance(name)
             if app is None:
-                raise exc.HTTPNotFound, name
+                raise exc.HTTPNotFound(name)
         c.app = app
         return app.root, remainder
 
diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py
index d061315..7e322f1 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -346,7 +346,7 @@ class ProjectController(FeedController):
 
         if c.project.deleted:
             if c.user not in c.project.admins():
-                raise exc.HTTPNotFound, name
+                raise exc.HTTPNotFound(name)
         app = c.project.app_instance(name)
 
         if app:
@@ -360,7 +360,7 @@ class ProjectController(FeedController):
             c.project = subproject
             c.app = None
             return ProjectController(), remainder
-        raise exc.HTTPNotFound, name
+        raise exc.HTTPNotFound(name)
 
     @expose('jinja:allura:templates/members.html')
     @with_trailing_slash
diff --git a/Allura/allura/controllers/rest.py b/Allura/allura/controllers/rest.py
index f488595..4603878 100644
--- a/Allura/allura/controllers/rest.py
+++ b/Allura/allura/controllers/rest.py
@@ -112,7 +112,7 @@ class RestController(object):
             c.user = c.api_token.user
         neighborhood = M.Neighborhood.query.get(url_prefix='/' + name + '/')
         if not neighborhood:
-            raise exc.HTTPNotFound, name
+            raise exc.HTTPNotFound(name)
         return NeighborhoodRestController(neighborhood), remainder
 
 
@@ -345,9 +345,9 @@ def nbhd_lookup_first_path(nbhd, name, current_user, remainder, api=False):
             log.info('Configuring %s database for access to %r', pname, remainder)
             project.configure_project(is_user_project=True)
         else:
-            raise exc.HTTPNotFound, pname
+            raise exc.HTTPNotFound(pname)
     if project is None or (project.deleted and not has_access(project, 'update')()):
-        raise exc.HTTPNotFound, pname
+        raise exc.HTTPNotFound(pname)
     return project, remainder
 
 
@@ -384,10 +384,10 @@ class ProjectRestController(object):
             return ProjectRestController(), remainder
         app = c.project.app_instance(name)
         if app is None:
-            raise exc.HTTPNotFound, name
+            raise exc.HTTPNotFound(name)
         c.app = app
         if app.api_root is None:
-            raise exc.HTTPNotFound, name
+            raise exc.HTTPNotFound(name)
         return app.api_root, remainder
 
     @expose('json:')
diff --git a/Allura/allura/controllers/search.py b/Allura/allura/controllers/search.py
index 3e55708..cf6a6d9 100644
--- a/Allura/allura/controllers/search.py
+++ b/Allura/allura/controllers/search.py
@@ -68,7 +68,7 @@ class ProjectBrowseController(BaseController):
             self.category = M.ProjectCategory.query.find(
                 dict(name=category_name, parent_id=parent_id)).first()
             if not self.category:
-                raise exc.HTTPNotFound, request.path
+                raise exc.HTTPNotFound(request.path)
         else:
             self.category = None
 
diff --git a/Allura/allura/controllers/site_admin.py b/Allura/allura/controllers/site_admin.py
index 75922a4..f703a11 100644
--- a/Allura/allura/controllers/site_admin.py
+++ b/Allura/allura/controllers/site_admin.py
@@ -84,7 +84,7 @@ class SiteAdminController(object):
             controller = admin_extension().controllers.get(name)
             if controller:
                 return controller(), remainder
-        raise HTTPNotFound, name
+        raise HTTPNotFound(name)
 
     def sidebar_menu(self):
         base_url = '/nf/admin/'
diff --git a/Allura/allura/ext/admin/admin_main.py b/Allura/allura/ext/admin/admin_main.py
index a9fedc4..cd14c06 100644
--- a/Allura/allura/ext/admin/admin_main.py
+++ b/Allura/allura/ext/admin/admin_main.py
@@ -197,7 +197,7 @@ class AdminExtensionLookup(object):
             controller = admin_extension().project_admin_controllers.get(name)
             if controller:
                 return controller(), remainder
-        raise exc.HTTPNotFound, name
+        raise exc.HTTPNotFound(name)
 
 
 class ProjectAdminController(BaseController):
@@ -301,7 +301,7 @@ class ProjectAdminController(BaseController):
     def _lookup(self, name, *remainder):
         app = c.project.app_instance(name)
         if app is None:
-            raise exc.HTTPNotFound, name
+            raise exc.HTTPNotFound(name)
         return app.admin, remainder
 
     @without_trailing_slash
@@ -956,11 +956,11 @@ class ProjectAdminRestController(BaseController):
     @expose()
     def _lookup(self, *args):
         if len(args) == 0:
-            raise exc.HTTPNotFound, args
+            raise exc.HTTPNotFound(args)
         name, remainder = args[0], args[1:]
         app = c.project.app_instance(name)
         if app is None or app.admin_api_root is None:
-            raise exc.HTTPNotFound, name
+            raise exc.HTTPNotFound(name)
         return app.admin_api_root, remainder
 
 
diff --git a/Allura/allura/lib/base.py b/Allura/allura/lib/base.py
index de91eb1..dc430c3 100644
--- a/Allura/allura/lib/base.py
+++ b/Allura/allura/lib/base.py
@@ -37,7 +37,7 @@ class WsgiDispatchController(TGController):
 
     def _setup_request(self):
         '''Responsible for setting all the values we need to be set on tg.tmpl_context'''
-        raise NotImplementedError, '_setup_request'
+        raise NotImplementedError('_setup_request')
 
     def _perform_call(self, context):
         self._setup_request()
diff --git a/Allura/allura/lib/mail_util.py b/Allura/allura/lib/mail_util.py
index eb89c15..e686502 100644
--- a/Allura/allura/lib/mail_util.py
+++ b/Allura/allura/lib/mail_util.py
@@ -110,17 +110,17 @@ def parse_address(addr):
             domain = domain[:-len(suffix)]
             break
     else:
-        raise exc.AddressException, 'Unknown domain: ' + domain
+        raise exc.AddressException('Unknown domain: ' + domain)
     path = '/'.join(reversed(domain.split('.')))
     project, mount_point = h.find_project('/' + path)
     if project is None:
-        raise exc.AddressException, 'Unknown project: ' + domain
+        raise exc.AddressException('Unknown project: ' + domain)
     if len(mount_point) != 1:
-        raise exc.AddressException, 'Unknown tool: ' + domain
+        raise exc.AddressException('Unknown tool: ' + domain)
     with h.push_config(c, project=project):
         app = project.app_instance(mount_point[0])
         if not app:
-            raise exc.AddressException, 'Unknown tool: ' + domain
+            raise exc.AddressException('Unknown tool: ' + domain)
     return userpart, project, app
 
 
diff --git a/Allura/allura/lib/repository.py b/Allura/allura/lib/repository.py
index 2ad3a5a..af88d9b 100644
--- a/Allura/allura/lib/repository.py
+++ b/Allura/allura/lib/repository.py
@@ -351,4 +351,4 @@ class RestWebhooksLookup(BaseController):
         for hook in self.app._webhooks:
             if hook.type == name and hook.api_controller:
                 return hook.api_controller(hook, self.app), remainder
-        raise exc.HTTPNotFound, name
+        raise exc.HTTPNotFound(name)
diff --git a/Allura/allura/model/project.py b/Allura/allura/model/project.py
index 4bd97ad..23fc27b 100644
--- a/Allura/allura/model/project.py
+++ b/Allura/allura/model/project.py
@@ -877,7 +877,7 @@ class Project(SearchIndexable, MappedClass, ActivityNode, ActivityObject):
             provider.shortname_validator.to_python(
                 name, check_allowed=False, neighborhood=self.neighborhood)
         except exceptions.Invalid:
-            raise exceptions.ToolError, 'Mount point "%s" is invalid' % name
+            raise exceptions.ToolError('Mount point "%s" is invalid' % name)
         return provider.register_subproject(self, name, user or c.user, install_apps, project_name=project_name)
 
     def ordered_mounts(self, include_hidden=False):
diff --git a/ForgeTracker/forgetracker/model/ticket.py b/ForgeTracker/forgetracker/model/ticket.py
index 17e890e..99061c3 100644
--- a/ForgeTracker/forgetracker/model/ticket.py
+++ b/ForgeTracker/forgetracker/model/ticket.py
@@ -829,11 +829,11 @@ class Ticket(VersionedArtifact, ActivityObject, VotableArtifact):
                 fld = f
                 break
         if not fld:
-            raise KeyError, 'Custom field "%s" does not exist.' % custom_user_field_name
+            raise KeyError('Custom field "%s" does not exist.' % custom_user_field_name)
         if fld.type != 'user':
-            raise TypeError, 'Custom field "%s" is of type "%s"; expected ' \
+            raise TypeError('Custom field "%s" is of type "%s"; expected ' \
                              'type "user".' % (
-                                 custom_user_field_name, fld.type)
+                                 custom_user_field_name, fld.type))
         username = self.custom_fields.get(custom_user_field_name)
         if not username:
             return None
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index c39b54f..2873051 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -1379,7 +1379,7 @@ class TicketController(BaseController, FeedController):
                         subscribed=subscribed, voting_enabled=voting_enabled,
                         page=page, limit=limit, count=post_count)
         else:
-            raise exc.HTTPNotFound, 'Ticket #%s does not exist.' % self.ticket_num
+            raise exc.HTTPNotFound('Ticket #%s does not exist.' % self.ticket_num)
 
     def get_feed(self, project, app, user):
         """Return a :class:`allura.controllers.feed.FeedArgs` object describing