IOReader.py 文件源码

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

项目:fluentanki 作者: jayrod 项目源码 文件源码
def read_text(self, path_to_file):
        """Read_text will read text from a file

            Args:
                path_to_file (str): Path to a valid file

            Returns:
                Tuple containing the text of the document and the title of it. Else returns None
        """
        if path_to_file is None:
            raise ValueError('parameter is of type None')
        if len(path_to_file) == 0:
            raise ValueError('Empty path tofile given')
        if os.path.isdir(path_to_file):
            raise ValueError('Path given is to a directory')

        full_text = open(path_to_file).read()
        title = os.path.basename(path_to_file)
        title = slugify.slugify(title.decode('utf-8'), only_ascii=True)


        return full_text, title
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号