-
Notifications
You must be signed in to change notification settings - Fork 10
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
sedsed as a Python module #9
Comments
I believe this has been done, and released on PyPI as 1.1dev0 It would be good to have a final 1.1 release, with tests included in the sdist. I was trying to build a rpm of it at https://build.opensuse.org/package/show/home:jayvdb:py-new/python-sedsed |
Hi @jayvdb, unfortunately, this work is still pending. Currently sedsed works only from the command line. If you try to import it, an error is shown since it will try to execute and parse something: >>> import sedsed
ERROR: there's no SED script to parse! (try --help) And the worst is that a |
Before: >>> import sedsed ERROR: there's no SED script to parse! (try --help) # interactive prompt aborted (sys.exit()) Now: >>> import sedsed >>> This is only a first step. The code is still not very friendly to be used as a module.
Done |
Previous to this change, some code was being executed bare in the global scope, unprotected by the `if __name__ == "__main__"` clause. In this "light" refactor I tried to keep the same logic, but isolating code into functions that set the usual global variables (they are still there, getting rid of them is a task for the future). All the global variables are now defined at the top, then come all the functions, then come the `if main` clause, where the command line parsing and sed script validation now occurs. The new functions: - parse_command_line() - set_debug_commands() - set_colors() Now the code is more friendly to be used as a Python module, and all of this was a necessary step to have (in following commits) an entrypoint and create the pypi package.
Besides being run from the command line, sedsed should also be importable as a Python module.
This will enable unit tests on classes/methods and the emulator could be used inside Python programs.
The text was updated successfully, but these errors were encountered: