abcd package¶
Submodules¶
abcd.authentication module¶
Classes related to facilitating authentication by the backend of some credentials gathered by the frontend.
-
class
abcd.authentication.
Credentials
(username=None)[source]¶ Bases:
object
-
username
¶ Get the username
Returns: The username
-
-
class
abcd.authentication.
UsernameAndPassword
(username, password)[source]¶ Bases:
abcd.authentication.Credentials
-
password
¶
-
abcd.backend module¶
The backend interface that must be implemented by any structure storage library that wants to be compliant with this framework.
In general implementations of this class should perform translation from to commands understood by the native storage format being used be it SQL, a filesystem, MongoDB or others.
-
class
abcd.backend.
Backend
[source]¶ Bases:
object
-
add_keys
(auth_token, filter, kvp)[source]¶ Adds key-value pairs to the selectd configurations
Parameters: - auth_token (AuthToken) – Authorisation token
- filter (dictionary?) – Filter (in MongoDB query language)
- kvp (dict) – Key-value pairs to be added
Return type:
-
authenticate
(credentials)[source]¶ Take a set of credentials and return an authorisation token or raise an exception
Parameters: credentials (Credentials) – The credentials, a subclass of :py:class:Credentials :return: :rtype: AuthToken
-
find
(auth_token, filter, sort, limit, keys, omit)[source]¶ Find entries that match the filter
Parameters: - auth_token (AuthToken) – Authorisation token
- filter (list of Conditions) – Filter
- sort (dict) – Dictionary where keys are columns byt which to sort end values are either abcd.Direction.ASCENDING or abcd.Direction.DESCENDING
- limit (int) – limit the number of returned entries
- keys (list) – keys to be returned. None for all.
- omit (bool) – if True, the keys parameter will be interpreted as the keys to omit (all keys except the ones specified will be returned).
Returns: Return type: Iterator to the Atoms object
-
insert
(auth_token, atoms)[source]¶ Take the Atoms object or an iterable to the Atoms and insert it to the database
Parameters: - auth_token (AuthToken) – Authorisation token
- atoms (Atoms or Atoms iterable) – Atoms to insert
Returns: Returns a result that holds a list of ids at which the objects were inserted and a message
Return type:
-
list
(auth_token)[source]¶ List all the databases the user has access to
Parameters: auth_token (AuthToken) – Authorisation token Return type: list
-
remove
(auth_token, filter, just_one)[source]¶ Remove entries from the databse that match the filter
Parameters: - auth_token (AuthToken) – Authorisation token
- filter (dictionary?) – Filter (in MongoDB query language)
- just_one (bool) – remove not more than one entry
Returns: Returns a result that holds the number of removed entries and a message
Return type:
-
remove_keys
(auth_token, filter, keys)[source]¶ Removes specified keys from selected configurations
Parameters: - auth_token (AuthToken) – Authorisation token
- filter (dictionary?) – Filter (in MongoDB query language)
- keys (dict) – Keys to be removed
Return type:
-
update
(auth_token, atoms, upsert, replace)[source]¶ Take the atoms object and find an entry in the database with the same unique id. If one exists, the old entry gets updated with the new entry.
Parameters: - auth_token (AuthToken) – Authorisation token
- atoms (Atoms or Atoms iterable) – Atoms to insert
- upsert (bool) – Insert configurations even if they don’t correspond to any existing ones
- replace (bool) – If a given configuration already exists, replace it
Returns: Return type:
-
-
exception
abcd.backend.
CommunicationError
(message)[source]¶ Bases:
exceptions.Exception
Error which is raised by the backend if communication with remote fails
-
abcd.backend.
Direction
¶ alias of
Enum
-
exception
abcd.backend.
ReadError
(message)[source]¶ Bases:
exceptions.Exception
Error which is raised by the backend if read fails
abcd.cli module¶
abcd.config module¶
config.py
Interact with configuration files and data files.
For testing, set XDG_CONFIG_HOME and XDG_DATA_HOME to avoid destroying existing files.
abcd.query module¶
abcd.results module¶
-
class
abcd.results.
AddKvpResult
(modified_ids, no_of_kvp_added, msg=None)[source]¶ Bases:
abcd.results.Result
-
modified_ids
¶
-
no_of_kvp_added
¶
-
-
class
abcd.results.
InsertResult
(inserted_ids, skipped_ids, msg=None)[source]¶ Bases:
abcd.results.Result
-
inserted_ids
¶
-
skipped_ids
¶
-
-
class
abcd.results.
RemoveKeysResult
(modified_ids, no_of_keys_removed, msg=None)[source]¶ Bases:
abcd.results.Result
-
modified_ids
¶
-
no_of_keys_removed
¶
-
-
class
abcd.results.
RemoveResult
(removed_count=1, msg=None)[source]¶ Bases:
abcd.results.Result
-
removed_count
¶ The number of entries removed :return: The number of entries removed
-
abcd.table module¶
-
abcd.table.
atoms_list2dict
(atoms_it)[source]¶ Converts an Atoms iterator into a plain, one-level-deep list of dicts
-
abcd.table.
print_keys_table
(atoms_list, border=True, truncate=True, show_keys=[], omit_keys=[])[source]¶ Prints two tables: Intersection table and Union table, and shows min and max values for each key
-
abcd.table.
print_kvps
(kvps)[source]¶ Takes a list of tuples, where each tuple is a key-value pair, and prints it.
abcd.util module¶
-
abcd.util.
atoms2dict
(atoms, plain_arrays=False)[source]¶ Converts the Atoms object to a dictionary. If plain_arrays is True, numpy arrays are converted to lists.
-
abcd.util.
dict2atoms
(d, plain_arrays=False)[source]¶ Converts a dictionary created with atoms2dict back to atoms.