ApdbMetadata#
- class lsst.dax.apdb.ApdbMetadata#
Bases:
ABCInterface for accessing APDB metadata.
Metadata is a collection of key/value items usually stored in a special table in the database. This abstract interface provides methods for accessing and modifying it.
Methods Summary
delete(key)Delete metadata record.
empty()Check whether attributes set is empty.
get(key[, default])Retrieve value of a given metadata record.
items()Iterate over records and yield their keys and values.
set(key, value, *[, force])Set value for a given metadata record.
Methods Documentation
- abstract delete(key: str) bool#
Delete metadata record.
Parameters#
- key
str Metadata key, arbitrary non-empty string.
Returns#
- existed
bool Trueis returned if attribute existed before it was deleted.
- key
- abstract empty() bool#
Check whether attributes set is empty.
Returns#
- empty
bool Trueif there are no any attributes defined.Trueis also returned if metadata table is missing.
- empty
- abstract get(key: str, default: str | None = None) str | None#
Retrieve value of a given metadata record.
Parameters#
- key
str Metadata key, arbitrary non-empty string.
- default
str, optional Default value returned when key does not exist, can be string or
None.
Returns#
- value
strorNone Metadata value, if key does not exist then
defaultis returned.
- key
- abstract items() Generator[tuple[str, str], None, None]#
Iterate over records and yield their keys and values.
Yields#
- key
str Metadata key.
- value
str Corresponding metadata value.
- key
- abstract set(key: str, value: str, *, force: bool = False) None#
Set value for a given metadata record.
Parameters#
- key
str Metadata key, arbitrary non-empty string.
- value
str New metadata value, an arbitrary string. Due to deficiencies of some database engines we are not allowing empty strings to be stored in the database, and
valuecannot be an empty string.- force
bool, optional Controls handling of existing metadata. With default
Falsevalue an exception is raised ifkeyalready exists, ifTrueis passed then value of the existing key will be updated.
Raises#
- KeyError
Raised if key already exists but
forceoption is false.- ValueError
Raised if key or value parameters are empty.
- key