Skip to content

Commit 60b9f87

Browse files
committed
Nicer name conflict resolution
1 parent a507c60 commit 60b9f87

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/ttboard/project_mux.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def disable(self):
4646
self.mux.disable()
4747

4848
def __str__(self):
49-
return self.name
49+
return f'{self.name} ({self.project_index}) @ {self.repo}'
5050

5151
def __repr__(self):
5252
return f'<Design {self.project_index}: {self.name}>'
@@ -62,8 +62,15 @@ def __init__(self, projectMux, src_JSON_file:str='shuttle_index.json'):
6262
des = Design(projectMux, project["address"], project)
6363
attrib_name = des.name
6464
if attrib_name in self._shuttle_index:
65-
log.warn(f'Already have a "{attrib_name}" here...')
66-
attrib_name = des.macro
65+
log.info(f'Already have a "{attrib_name}" here...')
66+
attempt = 1
67+
augmented_name = f'{attrib_name}_{attempt}'
68+
while augmented_name in self._shuttle_index:
69+
attempt += 1
70+
augmented_name = f'{attrib_name}_{attempt}'
71+
72+
attrib_name = augmented_name
73+
des.name = augmented_name
6774
self._shuttle_index[attrib_name] = des
6875
setattr(self, attrib_name, des)
6976
self._project_count += 1

0 commit comments

Comments
 (0)