except ImportError: from yaml import SafeLoader, SafeDumper
else:
'tag:yaml.org,2002:str', str(data), style='\'')
for k, v in self._data: yield (k, v)
for k, _ in self._data: yield k
for kv in self._data: if kv[0] == old: kv[0] = new
self._data = [kv for kv in self._data if kv[0] != k]
self._tagname = other._tagname self._data = copy.deepcopy(other._data)
for kv in self._data: if kv[0] == k: kv[1] = v return
self._data.append([k, v])
for kv in self._data: if kv[0] == item: return kv[1]
raise KeyError(item)
if len(args) == 1: return self.__getitem__(args[0]) else: try: return self.__getitem__(args[0]) except KeyError: return args[1]
'!'+data._tagname, data.inamevals_to_save(), flow_style=False)
def dump(*args, **kwargs):
def load(*args, **kwargs):
return load(string=s, *args, **kwargs)
def dump_all(*args, **kwargs): return guts._dump_all(Dumper=AgnosticSafeDumper, *args, **kwargs)
def load_all(*args, **kwargs): return guts._load_all(Loader=AgnosticSafeLoader, *args, **kwargs)
def iload_all(*args, **kwargs): return guts._iload_all(Loader=AgnosticSafeLoader, *args, **kwargs)
yield path, x
if isinstance(x, Object): for (name, val) in x.inamevals(): if isinstance(val, (list, tuple)): for iele, ele in enumerate(val): for y in walk(ele, path=path + ((name, iele),)): yield y elif isinstance(val, dict): for ele_k, ele_v in val.items(): for y in walk(ele_v, path=path + ((name, ele_k),)): yield y else: for y in walk(val, path=path+(name,)): yield y
if isinstance(x, Object): for (name, val) in x.inamevals(): if isinstance(val, (list, tuple)): for iele, ele in enumerate(val): apply_tree(ele, func, path=path + ((name, iele),)) elif isinstance(val, dict): for ele_k, ele_v in val.items(): apply_tree(ele_v, func, path=path + ((name, ele_k),)) else: apply_tree(val, func, path=path+(name,))
func(path, x) |