bestgui.utils

Utility classes and functions.

bestgui.utils.common_prefix(*sequences)
Return the list of common elements at the start of all sequences, than a list of lists that are the unique tails of each sequence.
bestgui.utils.fix_browser_cmd(browsercmd)
Manages the browser command (browsercmd) in order to guarantee a correct initialization of the webbrowser.GenericBrowser.
bestgui.utils.fix_path(path1, path2, maxpardir=2)
>>> pathName = os.path.join('/a','b','c')
>>> filename = os.path.join('/a','b','d','e','filename.ext')
>>> fix_path(pathName, filename)
'../d/e/filename.ext'
>>> pathName = os.path.join('/a','b','c')
>>> filename = os.path.join('/c','d','e','filename.ext')
>>> fix_path(pathName, filename)
'/c/d/e/filename.ext'
>>> pathName = os.path.join('/a','b','c','d1','e1','f1')
>>> filename = os.path.join('/a','b','c','d2','e2','f2','filename.ext')
>>> fix_path(pathName, filename)
'/a/b/c/d2/e2/f2/filename.ext'
bestgui.utils.fromstring(str_)
Try to convert a string in None, True or False, else simply remove quotes
bestgui.utils.get_best_version(bestbin='best', env=None)
Returns the BEST version string if available or None.
bestgui.utils.get_cfgfile(filename)
Return the full pathname of the configuration file.
bestgui.utils.get_docfile(*args)

Return the full pathname of the docfile.

If more than one argument is passed then all the arguments are joined together with the base doc directory in order to form the full pathname.

bestgui.utils.get_gladefile(filename)
Return the full pathname of the gladefile.
bestgui.utils.get_hmifile(filename)
Return the full pathname of the HMI file.
bestgui.utils.get_iconfile(filename)
Return the full pathname of the icon.
bestgui.utils.get_user_cfgfile()
Return the user configuration file path.
bestgui.utils.isexecutable(cmd)
Check if “cmd” actually is an executable program.
bestgui.utils.relative_path(path1, path2, sep='/', pardir='..')

Return the relative path from path1 equivalent to path2.

In particular:
the empty string, if path1 == path1; path2 if path1 and path2 have no common prefix.
>>> pathName = os.path.join('/a','b','c')
>>> filename = os.path.join('/c','d','e','filename.ext')
>>> relative_path(pathName, filename)
'/c/d/e/filename.ext'
>>> pathName = os.path.join('/a','b','c','d1','e1','f1')
>>> filename = os.path.join('/a','b','c','d2','e2','f2','filename.ext')
>>> relative_path(pathName, filename)
'../../../d2/e2/f2/filename.ext'
bestgui.utils.remove_quote(str_)
Remove <”> or <’> characters from both ends of the input string.
bestgui.utils.safe_eval(source, globals_=None, locals_=None)

Evaluate the source in safe mode.

>>> print safe_eval("('a','b','c',)")
('a', 'b', 'c')
>>> print safe_eval("__import__('sys').exit(23)")
Traceback (most recent call last):
  File "a.py", line 9, in ?
    print safe_eval("__import__('sys').exit(23)")
  File "a.py", line 4, in safe_eval
    raise ValueError, "Names %s not allowed" % (c.co_names,)
ValueError: Names ('__import__', 'exit') not allowed
bestgui.utils.which(cmd, env=None)

Return the full path of the program (cnd) or None.

>>> which('ls')
'/bin/ls'

Get BESTGUI at SourceForge.net. Fast, secure and Free Open Source software downloads

Previous topic

bestgui.viewers

Next topic

bestgui.xopen

This Page