forked from platformio/platformio-core
Specify encoding for "open()" functions
This commit is contained in:
1 parent
b9219a2b62
commit
d819617d2b
28 files changed
+63
-43
No files matched your search
@@ -62,7 +62,9 @@ class LockFile(object):
|
||||
else:
|
||||
raise LockFileExists
|
||||
|
||||
self._fp = open(self._lock_path, "w") # pylint: disable=consider-using-with
|
||||
self._fp = open(
|
||||
self._lock_path, mode="w", encoding="utf8"
|
||||
) # pylint: disable=consider-using-with
|
||||
try:
|
||||
if LOCKFILE_CURRENT_INTERFACE == LOCKFILE_INTERFACE_FCNTL:
|
||||
fcntl.flock(self._fp.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
|
||||
|
||||
@@ -156,7 +156,9 @@ def build_contrib_pysite_package(target_dir, with_metadata=True):
|
||||
subprocess.check_call(args + [dep])
|
||||
|
||||
# build manifests
|
||||
with open(os.path.join(target_dir, "package.json"), "w") as fp:
|
||||
with open(
|
||||
os.path.join(target_dir, "package.json"), mode="w", encoding="utf8"
|
||||
) as fp:
|
||||
json.dump(
|
||||
dict(
|
||||
name="contrib-pysite",
|
||||
|
||||
@@ -44,7 +44,9 @@ class LibraryPackageManager(BasePackageManager): # pylint: disable=too-many-anc
|
||||
root_dir = self.find_library_root(path)
|
||||
|
||||
# automatically generate library manifest
|
||||
with open(os.path.join(root_dir, "library.json"), "w") as fp:
|
||||
with open(
|
||||
os.path.join(root_dir, "library.json"), mode="w", encoding="utf8"
|
||||
) as fp:
|
||||
json.dump(
|
||||
dict(
|
||||
name=spec.name,
|
||||
|
||||
@@ -382,12 +382,12 @@ class PackageMetaData(object):
|
||||
)
|
||||
|
||||
def dump(self, path):
|
||||
with open(path, "w") as fp:
|
||||
with open(path, mode="w", encoding="utf8") as fp:
|
||||
return json.dump(self.as_dict(), fp)
|
||||
|
||||
@staticmethod
|
||||
def load(path):
|
||||
with open(path) as fp:
|
||||
with open(path, encoding="utf8") as fp:
|
||||
data = json.load(fp)
|
||||
if data["spec"]:
|
||||
data["spec"] = PackageSpec(**data["spec"])
|
||||
|
||||
@@ -181,7 +181,9 @@ class PackagePacker(object):
|
||||
and os.path.isdir(os.path.join(src, include[0]))
|
||||
):
|
||||
src = os.path.join(src, include[0])
|
||||
with open(os.path.join(src, "library.json"), "w") as fp:
|
||||
with open(
|
||||
os.path.join(src, "library.json"), mode="w", encoding="utf8"
|
||||
) as fp:
|
||||
manifest_updated = manifest.copy()
|
||||
del manifest_updated["export"]["include"]
|
||||
json.dump(manifest_updated, fp, indent=2, ensure_ascii=False)
|
||||
|
||||
Reference in new issue
Block a user