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