utils¶
The guidata.utils
module provides various utility helper functions
(pure python).
-
guidata.utils.
min_equals_max
(min, max)[source]¶ Return True if minimium value equals maximum value Return False if not, or if maximum or minimum value is not defined
-
guidata.utils.
pairs
(iterable)[source]¶ A simple generator that takes a list and generates pairs [ (l[0],l[1]), …, (l[n-2], l[n-1])]
-
guidata.utils.
add_extension
(item, value)[source]¶ Add extension to filename item: data item representing a file path value: possible value for data item
-
guidata.utils.
bind
(fct, value)[source]¶ Returns a callable representing the function ‘fct’ with it’s first argument bound to the value
if g = bind(f,1) and f is a function of x,y,z then g(y,z) will return f(1,y,z)
-
guidata.utils.
trace
(fct)[source]¶ A decorator that traces function entry/exit used for debugging only
-
guidata.utils.
unicode_to_stdout
(ustr)[source]¶ convert a unicode string to a byte string encoded for stdout output
-
guidata.utils.
update_dataset
(dest, source, visible_only=False)[source]¶ Update dest dataset items from source dataset
- dest should inherit from DataSet, whereas source can be:
any Python object containing matching attribute names
or a dictionary with matching key names
For each DataSet item, the function will try to get the attribute of the same name from the source.
visible_only: if True, update only visible items
-
guidata.utils.
restore_dataset
(source, dest)[source]¶ Restore dest dataset items from source dataset
This function is almost the same as update_dataset but requires the source to be a DataSet instead of the destination.
Symetrically from update_dataset, dest may also be a dictionary.
-
guidata.utils.
assert_interface_supported
(klass, iface)[source]¶ Makes sure a class supports an interface
-
guidata.utils.
assert_interfaces_valid
(klass)[source]¶ Makes sure a class supports the interfaces it declares
-
class
guidata.utils.
FormatTime
(hours_fmt='%d H ', min_fmt='%d min ', sec_fmt='%d s')[source]¶ Helper object that substitute as a string to format seconds into (nn H mm min ss s)
-
guidata.utils.
tic
(cat)¶ Starting timer
-
guidata.utils.
toc
(cat, msg='delta:')¶ Stopping timer
-
guidata.utils.
is_program_installed
(basename)[source]¶ Return program absolute path if installed in PATH Otherwise, return None
-
guidata.utils.
run_program
(name, args='', cwd=None, shell=True, wait=False)[source]¶ Run program in a separate process
-
guidata.utils.
getcwd_or_home
()[source]¶ Safe version of getcwd that will fallback to home user dir.
This will catch the error raised when the current working directory was removed for an external program.