Package henge Documentation

Class Henge

def __init__(self, database, schemas, henges=None, checksum_function=<function md5 at 0x7ffa8cf25c80>)

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

Parameters:

  • database (dict): Dict-like lookup database for sequences andhashes.
  • schemas (list): One or more jsonschema schemas describing thedata types stored by this Henge
  • 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)

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 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

Version Information: henge v0.0.3, generated by lucidoc v0.4.2