commonutilslib package

Submodules

commonutilslib.commonutilslib module

Main code for commonutilslib.

class commonutilslib.commonutilslib.Hasher(buffer_size=65536)[source]

Bases: object

Calculated sha1 hashes for files and directories.

hash_directory(path)[source]

Calculates the sha1 hash of the directory in the provided path.

Parameters:path (str) – The path to calculate the digest for
Returns:The digest of the path
Return type:(str)
hash_file(file_name)[source]

Calculates the sha1 hash of the provided file.

Parameters:file_name (str) – The filename of the file to calculate the hash for
Returns:The hash of the file provided
Return type:(str)
class commonutilslib.commonutilslib.Pushd(directory_name)[source]

Bases: object

Implements bash pushd capabilities.

cwd = None
original_dir = None
class commonutilslib.commonutilslib.RecursiveDictionary[source]

Bases: dict

Implements recursively updating dictionary.

RecursiveDictionary provides the methods rec_update and iter_rec_update that can be used to update member dictionaries rather than overwriting them.

iter_rec_update(iterator)[source]

Updates recursively.

rec_update(other, **third)[source]

Implements the recursion.

Recursively update the dictionary with the contents of other and third like dict.update() does - but don’t overwrite sub-dictionaries.

commonutilslib.commonutilslib.cd(new_directory, clean_up=<function <lambda>>)[source]

Changes into a given directory and cleans up after it is done.

Parameters:
  • new_directory – The directory to change to
  • clean_up – A method to clean up the working directory once done
commonutilslib.commonutilslib.on_error(func, path, exc_info)[source]

Error handler for shutil.rmtree.

If the error is due to an access error (read only file) it attempts to add write permission and then retries.

If the error is for another reason it re-raises the error.

Usage : shutil.rmtree(path, onerror=onerror)

# 2007/11/08 # Version 0.2.6 # pathutils.py # Functions useful for working with files and paths. # http://www.voidspace.org.uk/python/recipebook.shtml#utils

# Copyright Michael Foord 2004 # Released subject to the BSD License # Please see http://www.voidspace.org.uk/python/license.shtml

# For information about bugfixes, updates and support, please join the Pythonutils mailing list. # http://groups.google.com/group/pythonutils/ # Comments, suggestions and bug reports welcome. # Scripts maintained at http://www.voidspace.org.uk/python/index.shtml # E-mail fuzzyman@voidspace.org.uk

commonutilslib.commonutilslib.tempdir()[source]

Creates a temporary directory.

commonutilslib.commonutilslibexceptions module

Custom exception code for commonutilslib.

Module contents

commonutilslib package.

Import all parts from commonutilslib here