def _process_cache(self, split="\n", rstrip=True):
try:
ftype = magic.from_file(self.cache, mime=True)
except AttributeError:
try:
mag = magic.open(magic.MAGIC_MIME)
mag.load()
ftype = mag.file(self.cache)
except AttributeError as e:
raise RuntimeError('unable to detect cached file type')
if PYVERSION < 3:
ftype = ftype.decode('utf-8')
if ftype.startswith('application/x-gzip') or ftype.startswith('application/gzip'):
from csirtg_smrt.decoders.zgzip import get_lines
for l in get_lines(self.cache, split=split):
yield l
return
if ftype == "application/zip":
from csirtg_smrt.decoders.zzip import get_lines
for l in get_lines(self.cache, split=split):
yield l
return
# all others, mostly txt, etc...
with open(self.cache) as f:
for l in f:
yield l
评论列表
文章目录