mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 10:07:14 +02:00
Minor fixes
This commit is contained in:
@ -18,6 +18,7 @@
|
|||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import io
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
@ -82,7 +83,7 @@ class LibBuilderFactory(object):
|
|||||||
fname, piotool.SRC_BUILD_EXT + piotool.SRC_HEADER_EXT
|
fname, piotool.SRC_BUILD_EXT + piotool.SRC_HEADER_EXT
|
||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
with open(join(root, fname)) as fp:
|
with io.open(join(root, fname), errors="ignore") as fp:
|
||||||
content = fp.read()
|
content = fp.read()
|
||||||
if not content:
|
if not content:
|
||||||
continue
|
continue
|
||||||
|
@ -53,7 +53,7 @@ class InoToCPPConverter(object):
|
|||||||
self._safe_encoding = None
|
self._safe_encoding = None
|
||||||
|
|
||||||
def read_safe_contents(self, path):
|
def read_safe_contents(self, path):
|
||||||
last_exc = None
|
error_reported = False
|
||||||
for encoding in (
|
for encoding in (
|
||||||
"utf-8",
|
"utf-8",
|
||||||
None,
|
None,
|
||||||
@ -66,18 +66,17 @@ class InoToCPPConverter(object):
|
|||||||
contents = fp.read()
|
contents = fp.read()
|
||||||
self._safe_encoding = encoding
|
self._safe_encoding = encoding
|
||||||
return contents
|
return contents
|
||||||
except UnicodeDecodeError as e:
|
except UnicodeDecodeError:
|
||||||
last_exc = e
|
if not error_reported:
|
||||||
click.secho(
|
error_reported = True
|
||||||
"Unicode decode error has occurred, please remove invalid "
|
click.secho(
|
||||||
"(non-ASCII or non-UTF8) characters from %s file or convert it to UTF-8"
|
"Unicode decode error has occurred, please remove invalid "
|
||||||
% path,
|
"(non-ASCII or non-UTF8) characters from %s file or convert it to UTF-8"
|
||||||
fg="yellow",
|
% path,
|
||||||
err=True,
|
fg="yellow",
|
||||||
)
|
err=True,
|
||||||
if last_exc:
|
)
|
||||||
raise last_exc
|
return ""
|
||||||
return None
|
|
||||||
|
|
||||||
def write_safe_contents(self, path, contents):
|
def write_safe_contents(self, path, contents):
|
||||||
with io.open(
|
with io.open(
|
||||||
|
Reference in New Issue
Block a user