mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 01:57:13 +02:00
Implement universal "get_object_members" helper
This commit is contained in:
@ -38,12 +38,14 @@ def get_locale_encoding():
|
||||
return None
|
||||
|
||||
|
||||
def get_class_attributes(cls):
|
||||
attributes = inspect.getmembers(cls, lambda a: not inspect.isroutine(a))
|
||||
def get_object_members(obj, ignore_private=True):
|
||||
members = inspect.getmembers(obj, lambda a: not inspect.isroutine(a))
|
||||
if not ignore_private:
|
||||
return members
|
||||
return {
|
||||
a[0]: a[1]
|
||||
for a in attributes
|
||||
if not (a[0].startswith("__") and a[0].endswith("__"))
|
||||
item[0]: item[1]
|
||||
for item in members
|
||||
if not (item[0].startswith("__") and item[0].endswith("__"))
|
||||
}
|
||||
|
||||
|
||||
|
@ -21,7 +21,7 @@ import re
|
||||
import requests
|
||||
|
||||
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.project.helpers import is_platformio_project
|
||||
|
||||
@ -40,7 +40,7 @@ class ManifestFileType(object):
|
||||
|
||||
@classmethod
|
||||
def items(cls):
|
||||
return get_class_attributes(ManifestFileType)
|
||||
return get_object_members(ManifestFileType)
|
||||
|
||||
@classmethod
|
||||
def from_uri(cls, uri):
|
||||
|
Reference in New Issue
Block a user