]> sipb.mit.edu Git - ikiwiki.git/blobdiff - doc/todo/sort_parameter_for_map_plugin_and_directive/python_algorithms.py
recap of yamlfront issue opened on github
[ikiwiki.git] / doc / todo / sort_parameter_for_map_plugin_and_directive / python_algorithms.py
index ccee8185d090316b83ddf783c5223ed70204fbe9..e89c54fae994e52b6d45010b00975d67417a9002 100644 (file)
@@ -35,6 +35,11 @@ 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"))
+        """
         return tuple(sequence.index(item.rsplit('/', i)[0]) for i in range(item.count('/'), -1, -1))
 
     return sorted(sequence, key=partindices)