Add an abstract base class for documents

This commit is contained in:
Gergely Polonkai 2022-05-05 16:31:59 +02:00
parent 547c6b5205
commit 6bc7fc63b2
No known key found for this signature in database
GPG Key ID: 2D2885533B869ED4
2 changed files with 28 additions and 0 deletions

View File

@ -15,3 +15,4 @@ Usage example
__version__ = '0.1.0'
from .identity import Identity
from .document import Document

View 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.
"""