From 39ad7f2981714bba1f04c43a18b6e17b8cabf917 Mon Sep 17 00:00:00 2001 From: Jari Voutilainen Date: Mon, 9 Mar 2015 13:44:14 +0200 Subject: [PATCH] flake8 --- .../ckanext/ytp/comments/controller.py | 10 +------- .../ytp/comments/logic/action/__init__.py | 11 +++++---- .../ytp/comments/logic/action/delete.py | 1 - .../ckanext/ytp/comments/logic/action/get.py | 3 --- .../ytp/comments/logic/action/update.py | 1 - .../ytp/comments/logic/auth/__init__.py | 11 +++++---- .../ckanext/ytp/comments/model.py | 2 +- .../ckanext/ytp/comments/plugin.py | 24 ++++++++++--------- .../ckanext/ytp/user/controller.py | 3 ++- 9 files changed, 31 insertions(+), 35 deletions(-) diff --git a/modules/ckanext-ytp-comments/ckanext/ytp/comments/controller.py b/modules/ckanext-ytp-comments/ckanext/ytp/comments/controller.py index ff070d55c1..f2f9ab69e0 100644 --- a/modules/ckanext-ytp-comments/ckanext/ytp/comments/controller.py +++ b/modules/ckanext-ytp-comments/ckanext/ytp/comments/controller.py @@ -29,7 +29,6 @@ def edit(self, dataset_id, comment_id): except: abort(403) - errors = {} if request.method == 'POST': data_dict = clean_dict(unflatten( tuplize_dict(parse_params(request.POST)))) @@ -39,7 +38,6 @@ def edit(self, dataset_id, comment_id): res = get_action('comment_update')(context, data_dict) success = True except ValidationError, ve: - errors = ve.error_dict log.debug(ve) except Exception, e: log.debug(e) @@ -48,7 +46,6 @@ def edit(self, dataset_id, comment_id): if success: h.redirect_to(str('/dataset/%s#comment_%s' % (c.pkg.name, res['id']))) - vars = {'errors': errors} return render("package/read.html") def reply(self, dataset_id, parent_id): @@ -81,7 +78,6 @@ def _add_or_reply(self, dataset_id): except: abort(403) - errors = {} if request.method == 'POST': data_dict = clean_dict(unflatten( tuplize_dict(parse_params(request.POST)))) @@ -92,7 +88,6 @@ def _add_or_reply(self, dataset_id): res = get_action('comment_create')(context, data_dict) success = True except ValidationError, ve: - errors = ve.error_dict log.debug(ve) except Exception, e: log.debug(e) @@ -101,7 +96,6 @@ def _add_or_reply(self, dataset_id): if success: h.redirect_to(str('/dataset/%s#comment_%s' % (c.pkg.name, res['id']))) - vars = {'errors': errors} return render("package/read.html") def delete(self, dataset_id, comment_id): @@ -119,14 +113,12 @@ def delete(self, dataset_id, comment_id): except: abort(403) - errors = {} try: data_dict = {'id': comment_id} - res = get_action('comment_delete')(context, data_dict) + get_action('comment_delete')(context, data_dict) except Exception, e: log.debug(e) h.redirect_to(str('/dataset/%s' % c.pkg.name)) - vars = {'errors': errors} return render("package/read.html") diff --git a/modules/ckanext-ytp-comments/ckanext/ytp/comments/logic/action/__init__.py b/modules/ckanext-ytp-comments/ckanext/ytp/comments/logic/action/__init__.py index e9a4732eab..2e2033b3c0 100644 --- a/modules/ckanext-ytp-comments/ckanext/ytp/comments/logic/action/__init__.py +++ b/modules/ckanext-ytp-comments/ckanext/ytp/comments/logic/action/__init__.py @@ -1,4 +1,7 @@ -import create -import get -import update -import delete +# this is a namespace package +try: + import pkg_resources + pkg_resources.declare_namespace(__name__) +except ImportError: + import pkgutil + __path__ = pkgutil.extend_path(__path__, __name__) diff --git a/modules/ckanext-ytp-comments/ckanext/ytp/comments/logic/action/delete.py b/modules/ckanext-ytp-comments/ckanext/ytp/comments/logic/action/delete.py index 01afd8a7e0..e76870e01b 100644 --- a/modules/ckanext-ytp-comments/ckanext/ytp/comments/logic/action/delete.py +++ b/modules/ckanext-ytp-comments/ckanext/ytp/comments/logic/action/delete.py @@ -10,7 +10,6 @@ def comment_delete(context, data_dict): model = context['model'] - user = context['user'] logic.check_access("comment_delete", context, data_dict) diff --git a/modules/ckanext-ytp-comments/ckanext/ytp/comments/logic/action/get.py b/modules/ckanext-ytp-comments/ckanext/ytp/comments/logic/action/get.py index 54b9f01b4e..d3f8c4044a 100644 --- a/modules/ckanext-ytp-comments/ckanext/ytp/comments/logic/action/get.py +++ b/modules/ckanext-ytp-comments/ckanext/ytp/comments/logic/action/get.py @@ -17,7 +17,6 @@ def thread_show(context, data_dict): """ model = context['model'] - user = context['user'] url = data_dict.get('url') id = data_dict.get('id') @@ -73,8 +72,6 @@ def thread_show(context, data_dict): def comment_show(context, data_dict): - model = context['model'] - user = context['user'] id = logic.get_or_bust(data_dict, 'id') comment = comment_model.Comment.get(id) if not comment: diff --git a/modules/ckanext-ytp-comments/ckanext/ytp/comments/logic/action/update.py b/modules/ckanext-ytp-comments/ckanext/ytp/comments/logic/action/update.py index ec0bda190d..e9cfc358fc 100644 --- a/modules/ckanext-ytp-comments/ckanext/ytp/comments/logic/action/update.py +++ b/modules/ckanext-ytp-comments/ckanext/ytp/comments/logic/action/update.py @@ -10,7 +10,6 @@ def comment_update(context, data_dict): model = context['model'] - user = context['user'] logic.check_access("comment_update", context, data_dict) diff --git a/modules/ckanext-ytp-comments/ckanext/ytp/comments/logic/auth/__init__.py b/modules/ckanext-ytp-comments/ckanext/ytp/comments/logic/auth/__init__.py index 5c9bb2be5c..2e2033b3c0 100644 --- a/modules/ckanext-ytp-comments/ckanext/ytp/comments/logic/auth/__init__.py +++ b/modules/ckanext-ytp-comments/ckanext/ytp/comments/logic/auth/__init__.py @@ -1,4 +1,7 @@ -import create -import update -import get -import delete +# this is a namespace package +try: + import pkg_resources + pkg_resources.declare_namespace(__name__) +except ImportError: + import pkgutil + __path__ = pkgutil.extend_path(__path__, __name__) diff --git a/modules/ckanext-ytp-comments/ckanext/ytp/comments/model.py b/modules/ckanext-ytp-comments/ckanext/ytp/comments/model.py index c5f9a4c632..6a3494bef5 100644 --- a/modules/ckanext-ytp-comments/ckanext/ytp/comments/model.py +++ b/modules/ckanext-ytp-comments/ckanext/ytp/comments/model.py @@ -7,7 +7,7 @@ from sqlalchemy.ext.declarative import declarative_base from ckan.plugins import toolkit -from ckan.lib.base import * +from ckan.lib.base import model, config log = __import__('logging').getLogger(__name__) diff --git a/modules/ckanext-ytp-comments/ckanext/ytp/comments/plugin.py b/modules/ckanext-ytp-comments/ckanext/ytp/comments/plugin.py index 66b7857b1a..6449172472 100644 --- a/modules/ckanext-ytp-comments/ckanext/ytp/comments/plugin.py +++ b/modules/ckanext-ytp-comments/ckanext/ytp/comments/plugin.py @@ -30,22 +30,24 @@ def get_helpers(self): } def get_actions(self): - import ckanext.ytp.comments.logic.action as actions + from ckanext.ytp.comments.logic.action import get, create, delete, update + return { - "comment_create": actions.create.comment_create, - "thread_show": actions.get.thread_show, - "comment_update": actions.update.comment_update, - "comment_show": actions.get.comment_show, - "comment_delete": actions.delete.comment_delete + "comment_create": create.comment_create, + "thread_show": get.thread_show, + "comment_update": update.comment_update, + "comment_show": get.comment_show, + "comment_delete": delete.comment_delete } def get_auth_functions(self): - import ckanext.ytp.comments.logic.auth as auths + from ckanext.ytp.comments.logic.auth import get, create, delete, update + return { - 'comment_create': auths.create.comment_create, - 'comment_update': auths.update.comment_update, - 'comment_show': auths.get.comment_show, - 'comment_delete': auths.delete.comment_delete + 'comment_create': create.comment_create, + 'comment_update': update.comment_update, + 'comment_show': get.comment_show, + 'comment_delete': delete.comment_delete } # IPackageController diff --git a/modules/ckanext-ytp-main/ckanext/ytp/user/controller.py b/modules/ckanext-ytp-main/ckanext/ytp/user/controller.py index e828255fd7..1f6ed1a6c1 100644 --- a/modules/ckanext-ytp-main/ckanext/ytp/user/controller.py +++ b/modules/ckanext-ytp-main/ckanext/ytp/user/controller.py @@ -16,6 +16,7 @@ unflatten = dictization_functions.unflatten DataError = dictization_functions.DataError + class YtpUserController(UserController): # Modify original CKAN Edit user controller @@ -159,7 +160,7 @@ def _save_edit(self, id, context): if 'activity_streams_email_notifications' not in data_dict: data_dict['activity_streams_email_notifications'] = False - user = get_action('user_update')(context, data_dict) + get_action('user_update')(context, data_dict) h.flash_success(_('Profile updated')) h.redirect_to('home') except NotAuthorized: