MCPcopy Create free account
hub / github.com/VisionRush/DeepFakeDefenders / __init__

Method __init__

toolkit/yacs.py:74–109  ·  view source on GitHub ↗

Args: init_dict (dict): the possibly-nested dictionary to initailize the CfgNode. key_list (list[str]): a list of names which index this CfgNode from the root. Currently only used for logging purposes. new_allowed (bool): whether adding ne

(self, init_dict=None, key_list=None, new_allowed=False)

Source from the content-addressed store, hash-verified

72 NEW_ALLOWED = "__new_allowed__"
73
74 def __init__(self, init_dict=None, key_list=None, new_allowed=False):
75 """
76 Args:
77 init_dict (dict): the possibly-nested dictionary to initailize the CfgNode.
78 key_list (list[str]): a list of names which index this CfgNode from the root.
79 Currently only used for logging purposes.
80 new_allowed (bool): whether adding new key is allowed when merging with
81 other configs.
82 """
83 # Recursively convert nested dictionaries in init_dict into CfgNodes
84 init_dict = {} if init_dict is None else init_dict
85 key_list = [] if key_list is None else key_list
86 init_dict = self._create_config_tree_from_dict(init_dict, key_list)
87 super(CfgNode, self).__init__(init_dict)
88 # Manage if the CfgNode is frozen or not
89 self.__dict__[CfgNode.IMMUTABLE] = False
90 # Deprecated options
91 # If an option is removed from the code and you don't want to break existing
92 # yaml configs, you can add the full config key as a string to the set below.
93 self.__dict__[CfgNode.DEPRECATED_KEYS] = set()
94 # Renamed options
95 # If you rename a config option, record the mapping from the old name to the new
96 # name in the dictionary below. Optionally, if the type also changed, you can
97 # make the value a tuple that specifies first the renamed key and then
98 # instructions for how to edit the config file.
99 self.__dict__[CfgNode.RENAMED_KEYS] = {
100 # 'EXAMPLE.OLD.KEY': 'EXAMPLE.NEW.KEY', # Dummy example to follow
101 # 'EXAMPLE.OLD.KEY': ( # A more complex example to follow
102 # 'EXAMPLE.NEW.KEY',
103 # "Also convert to a tuple, e.g., 'foo' -> ('foo',) or "
104 # + "'foo:bar' -> ('foo', 'bar')"
105 # ),
106 }
107
108 # Allow new attributes after initialisation
109 self.__dict__[CfgNode.NEW_ALLOWED] = new_allowed
110
111 @classmethod
112 def _create_config_tree_from_dict(cls, dic, key_list):

Callers

nothing calls this directly

Calls 1

Tested by

no test coverage detected