forked from platformio/platformio-core
Fix handling user's platforms
This commit is contained in:
@ -90,7 +90,7 @@ def platforms_search(query, json_output):
|
|||||||
for item in data:
|
for item in data:
|
||||||
click.secho(item['type'], fg="cyan", nl=False)
|
click.secho(item['type'], fg="cyan", nl=False)
|
||||||
click.echo(" (available packages: %s)" % ", ".join(
|
click.echo(" (available packages: %s)" % ", ".join(
|
||||||
p.get_packages().keys()))
|
item.get("packages").keys()))
|
||||||
click.echo("-" * terminal_width)
|
click.echo("-" * terminal_width)
|
||||||
click.echo(item['description'])
|
click.echo(item['description'])
|
||||||
click.echo()
|
click.echo()
|
||||||
|
@ -119,7 +119,7 @@ class PlatformFactory(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_clsname(type_):
|
def get_clsname(type_):
|
||||||
return "%sPlatform" % type_.title()
|
return "%s%sPlatform" % (type_.upper()[0], type_.lower()[1:])
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def load_module(type_, path):
|
def load_module(type_, path):
|
||||||
@ -134,24 +134,30 @@ class PlatformFactory(object):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def get_platforms(cls, installed=False):
|
def get_platforms(cls, installed=False):
|
||||||
platforms = {}
|
platforms = {}
|
||||||
for d in (util.get_home_dir(), util.get_source_dir()):
|
|
||||||
pdir = join(d, "platforms")
|
try:
|
||||||
if not isdir(pdir):
|
platforms = cls.get_platforms_cache
|
||||||
continue
|
except AttributeError:
|
||||||
for p in listdir(pdir):
|
for d in (util.get_home_dir(), util.get_source_dir()):
|
||||||
if p in ("__init__.py", "base.py") or not p.endswith(".py"):
|
pdir = join(d, "platforms")
|
||||||
|
if not isdir(pdir):
|
||||||
continue
|
continue
|
||||||
type_ = p[:-3]
|
for p in listdir(pdir):
|
||||||
path = join(pdir, p)
|
if (p in ("__init__.py", "base.py") or not
|
||||||
try:
|
p.endswith(".py")):
|
||||||
isplatform = hasattr(
|
continue
|
||||||
cls.load_module(type_, path),
|
type_ = p[:-3]
|
||||||
cls.get_clsname(type_)
|
path = join(pdir, p)
|
||||||
)
|
try:
|
||||||
if isplatform:
|
isplatform = hasattr(
|
||||||
platforms[type_] = path
|
cls.load_module(type_, path),
|
||||||
except exception.UnknownPlatform:
|
cls.get_clsname(type_)
|
||||||
pass
|
)
|
||||||
|
if isplatform:
|
||||||
|
platforms[type_] = path
|
||||||
|
except exception.UnknownPlatform:
|
||||||
|
pass
|
||||||
|
cls.get_platforms_cache = platforms
|
||||||
|
|
||||||
if not installed:
|
if not installed:
|
||||||
return platforms
|
return platforms
|
||||||
|
Reference in New Issue
Block a user