Skip to content

Commit

Permalink
FIX: edb.configuration to support pathlib (#636)
Browse files Browse the repository at this point in the history
* REFACTOR: minor

* FIX: load to support Pathlib

* MISC: Auto fixes from pre-commit.com hooks

For more information, see https://pre-commit.ci

---------

Co-authored-by: ring630 <@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
hui-zhou-a and pre-commit-ci[bot] committed Jul 3, 2024
1 parent 77f8d06 commit 070de45
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
2 changes: 2 additions & 0 deletions src/pyedb/configuration/cfg_ports_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def get_data_from_db(self):
negative_terminal=neg_term_info,
)
self.sources.append(cfg_src)
return self.export_properties()

def export_properties(self):
sources = []
Expand Down Expand Up @@ -165,6 +166,7 @@ def get_data_from_db(self):
)

self.ports.append(cfg_port)
return self.export_properties()

def export_properties(self):
ports = []
Expand Down
24 changes: 12 additions & 12 deletions src/pyedb/configuration/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,16 @@ def load(self, config_file, append=True, apply_file=False, output_file=None, ope
"""
if isinstance(config_file, dict):
data = config_file
elif os.path.isfile(config_file):
with open(config_file, "r") as f:
if config_file.endswith(".json"):
data = json.load(f)
elif config_file.endswith(".toml"):
data = toml.load(f)
else: # pragma: no cover
return False
else:
config_file = str(config_file)
if os.path.isfile(config_file):
with open(config_file, "r") as f:
if config_file.endswith(".json"):
data = json.load(f)
elif config_file.endswith(".toml"):
data = toml.load(f)
else: # pragma: no cover
return False

if not append: # pragma: no cover
self.data = {}
Expand Down Expand Up @@ -270,11 +272,9 @@ def get_data_from_db(self, **kwargs):
if kwargs.get("setups", False):
data["setups"] = self.cfg_data.setups.get_data_from_db()
if kwargs.get("sources", False):
self.cfg_data.sources.get_data_from_db()
data["sources"] = self.cfg_data.sources.export_properties()
data["sources"] = self.cfg_data.sources.get_data_from_db()
if kwargs.get("ports", False):
self.cfg_data.ports.get_data_from_db()
data["ports"] = self.cfg_data.ports.export_properties()
data["ports"] = self.cfg_data.ports.get_data_from_db()
if kwargs.get("components", False):
data["components"] = self.cfg_data.components.get_data_from_db()
if kwargs.get("nets", False):
Expand Down

0 comments on commit 070de45

Please sign in to comment.