update: allow patch parsing to work with python 2

If we want to be able to read in patch information on python2-based
branches (e.g. fido) then we need to use codecs.open() instead of open()
here since python2's open() did not support the encoding parameter.

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2018-10-01 16:20:42 +13:00
parent 11a1d0859d
commit 8bb62fb82d

View File

@ -17,6 +17,7 @@ import re
import tempfile
import shutil
import errno
import codecs
from distutils.version import LooseVersion
import itertools
import utils
@ -77,7 +78,7 @@ def collect_patch(recipe, patchfn, layerdir_start, stop_on_error):
try:
for encoding in ['utf-8', 'latin-1']:
try:
with open(patchfn, 'r', encoding=encoding) as f:
with codecs.open(patchfn, 'r', encoding=encoding) as f:
for line in f:
line = line.rstrip()
if line.startswith('Index: ') or line.startswith('diff -') or line.startswith('+++ '):