Skip to content

Module Reference

Module Reference.

ModRef

Bases: LightObject

Module Reference.

Parameters:

Name Type Description Default
libname str

Library Name

required
modname str

Module Name

required

Other Parameters:

Name Type Description
modclsname str | None

Class Name

Module Reference Examples

Examples.

>>> ModRef('glbl_lib', 'clk_gate', modclsname='ClkGateMod')
ModRef('glbl_lib', 'clk_gate', modclsname='ClkGateMod')

Just a module:

>>> spec = ModRef.cast('glbl_lib.clk_gate')
>>> spec
ModRef('glbl_lib', 'clk_gate')
>>> str(spec)
'glbl_lib.clk_gate'

Module from a package and explicit class:

>>> spec = ModRef.cast('glbl_lib.clk_gate.ClkGateMod')
>>> spec
ModRef('glbl_lib', 'clk_gate', modclsname='ClkGateMod')
>>> str(spec)
'glbl_lib.clk_gate.ClkGateMod'
>>> ModRef.cast(ModRef('glbl_lib', 'clk_gate', modclsname='ClkGateMod'))
ModRef('glbl_lib', 'clk_gate', modclsname='ClkGateMod')

Invalid Pattern:

>>> ModRef.cast('lib.my:c-ls')
Traceback (most recent call last):
..
ValueError: 'lib.my:c-ls' does not match pattern 'lib.my[.MyMod]'

cast staticmethod

cast(value)

Cast value to ModRef.