CONFIG_ops

manimlib/utils/config_ops.py 这个文件中主要实现了处理CONFIG字典和类的属性有关的函数


manimlib.utils.config_ops.get_all_descendent_classes(Class)

获取类Class的全部子类


manimlib.utils.config_ops.filtered_locals(caller_locals)

将caller_locals字典中去掉 self, kwargs 两个键值对


manimlib.utils.config_ops.digest_config(obj, kwargs, caller_locals={})

Sets init args and CONFIG values as local variables

The purpose of this function is to ensure that all configuration of any object is inheritable, able to be easily passed into instantiation, and is attached as an attribute of the object.

获取当前类和所有父类的CONFIG字典,转换为属性(优先级已经处理好)

  • 若要将当前所有局部变量也转化为属性,使用 digest_config(self, kwargs, locals())


manimlib.utils.config_ops.merge_dicts_recursively(*dicts)

Creates a dict whose keyset is the union of all the input dictionaries. The value for each key is based on the first dict in the list with that key.

dicts later in the list have higher priority

When values are dictionaries, it is applied recursively

递归合并字典
创建一个字典,其键集是所有输入字典的并集,每个键的值都基于列表中带有该键的第一个字典
当值为字典时,将递归应用

manimlib.utils.config_ops.soft_dict_update(d1, d2)

Adds key values pairs of d2 to d1 only when d1 doesn’t already have that key

合并字典,仅当d1没有该键时,才将d2的键值对添加到d1中


manimlib.utils.config_ops.digest_locals(obj, keys=None)

把当前局部变量设为属性