dotted-notation 0.49.3__cp315-cp315-win_amd64.whl
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.
- dotted/__init__.py +105 -0
- dotted/__main__.py +7 -0
- dotted/access.c +101933 -0
- dotted/access.cp315-win_amd64.pyd +0 -0
- dotted/access.pxd +57 -0
- dotted/access.py +1199 -0
- dotted/api.c +53248 -0
- dotted/api.cp315-win_amd64.pyd +0 -0
- dotted/api.py +1390 -0
- dotted/base.c +47800 -0
- dotted/base.cp315-win_amd64.pyd +0 -0
- dotted/base.pxd +77 -0
- dotted/base.py +623 -0
- dotted/cli/__init__.py +0 -0
- dotted/cli/_compat.py +52 -0
- dotted/cli/formats.py +419 -0
- dotted/cli/main.py +347 -0
- dotted/containers.c +59206 -0
- dotted/containers.cp315-win_amd64.pyd +0 -0
- dotted/containers.py +1025 -0
- dotted/engine.c +22512 -0
- dotted/engine.cp315-win_amd64.pyd +0 -0
- dotted/engine.pxd +18 -0
- dotted/engine.py +238 -0
- dotted/filters.c +68727 -0
- dotted/filters.cp315-win_amd64.pyd +0 -0
- dotted/filters.pxd +60 -0
- dotted/filters.py +716 -0
- dotted/grammar.py +1182 -0
- dotted/groups.c +69177 -0
- dotted/groups.cp315-win_amd64.pyd +0 -0
- dotted/groups.pxd +34 -0
- dotted/groups.py +1011 -0
- dotted/matchers.c +59317 -0
- dotted/matchers.cp315-win_amd64.pyd +0 -0
- dotted/matchers.pxd +87 -0
- dotted/matchers.py +580 -0
- dotted/native.py +59 -0
- dotted/predicates.c +19950 -0
- dotted/predicates.cp315-win_amd64.pyd +0 -0
- dotted/predicates.py +174 -0
- dotted/recursive.c +41952 -0
- dotted/recursive.cp315-win_amd64.pyd +0 -0
- dotted/recursive.pxd +24 -0
- dotted/recursive.py +486 -0
- dotted/results.c +31573 -0
- dotted/results.cp315-win_amd64.pyd +0 -0
- dotted/results.py +327 -0
- dotted/sql/__init__.py +51 -0
- dotted/sql/core.py +807 -0
- dotted/sql/pg.py +1040 -0
- dotted/transforms.c +26600 -0
- dotted/transforms.cp315-win_amd64.pyd +0 -0
- dotted/transforms.py +587 -0
- dotted/utils.c +15239 -0
- dotted/utils.cp315-win_amd64.pyd +0 -0
- dotted/utils.py +153 -0
- dotted/utypes.c +12768 -0
- dotted/utypes.cp315-win_amd64.pyd +0 -0
- dotted/utypes.py +58 -0
- dotted/wrappers.c +65635 -0
- dotted/wrappers.cp315-win_amd64.pyd +0 -0
- dotted/wrappers.pxd +27 -0
- dotted/wrappers.py +816 -0
- dotted_notation-0.49.3.dist-info/METADATA +3981 -0
- dotted_notation-0.49.3.dist-info/RECORD +70 -0
- dotted_notation-0.49.3.dist-info/WHEEL +5 -0
- dotted_notation-0.49.3.dist-info/entry_points.txt +2 -0
- dotted_notation-0.49.3.dist-info/licenses/LICENSE +21 -0
- dotted_notation-0.49.3.dist-info/top_level.txt +1 -0
dotted/__init__.py
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Dotted notation for safe nested data traversal with optional chaining,
|
|
3
|
+
pattern matching, and transforms.
|
|
4
|
+
|
|
5
|
+
Missing keys and attributes are handled gracefully—no KeyError or AttributeError.
|
|
6
|
+
Use dotted to fetch, update, and remove data from deeply nested structures.
|
|
7
|
+
|
|
8
|
+
>>> import dotted
|
|
9
|
+
>>> d = {'hi': {'there': [1, 2, 3]}}
|
|
10
|
+
>>> dotted.get(d, 'hi.there[1]')
|
|
11
|
+
2
|
|
12
|
+
|
|
13
|
+
Core Operations
|
|
14
|
+
---------------
|
|
15
|
+
get(obj, path) Get value at dotted path
|
|
16
|
+
update(obj, path, val) Update value at dotted path
|
|
17
|
+
remove(obj, path) Remove value at dotted path
|
|
18
|
+
has(obj, path) Check if path exists
|
|
19
|
+
setdefault(obj, p, v) Set value only if path missing
|
|
20
|
+
is_mutable(obj, path) Check if update would mutate in place
|
|
21
|
+
|
|
22
|
+
Pattern Matching
|
|
23
|
+
----------------
|
|
24
|
+
match(pattern, path) Match pattern to path
|
|
25
|
+
replace(template, bind) Substitute $N in template path
|
|
26
|
+
expand(obj, pattern) Expand pattern to concrete paths
|
|
27
|
+
|
|
28
|
+
Building & Plucking
|
|
29
|
+
-------------------
|
|
30
|
+
build(obj, path) Build default structure for path
|
|
31
|
+
pack(pathvalues) Build object from path-value pairs
|
|
32
|
+
pluck(obj, pattern) Extract (path, value) pairs
|
|
33
|
+
walk(obj, pattern) Yield (path, value) pairs (lazy)
|
|
34
|
+
unpack(obj) Extract to dotted normal form
|
|
35
|
+
keys(obj) Dotted paths of obj
|
|
36
|
+
values(obj) Leaf values of obj
|
|
37
|
+
items(obj) (path, value) pairs as dict_items view
|
|
38
|
+
|
|
39
|
+
Transforms
|
|
40
|
+
----------
|
|
41
|
+
Append transforms with |: 'field|int', 'field|str:fmt'
|
|
42
|
+
|
|
43
|
+
>>> dotted.get({'n': '42'}, 'n|int')
|
|
44
|
+
42
|
|
45
|
+
|
|
46
|
+
register(name, fn) Register custom transform
|
|
47
|
+
transform(name) Decorator for custom transforms
|
|
48
|
+
|
|
49
|
+
Constants
|
|
50
|
+
---------
|
|
51
|
+
ANY Match any value (for remove)
|
|
52
|
+
AUTO Auto-infer root container type ({} or []) from first path
|
|
53
|
+
|
|
54
|
+
For full documentation including all options and flags:
|
|
55
|
+
$ pydoc dotted.api
|
|
56
|
+
or see README.md
|
|
57
|
+
"""
|
|
58
|
+
from . import native
|
|
59
|
+
|
|
60
|
+
# before anything else of dotted's is imported: see dotted.native
|
|
61
|
+
if not native.wanted():
|
|
62
|
+
native.use_source()
|
|
63
|
+
|
|
64
|
+
from .api import \
|
|
65
|
+
parse, compile, is_pattern, is_template, is_reference, is_indeterminate, is_simple, \
|
|
66
|
+
is_inverted, is_mutable, mutable, quote, ANY, AUTO, Attrs, GroupMode, \
|
|
67
|
+
set_simple_fastpath, set_parse_cache, \
|
|
68
|
+
register, transform, set_resolver, get_resolver, \
|
|
69
|
+
assemble, assemble_multi, \
|
|
70
|
+
build, build_multi, \
|
|
71
|
+
expand, expand_multi, \
|
|
72
|
+
match, match_multi, replace, overlaps, translate, translate_multi, \
|
|
73
|
+
apply, apply_multi, \
|
|
74
|
+
get, get_multi, \
|
|
75
|
+
has, setdefault, setdefault_multi, \
|
|
76
|
+
update, update_multi, pack, update_if, update_if_multi, \
|
|
77
|
+
remove, remove_multi, remove_if, remove_if_multi, \
|
|
78
|
+
pluck, pluck_multi, walk, walk_multi, unpack, keys, values, items
|
|
79
|
+
from .sql import sqlize, TranslationError, SQLFragment, Resolver, ParamStyle, ParamPool
|
|
80
|
+
# the run-time reference resolver; sqlize's Resolver, above, has the plain name
|
|
81
|
+
from .base import Resolver as ReferenceResolver, UnresolvedReference
|
|
82
|
+
|
|
83
|
+
__all__ = [
|
|
84
|
+
# Core
|
|
85
|
+
'get', 'update', 'remove', 'has', 'setdefault',
|
|
86
|
+
'ReferenceResolver', 'UnresolvedReference', 'set_resolver', 'get_resolver',
|
|
87
|
+
# Multi
|
|
88
|
+
'get_multi', 'update_multi', 'pack', 'update_if', 'update_if_multi', 'remove_multi', 'remove_if', 'remove_if_multi', 'setdefault_multi',
|
|
89
|
+
# Pattern
|
|
90
|
+
'match', 'match_multi', 'replace', 'overlaps', 'translate', 'translate_multi', 'expand', 'expand_multi',
|
|
91
|
+
# Build/Pluck
|
|
92
|
+
'build', 'build_multi', 'pluck', 'pluck_multi', 'walk', 'walk_multi', 'unpack', 'keys', 'values', 'items',
|
|
93
|
+
# Transform
|
|
94
|
+
'apply', 'apply_multi', 'register', 'transform',
|
|
95
|
+
# Utility
|
|
96
|
+
'parse', 'compile', 'assemble', 'assemble_multi', 'quote',
|
|
97
|
+
'is_pattern', 'is_template', 'is_reference',
|
|
98
|
+
'is_indeterminate', 'is_simple',
|
|
99
|
+
'is_inverted', 'is_mutable', 'mutable',
|
|
100
|
+
'set_simple_fastpath', 'set_parse_cache',
|
|
101
|
+
# SQL
|
|
102
|
+
'sqlize', 'Resolver', 'SQLFragment', 'ParamStyle', 'ParamPool', 'TranslationError',
|
|
103
|
+
# Constants
|
|
104
|
+
'ANY', 'AUTO', 'Attrs', 'GroupMode',
|
|
105
|
+
]
|