Skip to content

Commit

Permalink
buidl adaptation
Browse files Browse the repository at this point in the history
  • Loading branch information
thingsplode committed Mar 16, 2020
1 parent 1a2f58e commit 0c3775d
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[flake8]
ignore=E501,F401,E401,E127,E721,F405
ignore=E501,F401,E401,E127,E721,F405, W504, W503
exclude = .git,__pycache__,docs/*,venv*,.pytest_cache,appkernel.egg-info,keys
36 changes: 18 additions & 18 deletions appkernel/reflection.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def is_object(obj):
>>> is_object(lambda x: 1)
False
"""
return (isinstance(obj, object) and
not isinstance(obj, (type, types.FunctionType)))
return (isinstance(obj, object)
and not isinstance(obj, (type, types.FunctionType)))


def is_primitive(obj):
Expand Down Expand Up @@ -152,8 +152,8 @@ def is_dictionary_subclass(obj):
>>> is_dictionary_subclass(Temp())
True
"""
return (hasattr(obj, '__class__') and
issubclass(obj.__class__, dict) and not is_dictionary(obj))
return (hasattr(obj, '__class__')
and issubclass(obj.__class__, dict) and not is_dictionary(obj))


def is_sequence_subclass(obj):
Expand All @@ -164,10 +164,10 @@ def is_sequence_subclass(obj):
>>> is_sequence_subclass(Temp())
True
"""
return (hasattr(obj, '__class__') and
(issubclass(obj.__class__, SEQUENCES) or
is_list_like(obj)) and
not is_sequence(obj))
return (hasattr(obj, '__class__')
and (issubclass(obj.__class__, SEQUENCES)
or is_list_like(obj))
and not is_sequence(obj))


def is_list_like(obj):
Expand Down Expand Up @@ -206,11 +206,11 @@ def is_function(obj):
return False
module = translate_module_name(obj.__class__.__module__)
name = obj.__class__.__name__
return (module == '__builtin__' and
name in ('function',
'builtin_function_or_method',
'instancemethod',
'method-wrapper'))
return (module == '__builtin__'
and name in ('function',
'builtin_function_or_method',
'instancemethod',
'method-wrapper'))


def is_module_function(obj):
Expand All @@ -222,11 +222,11 @@ def is_module_function(obj):
False
"""

return (hasattr(obj, '__class__') and
isinstance(obj, types.FunctionType) and
hasattr(obj, '__module__') and
hasattr(obj, '__name__') and
obj.__name__ != '<lambda>')
return (hasattr(obj, '__class__')
and isinstance(obj, types.FunctionType)
and hasattr(obj, '__module__')
and hasattr(obj, '__name__')
and obj.__name__ != '<lambda>')


def is_module(obj):
Expand Down
48 changes: 24 additions & 24 deletions appkernel/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,26 +103,26 @@ def find(self):
Creates a cursor based on the filter and sorting criteria and yields the results;
:return: a generator object which yields found instances of Model class
"""
raise NotImplemented('abstract method')
raise NotImplementedError('abstract method')

def find_one(self):
"""
:return: One or none instances of the Model, depending on the query criteria
"""
raise NotImplemented('abstract method')
raise NotImplementedError('abstract method')

def count(self):
"""
:return: the number of items in the repository matching the filter expression;
"""
raise NotImplemented('abstract method')
raise NotImplementedError('abstract method')

def delete(self):
"""
Delete all elements which fulfill the filter criteria (defined in the where method);
:return: the deleted item count
"""
raise NotImplemented('abstract method')
raise NotImplementedError('abstract method')

def get(self, page=0, page_size=100):
"""
Expand All @@ -131,7 +131,7 @@ def get(self, page=0, page_size=100):
:param page_size: the size of the page (number of elements requested
:return: the result of the query as a list of Model instance objects
"""
raise NotImplemented('abstract method')
raise NotImplementedError('abstract method')


def mongo_type_converter_to_dict(value: any) -> any:
Expand Down Expand Up @@ -235,7 +235,7 @@ def find_by_id(cls, object_id):
:param object_id: the database id
:return:
"""
raise NotImplemented('abstract method')
raise NotImplementedError('abstract method')

@classmethod
def delete_by_id(cls, object_id):
Expand All @@ -244,7 +244,7 @@ def delete_by_id(cls, object_id):
:param object_id: the unique object ID
:return:
"""
raise NotImplemented('abstract method')
raise NotImplementedError('abstract method')

@classmethod
def create_object(cls, document):
Expand All @@ -253,7 +253,7 @@ def create_object(cls, document):
:param document:
:return:
"""
raise NotImplemented('abstract method')
raise NotImplementedError('abstract method')

@classmethod
def replace_object(cls, object_id, document):
Expand All @@ -263,15 +263,15 @@ def replace_object(cls, object_id, document):
:param document:
:return:
"""
raise NotImplemented('abstract method')
raise NotImplementedError('abstract method')

@classmethod
def patch_object(cls, document, object_id=None):
raise NotImplemented('abstract method')
raise NotImplementedError('abstract method')

@classmethod
def save_object(cls, document, object_id=None):
raise NotImplemented('abstract method')
raise NotImplementedError('abstract method')

@classmethod
def find(cls, *expressions):
Expand All @@ -281,7 +281,7 @@ def find(cls, *expressions):
:type expressions: Expression
:return: a Model Generator
"""
raise NotImplemented('abstract method')
raise NotImplementedError('abstract method')

@classmethod
def find_one(cls, *expressions):
Expand All @@ -292,7 +292,7 @@ def find_one(cls, *expressions):
:return: one Model object
:rtype: Model
"""
raise NotImplemented('abstract method')
raise NotImplementedError('abstract method')

@classmethod
def where(cls, *expressions):
Expand All @@ -302,7 +302,7 @@ def where(cls, *expressions):
:return: a query object preconfigured with the
:rtype: Query
"""
raise NotImplemented('abstract method')
raise NotImplementedError('abstract method')

@classmethod
def find_by_query(cls, query={}, page=1, page_size=50, sort_by=None, sort_order=SortOrder.ASC):
Expand All @@ -318,11 +318,11 @@ def find_by_query(cls, query={}, page=1, page_size=50, sort_by=None, sort_order=
:param sort_order:
:return:
"""
raise NotImplemented('abstract method')
raise NotImplementedError('abstract method')

@classmethod
def create_cursor_by_query(cls, query):
raise NotImplemented('abstract method')
raise NotImplementedError('abstract method')

@classmethod
def update_many(cls, match_query_dict, update_expression_dict):
Expand All @@ -332,7 +332,7 @@ def update_many(cls, match_query_dict, update_expression_dict):
:param update_expression_dict:
:return:
"""
raise NotImplemented('abstract method')
raise NotImplementedError('abstract method')

@classmethod
def delete_many(cls, match_query_dict):
Expand All @@ -341,15 +341,15 @@ def delete_many(cls, match_query_dict):
:param match_query_dict:
:return:
"""
raise NotImplemented('abstract method')
raise NotImplementedError('abstract method')

@classmethod
def delete_all(cls):
"""
:return:
"""
raise NotImplemented('abstract method')
raise NotImplementedError('abstract method')

@classmethod
def count(cls, query_filter={}):
Expand All @@ -359,21 +359,21 @@ def count(cls, query_filter={}):
:type query_filter: dict
:return:
"""
raise NotImplemented('abstract method')
raise NotImplementedError('abstract method')

def save(self):
"""
Saves or updates a model instance in the database
:return: the id of the inserted or updated document
"""
raise NotImplemented('abstract method')
raise NotImplementedError('abstract method')

def delete(self):
"""
Delete the current instance.
:raises RepositoryException: in case the instance was not deleted.
"""
raise NotImplemented('abstract method')
raise NotImplementedError('abstract method')


class MongoRepository(Repository):
Expand Down Expand Up @@ -411,7 +411,8 @@ def add_schema_validation(cls, validation_action='warn'):
MongoRepository.version_check(tuple([3, 6, 0]))
try:
config.mongo_database.create_collection(xtract(cls))
except CollectionInvalid as cix:
except CollectionInvalid:
# schema not found
pass

config.mongo_database.command(
Expand All @@ -424,7 +425,6 @@ def add_schema_validation(cls, validation_action='warn'):
@staticmethod
def create_index(collection, field_name, sort_order, unique=False):
# type: (pymongo.collection.Collection, str, SortOrder, bool) -> ()

"""
Args:
collection(pymongo.collection.Collection): the collection to which the index is applied to
Expand Down

0 comments on commit 0c3775d

Please sign in to comment.