gwsumm.utils module¶
Utilities for GWSumm
- gwsumm.utils.get_default_ifo(fqdn='build-24123547-project-416166-gwsumm')[source]¶
Find the default interferometer prefix (IFO) for the given host
- Parameters:
- fqdnstr
the fully-qualified domain name (FQDN) of the host on which you wish to find the default IFO
- Returns:
- IFOstr
the upper-case X1-style prefix for the default IFO, if found, e.g. L1
- Raises:
- ValueError
if not default interferometer prefix can be parsed
- gwsumm.utils.nat_sorted(iterable, key=None)[source]¶
Sorted a list in the way that humans expect.
- Parameters:
- iterableiterable
iterable to sort
- keycallable
sorting key
- Returns:
- lsortedlist
sorted() version of input
l
- gwsumm.utils.safe_eval(val, strict=False, globals_=None, locals_=None)[source]¶
Evaluate the given string as a line of python, if possible
If the :meth:`eval` fails, a str is returned instead, unless strict=True is given.
- Parameters:
- valstr
input text to evaluate
- strictbool, optional, default: False
raise an exception when the eval call fails (True) otherwise return the input as a str (False, default)
- globals_dict, optional
dict of global variables to pass to eval, defaults to current globals
- locals_dict, optional
dict of local variables to pass to eval, defaults to current locals
Note
Note the trailing underscore on the globals_ and locals_ kwargs, this is required to not clash with the builtin globals and locals methods`.
- Raises:
- ValueError
if the input string is considered unsafe to evaluate, normally meaning it contains something that might interact with the filesystem (e.g. os.path calls)
- NameError
- SyntaxError
if the input cannot be evaluated, and strict=True is given
See also
- :obj:`eval`
for more documentation on the underlying evaluation method
- gwsumm.utils.vprint(message, verbose=True, stream=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='utf-8'>, profile=True)[source]¶
Prints the given message to the stream.
- Parameters:
- messagestr
string to print
- verbosebool, optional, default: True
flag to print or not, default: print
- streamfile, optional, default: stdout
file object stream in which to print, default: stdout
- profilebool, optional, default: True
flag to print timestamp for debugging and profiling purposes