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
1 changed files with 6 additions and 6 deletions

View File

@ -82,17 +82,17 @@ 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
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.vault = False
with codecs.open(filename, mode='rb', encoding='utf-8') as f:
if f.readline().startswith("$ANSIBLE_VAULT"):
self.vault = True
self.filetype = type(self).__name__.lower()
self.expected_version = True