angelos.document.utils

Helper utilities for documents.

class angelos.document.utils.Definitions

Bases: object

Definitions of document types.

CACHED_MSG = 700
CLASS = {0: <class 'NoneType'>, 1: ('angelos.document.entities', 'PrivateKeys'), 10: ('angelos.document.entities', 'Keys'), 20: ('angelos.document.entities', 'Person'), 21: ('angelos.document.entities', 'Ministry'), 22: ('angelos.document.entities', 'Church'), 30: ('angelos.document.profile', 'PersonProfile'), 31: ('angelos.document.profile', 'MinistryProfile'), 32: ('angelos.document.profile', 'ChurchProfile'), 40: ('angelos.document.domain', 'Domain'), 41: ('angelos.document.domain', 'Node'), 42: ('angelos.document.domain', 'Network'), 50: ('angelos.document.statements', 'Verified'), 51: ('angelos.document.statements', 'Trusted'), 52: ('angelos.document.statements', 'Revoked'), 60: ('angelos.document.envelope', 'Envelope'), 70: ('angelos.document.messages', 'Note'), 71: ('angelos.document.messages', 'Instant'), 72: ('angelos.document.messages', 'Mail'), 73: ('angelos.document.messages', 'Share'), 74: ('angelos.document.messages', 'Report'), 700: ('angelos.document.misc', 'StoredLetter')}
COM_ENVELOPE = 60
COM_INSTANT = 71
COM_MAIL = 72
COM_NOTE = 70
COM_REPORT = 74
COM_SHARE = 73
ENTITY_CHURCH = 22
ENTITY_MINISTRY = 21
ENTITY_PERSON = 20
EXTENSION = {0: None, 1: '.pky', 10: '.key', 20: '.ent', 21: '.ent', 22: '.ent', 30: '.pfl', 31: '.pfl', 32: '.pfl', 40: '.dmn', 41: '.nod', 42: '.net', 50: '.ver', 51: '.rst', 52: '.rev', 60: '.env', 70: '.msg', 71: '.msg', 72: '.msg', 73: '.msg', 74: '.msg', 700: '.cmsg'}
KEYS = 10
KEYS_PRIVATE = 1
NET_DOMAIN = 40
NET_NETWORK = 42
NET_NODE = 41
NONE = 0
PROF_CHURCH = 32
PROF_MINISTRY = 31
PROF_PERSON = 30
STAT_REVOKED = 52
STAT_TRUSTED = 51
STAT_VERIFIED = 50
classmethod klass(doc_type: int) → DocumentMeta

Get class for document type.

class angelos.document.utils.Helper

Bases: object

Document helper utility.

EXCLUDE = ('signature',)
EXCLUDE_UPDATE = ('updated', 'expires')
classmethod deserialize(data: bytes) → Document

Build document from stream of bytes.

classmethod excludes(document: Document) → Tuple[str]

Fields that can be excluded from flattening.

classmethod extension(doc_type: int) → unicode

Get file extension for document type.

classmethod flatten_dictionary(data_dict: dict) → bytes

Flatten dictionaries that may have dictionaries, lists, bytes and None.

classmethod flatten_document(document: Document, exclude: tuple = ()) → bytes

Flatten the data of a Document in a standardized way to a byte string.

Parameters
  • document (Document) – The document to be flattened.

  • exclude (tuple) – List of fieldnames to exclude from flattening.

Returns (bytes):

The flattened document as bytes.

classmethod flatten_list(data_list: list) → bytes

Flatten list of items that may be dictionaries, bytes and None.

classmethod meta(document: Document, issuer_as_owner: bool = False) → Tuple[datetime.datetime, datetime.datetime, uuid.UUID, uuid.UUID]

Calculates the correct meta information about a document to be updated

Parameters

document (Document) – Enter a valid Document.

Returns (datetime.datetime, datetime.datetime, uuid.UUID):

Correct meta-data (created datetime, touched datetime, owner).

classmethod serialize(document: Document) → bytes

“Serialize document into streams of bytes.