fs module

file_utilities

py_utilities.fs.file_utilities.concat(file_paths, file)[source]

Concatenates contents in file_paths list to a file-like object, file

py_utilities.fs.file_utilities.copy_file(file_path, file=<open file '<stdout>', mode 'w' at 0x103690150>)[source]

Copy contents at file_path to a file-like object, file

py_utilities.fs.file_utilities.crc32(file_path)[source]

Computes cyclic redundancy check checksum of the contents of file_path

py_utilities.fs.file_utilities.file_ext(file_path)[source]

Returns the file extension at file_path

>>> file_ext('/foo/bar/what/temp.txt')
'.txt'
>>> file_ext('/foo/bar/what/temp.jpg')
'.jpg'
>>> file_ext('/foo/bar/what/temp.tar.gz')
'.gz'
>>> file_ext('/foo/bar/what/temp')
''
>>> file_ext('')
''
py_utilities.fs.file_utilities.file_hexdigest(file_path, algo='md5')[source]

Returns the hexdigest hash of file_path using algo

>>> cwd = os.path.dirname(os.path.abspath(__file__))
>>> file_hexdigest(os.path.join(cwd, '__init__.py'), algo='md5')
'd41d8cd98f00b204e9800998ecf8427e'
py_utilities.fs.file_utilities.write_file(file_path, contents)[source]

Writes contents to file path

fs_utilities

py_utilities.fs.fs_utilities.mkdir_p(path)[source]

Recursive directory creation function. Mimics mkdir -p. Doesn’t raise an error if the leaf exists and is a directory.

Reference: http://stackoverflow.com/questions/600268/ mkdir-p-functionality-in-python/600612#600612

py_utilities.fs.fs_utilities.rm_if_exists(path)[source]

Removes a file silently

py_utilities.fs.fs_utilities.rm_rf(path, ignore_errors=True)[source]

Recursive directory deletion function.

py_utilities.fs.fs_utilities.touch(path, times=None)[source]

Touches a file. If times is None, then the file’s access and modified times are set to the current time.

path_utilities

py_utilities.fs.path_utilities.filename(path)[source]

Returns filename in path

py_utilities.fs.path_utilities.get_first_dir_path(dir_paths)[source]

Returns the first valid dir path in dir_paths

py_utilities.fs.path_utilities.get_first_file_path(file_paths)[source]

Returns the first valid file path in file_paths