utils.utils
— Utilities¶
The utils.utils
module provides generic I/O utilities
.. versionadded:: 0.1.0
- plio.utils.utils.convert_string_to_float(s)[source]¶
Attempt to convert a string to a float.
- Parameters:
s (str) – The string to convert
- Returns:
If successful, the converted value, else the argument is passed back out.
- Return type:
float / str
- plio.utils.utils.create_dir(basedir='')[source]¶
Create a unique, temporary directory in /tmp where processing will occur
- Parameters:
basedir (str) – The PATH to create the temporary directory in.
- plio.utils.utils.delete_dir(dir)[source]¶
Delete a directory
- Parameters:
dir (str) – Remove a directory
- plio.utils.utils.file_search(searchdir, searchstring)[source]¶
Recursively search for files in the specified directory
- Parameters:
searchdir (str) – The directory to be searched
searchstring (str) – The string to be searched for
- Returns:
filelist – of files
- Return type:
list
- plio.utils.utils.find_in_dict(obj, key)[source]¶
Recursively find an entry in a dictionary
- Parameters:
obj (dict) – The dictionary to search
key (str) – The key to find in the dictionary
- Returns:
item – The value from the dictionary
- Return type:
obj
- plio.utils.utils.find_nested_in_dict(data, key_list)[source]¶
Traverse a list of keys into a dict.
- Parameters:
data (dict) – The dictionary to be traversed
key_list (list) – The list of keys to be travered. Keys are traversed in the order they are entered in the list
- Returns:
value – The value in the dict
- Return type:
object
- plio.utils.utils.is_number(s)[source]¶
Check if an argument is convertable to a number
- Parameters:
s (object) – The argument to check for conversion
- Returns:
True if conversion is possible, otherwise False.
- Return type:
bool