def alias(name, class_object):
"""
Create an alias of a class object
The objective of this method is to have
an alias that is Registered. i.e If we have
class_b = class_a
Makes `class_b` an alias of `class_a`, but if
`class_a` is registered by its metaclass,
`class_b` is not. The solution
alias('class_b', class_a)
is equivalent to:
class_b = class_a
Register['class_b'] = class_a
"""
module = inspect.getmodule(class_object)
module.__dict__[name] = class_object
if isinstance(class_object, Registry):
Registry[name] = class_object
评论列表
文章目录