bexchange.storage package

Submodules

bexchange.storage.storages module

class bexchange.storage.storages.file_storage(name, backend, **kwargs)[source]

Bases: storage

A basic file storage that allows separation of files based on object types. A typical structure passed to kwargs would be

“structure”: [
{ “object”:”SCAN”,

“path”:”/tmp/baltrad_bdb”, “name_pattern”:”${_baltrad/datetime_l:15:%Y/%m/%d/%H/%M}/${_bdb/source:NOD}_${/what/object}.tolower()_${/what/date}T${/what/time}Z_${/dataset1/where/elangle}.h5”

}, { “path”:”/tmp/baltrad_bdb”,

“name_pattern”:”${_baltrad/datetime_l:15:%Y/%m/%d/%H/%M}/${_bdb/source:NOD}_${/what/object}.tolower()_${/what/date}T${/what/time}Z.h5”

}]

get_attribute_value(name, meta)[source]
Parameters:
  • name – Name of attribute

  • meta – Metadata from where value for name should be taken

Returns:

the value for the name or None if not found

name()[source]

:return the name of this storage

store(path, meta)[source]

Stores a file in the correct directory structure :param path: The path to the file to be stored :param meta: The meta data for the file

class bexchange.storage.storages.file_store(path, name_pattern, naming_operations=[], simulate=False, keep_same_name=False)[source]

Bases: object

store(path, meta)[source]
class bexchange.storage.storages.none_storage(name, backend, **kwargs)[source]

Bases: storage

Simple storage that does nothing

name()[source]

:return the name identifying this storage

store(path, meta)[source]

Does nothing but prints that a file would have been stored :param path: The full path to the file to be stored :param meta: The meta data for this file.

class bexchange.storage.storages.simple_rotating_file_storage(name, backend, **kwargs)[source]

Bases: storage

A very simple rotating file storage that keeps a limited number of files in a single folder. The files will get two different names. Either: ${_baltrad/source_name}_scan_${/dataset1/where/elangle}_${/what/date}T${/what/time}.h5 - for scans ${_baltrad/source_name}_${/what/object}.tolower()_${/what/date}T${/what/time}.h5 - for any other file type NOTE! The number of files can be set to a maximum of 500

get_attribute_value(name, meta)[source]
Parameters:
  • name – Name of attribute

  • meta – Metadata from where value for name should be taken

Returns:

the value for the name or None if not found

name()[source]

:return the name of this storage

store(path, meta)[source]

Stores a file in the correct directory structure :param path: The path to the file to be stored :param meta: The meta data for the file

trim_folder(path)[source]
class bexchange.storage.storages.storage[source]

Bases: object

Base class for all storages

abstract name()[source]

:return the name identifying this storage

abstract store(path, meta)[source]

Passes on the file to the storage :param path: The full path to the file to be stored :param meta: The meta data for this file.

class bexchange.storage.storages.storage_manager[source]

Bases: object

The storage manager

add_storage(storage)[source]

Adds a storage instance to the internal list :param storage: The created storage that is a subclass of bexchange.storage.storages.storage

classmethod create_storage(clz, name, backend, extra_arguments)[source]

Creates an instance of clz with specified arguments :param clz: class name specified as <module>.<classname> :param arguments: a list of arguments that should be used to initialize the class

classmethod from_conf(config, backend)[source]

Creates a storage from the specified configuration if it is possible

Parameters:

config – A runner config pattern. Should at least contain the following

{ “class”:”<packagename>.<classname>”,

“name”:<name of storage>, “arguments”:{}”

}

get_storage(name)[source]
Parameters:

name – Name of the storage

Returns:

the storage with provided name

has_storage(name)[source]
Parameters:

name – Name of the storage

Returns:

if there is a storage with specified name

remove_storage(name)[source]
Parameters:

name – Name of the storage

store(name, path, meta)[source]

Stores a file in the specified storage. :param name: Name in which the file should be stored :param path: The file name that should be stored :param meta: Metadata about the file that should be stored

Module contents