diff --git a/ckanext/subscribe/action.py b/ckanext/subscribe/action.py index e43d581..49ab282 100644 --- a/ckanext/subscribe/action.py +++ b/ckanext/subscribe/action.py @@ -1,20 +1,20 @@ # encoding: utf-8 -import logging import datetime +import logging import ckan.plugins as p -from ckan.logic import validate # put in toolkit? from ckan.lib.mailer import MailerException +from ckan.logic import validate # put in toolkit? -from ckanext.subscribe.model import Subscription, Frequency from ckanext.subscribe import ( - schema, dictization, - email_verification, email_auth, + email_verification, notification, + schema, ) +from ckanext.subscribe.model import Frequency, Subscription log = logging.getLogger(__name__) _check_access = p.toolkit.check_access diff --git a/ckanext/subscribe/auth.py b/ckanext/subscribe/auth.py index 3149ea7..afa6ef1 100644 --- a/ckanext/subscribe/auth.py +++ b/ckanext/subscribe/auth.py @@ -1,6 +1,6 @@ # encoding: utf-8 -from ckan.plugins.toolkit import _, check_access, auth_allow_anonymous_access +from ckan.plugins.toolkit import _, auth_allow_anonymous_access, check_access @auth_allow_anonymous_access diff --git a/ckanext/subscribe/cli.py b/ckanext/subscribe/cli.py index 6141949..85abe3a 100644 --- a/ckanext/subscribe/cli.py +++ b/ckanext/subscribe/cli.py @@ -1,5 +1,5 @@ -import sys import datetime +import sys import time import ckan.lib.cli as cli diff --git a/ckanext/subscribe/controller.py b/ckanext/subscribe/controller.py index fe70c02..49f4344 100644 --- a/ckanext/subscribe/controller.py +++ b/ckanext/subscribe/controller.py @@ -5,19 +5,19 @@ import ckan.lib.helpers as h from ckan import model from ckan.common import g +from ckan.lib.mailer import MailerException from ckan.plugins.toolkit import ( - ValidationError, + BaseController, ObjectNotFound, - get_action, + ValidationError, _, - request, - BaseController, abort, - render, - redirect_to, config, + get_action, + redirect_to, + render, + request, ) -from ckan.lib.mailer import MailerException from ckanext.subscribe import email_auth from ckanext.subscribe import model as subscribe_model diff --git a/ckanext/subscribe/dictization.py b/ckanext/subscribe/dictization.py index cdb6bfa..356f742 100644 --- a/ckanext/subscribe/dictization.py +++ b/ckanext/subscribe/dictization.py @@ -1,9 +1,9 @@ import uuid -from ckan.lib.dictization import table_dict_save, table_dictize from ckan import model +from ckan.lib.dictization import table_dict_save, table_dictize -from ckanext.subscribe.model import Subscription, Frequency +from ckanext.subscribe.model import Frequency, Subscription def subscription_save(subscription_dict, context): diff --git a/ckanext/subscribe/email_auth.py b/ckanext/subscribe/email_auth.py index 9cf8c3d..39e548d 100644 --- a/ckanext/subscribe/email_auth.py +++ b/ckanext/subscribe/email_auth.py @@ -21,10 +21,11 @@ import datetime import random import string -from six import text_type import ckan.plugins as p from ckan import model +from six import text_type + from ckanext.subscribe import mailer from ckanext.subscribe.interfaces import ISubscribe from ckanext.subscribe.model import LoginCode diff --git a/ckanext/subscribe/email_verification.py b/ckanext/subscribe/email_verification.py index 71da450..a79af31 100644 --- a/ckanext/subscribe/email_verification.py +++ b/ckanext/subscribe/email_verification.py @@ -3,10 +3,11 @@ import datetime import random import string -from six import text_type import ckan.plugins as p from ckan import model +from six import text_type + from ckanext.subscribe import mailer from ckanext.subscribe.interfaces import ISubscribe diff --git a/ckanext/subscribe/interfaces.py b/ckanext/subscribe/interfaces.py index 0f232a2..34a56ba 100644 --- a/ckanext/subscribe/interfaces.py +++ b/ckanext/subscribe/interfaces.py @@ -1,20 +1,20 @@ from ckan.plugins.interfaces import Interface -from ckanext.subscribe.utils import get_footer_contents as subscribe_get_footer_contents +from ckanext.subscribe.utils import filter_activities as subscribe_filter_activities from ckanext.subscribe.utils import get_email_vars as subscribe_get_email_vars +from ckanext.subscribe.utils import get_footer_contents as subscribe_get_footer_contents from ckanext.subscribe.utils import ( get_manage_email_contents as subscribe_get_manage_email_contents, ) from ckanext.subscribe.utils import ( - get_subscription_confirmation_email_contents as subscribe_get_subscription_confirmation_email_contents, + get_notification_email_contents as subscribe_get_notification_email_contents, ) from ckanext.subscribe.utils import ( - get_notification_email_contents as subscribe_get_notification_email_contents, + get_subscription_confirmation_email_contents as subscribe_get_subscription_confirmation_email_contents, ) from ckanext.subscribe.utils import ( get_verification_email_contents as subscribe_get_verification_email_contents, ) -from ckanext.subscribe.utils import filter_activities as subscribe_filter_activities class ISubscribe(Interface): diff --git a/ckanext/subscribe/mailer.py b/ckanext/subscribe/mailer.py index 1becc43..7dcb254 100644 --- a/ckanext/subscribe/mailer.py +++ b/ckanext/subscribe/mailer.py @@ -2,15 +2,13 @@ # For sending HTML emails. Based on core ckan's mailer -from time import time import smtplib import socket - - +from email import utils +from email.header import Header from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText -from email.header import Header -from email import utils +from time import time import ckan import ckan.plugins as p diff --git a/ckanext/subscribe/model.py b/ckanext/subscribe/model.py index 3353902..42d1995 100644 --- a/ckanext/subscribe/model.py +++ b/ckanext/subscribe/model.py @@ -1,13 +1,12 @@ -import logging import datetime +import logging from enum import Enum -from sqlalchemy import Table, Column, types - from ckan import model -from ckan.model.meta import metadata, mapper, Session -from ckan.model.types import make_uuid from ckan.model.domain_object import DomainObject +from ckan.model.meta import Session, mapper, metadata +from ckan.model.types import make_uuid +from sqlalchemy import Column, Table, types log = logging.getLogger(__name__) diff --git a/ckanext/subscribe/notification.py b/ckanext/subscribe/notification.py index b9f7caa..10cd3de 100644 --- a/ckanext/subscribe/notification.py +++ b/ckanext/subscribe/notification.py @@ -1,22 +1,16 @@ import datetime from collections import defaultdict -from ckan import model -from ckan.model import Package, Group, Member -from ckan.lib.dictization import model_dictize import ckan.plugins.toolkit as toolkit +from ckan import model from ckan import plugins as p +from ckan.lib.dictization import model_dictize from ckan.lib.email_notifications import string_to_timedelta +from ckan.model import Group, Member, Package +from ckanext.subscribe import dictization, email_auth, notification_email from ckanext.subscribe.interfaces import ISubscribe -from ckanext.subscribe import dictization -from ckanext.subscribe.model import ( - Subscription, - Subscribe, - Frequency, -) -from ckanext.subscribe import notification_email -from ckanext.subscribe import email_auth +from ckanext.subscribe.model import Frequency, Subscribe, Subscription log = __import__("logging").getLogger(__name__) diff --git a/ckanext/subscribe/notification_email.py b/ckanext/subscribe/notification_email.py index 9beeb06..632f9ae 100644 --- a/ckanext/subscribe/notification_email.py +++ b/ckanext/subscribe/notification_email.py @@ -1,7 +1,6 @@ -from webhelpers.html import HTML - -from ckan import plugins as p from ckan import model +from ckan import plugins as p +from webhelpers.html import HTML from ckanext.subscribe import mailer from ckanext.subscribe.interfaces import ISubscribe diff --git a/ckanext/subscribe/plugin.py b/ckanext/subscribe/plugin.py index 1d013f8..7bc718e 100644 --- a/ckanext/subscribe/plugin.py +++ b/ckanext/subscribe/plugin.py @@ -3,8 +3,7 @@ import ckan.plugins as plugins import ckan.plugins.toolkit as toolkit -from ckanext.subscribe import action -from ckanext.subscribe import auth +from ckanext.subscribe import action, auth from ckanext.subscribe import model as subscribe_model from ckanext.subscribe.interfaces import ISubscribe diff --git a/ckanext/subscribe/schema.py b/ckanext/subscribe/schema.py index 7cfc5b0..65cda5e 100644 --- a/ckanext/subscribe/schema.py +++ b/ckanext/subscribe/schema.py @@ -3,7 +3,7 @@ import ckan.plugins as p from ckan.common import _ -from ckanext.subscribe.model import Subscription, Frequency +from ckanext.subscribe.model import Frequency, Subscription get_validator = p.toolkit.get_validator Invalid = p.toolkit.Invalid diff --git a/ckanext/subscribe/tests/factories.py b/ckanext/subscribe/tests/factories.py index 1c844a2..985d082 100644 --- a/ckanext/subscribe/tests/factories.py +++ b/ckanext/subscribe/tests/factories.py @@ -2,13 +2,12 @@ import datetime -import factory - +import ckan.lib.dictization.model_dictize as model_dictize import ckan.plugins as p import ckan.tests.factories as ckan_factories +import factory from ckan import model from ckan.lib.dictization import table_dictize -import ckan.lib.dictization.model_dictize as model_dictize import ckanext.subscribe.model from ckanext.subscribe import dictization diff --git a/ckanext/subscribe/tests/test_action.py b/ckanext/subscribe/tests/test_action.py index 13b8127..985d108 100644 --- a/ckanext/subscribe/tests/test_action.py +++ b/ckanext/subscribe/tests/test_action.py @@ -3,19 +3,18 @@ import datetime import mock -from nose.tools import assert_equal as eq -from nose.tools import assert_raises, assert_in - -from ckan.tests import helpers, factories -from ckan.plugins.toolkit import ValidationError from ckan import model +from ckan.plugins.toolkit import ValidationError +from ckan.tests import factories, helpers +from nose.tools import assert_equal as eq +from nose.tools import assert_in, assert_raises +from ckanext.subscribe import model as subscribe_model from ckanext.subscribe.tests.factories import ( + DatasetActivity, Subscription, SubscriptionLowLevel, - DatasetActivity, ) -from ckanext.subscribe import model as subscribe_model class TestSubscribeSignup(object): diff --git a/ckanext/subscribe/tests/test_auth.py b/ckanext/subscribe/tests/test_auth.py index 0d167e9..198f4e8 100644 --- a/ckanext/subscribe/tests/test_auth.py +++ b/ckanext/subscribe/tests/test_auth.py @@ -1,11 +1,10 @@ # encoding: utf-8 -from nose.tools import assert_raises, assert_in - -import ckan.tests.helpers as helpers -import ckan.tests.factories as factories import ckan.logic as logic +import ckan.tests.factories as factories +import ckan.tests.helpers as helpers from ckan import model +from nose.tools import assert_in, assert_raises class TestSubscribeSignupToDataset(object): diff --git a/ckanext/subscribe/tests/test_controller.py b/ckanext/subscribe/tests/test_controller.py index ab147a6..ec2ed32 100644 --- a/ckanext/subscribe/tests/test_controller.py +++ b/ckanext/subscribe/tests/test_controller.py @@ -1,19 +1,15 @@ # encoding: utf-8 -import mock import datetime -from nose.tools import assert_equal, assert_in - -from ckan.tests.helpers import FunctionalTestBase, reset_db, submit_and_follow +import mock from ckan.tests.factories import Dataset, Group, Organization +from ckan.tests.helpers import FunctionalTestBase, reset_db, submit_and_follow +from nose.tools import assert_equal, assert_in -from ckanext.subscribe import model as subscribe_model -from ckanext.subscribe.tests.factories import ( - Subscription, - SubscriptionLowLevel, -) from ckanext.subscribe import email_auth +from ckanext.subscribe import model as subscribe_model +from ckanext.subscribe.tests.factories import Subscription, SubscriptionLowLevel eq = assert_equal diff --git a/ckanext/subscribe/tests/test_email_verification.py b/ckanext/subscribe/tests/test_email_verification.py index 3bea143..e18b02a 100644 --- a/ckanext/subscribe/tests/test_email_verification.py +++ b/ckanext/subscribe/tests/test_email_verification.py @@ -1,15 +1,12 @@ # encoding: utf-8 -from nose.tools import assert_equal - from ckan import plugins as p from ckan.tests import factories as ckan_factories from ckan.tests import helpers +from nose.tools import assert_equal from ckanext.subscribe import model as subscribe_model -from ckanext.subscribe.email_verification import ( - get_verification_email_vars, -) +from ckanext.subscribe.email_verification import get_verification_email_vars from ckanext.subscribe.tests import factories from ckanext.subscribe.utils import get_footer_contents, get_verification_email_contents diff --git a/ckanext/subscribe/tests/test_notification.py b/ckanext/subscribe/tests/test_notification.py index 8951f52..80e8f72 100644 --- a/ckanext/subscribe/tests/test_notification.py +++ b/ckanext/subscribe/tests/test_notification.py @@ -3,26 +3,25 @@ import datetime import mock -from nose.tools import assert_equal, assert_in - -from ckan.tests import helpers -from ckan.tests.factories import Dataset, Organization, Group from ckan import model +from ckan.tests import helpers +from ckan.tests.factories import Dataset, Group, Organization +from nose.tools import assert_equal, assert_in from ckanext.subscribe import model as subscribe_model +from ckanext.subscribe import notification as subscribe_notification from ckanext.subscribe.model import Frequency from ckanext.subscribe.notification import ( - send_any_immediate_notifications, + dictize_notifications, + get_daily_notifications, get_immediate_notifications, - send_weekly_notifications_if_its_time_to, get_weekly_notifications, + most_recent_weekly_notification_datetime, + send_any_immediate_notifications, send_daily_notifications_if_its_time_to, - get_daily_notifications, send_emails, - dictize_notifications, - most_recent_weekly_notification_datetime, + send_weekly_notifications_if_its_time_to, ) -from ckanext.subscribe import notification as subscribe_notification from ckanext.subscribe.tests import factories eq = assert_equal diff --git a/ckanext/subscribe/tests/test_notification_email.py b/ckanext/subscribe/tests/test_notification_email.py index 2aa15e4..f76f6b1 100644 --- a/ckanext/subscribe/tests/test_notification_email.py +++ b/ckanext/subscribe/tests/test_notification_email.py @@ -2,20 +2,19 @@ import datetime +import ckan.tests.factories as ckan_factories import mock +from ckan.tests import helpers from nose.tools import assert_equal, assert_in from webhelpers.html import literal -from ckan.tests import helpers -import ckan.tests.factories as ckan_factories - from ckanext.subscribe import model as subscribe_model from ckanext.subscribe.notification import dictize_notifications from ckanext.subscribe.notification_email import ( - send_notification_email, - get_notification_email_vars, - dataset_link_from_activity, dataset_href_from_activity, + dataset_link_from_activity, + get_notification_email_vars, + send_notification_email, ) from ckanext.subscribe.tests import factories from ckanext.subscribe.utils import get_notification_email_contents diff --git a/ckanext/subscribe/utils.py b/ckanext/subscribe/utils.py index aa04d8c..7922dc7 100644 --- a/ckanext/subscribe/utils.py +++ b/ckanext/subscribe/utils.py @@ -1,9 +1,8 @@ # encoding: utf-8 -from jinja2 import Template - import ckan.plugins as p from ckan import model from ckan.model import Activity +from jinja2 import Template config = p.toolkit.config diff --git a/setup.py b/setup.py index 56c5620..c0d8d4c 100644 --- a/setup.py +++ b/setup.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- -from setuptools import setup, find_packages # Always prefer setuptools over distutils from codecs import open # To use a consistent encoding from os import path +from setuptools import find_packages, setup # Always prefer setuptools over distutils + here = path.abspath(path.dirname(__file__)) # Get the long description from the relevant file