fs module — py-utilities 0.0.1 documentation

# fs module

## file_utilities

`py_utilities.fs.file_utilities.` `concat`(file_paths, file)

  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>)

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

`py_utilities.fs.file_utilities.` `crc32`(file_path)

  Computes cyclic redundancy check checksum of the contents of file_path

`py_utilities.fs.file_utilities.` `file_ext`(file_path)

  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')

  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)

  Writes contents to file path

## fs_utilities

`py_utilities.fs.fs_utilities.` `mkdir_p`(path)

  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)

  Removes a file silently

`py_utilities.fs.fs_utilities.` `rm_rf`(path, ignore_errors=True)

  Recursive directory deletion function.

`py_utilities.fs.fs_utilities.` `touch`(path, times=None)

  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)

  Returns filename in path

`py_utilities.fs.path_utilities.` `get_first_dir_path`(dir_paths)

  Returns the first valid dir path in dir_paths

`py_utilities.fs.path_utilities.` `get_first_file_path`(file_paths)

  Returns the first valid file path in file_paths