dashloom 1.1.0__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.

Potentially problematic release.


This version of dashloom might be problematic. Click here for more details.

@@ -0,0 +1,24 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+
7
+ jobs:
8
+ test:
9
+ runs-on: ubuntu-latest
10
+ strategy:
11
+ fail-fast: false
12
+ matrix:
13
+ python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - uses: actions/setup-python@v5
17
+ with:
18
+ python-version: ${{ matrix.python-version }}
19
+ - name: Install
20
+ run: python -m pip install -e ".[dev]"
21
+ - name: Lint
22
+ run: python -m ruff check src tests examples
23
+ - name: Test
24
+ run: python -m pytest
@@ -0,0 +1,14 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .pytest_cache/
4
+ .ruff_cache/
5
+ .mypy_cache/
6
+ .venv/
7
+ venv/
8
+ dist/
9
+ build/
10
+ *.egg-info/
11
+ .coverage
12
+ htmlcov/
13
+ .idea/
14
+ .vscode/
@@ -0,0 +1,12 @@
1
+ # Changelog
2
+
3
+ ## 1.1.0
4
+
5
+ First public release of dashloom.
6
+
7
+ - Integrates pydash 8 and re-exports it as `dashloom.pydash`.
8
+ - Adds a lazy `loom()` / `chain()` pipeline that calls dashloom and pydash.
9
+ - Adds record queries: where, select, join, pivot, paginate, and order.
10
+ - Adds non-destructive deep paths, key recasing, and flatten/unflatten.
11
+ - Adds index-based structural diff and patch.
12
+ - Adds a small schema validator and text, number, retry, and sequence helpers.
dashloom-1.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2016 Michael Beeks <michael.beeks23@proton.me>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,188 @@
1
+ Metadata-Version: 2.5
2
+ Name: dashloom
3
+ Version: 1.1.0
4
+ Summary: Functional essentials woven on pydash: records, paths, diffs, validation, and a lazy chain.
5
+ Author-email: Michael Beeks <michael.beeks23@proton.me>
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Keywords: functional,lodash,pydash,records,utilities,validation
9
+ Classifier: Development Status :: 3 - Alpha
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Topic :: Software Development :: Libraries
20
+ Classifier: Typing :: Typed
21
+ Requires-Python: >=3.10
22
+ Requires-Dist: pydash==5.1.2
23
+ Provides-Extra: dev
24
+ Requires-Dist: pytest>=8.0; extra == 'dev'
25
+ Requires-Dist: ruff>=0.6; extra == 'dev'
26
+ Description-Content-Type: text/markdown
27
+
28
+ # dashloom
29
+
30
+ Functional essentials woven on [pydash](https://pypi.org/project/pydash/). dashloom keeps pydash as the engine for map, filter, deep get, grouping, case conversion, chunking, debounce, and the rest of its API, and adds the record, path, diff, and validation tools that show up in everyday Python.
31
+
32
+ Requires Python 3.10+ and pydash.
33
+
34
+ ## Install
35
+
36
+ After the package is published on PyPI:
37
+
38
+ ```bash
39
+ pip install dashloom
40
+ ```
41
+
42
+ That installs dashloom and its dependency, pydash. It does not install the test tools.
43
+
44
+ ## A chain
45
+
46
+ `loom()` (also available as `chain()`) queues steps and runs them at `value()`. A chain with no seed can be called like a function. Unknown methods are pydash functions, so `sum` reaches `pydash.sum_` and `without` reaches `pydash.without`.
47
+
48
+ ```python
49
+ from dashloom import loom, pydash
50
+
51
+ people = [
52
+ {"name": "Ada", "city": "London", "score": 91},
53
+ {"name": "Grace", "city": "New York", "score": 88},
54
+ {"name": "Lin", "city": "London", "score": 95},
55
+ ]
56
+
57
+ leaders = (
58
+ loom(people)
59
+ .where(city="London")
60
+ .order_by("score", "desc")
61
+ .select("name", "score")
62
+ .value()
63
+ )
64
+ # [{"name": "Lin", "score": 95}, {"name": "Ada", "score": 91}]
65
+
66
+ assert loom().map(lambda n: n * 2).sum()([1, 2, 3]) == 12
67
+ assert pydash.debounce is not None
68
+ ```
69
+
70
+ `set` and `set_` on a chain copy the container. Pass `inplace=True` to mutate. Direct pydash writers are still available on `dashloom.pydash`.
71
+
72
+ ## Records
73
+
74
+ ```python
75
+ from dashloom import join, paginate, pivot, where
76
+
77
+ rows = [
78
+ {"id": 1, "region": "us", "amount": 10},
79
+ {"id": 2, "region": "eu", "amount": 5},
80
+ {"id": 1, "region": "us", "amount": 2},
81
+ ]
82
+ page = paginate(where(rows, region="us"), page=1, per_page=1)
83
+ table = pivot(rows, "region", "id", "amount", agg="sum")
84
+ paired = join(
85
+ [{"id": 1, "name": "Ada"}],
86
+ [{"id": 1, "name": "Admin", "role": "owner"}],
87
+ on="id",
88
+ )
89
+ ```
90
+
91
+ `where`, `order_by`, `group`, `index`, and `unique_by` keep the original row objects. `select`, `rename`, `join`, and `pivot` return new dicts. List order is stable. `None` sort keys stay last. `order_by` accepts `asc`/`desc` and pydash-style booleans (`True` ascending, `False` descending). A leading `-` on a key means descending when orders are omitted.
92
+
93
+ `join` supports `inner`, `left`, `right`, and `full`. Overlapping non-key fields get the suffixes `_x` and `_y`.
94
+
95
+ ## Paths, keys, diff
96
+
97
+ ```python
98
+ from dashloom import coalesce, deep_defaults, diff, flatten_keys, patch, set_, snake_keys
99
+
100
+ profile = {"user": {"name": "Ada"}}
101
+ renamed = set_(profile, "user.roles[0]", "admin") # profile is unchanged
102
+ city = coalesce({"address": {"city": None}, "city": "London"}, "address.city", "city")
103
+ config = deep_defaults({"db": {"host": "local"}}, {"db": {"port": 5432}})
104
+ flat = flatten_keys({"user": {"name": "Ada"}, "tags": ["a"]})
105
+ # {"user.name": "Ada", "tags[0]": "a"}
106
+
107
+ before = {"service": {"retries": 1}}
108
+ after = {"service": {"retries": 3}, "region": "us"}
109
+ assert patch(before, diff(before, after)) == after
110
+
111
+ snake_keys({"userName": {"cityName": "Paris"}})
112
+ ```
113
+
114
+ Paths use dots, list indexes, and quoted keys: `user.name`, `items[0].id`, `["a.b"]`. Dict keys in diff and flatten are strings. Lists are compared by index, so a reorder is a series of replacements. `patch(before, diff(before, after))` rebuilds `after` for dicts, lists, and scalars.
115
+
116
+ `get` returns a stored `None`. The default is used only when the path is missing. `dig` raises `PathError` when the path is missing.
117
+
118
+ ## Validation
119
+
120
+ ```python
121
+ from dashloom import Schema, between, email, integer, required, string
122
+
123
+ account = (
124
+ Schema()
125
+ .field("email", required(), string(), email())
126
+ .field("age", required(), integer(), between(0, 120))
127
+ .field("address.city", string(), required())
128
+ )
129
+ account.assert_valid({"email": "ada@example.com", "age": 36, "address": {"city": "London"}})
130
+ ```
131
+
132
+ Field paths are pydash paths. Every failed rule is reported. `required` rejects a missing path and `None`.
133
+
134
+ ## Text, numbers, calls, sequences
135
+
136
+ ```python
137
+ from dashloom import human_size, mask, parse_duration, retry, slug, window
138
+
139
+ slug("Crème brûlée") # creme-brulee
140
+ mask("secret", keep_start=1, keep_end=1)
141
+ human_size(1536) # 1.5 KiB
142
+ parse_duration("1h30m") # 5400.0
143
+ window([1, 2, 3, 4], 2) # [[1, 2], [2, 3], [3, 4]]
144
+
145
+ @retry(attempts=3, delay=0)
146
+ def load():
147
+ return "ok"
148
+ ```
149
+
150
+ `pluralize` is a regular-English heuristic. `compact` follows pydash and removes every falsey value, including `0` and `""`. `parse_number` accepts currency marks, thousands separators, and parentheses for negatives.
151
+
152
+ ## pydash
153
+
154
+ ```python
155
+ from dashloom import pydash
156
+
157
+ pydash.map_([1, 2, 3], lambda n: n + 1)
158
+ pydash.chain([1, 2, 3, 4]).without(2).value()
159
+ ```
160
+
161
+ `from dashloom import pydash` is the installed pydash package. Use it for debounce, throttle, curry, merge, clone, and the rest of the pydash 8 API. The main pydash module is the supported surface; dashloom calls that, not pydash's private submodules.
162
+
163
+ ## Develop
164
+
165
+ From this folder, install the local source plus pytest and ruff:
166
+
167
+ ```bash
168
+ python -m pip install -e ".[dev]"
169
+ python -m ruff check src tests examples
170
+ python -m pytest
171
+ python examples/quickstart.py
172
+ ```
173
+
174
+ `-e` means editable: Python uses this folder, so edits apply without reinstalling. `.[dev]` is the optional `dev` dependency group in `pyproject.toml`.
175
+
176
+ Build the files that get uploaded to PyPI:
177
+
178
+ ```bash
179
+ python -m pip install build twine
180
+ python -m build
181
+ python -m twine upload dist/*
182
+ ```
183
+
184
+ `python -m build` writes `dist/dashloom-1.1.0.tar.gz` and a wheel. `twine upload` publishes them. After that, other people can run `pip install dashloom`. Uploading needs a PyPI account and an API token.
185
+
186
+ ## License
187
+
188
+ MIT. pydash is a separate project under its own MIT license.
@@ -0,0 +1,161 @@
1
+ # dashloom
2
+
3
+ Functional essentials woven on [pydash](https://pypi.org/project/pydash/). dashloom keeps pydash as the engine for map, filter, deep get, grouping, case conversion, chunking, debounce, and the rest of its API, and adds the record, path, diff, and validation tools that show up in everyday Python.
4
+
5
+ Requires Python 3.10+ and pydash.
6
+
7
+ ## Install
8
+
9
+ After the package is published on PyPI:
10
+
11
+ ```bash
12
+ pip install dashloom
13
+ ```
14
+
15
+ That installs dashloom and its dependency, pydash. It does not install the test tools.
16
+
17
+ ## A chain
18
+
19
+ `loom()` (also available as `chain()`) queues steps and runs them at `value()`. A chain with no seed can be called like a function. Unknown methods are pydash functions, so `sum` reaches `pydash.sum_` and `without` reaches `pydash.without`.
20
+
21
+ ```python
22
+ from dashloom import loom, pydash
23
+
24
+ people = [
25
+ {"name": "Ada", "city": "London", "score": 91},
26
+ {"name": "Grace", "city": "New York", "score": 88},
27
+ {"name": "Lin", "city": "London", "score": 95},
28
+ ]
29
+
30
+ leaders = (
31
+ loom(people)
32
+ .where(city="London")
33
+ .order_by("score", "desc")
34
+ .select("name", "score")
35
+ .value()
36
+ )
37
+ # [{"name": "Lin", "score": 95}, {"name": "Ada", "score": 91}]
38
+
39
+ assert loom().map(lambda n: n * 2).sum()([1, 2, 3]) == 12
40
+ assert pydash.debounce is not None
41
+ ```
42
+
43
+ `set` and `set_` on a chain copy the container. Pass `inplace=True` to mutate. Direct pydash writers are still available on `dashloom.pydash`.
44
+
45
+ ## Records
46
+
47
+ ```python
48
+ from dashloom import join, paginate, pivot, where
49
+
50
+ rows = [
51
+ {"id": 1, "region": "us", "amount": 10},
52
+ {"id": 2, "region": "eu", "amount": 5},
53
+ {"id": 1, "region": "us", "amount": 2},
54
+ ]
55
+ page = paginate(where(rows, region="us"), page=1, per_page=1)
56
+ table = pivot(rows, "region", "id", "amount", agg="sum")
57
+ paired = join(
58
+ [{"id": 1, "name": "Ada"}],
59
+ [{"id": 1, "name": "Admin", "role": "owner"}],
60
+ on="id",
61
+ )
62
+ ```
63
+
64
+ `where`, `order_by`, `group`, `index`, and `unique_by` keep the original row objects. `select`, `rename`, `join`, and `pivot` return new dicts. List order is stable. `None` sort keys stay last. `order_by` accepts `asc`/`desc` and pydash-style booleans (`True` ascending, `False` descending). A leading `-` on a key means descending when orders are omitted.
65
+
66
+ `join` supports `inner`, `left`, `right`, and `full`. Overlapping non-key fields get the suffixes `_x` and `_y`.
67
+
68
+ ## Paths, keys, diff
69
+
70
+ ```python
71
+ from dashloom import coalesce, deep_defaults, diff, flatten_keys, patch, set_, snake_keys
72
+
73
+ profile = {"user": {"name": "Ada"}}
74
+ renamed = set_(profile, "user.roles[0]", "admin") # profile is unchanged
75
+ city = coalesce({"address": {"city": None}, "city": "London"}, "address.city", "city")
76
+ config = deep_defaults({"db": {"host": "local"}}, {"db": {"port": 5432}})
77
+ flat = flatten_keys({"user": {"name": "Ada"}, "tags": ["a"]})
78
+ # {"user.name": "Ada", "tags[0]": "a"}
79
+
80
+ before = {"service": {"retries": 1}}
81
+ after = {"service": {"retries": 3}, "region": "us"}
82
+ assert patch(before, diff(before, after)) == after
83
+
84
+ snake_keys({"userName": {"cityName": "Paris"}})
85
+ ```
86
+
87
+ Paths use dots, list indexes, and quoted keys: `user.name`, `items[0].id`, `["a.b"]`. Dict keys in diff and flatten are strings. Lists are compared by index, so a reorder is a series of replacements. `patch(before, diff(before, after))` rebuilds `after` for dicts, lists, and scalars.
88
+
89
+ `get` returns a stored `None`. The default is used only when the path is missing. `dig` raises `PathError` when the path is missing.
90
+
91
+ ## Validation
92
+
93
+ ```python
94
+ from dashloom import Schema, between, email, integer, required, string
95
+
96
+ account = (
97
+ Schema()
98
+ .field("email", required(), string(), email())
99
+ .field("age", required(), integer(), between(0, 120))
100
+ .field("address.city", string(), required())
101
+ )
102
+ account.assert_valid({"email": "ada@example.com", "age": 36, "address": {"city": "London"}})
103
+ ```
104
+
105
+ Field paths are pydash paths. Every failed rule is reported. `required` rejects a missing path and `None`.
106
+
107
+ ## Text, numbers, calls, sequences
108
+
109
+ ```python
110
+ from dashloom import human_size, mask, parse_duration, retry, slug, window
111
+
112
+ slug("Crème brûlée") # creme-brulee
113
+ mask("secret", keep_start=1, keep_end=1)
114
+ human_size(1536) # 1.5 KiB
115
+ parse_duration("1h30m") # 5400.0
116
+ window([1, 2, 3, 4], 2) # [[1, 2], [2, 3], [3, 4]]
117
+
118
+ @retry(attempts=3, delay=0)
119
+ def load():
120
+ return "ok"
121
+ ```
122
+
123
+ `pluralize` is a regular-English heuristic. `compact` follows pydash and removes every falsey value, including `0` and `""`. `parse_number` accepts currency marks, thousands separators, and parentheses for negatives.
124
+
125
+ ## pydash
126
+
127
+ ```python
128
+ from dashloom import pydash
129
+
130
+ pydash.map_([1, 2, 3], lambda n: n + 1)
131
+ pydash.chain([1, 2, 3, 4]).without(2).value()
132
+ ```
133
+
134
+ `from dashloom import pydash` is the installed pydash package. Use it for debounce, throttle, curry, merge, clone, and the rest of the pydash 8 API. The main pydash module is the supported surface; dashloom calls that, not pydash's private submodules.
135
+
136
+ ## Develop
137
+
138
+ From this folder, install the local source plus pytest and ruff:
139
+
140
+ ```bash
141
+ python -m pip install -e ".[dev]"
142
+ python -m ruff check src tests examples
143
+ python -m pytest
144
+ python examples/quickstart.py
145
+ ```
146
+
147
+ `-e` means editable: Python uses this folder, so edits apply without reinstalling. `.[dev]` is the optional `dev` dependency group in `pyproject.toml`.
148
+
149
+ Build the files that get uploaded to PyPI:
150
+
151
+ ```bash
152
+ python -m pip install build twine
153
+ python -m build
154
+ python -m twine upload dist/*
155
+ ```
156
+
157
+ `python -m build` writes `dist/dashloom-1.1.0.tar.gz` and a wheel. `twine upload` publishes them. After that, other people can run `pip install dashloom`. Uploading needs a PyPI account and an API token.
158
+
159
+ ## License
160
+
161
+ MIT. pydash is a separate project under its own MIT license.
@@ -0,0 +1,45 @@
1
+ """Run a short dashloom workflow."""
2
+
3
+ from dashloom import Schema, between, diff, email, integer, loom, patch, required, string
4
+
5
+
6
+ def london_leaders():
7
+ people = [
8
+ {"name": "Ada", "city": "London", "score": 91},
9
+ {"name": "Grace", "city": "New York", "score": 88},
10
+ {"name": "Lin", "city": "London", "score": 95},
11
+ ]
12
+ return (
13
+ loom(people)
14
+ .where(city="London")
15
+ .order_by("score", "desc")
16
+ .select("name", "score")
17
+ .value()
18
+ )
19
+
20
+
21
+ def promote_retries():
22
+ before = {"service": {"retries": 1, "name": "billing"}}
23
+ after = {"service": {"retries": 3, "name": "billing"}, "region": "us"}
24
+ return patch(before, diff(before, after))
25
+
26
+
27
+ def account_schema():
28
+ return (
29
+ Schema()
30
+ .field("email", required(), string(), email())
31
+ .field("age", required(), integer(), between(0, 120))
32
+ )
33
+
34
+
35
+ def main() -> None:
36
+ leaders = london_leaders()
37
+ updated = promote_retries()
38
+ schema = account_schema()
39
+ print(leaders)
40
+ print(updated)
41
+ print(schema.is_valid({"email": "ada@example.com", "age": 36}))
42
+
43
+
44
+ if __name__ == "__main__":
45
+ main()
@@ -0,0 +1,56 @@
1
+ [build-system]
2
+ requires = ["hatchling"]
3
+ build-backend = "hatchling.build"
4
+
5
+ [project]
6
+ name = "dashloom"
7
+ dynamic = ["version"]
8
+ description = "Functional essentials woven on pydash: records, paths, diffs, validation, and a lazy chain."
9
+ readme = "README.md"
10
+ license = "MIT"
11
+ requires-python = ">=3.10"
12
+ authors = [{ name = "Michael Beeks", email = "michael.beeks23@proton.me" }]
13
+ keywords = [
14
+ "pydash",
15
+ "lodash",
16
+ "functional",
17
+ "utilities",
18
+ "records",
19
+ "validation",
20
+ ]
21
+ classifiers = [
22
+ "Development Status :: 3 - Alpha",
23
+ "Intended Audience :: Developers",
24
+ "License :: OSI Approved :: MIT License",
25
+ "Operating System :: OS Independent",
26
+ "Programming Language :: Python :: 3",
27
+ "Programming Language :: Python :: 3.10",
28
+ "Programming Language :: Python :: 3.11",
29
+ "Programming Language :: Python :: 3.12",
30
+ "Programming Language :: Python :: 3.13",
31
+ "Programming Language :: Python :: 3.14",
32
+ "Topic :: Software Development :: Libraries",
33
+ "Typing :: Typed",
34
+ ]
35
+ dependencies = ["pydash==5.1.2"]
36
+
37
+ [project.optional-dependencies]
38
+ dev = ["pytest>=8.0", "ruff>=0.6"]
39
+
40
+ [tool.hatch.version]
41
+ path = "src/dashloom/__init__.py"
42
+
43
+ [tool.pytest.ini_options]
44
+ testpaths = ["tests"]
45
+ addopts = "-q"
46
+
47
+ [tool.ruff]
48
+ line-length = 100
49
+ target-version = "py310"
50
+ src = ["src", "tests"]
51
+
52
+ [tool.ruff.lint]
53
+ select = ["E", "F", "I", "UP"]
54
+
55
+ [tool.ruff.lint.isort]
56
+ known-first-party = ["dashloom"]