Implement "get_file_contents" helper
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
import codecs
|
||||
import hashlib
|
||||
import os
|
||||
import re
|
||||
@@ -74,13 +75,7 @@ class LibBuilderFactory(object):
|
||||
if not env.IsFileWithExt(
|
||||
fname, piotool.SRC_BUILD_EXT + piotool.SRC_HEADER_EXT):
|
||||
continue
|
||||
content = ""
|
||||
try:
|
||||
with open(join(root, fname)) as f:
|
||||
content = f.read()
|
||||
except UnicodeDecodeError:
|
||||
with open(join(root, fname), encoding="latin-1") as f:
|
||||
content = f.read()
|
||||
content = util.get_file_contents(join(root, fname))
|
||||
if not content:
|
||||
continue
|
||||
if "Arduino.h" in content and include_re.search(content):
|
||||
@@ -481,7 +476,8 @@ class ArduinoLibBuilder(LibBuilderBase):
|
||||
manifest = {}
|
||||
if not isfile(join(self.path, "library.properties")):
|
||||
return manifest
|
||||
with open(join(self.path, "library.properties")) as fp:
|
||||
manifest_path = join(self.path, "library.properties")
|
||||
with codecs.open(manifest_path, encoding="utf-8") as fp:
|
||||
for line in fp.readlines():
|
||||
if "=" not in line:
|
||||
continue
|
||||
|
||||
@@ -76,8 +76,7 @@ class InoToCPPConverter(object):
|
||||
def process(self, contents):
|
||||
out_file = self._main_ino + ".cpp"
|
||||
assert self._gcc_preprocess(contents, out_file)
|
||||
with open(out_file) as fp:
|
||||
contents = fp.read()
|
||||
contents = util.get_file_contents(out_file)
|
||||
contents = self._join_multiline_strings(contents)
|
||||
with open(out_file, "w") as fp:
|
||||
fp.write(self.append_prototypes(contents))
|
||||
|
||||
Reference in New Issue
Block a user