Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: edb.configuration to support pathlib #636

Merged
merged 3 commits into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading