diff --git a/platformio/home/rpc/handlers/project.py b/platformio/home/rpc/handlers/project.py index 097f7e45..f7a9b8f8 100644 --- a/platformio/home/rpc/handlers/project.py +++ b/platformio/home/rpc/handlers/project.py @@ -32,6 +32,10 @@ from platformio.project.helpers import is_platformio_project class ProjectRPC(object): + @staticmethod + def config_call(path, method, *args): + return getattr(ProjectConfig(path), method)(*args) + @staticmethod def _get_projects(project_dirs=None): def _get_project_data(): diff --git a/platformio/project/config.py b/platformio/project/config.py index d0abf25c..988b53c2 100644 --- a/platformio/project/config.py +++ b/platformio/project/config.py @@ -409,11 +409,11 @@ class ProjectConfig(ProjectConfigBase, ProjectConfigDirsMixin): def __repr__(self): return "" % (self.path or "in-memory") + def as_dict(self): + return {s: self.items(s, as_dict=True) for s in self.sections()} + def to_json(self): - result = {} - for section in self.sections(): - result[section] = self.items(section, as_dict=True) - return json.dumps(result) + return json.dumps(self.as_dict()) def save(self, path=None): path = path or self.path