forked from platformio/platformio-core
Implement universal "get_object_members" helper
This commit is contained in:
@@ -38,12 +38,14 @@ def get_locale_encoding():
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_class_attributes(cls):
|
def get_object_members(obj, ignore_private=True):
|
||||||
attributes = inspect.getmembers(cls, lambda a: not inspect.isroutine(a))
|
members = inspect.getmembers(obj, lambda a: not inspect.isroutine(a))
|
||||||
|
if not ignore_private:
|
||||||
|
return members
|
||||||
return {
|
return {
|
||||||
a[0]: a[1]
|
item[0]: item[1]
|
||||||
for a in attributes
|
for item in members
|
||||||
if not (a[0].startswith("__") and a[0].endswith("__"))
|
if not (item[0].startswith("__") and item[0].endswith("__"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -21,7 +21,7 @@ import re
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
from platformio import util
|
from platformio import util
|
||||||
from platformio.compat import get_class_attributes, string_types
|
from platformio.compat import get_object_members, string_types
|
||||||
from platformio.package.exception import ManifestParserError, UnknownManifestError
|
from platformio.package.exception import ManifestParserError, UnknownManifestError
|
||||||
from platformio.project.helpers import is_platformio_project
|
from platformio.project.helpers import is_platformio_project
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ class ManifestFileType(object):
|
|||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def items(cls):
|
def items(cls):
|
||||||
return get_class_attributes(ManifestFileType)
|
return get_object_members(ManifestFileType)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_uri(cls, uri):
|
def from_uri(cls, uri):
|
||||||
|
Reference in New Issue
Block a user