module documentation
(source)

Module with assorted useful classes and functions used in the zim code
Class classproperty Like property() but for klass properties Typically used as decorator
Class DefinitionOrderedDict Class that behaves like a dict but keeps items the order they were defined. Updating an items keeps it at the current position, removing and re-inserting an item puts it at the end of the sequence.
Class MovingWindowIter No summary
Function get_module Import a module
Function lookup_subclass Look for a subclass of klass in the module
Function lookup_subclasses Look for all subclasses of klass in the module
Function natural_sort No summary
Function natural_sort_key Format string such that it gives 'natural' sorting on string compare. Will pad any numbers in the string with "0" such that "10" sorts after "9". Also includes locale.strxfrm().
Function natural_sorted No summary
Variable _num_re Undocumented
def get_module(name): (source)
Import a module
Parameters
namethe module name
Returns
module object
Raises
ImportErrorif the given name does not exist
def lookup_subclass(module, klass): (source)

Look for a subclass of klass in the module

This function is used in several places in zim to get extension classes. Typically get_module() is used first to get the module object, then this lookup function is used to locate a class that derives of a base class (e.g. PluginClass).

Parameters
modulemodule object
klassbase class
Note
don't actually use this method to get plugin classes, see PluginManager.get_plugin_class() instead.
def lookup_subclasses(module, klass): (source)
Look for all subclasses of klass in the module
Parameters
modulemodule object
klassbase class
def natural_sort(list, key=None): (source)
Natural sort a list in place. See natural_sort_key for details.
Parameters
listlist of strings to be sorted
keyfunction producing strings for list items
def natural_sort_key(string, numeric_padding=5): (source)
Format string such that it gives 'natural' sorting on string compare. Will pad any numbers in the string with "0" such that "10" sorts after "9". Also includes locale.strxfrm().
Parameters
stringthe string to format
numeric_paddingnumber of digits to use for padding
Returns
string transformed to sorting key
Note
sorting not 100% stable for case, so order between "foo" and "Foo" is not defined. For this reason when sort needs to be absolutely stable it is advised to sort based on tuples of (sort_key, original_string). Or use either natural_sort() or natural_sorted() instead.
def natural_sorted(iter, key=None): (source)
Natural sort a list. See natural_sort_key for details.
Parameters
iterlist or iterable of strings to be sorted
keyfunction producing strings for list items
Returns
sorted copy of the list
_num_re = (source)

Undocumented