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

Module contents

Miscellaneous tools