mewlo.mpacks.core.helpers.misc module This module contains misclenaeous helper functions.

mewlo.mpacks.core.helpers.misc.append_text(mainstring, newstring, separator='; ')[source]

Add some text to a string which is accumulating it.


Convert to / and remove trailing /

mewlo.mpacks.core.helpers.misc.compare_versionstrings_isremotenewer(localversion, remoteversion)[source]

Return true if remote version is newer. We expect versions to be of format ##.##.## where ## can be 0 leading or not, and .05 is same a .5, we integerize the #s :return: tuple (isremotenewer, failure)

mewlo.mpacks.core.helpers.misc.convert_list_to_attribute_indexed_dict(objlist, attributename)[source]

Convert a list of objects to a dictionary indexed by


Convert a list of objects to a dictionary indexed by

mewlo.mpacks.core.helpers.misc.copy_tree_withcallback(src, dst, preserve_mode=1, preserve_times=1, preserve_symlinks=0, update=0, verbose=1, dry_run=0, callbackfp=None)[source]

Improved version of Python’s distutils.file_util.copy_tree With support for a callback evaluating files before operations.

Copy an entire directory tree ‘src’ to a new location ‘dst’.

Both ‘src’ and ‘dst’ must be directory names. If ‘src’ is not a directory, raise DistutilsFileError. If ‘dst’ does not exist, it is created with ‘mkpath()’. The end result of the copy is that every file in ‘src’ is copied to ‘dst’, and directories under ‘src’ are recursively copied to ‘dst’. Return the list of files that were copied or might have been copied, using their output name. The return value is unaffected by ‘update’ or ‘dry_run’: it is simply the list of all files under ‘src’, with the names changed to be under ‘dst’.

‘preserve_mode’ and ‘preserve_times’ are the same as for ‘copy_file’; note that they only apply to regular files, not to directories. If ‘preserve_symlinks’ is true, symlinks will be copied as symlinks (on platforms that support them!); otherwise (the default), the destination of the symlink will be copied. ‘update’ and ‘verbose’ are the same as for ‘copy_file’.

mewlo.mpacks.core.helpers.misc.does_dict_filter_match(object_features, feature_filter)[source]

Compare feature_filter against objectfeatures, return True if its a match.

mewlo.mpacks.core.helpers.misc.does_plaintext_rehash(plaintext, hashedchecktext)[source]

We want to see if the plaintext matches the hashedchecktext.


Given plaintext, create a random-salted hash suitable for db storage; the salted+hashed string includes an algorithmstring to let us change algorithms later.

mewlo.mpacks.core.helpers.misc.encode_hash_and_salt_withparams(plaintext, algorithmstring, salt)[source]

Given plaintext, create a salted hash suitable for db storage; the salted+hashed string includes an algorithmstring to let us change algorithms later.

mewlo.mpacks.core.helpers.misc.get_value_from_dict(thedict, keyname, defaultval=None)[source]

Very simple function to get value from dictionary or fall back to default value.


Return a nice string describing the datetime atime.


Parse the parameters in the hashstring which takes the form a={0}|s={1}|h={2}. Return dictionary of var=val.

mewlo.mpacks.core.helpers.misc.readfile_asjson(filepath, nicelabel)[source]

Read a file and return json dictionary :return: EFailure on error

mewlo.mpacks.core.helpers.misc.resolve_expand_string(patternstring, replacementdict, depthcount=0)[source]

Do recursive replacement in string with patterns.


Serialize an object (usually a list or dictionary), and if there are objects we can’t serialize, just serialize them as a string. That is, we don’t mind if objects in the list/dictionary can’t be unserialized as objects, we just care about top level separation.


Helper function for serialize_for_readability(obj) that converts items of a list/dictionary into simpler objects

mewlo.mpacks.core.helpers.misc.strvalnone(val, noneval='n/a')[source]

Return string cast of a value or a default value if None.

mewlo.mpacks.core.helpers.misc.unserialize_fromstorage(serializedtext, defaultval=None)[source]

Throw exception on error.

Table Of Contents

Previous topic

mewlo.mpacks.core.helpers.dictlist module

Next topic

mewlo.mpacks.core.helpers.serializabledbdict module

This Page