mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 10:07:14 +02:00
Use globals() instead of sys.modules
This commit is contained in:
@ -60,16 +60,16 @@ class LibBuilderFactory(object):
|
|||||||
elif used_frameworks:
|
elif used_frameworks:
|
||||||
clsname = "%sLibBuilder" % used_frameworks[0].capitalize()
|
clsname = "%sLibBuilder" % used_frameworks[0].capitalize()
|
||||||
|
|
||||||
obj = getattr(sys.modules[__name__], clsname)(env, path, verbose=verbose)
|
obj = globals()[clsname](env, path, verbose=verbose)
|
||||||
|
|
||||||
# Handle PlatformIOLibBuilder.manifest.build.builder
|
# Handle PlatformIOLibBuilder.manifest.build.builder
|
||||||
# pylint: disable=protected-access
|
# pylint: disable=protected-access
|
||||||
if isinstance(obj, PlatformIOLibBuilder) and obj._manifest.get("build", {}).get(
|
if isinstance(obj, PlatformIOLibBuilder) and obj._manifest.get("build", {}).get(
|
||||||
"builder"
|
"builder"
|
||||||
):
|
):
|
||||||
obj = getattr(
|
obj = globals()[obj._manifest.get("build", {}).get("builder")](
|
||||||
sys.modules[__name__], obj._manifest.get("build", {}).get("builder")
|
env, path, verbose=verbose
|
||||||
)(env, path, verbose=verbose)
|
)
|
||||||
|
|
||||||
assert isinstance(obj, LibBuilderBase)
|
assert isinstance(obj, LibBuilderBase)
|
||||||
return obj
|
return obj
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from platformio import proc
|
from platformio import proc
|
||||||
@ -47,12 +46,12 @@ class VCSClientFactory(object):
|
|||||||
if not type_:
|
if not type_:
|
||||||
raise VCSBaseException("VCS: Unknown repository type %s" % remote_url)
|
raise VCSBaseException("VCS: Unknown repository type %s" % remote_url)
|
||||||
try:
|
try:
|
||||||
obj = getattr(sys.modules[__name__], "%sClient" % type_.capitalize())(
|
obj = globals()["%sClient" % type_.capitalize()](
|
||||||
src_dir, remote_url, tag, silent
|
src_dir, remote_url, tag, silent
|
||||||
)
|
)
|
||||||
assert isinstance(obj, VCSClientBase)
|
assert isinstance(obj, VCSClientBase)
|
||||||
return obj
|
return obj
|
||||||
except (AttributeError, AssertionError):
|
except (KeyError, AssertionError):
|
||||||
raise VCSBaseException("VCS: Unknown repository type %s" % remote_url)
|
raise VCSBaseException("VCS: Unknown repository type %s" % remote_url)
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,11 +31,11 @@ class PlatformFactory(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def load_platform_module(name, path):
|
def load_platform_module(name, path):
|
||||||
# support for legacy dev-platforms
|
# backward compatibiility with the legacy dev-platforms
|
||||||
sys.modules["platformio.managers.platform"] = base
|
sys.modules["platformio.managers.platform"] = base
|
||||||
try:
|
try:
|
||||||
return load_python_module("platformio.platform.%s" % name, path)
|
return load_python_module("platformio.platform.%s" % name, path)
|
||||||
except ImportError as exc:
|
except ImportError:
|
||||||
raise UnknownPlatform(name)
|
raise UnknownPlatform(name)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
Reference in New Issue
Block a user