xonsh.lib.collections

Base class for chaining DBs

class xonsh.lib.collections.ChainDB(*maps)[source]

A ChainMap who’s _getitem__ returns either a ChainDB or the result. The results resolve to the outermost mapping.

Initialize a ChainMap by setting maps to the given mappings. If no mappings are provided, a single empty dictionary is used.

clear()

Clear maps[0], leaving maps[1:] intact.

copy()

New ChainMap or subclass with a new copy of maps[0] and refs to maps[1:]

classmethod fromkeys(iterable, *args)

Create a ChainMap with a single dict created from the iterable.

get(k[, d]) D[k] if k in D, else d.  d defaults to None.
items() a set-like object providing a view on D's items
keys() a set-like object providing a view on D's keys
new_child(m=None, **kwargs)

New ChainMap with a new map followed by all previous maps. If no map is provided, an empty dict is used. Keyword arguments update the map or new empty dict.

pop(key, *args)

Remove key from maps[0] and return its value. Raise KeyError if key not in maps[0].

popitem()

Remove and return an item pair from maps[0]. Raise KeyError is maps[0] is empty.

setdefault(k[, d]) D.get(k,d), also set D[k]=d if k not in D
update([E, ]**F) None.  Update D from mapping/iterable E and F.

If E present and has a .keys() method, does: for k in E: D[k] = E[k] If E present and lacks .keys() method, does: for (k, v) in E: D[k] = v In either case, this is followed by: for k, v in F.items(): D[k] = v

values() an object providing a view on D's values
property parents

New ChainMap from maps[1:].

class xonsh.lib.collections.ChainDBDefaultType[source]

Singleton for representing when no default value is given.