def recognize_format(self):
for line in self.input.split('\n'):
if self.format: break
for format, rex in BytesParser.formats_compiled.items():
line = BytesParser.make_line_printable(line)
out(dbg("Trying format %s on ('%s')" % (format, line)))
if rex.match(line):
out(ok("%s has been recognized as %s formatted." % (self.name, format)))
self.format = format
break
if not self.format:
if not all(c in string.printable for c in self.input):
out(ok("%s has been recognized as RAW bytes." % (self.name)))
self.format = 'raw'
return True
else:
out(err("Could not recognize input bytes format of the %s!" % self.name))
return False
return (len(self.format) > 0)
评论列表
文章目录