BDP — Basic data product base.

This module defines the Basic Data Product (BDP) base class.

class admit.bdp.BDP.BDP(xmlFile=None, **keyval)[source]

Basic Data Product base.

Basic Data Products (BDPs) are data containers used to transport information within ADMIT, as well as deliver it to users in a persistent, well-defined format.

Parameters:

xmlFile : str, optional

XML file associated with BDP (for persistence); defaults to None.

keyval : dict

Dictionary of keyword value pairs.

Attributes

gous (TBD) TBD
mous (TBD) TBD
sous (TBD) TBD (the official name is sous)
project (TBD) TBD
xmlFile (str) XML file associated with BDP (for persistence).
_baseDir (str) ADMIT project directory (None if unknown).
_date (TBD) Date of last edit.
_taskid (int) Originating ADMIT task ID number.
_type (admit.util.bdp_types) Concrete BDP type.
_updated (bool) Whether BDP has been modified since latest XML output.

Methods

baseDir([path]) Get/set project base directory.
delete([delfiles]) Method to delete the BDP.
get(key) Access an attribute.
getdir() Method to get the subdirectory(s) of the current BDP relative to the ADMIT working directory.
getfiles() Return the filename(s) associated with the basic data in a BDP.
haskey(key) Query if a key exists for an BDP.
isequal(bdp) Tests for equality with another BDP.
report() Report BDP properties in human readable format.
setkey([name, key]) Sets keyword value(s).
show() Show the xmlFile name.
update(new_state) Updates BDP state.
write([xmlFile]) Writes the BDP to an XML file.
baseDir(path=None)[source]

Get/set project base directory.

Parameters:

path : str, optional

New project base directory (ignored if None).

Returns:

Updated project base directory.

Notes

Unless empty, the base directory is guaranteed to end in os.sep.

delete(delfiles=True)[source]

Method to delete the BDP. This method will search through all class variables and delete any images since they contain external files, and then deletes the BDP’s XML file.

Parameters:

basedir : str, optional

XML file directory; defaults to current directory.

delfiles : bool, optional

Whether or not to delete the actual files on disk; defaults to True.

Notes

It is recommended that any BDP that stores images inside of lists, dictionaries, tuples, etc. override this method with a customized version.

get(key)[source]

Access an attribute.

Parameters:

key : str

Keyword name.

Returns:

varies

Attribute value if keyword is present, else None.

getdir()[source]

Method to get the subdirectory(s) of the current BDP relative to the ADMIT working directory.

Parameters:None
Returns:String containing the current BDPs subdirectory
getfiles()[source]

Return the filename(s) associated with the basic data in a BDP.

Parameters:None
Returns:List of files

Notes

Todo

Really should look for attribute .filename, but normally derived classes should implement these; see e.g. File_AT.

haskey(key)[source]

Query if a key exists for an BDP.

Parameters:

key : str

Keyword name.

Returns:

True if keyword is present, else False.

isequal(bdp)[source]

Tests for equality with another BDP.

Parameters:

bdp : BDP

The other BDP.

Returns:

True if the BDP types and contents match, else False.

report()[source]

Report BDP properties in human readable format.

Parameters:None
Returns:None
setkey(name='', key={})[source]

Sets keyword value(s).

Two styles are possible:

  1. name = {key:val} e.g. setkey({“a”:1})
  2. name = “key”, key = val e.g. setkey(“a”, 1)
Parameters:

name : dict or str, optional

Keyword/values pairs, or single keyword name; defaults to empty string.

key : str, optional

Keyword value; defaults to empty dictionary.

init : bool, optional

Whether keyword is being set for the first time.

show()[source]

Show the xmlFile name.

Parameters:None
Returns:the xml file name

Notes

Todo

Extend functionality to show more.

update(new_state)[source]

Updates BDP state.

Parameters:

new_state : varies

New BDP state.

Returns:

None

write(xmlFile=None)[source]

Writes the BDP to an XML file.

Parameters:

xmlFile : str, optional

Output XML file name; defaults to eponymous internal attribute.

Notes

Do not edit unless you know what you are doing as all BDP’s rely on this method to work properly. Normally the xmlFile here should be the full path.