Utility classes and functions.
>>> 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'
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.
Return the relative path from path1 equivalent to path2.
>>> 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'
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
Return the full path of the program (cnd) or None.
>>> which('ls')
'/bin/ls'