-
Notifications
You must be signed in to change notification settings - Fork 4
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
Remove use of eval #4
Remove use of eval #4
Conversation
Able to open UI but cannot open files yet
Update error window message so it's more generic
Add new parser so no need to use eval. Add tests for basic interpreter
Change default value for number field from 0 to 1 Add check for number >0 before allowing return OK
…with-zero-elements-creates-ghost-data-in-od Fix ghost data created in OD files if number left as 0 in MapVariableDialog
Correct mistakes in comments
…-from-object-type-record Fix unable to remove sub-indexes from record types
…on 2 Update README to remove python 2 references
Refactor FileDialog for SaveAs to use wxPython recommended implementation Update wildcards for easier selection of OD type
…type-od-without-closing-the-file-and-opening-again Fix filepath not set on SaveAs success
…for python 2" This reverts commit 3d1f1c2.
This paritally reverts commit 377f3bc. Removes refactoring of node.py to remove use of ast methods, reintroduces eval().
Add new parser so no need to use eval. Add tests for basic interpreter
Somewhat messy commit history here, but the diff seems ok, so it'll be ok if we squash it. Please explain the logic of what you've done here
|
Of course. I'll do the necessary updates as soon as I can. The The historic behavior (pre-this-change) would be as follows:
I changed the regex so that it now matches and groups ignoring the
This should mean that the strings in The As the majority of strings passed to this method are just constants (i.e. If it's unable to match the expression then currently this method throws a SyntaxError although potentially another error type should be used. Hopefully this provides some clarity on the implementation. @sveinse One observation I had in the previous PR is that the new .json formatted ODs are directly using the unparsed strings that are contained in maps.py. You can see a simple example of this by generating a new OD. Potentially this should be changed?
|
Add recursive parsing function to help evaluate ast trees Fix unexpected behaviour with EvaluateExpression() resulting in successfully parsing constant strings Improve test completeness for EvaluateExpression and StringFormat methods
@sveinse I've significantly refactored the evaluate expression functions due to finding some issues when building out the tests. The approach now attempts to recursively parse the ast.tree that's generated from the input string. This is a little cleaner and helps handle the wide variety of potential inputs without requiring an extensive set of if statements. I was considering updating all string formatting to new py3 style but as the current .json format includes old style formatting strings I did not want to do this until a decision is made on how to handle them. |
- Fix exceptions for types in EvaluateNode() - Add tests for different ast.Node types
Removes use of unsafe eval() and replaces with a rudimentary interpreter