def parse(self, file):
if not isinstance(file, str) and not isinstance(file, IO):
raise TypeError("file is not str or IO")
if isinstance(file, str):
try:
enc = 'windows-1251'
with open(file, encoding=enc) as f:
content = f.readlines()
except FileNotFoundError:
raise FileNotFoundError("Not found " + file)
else:
content = file.readlines()
self._data = [x.strip() for x in content]
self.clear()
return self
评论列表
文章目录