twcommon provides a collection snippets, pieces of code, stuff found on the net I use all the time.. Will grow over time.
Currently it consists of:
Platform independant way to calculate free space.
It will check if there`s a filename by that name allready, and if so, return a new filename adding ~1 to the filename. For example if you want to write to /tmp/test.txt but that file allready exists, using CheckTargetFilename('/tmp/test.txt') will return /tmp/test~1.txt. If /tmp/test~1.txt allready exists the returned file will be /tmp/test~2.txt.
Converts bytes to nearest kilobyte, megabyte, gigabyte etc.
getWords(text, ignore_words = , minsize = 2)
Extracts words from a piece of text. It splits words based on spaces, change in char-case inside a text, numbers etc.
Generates a hexdigest version of a SHA-512 checksum based on a file.
Returns a dictionary of filedata.
dirwalk(dir, extensions_to_include = None)
Directory walk, yielding filenames found. Can filter based on extensions.