blackfennec.document_system.mime_type package

Subpackages

Submodules

blackfennec.document_system.mime_type.mime_type module

class blackfennec.document_system.mime_type.mime_type.MimeType[source]

Bases: object

abstract export_structure(output: IO, structure: Structure)[source]

Export the structure to output IO

Raises

NotImplementedError – if subclass did not implement this method

abstract import_structure(data: IO) Structure[source]

Import the structure from IO data

Returns

Structure contained in raw data

Return type

Structure

Raises

NotImplementedError – if subclass did not implement this method

abstract property mime_type_id: str

Identification of mime type via ID

Returns

mime type ID

Return type

str

Raises

NotImplementedError – if subclass did not implement this property

static try_determine_mime_type(uri: str, resource_type: ResourceType) str[source]

Get mime_type through different approaches.

Tries guessing the mime_type from the URI ending, then by retrieving

the content-type of the URI if the UriType is HOST_URI.

Parameters
  • uri (str) – of which the mime_type should be searched

  • resource_type (ResourceType) – type of the passed uri

Returns

mime_type

Return type

str

Raises

ValueError – if no mime_type could have been guessed automatically.

blackfennec.document_system.mime_type.mime_type_registry module

class blackfennec.document_system.mime_type.mime_type_registry.MimeTypeRegistry[source]

Bases: object

MimeType Registry Class

Is a register of all registered mime_types.

_mime_types

stores internal mime_types

deregister_mime_type(mime_type_id)[source]
Function to deregister a mime_type from the registry if its class

matches the passed type

Parameters

mime_type_id (str) – key in the mime_type dict

property mime_types

mime_types getter

Returns

of mime_type

Return type

dict

register_mime_type(mime_type_id: str, mime_type: MimeType)[source]

Function to register a new mime_type

Parameters
  • mime_type_id (str) – Key at which the MimeType is to be inserted

  • mime_type (MimeType) – future element of the mime_type registry

Module contents