bexchange.naming package

Submodules

bexchange.naming.namer module

class bexchange.naming.namer.metadata_namer(tmpl)[source]

Bases: object

Creates names from metadata

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

  • meta – the meta data

Returns:

the value if possible

Throws LookupError:

if name not could be found

get_property(name)[source]

Returns the property with specified name. :param name: the name of the property :return the property if found, otherwise an empty string

get_source_item(key, source)[source]
name(meta)[source]
Parameters:

meta – the metadata to create the name from

Returns:

the created string

register_operation(tag, operation)[source]

Registers a namer operation :param tag: the identifier used in the name template :param operation: a metadata_namer_operation instance

set_properties(properties)[source]

Sets properties in the namer. Can either provide a property file name or else a dictionary. :param properties: Either a filename (string) to a property file or a dictionary with the properties

template()[source]
Returns:

the template string

class bexchange.naming.namer.metadata_namer_manager[source]

Bases: object

classmethod create_operation(clz, tag, backend, extra_arguments)[source]
classmethod from_conf(config, backend)[source]

Creates a naming operation from the specified configuration if it is possible

Parameters:

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

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

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

}

class bexchange.naming.namer.metadata_namer_operation(tag, backend, arguments={})[source]

Bases: object

Provides possibility to add custom namer operations

arguments()[source]
backend()[source]
create(placeholder, meta)[source]

Whenever a registered place holder is found, this method will be called with the current metadata. If it is possible to create the place holder string it is returned, otherwise the placeholder is returned. :param placeholder: the string that was found :param meta: the metadata :return: the string that the placeholder should be replaced with

tag()[source]
class bexchange.naming.namer.opera_filename_namer(tag, backend, arguments={})[source]

Bases: metadata_namer_operation

filename operation that implements support for the OPERA naming convention

create(placeholder, meta)[source]

Atempts to create a opera filename from the metadata. The created name will be in the format T_{T1}{T2}{A1}{A2}{ii}_C_{CCCC}_{yyyyMMddhhmmss}.h5 Where {T1}{T2} = PA {A1} G-Z depending on content of file {A2} A-Z depending on content of file {ii} the last 2 digits in the RAD identifier. {CCCC} - the CCCC {yyyyMMddhhmmss} - the date time from the file.

Parameters:
  • placeholder – the placeholder

  • meta – the metadata

:return the string to replace the placeholder with if possible

read_config(filename)[source]
class bexchange.naming.namer.property_metadata_namer(tmpl)[source]

Bases: metadata_namer

Creates names from metadata

name(meta)[source]
Parameters:

meta – the metadata to create the name from

Returns:

the created string

class bexchange.naming.namer.suboperation_helper(value, suboperations)[source]

Bases: object

Used to simplify suboperation execution in a name pattern. Each suboperation is implemented as a method in this function and called by eval upon execution

eval()[source]

Executes the suboperation(s) on the value in from left to right

interval_l(interval)[source]

Assumes that the 2 last characters in eval value is a integer, (00, 01, 10…). Then this value is modified to lower part of that interval. For example assuming that it is minutes that are evaluated and interval = 15 and limit = 60. Then the following modification will be performed. 00-14 => 00 15-29 => 15 30-44 => 30 45-59 => 45. :param interval: Interval

interval_u(interval, limit=60)[source]

Assumes that the 2 last characters in eval value is a integer, (00, 01, 10…). Then this value is modified to upper part of that interval. For example assuming that it is minutes that are evaluated and interval = 15 and limit = 60. Then the following modification will be performed. 00-14 => 15 15-29 => 30 30-44 => 45 45-59 => 00. Since limit is 60, the value will be put back to 0 :param interval: Interval :param limit: Limit for a wrap around

ltrim()[source]

Trims left side of the eval-value from whitespaces :return the trimmed string

replace(c1, c2)[source]

Replace one string with a different one :param c1: string to replace :param c2: string to replace with :return the string that has been modified

rtrim()[source]

Trims right side of the eval-value from whitespaces :return the trimmed string

substring(start, end=None)[source]

Returns a substring between start & end. :param start: The start position :param end: End position (if specified, otherwise rest of string) :return the substring

tolower(start=None, end=None)[source]

Changes to lower case between start and end position. If start and end is given, then a subset is changed. :param start: Start position :param end: End position :return new value

toupper(start=None, end=None)[source]

Changes to upper case between start and end position. If start and end is given, then a subset is changed. :param start: Start position :param end: End position :return new value

trim()[source]

Trims both ends of the eval-value from whitespaces :return the trimmed string

Module contents