don't read whole file to detect encoding
This commit is contained in:
@@ -31,14 +31,14 @@ from yamllint.linter import PROBLEM_LEVELS
|
|||||||
|
|
||||||
def determine_encoding(file):
|
def determine_encoding(file):
|
||||||
with io.open(file, 'rb') as raw_file:
|
with io.open(file, 'rb') as raw_file:
|
||||||
data = raw_file.read()
|
data = raw_file.read(4)
|
||||||
if data.startswith(codecs.BOM_UTF16_LE):
|
if data.startswith(codecs.BOM_UTF16_LE):
|
||||||
encoding = 'utf-16-le'
|
encoding = 'utf-16-le'
|
||||||
elif data.startswith(codecs.BOM_UTF16_BE):
|
elif data.startswith(codecs.BOM_UTF16_BE):
|
||||||
encoding = 'utf-16-be'
|
encoding = 'utf-16-be'
|
||||||
else:
|
else:
|
||||||
encoding = 'utf-8'
|
encoding = 'utf-8'
|
||||||
return encoding
|
return encoding
|
||||||
|
|
||||||
|
|
||||||
def find_files_recursively(items, conf):
|
def find_files_recursively(items, conf):
|
||||||
|
|||||||
Reference in New Issue
Block a user