Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
sfermigier committed May 30, 2018
1 parent 2fd4178 commit 944c298
Show file tree
Hide file tree
Showing 77 changed files with 100 additions and 62 deletions.
4 changes: 1 addition & 3 deletions abilian/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ def register_plugin(self, name):


class AssetManagerMixin(Flask):

def init_assets(self):
js_filters = ("closure_js",) if self.config.get("PRODUCTION", False) else None
# js_filters = None
Expand Down Expand Up @@ -290,7 +289,6 @@ def _register_base_assets(self):


class ErrorManagerMixin(Flask):

def setup_logging(self):
# Force flask to create application logger before logging
# configuration; else, flask will overwrite our settings
Expand Down Expand Up @@ -461,7 +459,6 @@ def handle_http_error(self, code, error):


class JinjaManagerMixin(Flask):

def __init__(self):
self._jinja_loaders = []

Expand Down Expand Up @@ -550,6 +547,7 @@ class Application(
Extend it in your own app.
"""

default_config = default_config

#: Custom apps may want to always load some plugins: list them here.
Expand Down
1 change: 1 addition & 0 deletions abilian/core/celery.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def read_configuration(self):

class FlaskTask(Task):
"""Base Task class for :FlaskCelery: based applications."""

abstract = True

def __call__(self, *args, **kwargs):
Expand Down
3 changes: 2 additions & 1 deletion abilian/core/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class _EntityInherit(object):
Entity meta-class takes care of inserting it in base classes.
"""

__indexable__ = True

@declared_attr
Expand All @@ -141,7 +142,6 @@ def __mapper_args__(cls):


class EntityQuery(db.Model.query_class):

def with_permission(self, permission, user=None):
from abilian.services import get_service

Expand Down Expand Up @@ -244,6 +244,7 @@ def __mapper_args__(cls):
args['order_by'] = cls.created_at # for example
return args
"""

# __metaclass__ = EntityMeta
__indexable__ = False
__indexation_args__ = {}
Expand Down
1 change: 1 addition & 0 deletions abilian/core/extensions/csrf.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class AbilianCsrf(object):
views supporting this must
"""

#: for views that gracefully support csrf errors, this message can be
#: displayed to user. It can be changed if you have a better one for your
#: users.
Expand Down
1 change: 0 additions & 1 deletion abilian/core/extensions/login.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class AnonymousUser(AnonymousUserMixin):

def has_role(self, role):
from abilian.services import get_service

Expand Down
2 changes: 2 additions & 0 deletions abilian/core/jinjaext.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

class DeferredJS(object):
"""Flask extension for use with DeferredJSExtension for jinja."""

name = "deferred_js"

def __init__(self, app=None):
Expand Down Expand Up @@ -45,6 +46,7 @@ class DeferredJSExtension(JinjaExtension):
The JS fragment can contains <script> tag so that your favorite
editor keeps doing proper indentation, syntax highlighting...
"""

tags = {"deferJS", "deferredJS"}

def parse(self, parser):
Expand Down
1 change: 0 additions & 1 deletion abilian/core/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@


class PatchLoggerAdapter(logging.LoggerAdapter):

def process(self, msg, kwargs):
if isinstance(msg, string_types):
return super(PatchLoggerAdapter, self).process(msg, kwargs)
Expand Down
1 change: 0 additions & 1 deletion abilian/core/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@

@python_2_unicode_compatible
class BaseMixin(IdMixin, TimestampedMixin, OwnedMixin):

@declared_attr
def __tablename__(cls):
return cls.__name__.lower()
Expand Down
1 change: 1 addition & 0 deletions abilian/core/models/attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def for_entity(obj, check_support_attachments=False):

class Attachment(Entity):
"""An Attachment owned by an :class:`Entity`."""

__auditable_entity__ = ("entity", "attachment", ("id", "name"))

@sa.ext.declarative.declared_attr
Expand Down
2 changes: 1 addition & 1 deletion abilian/core/models/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@


class Info(dict):

def __init__(self, **kw):
for k, v in kw.items():
self[k] = v
Expand Down Expand Up @@ -55,6 +54,7 @@ class IdMixin(object):

class Indexable(object):
"""Mixin with sensible defaults for indexable objects."""

__indexable__ = True
__indexation_args__ = {
"index_to": (
Expand Down
1 change: 1 addition & 0 deletions abilian/core/models/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def for_entity(obj, check_commentable=False):

class Comment(Entity):
"""A Comment related to an :class:`Entity`."""

__default_permissions__ = {WRITE: {Owner}, DELETE: {Owner}, CREATE: {Anonymous}}

@declared_attr
Expand Down
2 changes: 0 additions & 2 deletions abilian/core/models/subjects.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ def gen_random_password(length=15):

@add_metaclass(ABCMeta)
class PasswordStrategy(object):

@property
@abstractmethod
def name(self):
Expand Down Expand Up @@ -143,7 +142,6 @@ def process(self, user, password):


class UserQuery(db.Model.query_class):

def get_by_email(self, email):
return self.filter_by(email=email).one()

Expand Down
1 change: 1 addition & 0 deletions abilian/core/models/tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class Tag(IdMixin, Model):
They are namespaced, so that independent group of tags can be
defined in the application. The default namespace is `"default"`.
"""

__tablename__ = "tag"

#: namespace
Expand Down
1 change: 0 additions & 1 deletion abilian/core/models/tests/test_comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def test_commentable_interface():


def test_cannot_register_non_entities():

class Dummy(object):
pass

Expand Down
1 change: 1 addition & 0 deletions abilian/core/redis.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

class Extension(object):
"""Redis extension for flask."""

client = None

def __init__(self, app=None):
Expand Down
1 change: 0 additions & 1 deletion abilian/core/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


class Sentry(RavenExt):

def init_app(self, app, *args, **kwargs):
super(Sentry, self).init_app(app, *args, **kwargs)
user_logged_in.connect(self._on_user_logged_in, sender=app)
Expand Down
3 changes: 2 additions & 1 deletion abilian/core/singleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


class ValueSingletonMeta(type):

def __new__(cls, name, bases, dct):
dct["__instances__"] = {}
dct.setdefault("__slots__", ())
Expand All @@ -31,6 +30,7 @@ class UniqueName(with_metaclass(ValueSingletonMeta, object)):
A subclass of :class:`UniqueName` defines a namespace.
"""

# __metaclass__ = ValueSingletonMeta
__slots__ = ("_hash", "__name")
attr = "name"
Expand Down Expand Up @@ -68,6 +68,7 @@ class MySingleton(UniqueName):
class MySingletonType(UniqueNameType):
Type = MySingleton
"""

impl = String
Type = None
default_max_length = 100
Expand Down
4 changes: 4 additions & 0 deletions abilian/core/sqlalchemy.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ class JSON(sa.types.TypeDecorator):
Usage JSON() Takes same parameters as sqlalchemy.types.Text
"""

impl = sa.types.Text

def process_bind_param(self, value, dialect):
Expand Down Expand Up @@ -326,6 +327,7 @@ class UUID(sa.types.TypeDecorator):
From SQLAlchemy documentation.
"""

impl = sa.types.CHAR

def load_dialect_impl(self, dialect):
Expand Down Expand Up @@ -357,6 +359,7 @@ def compare_against_backend(self, dialect, conn_type):

class Locale(sa.types.TypeDecorator):
"""Store a :class:`babel.Locale` instance."""

impl = sa.types.UnicodeText

@property
Expand Down Expand Up @@ -388,6 +391,7 @@ def process_result_value(self, value, dialect):

class Timezone(sa.types.TypeDecorator):
"""Store a :class:`pytz.tzfile.DstTzInfo` instance."""

impl = sa.types.UnicodeText

@property
Expand Down
1 change: 0 additions & 1 deletion abilian/core/tests/test_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ def test_meta(session):


def test_entity_type():

class MyType(Entity):
pass

Expand Down
1 change: 0 additions & 1 deletion abilian/core/tests/test_permissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


def test_default_permissions(app, db, session):

class MyRestrictedType(Entity):
__default_permissions__ = {
security.READ: {security.Anonymous},
Expand Down
1 change: 0 additions & 1 deletion abilian/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ def __get__(self, obj, objtype):

# From http://flask.pocoo.org/snippets/44/
class Pagination(object):

def __init__(self, page, per_page, total_count):
self.page = page
self.per_page = per_page
Expand Down
2 changes: 2 additions & 0 deletions abilian/i18n.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ def timezones_choices():

class Babel(BabelBase):
"""Allow to load translations from other modules."""

_translations_paths = None

def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -349,6 +350,7 @@ def get_template_i18n(template_name, locale):

class ensure_request_context(object):
"""Context manager that ensures a request context is set up."""

_rq_ctx = None

def __enter__(self):
Expand Down
1 change: 1 addition & 0 deletions abilian/services/antivirus/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def _size_to_int(size_str):

class AntiVirusService(Service):
"""Antivirus service."""

name = "antivirus"

def scan(self, file_or_stream):
Expand Down
1 change: 1 addition & 0 deletions abilian/services/audit/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ def __bool__(self):

class AuditEntry(db.Model):
"""Logs modifications to auditable classes."""

id = Column(Integer, primary_key=True)
happened_at = Column(DateTime, default=datetime.utcnow, index=True)
type = Column(Integer) # CREATION / UPDATE / DELETION
Expand Down
1 change: 0 additions & 1 deletion abilian/services/auth/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@


class LoginSessionQuery(BaseQuery):

def get_active_for(self, user, user_agent=_MARK, ip_address=_MARK):
"""Return last known session for given user.
Expand Down
2 changes: 2 additions & 0 deletions abilian/services/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class ServiceNotRegistered(Exception):

class ServiceState(object):
"""Service state stored in Application.extensions."""

#: reference to :class:`Service` instance
service = None

Expand All @@ -30,6 +31,7 @@ def __init__(self, service, running=False):

class Service(object):
"""Base class for services."""

#: State class to use for this Service
AppStateClass = ServiceState

Expand Down
1 change: 0 additions & 1 deletion abilian/services/conversion/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def clear(self):


class Converter(object):

def __init__(self):
self.handlers = []
self.cache = Cache()
Expand Down
1 change: 1 addition & 0 deletions abilian/services/indexing/debug_toolbar.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class IndexedTermsDebugPanel(DebugPanel):
FIXME: this notion of "current" object should formalized in
abilian.app.Application
"""

name = "IndexedTerms"

@property
Expand Down
1 change: 1 addition & 0 deletions abilian/services/indexing/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def EdgeNgramField():

class _DefaultSearchSchema(SchemaClass):
"""General search schema."""

object_key = ID(stored=True, unique=True)
id = NUMERIC(numtype=int, bits=64, signed=False, stored=True)
object_type = ID(stored=True)
Expand Down
1 change: 1 addition & 0 deletions abilian/services/indexing/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def to_update(self, value):

class WhooshIndexService(Service):
"""Index documents using whoosh."""

name = "indexing"
AppStateClass = IndexServiceState

Expand Down
1 change: 1 addition & 0 deletions abilian/services/preferences/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

class UserPreference(db.Model):
"""An atom of user preference."""

__tablename__ = "user_preference"
__table_args__ = (UniqueConstraint("user_id", "key"),)

Expand Down
1 change: 1 addition & 0 deletions abilian/services/preferences/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def __init__(self, *args, **kwargs):
class PreferenceService(Service):
"""Flask extension for a user-level preference service, with pluggable
panels."""

name = "preferences"
AppStateClass = PreferenceState

Expand Down
1 change: 0 additions & 1 deletion abilian/services/preferences/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ def get(self):


class Application(BaseApplication):

def init_extensions(self):
super(Application, self).init_extensions()
prefs = self.services["preferences"]
Expand Down
Loading

0 comments on commit 944c298

Please sign in to comment.