typedparser 0.6.1__tar.gz → 0.6.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {typedparser-0.6.1 → typedparser-0.6.3}/PKG-INFO +1 -1
- {typedparser-0.6.1 → typedparser-0.6.3}/src/typedparser/__init__.py +1 -1
- {typedparser-0.6.1 → typedparser-0.6.3}/src/typedparser/objects.py +22 -0
- {typedparser-0.6.1 → typedparser-0.6.3}/src/typedparser.egg-info/PKG-INFO +1 -1
- {typedparser-0.6.1 → typedparser-0.6.3}/LICENSE +0 -0
- {typedparser-0.6.1 → typedparser-0.6.3}/README.md +0 -0
- {typedparser-0.6.1 → typedparser-0.6.3}/pyproject.toml +0 -0
- {typedparser-0.6.1 → typedparser-0.6.3}/requirements.txt +0 -0
- {typedparser-0.6.1 → typedparser-0.6.3}/setup.cfg +0 -0
- {typedparser-0.6.1 → typedparser-0.6.3}/src/typedparser/_typedattr.py +0 -0
- {typedparser-0.6.1 → typedparser-0.6.3}/src/typedparser/_typedparser.py +0 -0
- {typedparser-0.6.1 → typedparser-0.6.3}/src/typedparser/custom_format.py +0 -0
- {typedparser-0.6.1 → typedparser-0.6.3}/src/typedparser/funcs.py +0 -0
- {typedparser-0.6.1 → typedparser-0.6.3}/src/typedparser.egg-info/SOURCES.txt +0 -0
- {typedparser-0.6.1 → typedparser-0.6.3}/src/typedparser.egg-info/dependency_links.txt +0 -0
- {typedparser-0.6.1 → typedparser-0.6.3}/src/typedparser.egg-info/requires.txt +0 -0
- {typedparser-0.6.1 → typedparser-0.6.3}/src/typedparser.egg-info/top_level.txt +0 -0
- {typedparser-0.6.1 → typedparser-0.6.3}/src/typedparser.egg-info/zip-safe +0 -0
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"""
|
|
2
2
|
Generic utilities for python objects
|
|
3
3
|
"""
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
4
6
|
from abc import ABCMeta, abstractmethod
|
|
5
7
|
from collections.abc import Mapping, Iterable
|
|
6
8
|
from copy import deepcopy
|
|
@@ -312,3 +314,23 @@ def big_obj_to_short_str(d: Any) -> str:
|
|
|
312
314
|
return f"{class_name} len {len(d)}"
|
|
313
315
|
except TypeError:
|
|
314
316
|
return f"Object of type {class_name}"
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
def invert_dictionary(inv_dict: dict[str, dict[str, any]]) -> dict[str, dict[str, any]]:
|
|
320
|
+
"""
|
|
321
|
+
Invert a dictionary of dictionaries. Useful for creating dataframes.
|
|
322
|
+
|
|
323
|
+
Args:
|
|
324
|
+
inv_dict: dictionary of {key1: {field1: value1, field2: value2, ...}, ...}
|
|
325
|
+
|
|
326
|
+
Returns:
|
|
327
|
+
Dictionary of {field1: {key1: value1, key2: value2, ...}, ...}
|
|
328
|
+
|
|
329
|
+
"""
|
|
330
|
+
regular_dict = {}
|
|
331
|
+
for key, value_dict in inv_dict.items():
|
|
332
|
+
for field, value in value_dict.items():
|
|
333
|
+
if field not in regular_dict:
|
|
334
|
+
regular_dict[field] = {}
|
|
335
|
+
regular_dict[field][key] = value
|
|
336
|
+
return regular_dict
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|