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
评论列表
文章目录