+ def _split_path(self, path):
+ """Split include path into sortable compoments.
+
+ Plain string on the full path in the #include directive causes some
+ unintuitive behavior, so this splits the path into a tuple at
+ points that allow more natural sorting: primary sort criterion is the
+ directory name, followed by the basename (without extension) of the
+ included file.
+ """
+ path_components = list(os.path.split(path))
+ path_components[1] = os.path.splitext(path_components[1])
+ return tuple(path_components)
+
+ def _join_path(self, path_components):
+ """Reconstruct path from the return value of _split_path."""
+ return os.path.join(path_components[0], ''.join(path_components[1]))
+