bank/description/AutoCSR: add autocsr_exclude
This commit is contained in:
parent
10212e85e7
commit
c82b53f1cd
|
@ -96,23 +96,33 @@ def memprefix(prefix, memories):
|
||||||
|
|
||||||
class AutoCSR:
|
class AutoCSR:
|
||||||
def get_memories(self):
|
def get_memories(self):
|
||||||
|
try:
|
||||||
|
exclude = self.autocsr_exclude
|
||||||
|
except AttributeError:
|
||||||
|
exclude = {}
|
||||||
r = []
|
r = []
|
||||||
for k, v in self.__dict__.items():
|
for k, v in self.__dict__.items():
|
||||||
if isinstance(v, Memory):
|
if k not in exclude:
|
||||||
r.append(v)
|
if isinstance(v, Memory):
|
||||||
elif hasattr(v, "get_memories") and callable(v.get_memories):
|
r.append(v)
|
||||||
memories = v.get_memories()
|
elif hasattr(v, "get_memories") and callable(v.get_memories):
|
||||||
memprefix(k + "_", memories)
|
memories = v.get_memories()
|
||||||
r += memories
|
memprefix(k + "_", memories)
|
||||||
|
r += memories
|
||||||
return sorted(r, key=lambda x: x.huid)
|
return sorted(r, key=lambda x: x.huid)
|
||||||
|
|
||||||
def get_csrs(self):
|
def get_csrs(self):
|
||||||
|
try:
|
||||||
|
exclude = self.autocsr_exclude
|
||||||
|
except AttributeError:
|
||||||
|
exclude = {}
|
||||||
r = []
|
r = []
|
||||||
for k, v in self.__dict__.items():
|
for k, v in self.__dict__.items():
|
||||||
if isinstance(v, _CSRBase):
|
if k not in exclude:
|
||||||
r.append(v)
|
if isinstance(v, _CSRBase):
|
||||||
elif hasattr(v, "get_csrs") and callable(v.get_csrs):
|
r.append(v)
|
||||||
csrs = v.get_csrs()
|
elif hasattr(v, "get_csrs") and callable(v.get_csrs):
|
||||||
csrprefix(k + "_", csrs)
|
csrs = v.get_csrs()
|
||||||
r += csrs
|
csrprefix(k + "_", csrs)
|
||||||
|
r += csrs
|
||||||
return sorted(r, key=lambda x: x.huid)
|
return sorted(r, key=lambda x: x.huid)
|
||||||
|
|
Loading…
Reference in New Issue