Skip to content

Commit

Permalink
more stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasborgen committed Dec 26, 2021
1 parent 673f8cb commit c07636c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 28 deletions.
2 changes: 1 addition & 1 deletion kaiba/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ def apply_separator(


def apply_slicing(
value_to_slice: Optional[Any],
value_to_slice: Any,
slicing: Slicing,
) -> Optional[AnyType]:
"""Slice value from index to index.
Expand Down
31 changes: 4 additions & 27 deletions kaiba/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ def handle_data_fetcher(
if produced_value and cfg.regex:
produced_value = unsafe_apply_regex(produced_value, regex=cfg.regex)

produced_value = apply_slicing(produced_value, cfg.slicing)
if produced_value and cfg.slicing:
produced_value = apply_slicing(produced_value, cfg.slicing)

produced_value = unsafe_apply_if_statements(
produced_value,
Expand All @@ -65,35 +66,11 @@ def handle_data_fetcher(
cfg.default,
)

# just return the modals so tests will still work.
if produced_value:
return Success(produced_value)

return Failure('Failed to produce a value')


# return produced_value


return flow(
collection,
partial(fetch_data_by_keys, path=cfg.path),
fix(lambda _: None), # type: ignore
bind(
partial(
apply_regex, regex=cfg.regex,
),
),
fix(lambda _: None), # type: ignore
map_(partial(
apply_slicing, slicing=cfg.slicing,
)),
bind(partial(
apply_if_statements, statements=cfg.if_statements,
)),
rescue( # type: ignore
lambda _: apply_default(cfg.default),
),
)
return Failure(ValueError('Failed to produce a value'))


def handle_attribute(
Expand Down

0 comments on commit c07636c

Please sign in to comment.