Skip to content

Commit ff8cb7f

Browse files
committed
DesignStub repr include index (issue #20) full fix
1 parent b774be3 commit ff8cb7f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/ttboard/project_mux.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ def _lazy_load(self):
7272
self._des = des
7373
return des
7474

75+
@property
76+
def project_index(self):
77+
return self.design_index.project_index(self.name)
78+
7579
def __getattr__(self, name:str):
7680
if hasattr(self, '_des') and self._des is not None:
7781
des = self._des
@@ -84,7 +88,7 @@ def __dir__(self):
8488
return dir(des)
8589

8690
def __repr__(self):
87-
return f'<Design {self.design_index.count}: {self.name} (uninit)>'
91+
return f'<Design {self.project_index}: {self.name} (uninit)>'
8892

8993
class DesignIndex:
9094

@@ -149,6 +153,8 @@ def count(self):
149153
@property
150154
def names(self):
151155
return sorted(self._available_projects.keys())
156+
157+
152158
@property
153159
def all(self):
154160
'''
@@ -207,6 +213,11 @@ def load_project(self, project_name:str) -> Design:
207213
def is_available(self, project_name:str):
208214
return project_name in self._available_projects
209215

216+
def project_index(self, project_name:str) -> int:
217+
if self.is_available(project_name):
218+
return self._available_projects[project_name]
219+
220+
return None
210221
def _get_from_shuttle_index(self, name:str):
211222
if hasattr(self, '_shuttle_index') and name in self._shuttle_index:
212223
if self._shuttle_index[name] is None:

0 commit comments

Comments
 (0)