-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(addSlices): serialize slicedata
AddSlices wasn't serializing the slicedata it was sending up.
- Loading branch information
Showing
3 changed files
with
42 additions
and
1 deletion.
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
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,36 @@ | ||
""" | ||
addSlices API | ||
Author: Will Pringle <[email protected]> | ||
Date: September 2024 | ||
""" | ||
|
||
import pythonmonkey as pm | ||
from .. import dry | ||
from .. import js | ||
from .job_serializers import default_serializers, serialize | ||
|
||
def add_slices_maker(add_slices_js): | ||
def is_iterable(maybe_iterable): | ||
try: | ||
iter(maybe_iterable) | ||
return True | ||
except TypeError: | ||
return False | ||
|
||
def add_slices(*args, serializers=default_serializers): | ||
new_args = [] | ||
|
||
for arg in args: | ||
if not isinstance(arg, str) and is_iterable(arg): | ||
serialized_vals = [] | ||
for val in arg: | ||
serialized_vals.append(serialize(val, serializers)) | ||
new_args.append(serialized_vals) | ||
else: | ||
new_args.append(arg) | ||
|
||
js_val = dry.aio.blockify(add_slices_js)(*new_args) | ||
|
||
return js_val | ||
return add_slices |
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