-
Notifications
You must be signed in to change notification settings - Fork 124
Switch parsing logic from pyparsing to shlex #370
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
Conversation
… not the redirection
# Conflicts: # setup.py
Miles to go, but the new parser is partially grafted in to cmd2, and the mumble command from example.py works.
|
Aliases worked fine, but shortcuts nested in aliases didn't get expanded properly. Fixed, with some new unit tests to ensure it works in the future. |
tleonhardt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aliases are now working fine for me. Thanks!
| re.DOTALL | re.MULTILINE | ||
| ) | ||
|
|
||
| # aliases have to be a word, so make a regular expression |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aliases now work great
Changes include:
- Removed support for versions of setuptools prior to 18.0 (dating to early 2015)
- This removed some extra logic related to conditional dependencies and simplified the imports
- Added a python_requires statement to require Python 3.4 or newer
- I believe this requires setuptools >= 34.4
| ":python_version<'3.5'": ['contextlib2', 'typing'], | ||
| } | ||
|
|
||
| if int(setuptools.__version__.split('.')[0]) < 18: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kotfu
setuptools 18 dates back to early/mid 2015, so I don't think we really need to worry about people using a version prior to this. If you think I'm off-base, please feel free to revert this.
I probably should have put this on master, but you made some changes to this file as well so I didn't want to create any conflicts.
| platforms=['any'], | ||
| packages=['cmd2'], | ||
| keywords='command prompt console cmd', | ||
| python_requires='>=3.4', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I figure we need some way of ensuring nobody tries to install the new version of cmd2 on older un-supported versions of Python. If we can make the assumption that people will have a pretty new version of setuptools >= 34.4 then this is a really easy way. If we think it isn't wise to make that assumption, then we could remove this and do something more like:
import sys
if sys.version_info < (3,4):
sys.exit('Sorry, Python < 3.4 is not supported by this version of cmd2. Install cmd2 0.8.x instead')|
@kotfu Would you be OK with deleting the TODO file in this PR, opening a new Issue for the refactoring that should be done in relation to this PR, and then merging this PR in as-is? I think that might be the least painful path forward. |
|
I tested merges between bash_completion and pyscript as well as between ply and pyscript and both resulted in very minor merge conflicts that were easy to resolve. The main conflict is between the bash_completion and ply branches because I got rid of imports in The bulk of the changes in both the bash_completion and pyscript branches are in new files. We can probably opt to favor the changes in the ply branch for most of the conflicting changes in the examples and tests. |
|
@anselor |
|
I tried first merging bash_completion then pyscript and something went wonky and a bunch of unit tests failed. I tried merging pyscript then bash_completion into master and all of the tests pass. |
|
Ok, both bash_completion and pyscript are merged into master. I've also merged the result of that into ply and got the unit tests passing again. @kotfu please take a look and make sure I didn't jack up your changes. |
|
@anselor Thanks for doing all the hard work to get these three branches to merge. My review and testing of the merged code looks good. I'm going to merge ply into master. |
When I created this branch, I thought we should use
plyto parse user input. After struggling to make it happen, I switched toshlex, and it worked out much better. It's a pain to rename branches, so I didn't.This PR switches the parsing engine from
pyparsingtoshlexas described in #37, which reduced the time required to run the test suite by more than 3 orders of magnitude, resolving issue #287. I also removed POSIX_SHLEX and STRIP_QUOTES_FOR_NON_POSIX to close #327.There are a few items remaining before this PR should be merged:
complete()to useStatementParser.parse()instead ofparseline(). We may need to create a new method inStatementParserto get the desired behavior, because tab completion needs to work even if there are current syntax errors in the line of user input.parseline()to useStatementParser.parse()pytest-xdistandpytest-forkedfrom tox.ini for running the unit testspytest-xdistandpytest-forkedDue to the extensive nature of these changes, I welcome any additional manual testing that anyone is able to do.