MCPcopy Create free account
hub / github.com/cdgriffith/Box / update

Method update

box/box.py:1143–1159  ·  view source on GitHub ↗
(self, *args, **kwargs)

Source from the content-addressed store, hash-verified

1141 return out_dict
1142
1143 def update(self, *args, **kwargs):
1144 if self._box_config["frozen_box"]:
1145 raise BoxError("Box is frozen")
1146 if len(args) > 1:
1147 raise BoxTypeError(f"update expected at most 1 argument, got {len(args)}")
1148 single_arg = next(iter(args), None)
1149 if single_arg is not None:
1150 if hasattr(single_arg, "keys"):
1151 # As dict.update does: by keys(), not by iterating the object, which need not yield its keys
1152 # (a sqlite3.Row yields its values)
1153 for k in single_arg.keys():
1154 self._update_store(k, single_arg[k])
1155 else:
1156 for k, v in single_arg:
1157 self._update_store(k, v)
1158 for k in kwargs:
1159 self._update_store(k, kwargs[k])
1160
1161 def _update_store(self, key, value):
1162 self.__setitem__(key, value)

Calls 4

_update_storeMethod · 0.95
BoxErrorClass · 0.90
BoxTypeErrorClass · 0.90
keysMethod · 0.45