Skip to content

Finder

Find Module With Specific Attribute Or Method.

>>> import ucdp as u
>>> class SubMod(u.AMod):
...     def _build(self):
...         pass
>>> class AnotherSubMod(u.AMod):
...     def _build(self):
...         pass
...     @property
...     def feature(self):
...         return "Hello World"
>>> class TopMod(u.AMod):
...     def _build(self):
...         SubMod(self, 'u_sub')
...         AnotherSubMod(self, 'u_anothersub')

>>> from ucdp_glbl.finder import find
>>> top = TopMod()
>>> find([top], 'feature')
(<ucdp_glbl.finder.AnotherSubMod(inst='top/u_anothersub', ...)>, 'Hello World')

Functions:

Name Description
find

Find module with attribute named name, starting from top to bottom.

find

find(mods, name)

Find module with attribute named name, starting from top to bottom.