def match_pagination(self, record, url_path):
        """Matches the pagination from the URL path."""
        if not self.enabled:
            return
        suffixes = self.url_suffix.strip('/').split('/')
        if url_path[:len(suffixes)] != suffixes:
            return

        try:
            page_num = int(url_path[len(suffixes)])
        except (__HOLE__, IndexError):
            return

        # It's important we do not allow "1" here as the first page is always
        # on the root.  Changing this would mean the URLs are incorrectly
        # generated if someone manually went to /page/1/.
        if page_num == 1 or len(url_path) != len(suffixes) + 1:
            return

        # Page needs to have at least a single child.
        rv = self.get_record_for_page(record, page_num)
        if rv.pagination.items.first() is not None:
            return rv
dataset/ETHPy150Open lektor/lektor-archive/lektor/datamodel.py/PaginationConfig.match_pagination