Utility Functions
- hxrsnd.utils.absolute_submodule_path(submodule, cur_dir='/home/runner/work/hxrsnd/hxrsnd/hxrsnd/utils.py')[source]
Returns the absolute path of the inputted SnD submodule based on an inputted absolute path, or the absolute path of this file.
- Parameters:
- submodulestr or Path
Desired submodule path.
- cur_dirstr or Path, optional
Absolute path to use as a template for the full submodule path.
- Returns:
- full_pathstr
Full string path to the inputted submodule.
- hxrsnd.utils.as_list(obj, length=None, tp=None, iter_to_list=True)[source]
Force an argument to be a list, optionally of a given length, optionally with all elements cast to a given type if not None.
Parameters
- objObject
The obj we want to convert to a list.
- lengthint or None, optional
Length of new list. Applies if the inputted obj is not an iterable and iter_to_list is false.
- tptype, optional
Type to cast the values inside the list as.
- iter_to_listbool, optional
Determines if we should cast an iterable (not str) obj as a list or to enclose it in one.
- Returns:
- objlist
The object enclosed or cast as a list.
- hxrsnd.utils.isiterable(obj)[source]
Function that determines if an object is an iterable, not including str.
- Parameters:
- objobject
Object to test if it is an iterable.
- Returns:
- boolbool
True if the obj is an iterable, False if not.