Skip to content

Commit

Permalink
component.py::MepoComponent - renamed to_dict to to_registry_format. …
Browse files Browse the repository at this point in the history
…Added to_dict
  • Loading branch information
pchakraborty committed May 2, 2024
1 parent 92bce58 commit 71591c4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/mepo/command/save.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def run(args):
complist = dict()
relpath_start = MepoState.get_root_dir()
for comp in allcomps:
complist.update(comp.to_dict(relpath_start))
complist.update(comp.to_registry_format())
registry_root_dir=os.path.join(relpath_start,args.registry)
Registry(registry_root_dir).write_yaml(complist)
print(f"Components written to '{registry_root_dir}'")
Expand Down
2 changes: 1 addition & 1 deletion src/mepo/command/update-state.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def run(args):
# needed to avoid pickle trying to use the path to the old modules
allcomps = []
for comp in allcomps_old:
tmp_dict = comp.to_dict(None)
tmp_dict = comp.to_registry_format()
name = list(tmp_dict)[0]
comp = tmp_dict[name]
allcomps.append(MepoComponent().to_component(name, comp, None))
Expand Down
9 changes: 8 additions & 1 deletion src/mepo/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ def to_component(self, comp_name, comp_details, comp_style):
self.__set_original_version(comp_details)
return self

def to_dict(self, start):
def to_registry_format(self):
details = dict()
# Fixtures are allowed exactly two entries
if self.fixture:
Expand Down Expand Up @@ -195,6 +195,13 @@ def to_dict(self, start):
details['ignore_submodules'] = self.ignore_submodules
return {self.name: details}

def to_dict(self):
d = {}
for k in self.__slots__:
v = getattr(self, k)
d.update({k: v})
return d

def get_current_remote_url():
cmd = 'git remote get-url origin'
output = shellcmd.run(shlex.split(cmd), output=True).strip()
Expand Down

0 comments on commit 71591c4

Please sign in to comment.