Skip to content

Commit

Permalink
Format code with Black
Browse files Browse the repository at this point in the history
  • Loading branch information
douglaslassance committed Dec 1, 2021
1 parent 730e621 commit 816609e
Show file tree
Hide file tree
Showing 20 changed files with 621 additions and 540 deletions.
9 changes: 5 additions & 4 deletions gitmodel/conf.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
DEFAULTS = {
'DEFAULT_SERIALIZER': 'gitmodel.serializers.json',
'LOCK_WAIT_TIMEOUT': 30, # in seconds
'LOCK_WAIT_INTERVAL': 1000, # in milliseconds
'DEFAULT_GIT_USER': ('gitmodel', 'gitmodel@local'),
"DEFAULT_SERIALIZER": "gitmodel.serializers.json",
"LOCK_WAIT_TIMEOUT": 30, # in seconds
"LOCK_WAIT_INTERVAL": 1000, # in milliseconds
"DEFAULT_GIT_USER": ("gitmodel", "gitmodel@local"),
}


Expand All @@ -24,4 +24,5 @@ def __getattr__(self, name):
def __setattr__(self, name, value):
self[name] = value


defaults = Config(DEFAULTS)
15 changes: 12 additions & 3 deletions gitmodel/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,44 @@
class GitModelError(Exception):
"""A base exception for other gitmodel-related errors."""

pass


class ConfigurationError(GitModelError):
"""Raised during configuration errors"""

pass


class UnsupportedFormat(GitModelError):
"""
Raised when an unsupported serialization format is requested.
"""

pass


class FieldError(GitModelError):
"""
Raised when there is a configuration error with a ``Field``.
"""

pass


class DoesNotExist(GitModelError):
"""
Raised when the object in question can't be found.
"""

pass


class RepositoryError(GitModelError):
"""
Raises during an error while operating with the repository
"""

pass


Expand All @@ -46,13 +52,14 @@ class ValidationError(GitModelError):
"""
Raised when an invalid value is encountered
"""

def __init__(self, msg_or_code, field=None, **kwargs):
self.field = field
self.msg_or_code = msg_or_code
if self.field:
msg = self.field.get_error_message(msg_or_code,
default=msg_or_code,
**kwargs)
msg = self.field.get_error_message(
msg_or_code, default=msg_or_code, **kwargs
)
else:
msg = msg_or_code
super(ValidationError, self).__init__(msg)
Expand All @@ -62,11 +69,13 @@ class IntegrityError(GitModelError):
"""
Raised when a save results in duplicate values
"""

pass


class ModelNotFound(Exception):
"""
Raised during deserialization if the model class no longer exists
"""

pass
Loading

0 comments on commit 816609e

Please sign in to comment.