HErmes.utils package

Submodules

HErmes.utils.files module

Locate files on the filesystem and group them together

HErmes.utils.files.DS_ID(filename)
HErmes.utils.files.ENDING(filename)
HErmes.utils.files.EXP_RUN_ID(filename)
HErmes.utils.files.GCD(filename)
HErmes.utils.files.SIM_RUN_ID(filename)
HErmes.utils.files.check_hdf_integrity(infiles, checkfor=None)[source]

Checks if hdfiles can be openend and returns a tuple integer_files,corrupt_files

Parameters:infiles (list) –
Keyword Arguments:
 checkfor (str) –
HErmes.utils.files.group_names_by_regex(names, regex=<function <lambda>>, firstpattern=<function <lambda>>, estimate_first=<function <lambda>>)[source]

Generate lists with files which all have the same name patterns, group by regex

Parameters:

names (list) – a list of file names

Keyword Arguments:
 
  • regex (func) – a regex to group by
  • firstpattern (func) – the leading element of each list
  • estimate_first (func) – if there are servaral elements which match firstpattern, estimate which is the first
Returns:

names grouped by reges with first pattern as leading element

Return type:

list

HErmes.utils.files.harvest_files(path, ending='.bz2', sanitizer=<function <lambda>>, use_ls=False, prefix='dcap://')[source]

Get all the files with a specific ending from a certain path

Parameters:

path (str) – a path on the filesystem to look for files

Keyword Arguments:
 
  • ending (str) – glob for files with this ending
  • sanitizer (func) – clean the file list with a filter
  • use_ls (bool) – use unix ls to compile the filelist
  • prefix (str) – apply this prefix to the file names
Returns:

All files in path which match ending and are filtered by sanitizer

Return type:

list

HErmes.utils.files.strip_all_endings(filename)[source]

Split a filename at the first dot and declare everything which comes after it and consists of 3 or 4 characters (including the dot) as “ending”

Parameters:filename (str) – a filename which shall be split
Returns:file basename + ending
Return type:list

HErmes.utils.itools module

Tools for managing iterables

HErmes.utils.itools.flatten(iterable_of_iterables)[source]

Concat an iterable of iterables in a single iterable, chaining its elements

Parameters:iterable_of_iterables (iterable) – Currently supported is dimensionality of 2
Returns:np.ndarray
HErmes.utils.itools.slicer(list_to_slice, slices)[source]

Generator Slice a list in individual slices

Parameters:
  • list_to_slice (list) – a list of items
  • slices (int) – how many lists will be sliced of
Returns:

slices of the given list

Return type:

list

HErmes.utils.logger module

A logger with customizable loglevel at runtime.

class HErmes.utils.logger.AbstractCustomLoggerType[source]

Bases: type

A modified logging.logger. Do not use directly, but as metaclass. Whenever the logger is called, HErmes.utils.logger.LOGLEVEL is queried to check for a change in the loglevel and a new logger instance is created accordingly. Python inspect is used to inspect the stack.

class HErmes.utils.logger.Logger[source]

Bases: object

A custom logger with loglevel changeable at runtime. To change the loglevel, set the HErmes.utils.logger.LOGLEVEL variable: 10 = DEBUG, 20 = INFO, 30 = WARNING

HErmes.utils.logger.alertstring(x)
HErmes.utils.logger.get_logger(loglevel)[source]

A logger from python logging on steroids.

Parameters:loglevel (int) – 10 = DEBUG, 20 = INFO, 30 = WARNING
Returns:logging.Logger

Module contents

Miscellaneous tools