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

Method dump

toolkit/yacs.py:188–207  ·  view source on GitHub ↗

Dump to a string.

(self, **kwargs)

Source from the content-addressed store, hash-verified

186 return "{}({})".format(self.__class__.__name__, super(CfgNode, self).__repr__())
187
188 def dump(self, **kwargs):
189 """Dump to a string."""
190
191 def convert_to_dict(cfg_node, key_list):
192 if not isinstance(cfg_node, CfgNode):
193 _assert_with_logging(
194 _valid_type(cfg_node),
195 "Key {} with value {} is not a valid type; valid types: {}".format(
196 ".".join(key_list), type(cfg_node), _VALID_TYPES
197 ),
198 )
199 return cfg_node
200 else:
201 cfg_dict = dict(cfg_node)
202 for k, v in cfg_dict.items():
203 cfg_dict[k] = convert_to_dict(v, key_list + [k])
204 return cfg_dict
205
206 self_as_dict = convert_to_dict(self, [])
207 return yaml.safe_dump(self_as_dict, **kwargs)
208
209 def merge_from_file(self, cfg_filename):
210 """Load a yaml config file and merge it this CfgNode."""

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected