-
Notifications
You must be signed in to change notification settings - Fork 91
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
Add ability to select path segments using Python re
regexprs
#146
Conversation
…tests in conformance with options.ALLOW_EMPTY_STRING_KEYS Still required to add tests for regext path segments. Ran tests with Python-3 and Python-2.7 (nose)
Still needed: test and documentation of added functionality
Random test has shown 1 issue not related to new feature, non repeatable suspect binary string with single null byte;documented in issues/nonrepeatableErr.txt.
…ing to diagnostics Cleaned up formatting
…ments Uncontrolled test complexity apparently caused by translation of "***.."" into costly regexp in test framework; now simplified.
…y, test generator coming up with keys interpreted literally when walking tree, but interpreted as a bash glob when matching. See in file issues/err_walk.py. (e.g '[0]' is also a glob meaning '0' ...)
…H_ACCEPT_RE_REGEXP does not break things
…t discovery in nose2)
…if Flake still complains
@AlainLich Hey, are you still interested in working on this PR? |
@moomoohk Hello, I have not touched this for a year and a half, could be interested to work on this PR, likely at a slow pace, since this would facilitate my own use (loading via However, only on Python3... not interested in Python2 compatibility and such. |
That's great to hear :) |
How do you suggest to proceed. I suppose the simpler is for me to pull the latest from branch Please advise. |
Yes indeed. Please start by merging |
How do you suggest to proceed. I suppose the simpler is for me to pull the latest from branch Please advise. |
Hi, I have entered a new PR #177 with revised code integrated in the current commit for branch master. This PR should be closed. |
Hi,
In case there is an interest, this allows to use python
re
regular expressions, like in following examples:I found this useful navigating JSON.
Remarks:
. This runs under Python3 as shown on https://github.com/AlainLich/dpath-python/actions/runs/896380770 ;
. the trickwith
dpath.options.DPATH_ACCEPT_RE_REGEXP
, means the option has to be enabled make this compatiblewith earlier versions and will not break if users have path segments in curly brackets.
WARNING: this will not work under Python2.7, since it requires Python3 features like 'f' strings; however I might
do a compatible version if there is interest.
Changes (most in random tests):
dpath/segments.py
DPATH_ACCEPT_RE_REGEXP
in options as explained abovedpath/util.py
re.compile
extended regexprs once when they are foundunittest
, in particular this permits to select and reproduce a single test functionissues/err_walk.py
where a path segmentgets generated which is interpreted by the bash globbing function resulting in a test failure (e.g. ̀seg[0]
) which is globbed into something accepting
seg0` but not its literal version with the brackets