PyFoam.Basics.Utilities module¶
Utility functions
Can be used via a class or as functions
-
class
PyFoam.Basics.Utilities.
Utilities
[source]¶ Bases:
object
Class with utility methods
Can be inherited without side effects by classes that need these methods
-
copyfile
(src, dst)[source]¶ Encapsulates the shutil copyfile and provides an alternative for old Python-version
-
copytree
(src, dst, symlinks=False, force=False)[source]¶ Encapsulates the shutil copytree and provides an alternative for old Python-version
-
excludeNames
= ['^.svn$', '~$']¶
-
execute
(cmd, debug=False, workdir=None, echo=None, outfile=None, getReturnCode=False)[source]¶ Execute the command cmd. If specified change the working directory
Currently no error-handling is done :return: A list with all the output-lines of the execution
-
find
(pattern, path, directoriesToo=True)[source]¶ Find all files whose names match :param pattern: glob-style pattern :param path: path under which this files are to be searched :param directoriesToo: also match directories?
-
findFileInDir
(dName, fName)[source]¶ Find file in a directory (search recursively) :param dName: name of the directory :param fName: name of the file to look force :return: the complete path. Directory and path joined if nothing is found
-
humanReadableDuration
(num)[source]¶ Creates a string that prints a duration in an easily readable form. Easily readable means that the two highest non-zero values will be printed
-
humanReadableSize
(num)[source]¶ Lifted from http://stackoverflow.com/questions/1094841/reusable-library-to-get-human-readable-version-of-file-size Gets a number in bytes and returns a human readable string
-
listDirectory
(d)[source]¶ Lists the files in a directory, but excludes certain names and files with certain endings :param d: The directory to list :return: List of the found files and directories
-
-
PyFoam.Basics.Utilities.
copyfile
(src, dest)[source]¶ Calls the method of the same name from the Utilites class
-
PyFoam.Basics.Utilities.
copytree
(src, dest, symlinks=False, force=False)[source]¶ Calls the method of the same name from the Utilites class
-
PyFoam.Basics.Utilities.
diskUsage
(fpath)[source]¶ Calls the method of the same name from the Utilites class
-
PyFoam.Basics.Utilities.
execute
(cmd, debug=False, workdir=None, echo=None, outfile=None, getReturnCode=False)[source]¶ Calls the method of the same name from the Utilites class
-
PyFoam.Basics.Utilities.
find
(pattern, path, directoriesToo=True)[source]¶ Calls the method of the same name from the Utilites class
-
PyFoam.Basics.Utilities.
findFileInDir
(d, f)[source]¶ Calls the method of the same name from the Utilites class
-
PyFoam.Basics.Utilities.
humanReadableDuration
(num)[source]¶ Calls the method of the same name from the Utilites class
-
PyFoam.Basics.Utilities.
humanReadableSize
(num)[source]¶ Calls the method of the same name from the Utilites class
-
PyFoam.Basics.Utilities.
listDirectory
(d)[source]¶ Calls the method of the same name from the Utilites class
-
PyFoam.Basics.Utilities.
remove
(f)[source]¶ Calls the method of the same name from the Utilites class
-
PyFoam.Basics.Utilities.
rmtree
(path, ignore_errors=False)[source]¶ Calls the method of the same name from the Utilites class