Add an abstract base class for documents
This commit is contained in:
parent
547c6b5205
commit
6bc7fc63b2
@ -15,3 +15,4 @@ Usage example
|
|||||||
__version__ = '0.1.0'
|
__version__ = '0.1.0'
|
||||||
|
|
||||||
from .identity import Identity
|
from .identity import Identity
|
||||||
|
from .document import Document
|
||||||
|
27
earthsnake/document/__init__.py
Normal file
27
earthsnake/document/__init__.py
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
"""Document handling classes"""
|
||||||
|
|
||||||
|
from abc import ABC, abstractmethod
|
||||||
|
from datetime import datetime
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from ..identity import Identity
|
||||||
|
from ..path import Path
|
||||||
|
|
||||||
|
|
||||||
|
class Document(ABC): # pragma: no cover pylint: disable=too-few-public-methods
|
||||||
|
"""Abstract base class for documents"""
|
||||||
|
|
||||||
|
path: Path
|
||||||
|
|
||||||
|
author: Identity
|
||||||
|
|
||||||
|
timestamp: datetime
|
||||||
|
|
||||||
|
signature: str
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def sign(self, identity: Optional[Identity] = None) -> None:
|
||||||
|
"""Sign the document as identity
|
||||||
|
|
||||||
|
If ``identity`` is ``None``, use ``self.author`` instead.
|
||||||
|
"""
|
Loading…
Reference in New Issue
Block a user