fix file classification error if file is a binary

This commit is contained in:
Robert Kaussow 2019-01-29 16:27:56 +01:00
parent 6206dd968c
commit 86ffffd8e1

View File

@ -82,16 +82,16 @@ class Result(object):
class Candidate(object):
def __init__(self, filename):
self.path = filename
self.binary = False
self.vault = False
try:
self.version = find_version(filename)
self.binary = False
except UnicodeDecodeError:
self.binary = True
self.vault = False
with codecs.open(filename, mode='rb', encoding='utf-8') as f:
if f.readline().startswith("$ANSIBLE_VAULT"):
self.vault = True
except UnicodeDecodeError:
self.binary = True
self.filetype = type(self).__name__.lower()
self.expected_version = True