A dictionary based backend for testing

class madas.backend.dictionary_backend.DictBackend(filename=None, filepath=None, make_dirs=True, key_name='mid', log=None)

Storage of materials data in a dictionary in memory.

Inteded use are development and testing, however, data can be stored by json.dump ing the dict.

property abs_path

Included for compatibility, returns None.

add_many(materials: List[Material]) None

Add data to the database.

add_single(material: Material) None

Add data to the database.

static from_json(json_data) object

Restore data from string. Inverse option to DictBackend().to_json().

get_by_id(db_id: int) Material

Return a single entry from an (integer valued) database id.

get_length() int

Return the length of the database, i.e. the total number of entries.

get_many(mids: List[str]) List[Material]

Get several entry from the database.

get_single(mid: str) Material

Get a single entry from the database.

has_entry(entry_id: str) bool

Check if an entry with the given id is present in the database.

to_json() str

json.dumps the content of the database.

update_many(mids: List[str], kwargs_list: List[dict] = [])

Update several entries in the database.

The properties attributes of entries mids will be updated with entries of kwargs_list.

update_metadata(**kwargs) None

Updata database metadata.

update_single(mid: str, **kwargs) None

Update a single entry in the database.

The properties attribute of entry mid will be updated with **kwargs.