Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance filtering and updating for set method #143

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

sygutss
Copy link

@sygutss sygutss commented Apr 1, 2021

  1. Added possibility to filter not only leaves but all dict structures like in search.
    Flag parameter "only_leaves" - by default is True and functionality is off (Backward compatibility)

  2. Added possibility to update dictionaries (works only with "only_leaves" set to False
    and dictionaries nodes). With this flag we can update specified node (dictionary).
    By default is set to False (Backward compatibility)

1. Added possibility to filter not only leaves but all dict structures like in search.
Flag parameter "only_leaves" - by default is True and functionality is off (Backward compatibility)

2. Added possibility to update dictionaries (works only with "only_leaves" set to False
and dictionaries nodes). With this flage we can update specified node (dictionary)
@moomoohk
Copy link
Collaborator

moomoohk commented Dec 4, 2022

@sygutss Hey, are you still interested in working on this PR?

@sygutss
Copy link
Author

sygutss commented Dec 4, 2022

Why not :) I can have a look in the meantime

… feature/set_filter_not_for_leaves_and_update

� Conflicts:
�	dpath/util.py
�	tests/test_util_set.py
@moomoohk
Copy link
Collaborator

moomoohk commented Dec 4, 2022

Awesome! If you have any questions feel free to reach out here or on Gitter.

1. Adjusted to the latest version of master branch.
2. Refactored one method '_split_path' to be more pythonic
and concise
@sygutss
Copy link
Author

sygutss commented Dec 4, 2022

I've adjusted to the latest version of the master branch and refactored one method '_split_path' to be more pythonic
and concise :)

@moomoohk
Copy link
Collaborator

moomoohk commented Dec 4, 2022

Could you please provide some example code to give me a better idea of what this PR proposes?

1. Fixed a small bug under new logic.
2. Provided more self-explained tests.
@sygutss
Copy link
Author

sygutss commented Dec 4, 2022

  1. Found a small bug in my implementation and I've fixed it in the previous commit - right now it should work as expected

  2. I've added tests for that and in the previous commit I've changed a bit them - maybe right now would be clearer what's the purpose of that functionality - Treat them as an example :)

Description:
The main purpose of my enhancement was to provide a possibility to filter not only via values from the last level - the leaves level (basic types under keys) but also from the higher levels - so using the entire objects (dictionaries) from whichever level.

With that approach we can eg. indicate some known levels Eg. "A/B/*" - in that case, are 'A' and 'B' known but the rest is unknown so we use "*". What else, we know that on some level there should be a specific key with some specific value eg. some type. We can filter using a provided function that is able to compare a specific key from the object from some level.

Additionally, I've added the dictionary update possibility instead of the entire replacement during the setting process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants