-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduced experimental c.this.dispatch
- Loading branch information
1 parent
fbfc789
commit 7e5b703
Showing
28 changed files
with
1,567 additions
and
1,167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
1,096 changes: 568 additions & 528 deletions
1,096
ci-requirements/py3.9-lint-doc-build/requirements.txt
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
===! "convtools" | ||
```python | ||
from convtools import conversion as c | ||
|
||
|
||
input_data = [ | ||
{"version": "v1", "field1": 10}, | ||
{"version": "v2", "field2": 20}, | ||
{"version": "v3", "field": 30}, | ||
] | ||
|
||
converter = ( | ||
c.iter( | ||
c.this.dispatch( | ||
c.item("version"), | ||
{ | ||
"v1": c.item("field1"), | ||
"v2": c.item("field2"), | ||
}, | ||
default=c.item("field"), | ||
) | ||
) | ||
.as_type(list) | ||
.gen_converter(debug=True) | ||
) | ||
|
||
assert converter(input_data) == [10, 20, 30] | ||
``` | ||
|
||
=== "debug stdout" | ||
```python | ||
def branch(data_): | ||
return data_["field1"] | ||
|
||
def branch_i(data_): | ||
return data_["field2"] | ||
|
||
def branch_else(data_): | ||
return data_["field"] | ||
|
||
def converter(data_, *, __branch_else=__naive_values__["__branch_else"], __v=__naive_values__["__v"]): | ||
try: | ||
return [__v.get(i["version"], __branch_else)(i) for i in data_] | ||
except __exceptions_to_dump_sources: | ||
__convtools__code_storage.dump_sources() | ||
raise | ||
|
||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from convtools import conversion as c | ||
|
||
|
||
input_data = [ | ||
{"version": "v1", "field1": 10}, | ||
{"version": "v2", "field2": 20}, | ||
{"version": "v3", "field": 30}, | ||
] | ||
|
||
converter = ( | ||
c.iter( | ||
c.this.dispatch( | ||
c.item("version"), | ||
{ | ||
"v1": c.item("field1"), | ||
"v2": c.item("field2"), | ||
}, | ||
default=c.item("field"), | ||
) | ||
) | ||
.as_type(list) | ||
.gen_converter(debug=True) | ||
) | ||
|
||
assert converter(input_data) == [10, 20, 30] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
"""Public API.""" | ||
|
||
from ._conversion import conversion # noqa: F401 | ||
from ._dt import DateGrid, DateTimeGrid | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
"""Conversions for slicing iterables into chunks.""" | ||
|
||
import typing as t | ||
|
||
from ._aggregations import Aggregate | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
"""The main module exposing public API.""" | ||
|
||
from itertools import repeat | ||
|
||
from ._aggregations import ( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
"""Cumulative conversions.""" | ||
|
||
import typing as t | ||
from uuid import uuid4 | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
"""Provide conversions which simplify debugging.""" | ||
|
||
import pdb | ||
import sys | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
"""Helpers to collect info about environment.""" | ||
|
||
import sys | ||
|
||
|
||
|
Oops, something went wrong.