Add ability to select path segments using Python re regexprs#146
Add ability to select path segments using Python re regexprs#146AlainLich wants to merge 14 commits intodpath-maintainers:masterfrom
re regexprs#146Conversation
…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
reregular 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.pyDPATH_ACCEPT_RE_REGEXPin options as explained abovedpath/util.pyre.compileextended regexprs once when they are foundunittest, in particular this permits to select and reproduce a single test functionissues/err_walk.pywhere 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 acceptingseg0` but not its literal version with the brackets