brennivin.osutils module¶
Functionality that you wish was on os and os.path. And some that you don’t!
Members¶
- brennivin.osutils.abspathex(path, relative_to, _ignore_this=False)¶
Returns a normalized absoluted version of the pathname path, relative to relativeTo directory. relativeTo must be an actual directory.
Parameters: - path – The relative path to make absolute.
- relative_to – The filename to make path absolute to. This path will be made absolute before using it.
- _ignore_this – For internal use only.
NOTE: This actually works by changing the cwd temporarily, but will always set it back. That said, there could be some side effects so use with care.
- brennivin.osutils.change_cwd(*args, **kwds)¶
Context manager for temporarily changing the cwd.
Parameters: cwd – The directory to use as the cwd.
- brennivin.osutils.change_environ(*args, **kwds)¶
Context manager for temporarily changing an os.environ entry. A newvalue of None will delete the entry.
- brennivin.osutils.change_ext(path, ext)¶
Changes the extension of path to be ext. If path has no extension, ext will be appended.
Parameters: - path – The path.
- ext – The extension, should begin in a ‘.’.
- brennivin.osutils.copy(src, dst)¶
Copies src to dst, recursively making directories for dst if they do not exist.
src and dst should be filenames (not directories).
- brennivin.osutils.crc_from_filename(filename)¶
Returns the 32-bit crc for the file at filename.
- brennivin.osutils.iter_files(directory, pattern='*')¶
Returns a generator of files under directory that match pattern.
- brennivin.osutils.listdirex(path, pattern='*.*')¶
Return absolute filepaths in path that matches pattern.
- brennivin.osutils.makedirs(path, mode=511)¶
Like os.makedirs, but will not fail if directory exists.
- brennivin.osutils.mktemp(*args, **kwargs)¶
Returns an absolute temporary filename. A replacement for python’s deprecated mktemp. Will call mkstemp and close the resultant file.
Args are the same as tempfile.mkstemp
- brennivin.osutils.path_components(path)¶
Return list of a path’s components.
- brennivin.osutils.purename(filename)¶
Returns the basename of a path without the extension.
- brennivin.osutils.split3(path)¶
Returns a tuple of (dirname, filename without ext, ext).