forked from platformio/platformio-core
Switch to FS JSON loader
This commit is contained in:
@ -15,6 +15,7 @@
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
|
||||||
|
from platformio import fs
|
||||||
from platformio.package.exception import PackageException
|
from platformio.package.exception import PackageException
|
||||||
from platformio.package.meta import PackageItem, PackageSpec
|
from platformio.package.meta import PackageItem, PackageSpec
|
||||||
|
|
||||||
@ -27,9 +28,7 @@ class PackageManagerSymlinkMixin(object):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def resolve_symlink(cls, path):
|
def resolve_symlink(cls, path):
|
||||||
assert cls.is_symlink(path)
|
assert cls.is_symlink(path)
|
||||||
data = None
|
data = fs.load_json(path)
|
||||||
with open(path, "r", encoding="utf-8") as fp:
|
|
||||||
data = json.load(fp)
|
|
||||||
spec = PackageSpec(**data["spec"])
|
spec = PackageSpec(**data["spec"])
|
||||||
assert spec.symlink
|
assert spec.symlink
|
||||||
pkg_dir = spec.uri[10:]
|
pkg_dir = spec.uri[10:]
|
||||||
|
@ -21,6 +21,7 @@ from urllib.parse import urlparse
|
|||||||
|
|
||||||
import semantic_version
|
import semantic_version
|
||||||
|
|
||||||
|
from platformio import fs
|
||||||
from platformio.compat import get_object_members, hashlib_encode_data, string_types
|
from platformio.compat import get_object_members, hashlib_encode_data, string_types
|
||||||
from platformio.package.manifest.parser import ManifestFileType
|
from platformio.package.manifest.parser import ManifestFileType
|
||||||
from platformio.package.version import cast_version_to_semver
|
from platformio.package.version import cast_version_to_semver
|
||||||
@ -415,15 +416,14 @@ class PackageMetaData(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def load(path):
|
def load(path):
|
||||||
with open(path, encoding="utf8") as fp:
|
data = fs.load_json(path)
|
||||||
data = json.load(fp)
|
if data["spec"]:
|
||||||
if data["spec"]:
|
# legacy support for Core<5.3 packages
|
||||||
# legacy support for Core<5.3 packages
|
if "url" in data["spec"]:
|
||||||
if "url" in data["spec"]:
|
data["spec"]["uri"] = data["spec"]["url"]
|
||||||
data["spec"]["uri"] = data["spec"]["url"]
|
del data["spec"]["url"]
|
||||||
del data["spec"]["url"]
|
data["spec"] = PackageSpec(**data["spec"])
|
||||||
data["spec"] = PackageSpec(**data["spec"])
|
return PackageMetaData(**data)
|
||||||
return PackageMetaData(**data)
|
|
||||||
|
|
||||||
|
|
||||||
class PackageItem(object):
|
class PackageItem(object):
|
||||||
|
@ -12,7 +12,6 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
import json
|
|
||||||
import os
|
import os
|
||||||
import subprocess
|
import subprocess
|
||||||
from hashlib import sha1
|
from hashlib import sha1
|
||||||
@ -162,6 +161,5 @@ def _load_cached_project_ide_data(project_dir, env_names):
|
|||||||
for name in env_names:
|
for name in env_names:
|
||||||
if not os.path.isfile(os.path.join(build_dir, name, "idedata.json")):
|
if not os.path.isfile(os.path.join(build_dir, name, "idedata.json")):
|
||||||
continue
|
continue
|
||||||
with open(os.path.join(build_dir, name, "idedata.json"), encoding="utf8") as fp:
|
result[name] = fs.load_json(os.path.join(build_dir, name, "idedata.json"))
|
||||||
result[name] = json.load(fp)
|
|
||||||
return result
|
return result
|
||||||
|
Reference in New Issue
Block a user