Package henge Documentation

Class Henge

def __init__(self, database, schemas, schemas_str=[], henges=None, checksum_function=<function md5 at 0x7f7051716f80>)

A user interface to insert and retrieve decomposable recursive unique identifiers (DRUIDs).

Parameters:

  • database (dict): Dict-like lookup database for sequences andhashes.
  • schemas (list): A list of file paths containing YAML jsonschema schemas describing thedata types stored by this Henge
  • schemas_str (list): A list of strings containing YAML jsonschema schemas directly
  • henges (dict): One or more henge objects indexed by object name forremote storing of items.
  • checksum_function (function(str) -> str): Default function tohandle the digest of the serialized items stored in this henge.
def clean(self)

Remove all items from this database.

def insert(self, item, item_type, reclimit=None)

Add structured items of a specified type to the database.

Parameters:

  • item (list): List of items to add.
  • item_type (str): A string specifying the type of item. Must matchsomething from Henge.list_item_types. You can use Henge.select_item_type to automatically choose this, if only one fits.
def item_types(self)

A list of item types handled by this Henge instance

def lookup(self, druid, item_type)
def retrieve(self, druid, reclimit=None, raw=False)

Retrieve an item given a digest

Parameters:

  • druid (str): The Decomposable recursive unique identifier (DRUID), ordigest that uniquely identifies that item to retrieve.
  • reclimit (int): Recursion limit. Set to None for no limit (default).
  • raw (bool): Return the value as a raw, henge-delimited string, insteadof processing into a mapping. Default: False.
def select_item_type(self, item)

Returns a list of all item types handled by this instance that validate with the given item.

Parameters:

  • item (dict): The item you wish to validate type of.
def show(self)

Show all items in the database.

Class NotFoundException

Raised when a digest is not found

def __init__(self, m)

Initialize self. See help(type(self)) for accurate signature.

def connect_mongo(host='0.0.0.0', port=27017, database='henge_dict', collection='store')

Connect to MongoDB and return the MongoDB-backed dict object

Firstly, the required libraries are imported.

Parameters:

  • host (str): DB address
  • port (int): port DB is listening on
  • database (str): DB name
  • collection (str): collection key

Returns:

  • mongodict.MongoDict: a dict backed by MongoDB, ready to use as aHenge backend
def split_schema(schema, name=None)

Splits a hierarchical schema into flat components suitable for a Henge

def canonical_str(item: dict) -> str

Convert a dict into a canonical string representation

Version Information: henge v0.2.1, generated by lucidoc v0.4.4