Exemple #1
0
    def find_related(self, filtr=lambda _ : True):
        """
        Get all related sections of this section.

        The result can be filtered. On each related section a filter is applied. If the filter
        returns true the respective section will be added to the result list. By default a filter
        is used that accepts all sections.

        :param filtr: A filter function
        :type filtr:  function

        :returns: A list containing the matching related sections.
        :rtype: list of Section
        """
        result = []
        if self.parent is not None:
            result = finders._find_sections(self.parent, filtr, 1)
        if self in result:
            del result[result.index(self)]
        result += finders._find_sections(self, filtr, 1)
        return result
Exemple #2
0
    def find_related(self, filtr=lambda _: True):
        """
        Get all related sections of this section.

        The result can be filtered. On each related section a filter is applied. If the filter
        returns true the respective section will be added to the result list. By default a filter
        is used that accepts all sections.

        :param filtr: A filter function
        :type filtr:  function

        :returns: A list containing the matching related sections.
        :rtype: list of Section
        """
        result = []
        if self.parent is not None:
            result = finders._find_sections(self.parent, filtr, 1)
        if self in result:
            del result[result.index(self)]
        result += finders._find_sections(self, filtr, 1)
        return result
Exemple #3
0
    def find_sections(self, filtr=lambda _ : True, limit=sys.maxint):
        """
        Get all sections and their child sections recursively.

        This method traverses the trees of all sections. The traversal
        is accomplished via breadth first and can be limited in depth. On each node or
        section a filter is applied. If the filter returns true the respective section
        will be added to the result list.
        By default a filter is used that accepts all sections.

        :param filtr: A filter function
        :type filtr:  function
        :param limit: The maximum depth of traversal
        :type limit:  int

        :returns: A list containing the matching sections.
        :rtype: list of Section
        """
        return finders._find_sections(self, filtr, limit)
Exemple #4
0
    def find_sections(self, filtr=lambda _: True, limit=maxint):
        """
        Get all sections and their child sections recursively.

        This method traverses the trees of all sections. The traversal
        is accomplished via breadth first and can be limited in depth. On each node or
        section a filter is applied. If the filter returns true the respective section
        will be added to the result list.
        By default a filter is used that accepts all sections.

        :param filtr: A filter function
        :type filtr:  function
        :param limit: The maximum depth of traversal
        :type limit:  int

        :returns: A list containing the matching sections.
        :rtype: list of Section
        """
        return finders._find_sections(self, filtr, limit)