qqhtml.py 文件源码

python
阅读 35 收藏 0 点赞 0 评论 0

项目:qqmbr 作者: ischurov 项目源码 文件源码
def url_for_chapter(self, index=None, label=None,
                        fromindex=None) -> str:
        """
        Returns url for chapter. Either index or label of
        the target chapter have to be provided.
        Optionally, fromindex can be provided. In this case
        function will return empty string if
        target chapter coincides with current one.

        You can inherit from QqHTMLFormatter and override
        url_for_chapter_by_index and url_for_chapter_by_label too
        use e.g. Flask's url_for.
        """
        assert index is not None or label is not None
        if index is None:
            index = self.label_to_chapter[label]
        if fromindex is not None and fromindex == index:
            # we are already on the right page
            return ""
        if label is None:
            label = self.chapters[index].heading.find("label")
        if not label:
            return self.url_for_chapter_by_index(index)
        return self.url_for_chapter_by_label(label.value)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号