From: chrysn Date: Tue, 20 Mar 2012 15:59:33 +0000 (-0400) Subject: comment on a non-obvious function X-Git-Url: https://sipb.mit.edu/gitweb.cgi/ikiwiki.git/commitdiff_plain/c9d9769f8373f64e027f3e041fd16c412f76b19a comment on a non-obvious function --- diff --git a/doc/todo/sort_parameter_for_map_plugin_and_directive/python_algorithms.py b/doc/todo/sort_parameter_for_map_plugin_and_directive/python_algorithms.py index ccee8185d..894c5212e 100644 --- a/doc/todo/sort_parameter_for_map_plugin_and_directive/python_algorithms.py +++ b/doc/todo/sort_parameter_for_map_plugin_and_directive/python_algorithms.py @@ -35,6 +35,12 @@ def strategy_byparents(sequence): """ def partindices(item): + """Convert an entry a tuple of the indices of the entry's parts. + + >>> sequence = testsequence + >>> assert partindices("c/2/x") == (sequence.index("c"), sequence.index("c/2"), sequence.index("c/2/x")) + fnord + """ return tuple(sequence.index(item.rsplit('/', i)[0]) for i in range(item.count('/'), -1, -1)) return sorted(sequence, key=partindices)