This repository has been archived by the owner on Oct 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/referenced-attributes
- Loading branch information
Showing
11 changed files
with
198 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
"""Base classes for mapping and conversion.""" | ||
|
||
MESSAGE = "method must be implemented in subclasses" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
"""Base classes for containers.""" | ||
|
||
import abc | ||
|
||
from .. import common | ||
from . import MESSAGE | ||
from .convertible import Convertible | ||
from .mappable import Mappable | ||
|
||
|
||
log = common.logger(__name__) | ||
|
||
|
||
class Container(Convertible, Mappable): | ||
|
||
"""Base class for mutable types.""" | ||
|
||
@abc.abstractclassmethod | ||
def default(cls): | ||
"""Create an empty container.""" | ||
raise NotImplementedError(MESSAGE) | ||
|
||
@abc.abstractmethod | ||
def apply(self, data): # pylint: disable=E0213 | ||
"""Update the container's values with the loaded data.""" | ||
raise NotImplementedError(MESSAGE) | ||
|
||
def format(self): # pylint: disable=E0213 | ||
"""Convert the container's values to data optimized for dumping.""" | ||
return self.to_data(self) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
"""Base class for mapped objects.""" | ||
"""Base classes for mapping.""" | ||
|
||
import abc | ||
import functools | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.