iblutil.io.params
Functions
Returns full path of the param file per system convention: |
|
Reads in and parse Json parameter file into dictionary. |
|
Set a given file or folder path to be hidden. |
|
Write a parameter file in Json format |
Classes
- getfile(str_params)[source]
- Returns full path of the param file per system convention:
linux/mac: ~/.str_params, Windows: APPDATA folder
- Parameters:
str_params – string that identifies parm file
- Returns:
string of full path
Set a given file or folder path to be hidden. On macOS and Windows a specific flag is set, while on other systems the file or folder is simply renamed to start with a dot. On macOS the folder may only be hidden in Explorer.
- Parameters:
path (str, pathlib.Path) – The path of the file or folder to (un)hide.
hide (bool) – If True the path is set to hidden, otherwise it is unhidden.
- Returns:
The path of the file or folder, which may have been renamed.
- Return type:
pathlib.Path
- read(str_params, default=None)[source]
Reads in and parse Json parameter file into dictionary. If the parameter file doesn’t exist and no defaults are provided, a FileNotFound error is raised, otherwise any extra default parameters will be written into the file.
Examples
# Load parameters, raise error if file not found par = read(‘globus/admin’)
# Load with defaults par = read(‘globus/admin’, {‘local_endpoint’: None, ‘remote_endpoint’: None})
# Return empty dict if file not found (i.e. touch new param file) par = read(‘new_pars’, {})
- Parameters:
str_params – path to text json file
default – default values for missing parameters
- Returns:
named tuple containing parameters