archivant package¶
-
class
archivant.
Archivant
(conf={})[source]¶ Implementation of a Data Access Layer
Archivant handles both an fsdb instance and a libreantdb one and exposes an high-level API to operate on ‘volumes’.
A ‘volume’ represents a physical/digital object stored within archivant. Volumes are structured as described in
normalize_volume()
; shortly, they have language, metadata and attachments. An attachment is an URL plus some metadata.If you won’t configure the FSDB_PATH parameter, fsdb will not be initialized and archivant will start in metadata-only mode. In metdata-only mode all file related functions will raise FileOpNotSupported.
-
static
denormalize_attachment
(attachment)[source]¶ convert attachment metadata from archivant to es format
-
insert_volume
(metadata, attachments=[])[source]¶ Insert a new volume
Returns the ID of the added volume
metadata must be a dict containg metadata of the volume:
{ "_language" : "it", # language of the metadata "key1" : "value1", # attribute "key2" : "value2", ... "keyN" : "valueN" } The only required key is `_language`
attachments must be an array of dict:
{ "file" : "/prova/una/path/a/caso" # path or fp "name" : "nome_buffo.ext" # name of the file (extension included) [optional if a path was given] "mime" : "application/json" # mime type of the file [optional] "notes" : "this file is awesome" # notes that will be attached to this file [optional] }
-
static
normalize_attachment
(attachment)[source]¶ Convert attachment metadata from es to archivant format
This function makes side effect on input attachment
-
static
normalize_volume
(volume)[source]¶ convert volume metadata from es to archivant format
This function makes side effect on input volume
output example:
{ 'id': 'AU0paPZOMZchuDv1iDv8', 'type': 'volume', 'metadata': {'_language': 'en', 'key1': 'value1', 'key2': 'value2', 'key3': 'value3'}, 'attachments': [{'id': 'a910e1kjdo2d192d1dko1p2kd1209d', 'type' : 'attachment', 'url': 'fsdb:///624bffa8a6f90813b7982d0e5b4c1475ebec40e3', 'metadata': {'download_count': 0, 'mime': 'application/json', 'name': 'tmp9fyat_', 'notes': 'this file is awsome', 'sha1': '624bffa8a6f90813b7982d0e5b4c1475ebec40e3', 'size': 10} }] }
-
shrink_local_fsdb
(dangling=True, corrupted=True, dryrun=False)[source]¶ shrink local fsdb by removing dangling and/or corrupted files
return number of deleted files
-
static
Submodules¶
-
class
archivant.archivant.
Archivant
(conf={})[source]¶ Implementation of a Data Access Layer
Archivant handles both an fsdb instance and a libreantdb one and exposes an high-level API to operate on ‘volumes’.
A ‘volume’ represents a physical/digital object stored within archivant. Volumes are structured as described in
normalize_volume()
; shortly, they have language, metadata and attachments. An attachment is an URL plus some metadata.If you won’t configure the FSDB_PATH parameter, fsdb will not be initialized and archivant will start in metadata-only mode. In metdata-only mode all file related functions will raise FileOpNotSupported.
-
static
denormalize_attachment
(attachment)[source]¶ convert attachment metadata from archivant to es format
-
insert_volume
(metadata, attachments=[])[source]¶ Insert a new volume
Returns the ID of the added volume
metadata must be a dict containg metadata of the volume:
{ "_language" : "it", # language of the metadata "key1" : "value1", # attribute "key2" : "value2", ... "keyN" : "valueN" } The only required key is `_language`
attachments must be an array of dict:
{ "file" : "/prova/una/path/a/caso" # path or fp "name" : "nome_buffo.ext" # name of the file (extension included) [optional if a path was given] "mime" : "application/json" # mime type of the file [optional] "notes" : "this file is awesome" # notes that will be attached to this file [optional] }
-
static
normalize_attachment
(attachment)[source]¶ Convert attachment metadata from es to archivant format
This function makes side effect on input attachment
-
static
normalize_volume
(volume)[source]¶ convert volume metadata from es to archivant format
This function makes side effect on input volume
output example:
{ 'id': 'AU0paPZOMZchuDv1iDv8', 'type': 'volume', 'metadata': {'_language': 'en', 'key1': 'value1', 'key2': 'value2', 'key3': 'value3'}, 'attachments': [{'id': 'a910e1kjdo2d192d1dko1p2kd1209d', 'type' : 'attachment', 'url': 'fsdb:///624bffa8a6f90813b7982d0e5b4c1475ebec40e3', 'metadata': {'download_count': 0, 'mime': 'application/json', 'name': 'tmp9fyat_', 'notes': 'this file is awsome', 'sha1': '624bffa8a6f90813b7982d0e5b4c1475ebec40e3', 'size': 10} }] }
-
shrink_local_fsdb
(dangling=True, corrupted=True, dryrun=False)[source]¶ shrink local fsdb by removing dangling and/or corrupted files
return number of deleted files
-
static