MCPcopy Create free account
hub / github.com/Paper2Poster/Paper2Poster / object_to_dict

Function object_to_dict

utils/src/utils.py:269–288  ·  view source on GitHub ↗
(obj, result=None, exclude=None)

Source from the content-addressed store, hash-verified

267
268
269def object_to_dict(obj, result=None, exclude=None):
270 if result is None:
271 result = {}
272 exclude = DEFAULT_EXCLUDE.union(exclude or set())
273 for attr in dir(obj):
274 if attr in exclude:
275 continue
276 try:
277 if not attr.startswith("_") and not callable(getattr(obj, attr)):
278 attr_value = getattr(obj, attr)
279 if "real" in dir(attr_value):
280 attr_value = attr_value.real
281 if attr == "size" and isinstance(attr_value, int):
282 attr_value = Length(attr_value).pt
283
284 if is_primitive(attr_value):
285 result[attr] = attr_value
286 except:
287 pass
288 return result
289
290
291def merge_dict(d1: dict, d2: list[dict]):

Callers 2

__init__Method · 0.90
__init__Method · 0.90

Calls 2

is_primitiveFunction · 0.70
unionMethod · 0.45

Tested by

no test coverage detected