PyFoam.Basics.Utilities module¶
Utility functions
Can be used via a class or as functions
-
class
PyFoam.Basics.Utilities.Utilities[source]¶ Bases:
objectClass with utility methods
Can be inherited without side effects by classes that need these methods
-
__dict__= mappingproxy({'humanReadableSize': <function Utilities.humanReadableSize>, '__module__': 'PyFoam.Basics.Utilities', 'copyfile': <function Utilities.copyfile>, '__doc__': 'Class with utility methods\n\n Can be inherited without side effects by classes that need these\n methods', 'diskUsage': <function Utilities.diskUsage>, 'execute': <function Utilities.execute>, 'which': <function Utilities.which>, 'listDirectory': <function Utilities.listDirectory>, 'find': <function Utilities.find>, '__dict__': <attribute '__dict__' of 'Utilities' objects>, 'remove': <function Utilities.remove>, '__init__': <function Utilities.__init__>, '__weakref__': <attribute '__weakref__' of 'Utilities' objects>, 'rmtree': <function Utilities.rmtree>, 'copytree': <function Utilities.copytree>, 'writeDictionaryHeader': <function Utilities.writeDictionaryHeader>, 'excludeNames': ['^.svn$', '~$']})¶
-
__module__= 'PyFoam.Basics.Utilities'¶
-
__weakref__¶ list of weak references to the object (if defined)
-
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, 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?
-
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, 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.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