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 |
Parameters | |
name | the module name |
Returns | |
module object | |
Raises | |
ImportError | if the given name does not exist |
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 | |
module | module object |
klass | base class |
Note | |
don't actually use this method to get plugin classes, see PluginManager.get_plugin_class() instead. |
natural_sort_key
for details.Parameters | |
list | list of strings to be sorted |
key | function producing strings for list items |
Parameters | |
string | the string to format |
numeric_padding | number 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. |
natural_sort_key
for details.Parameters | |
iter | list or iterable of strings to be sorted |
key | function producing strings for list items |
Returns | |
sorted copy of the list |