-
Notifications
You must be signed in to change notification settings - Fork 382
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
#6697 beakerx commands refactor #6727
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import argparse | ||
import sys | ||
import subprocess | ||
import beakerx | ||
from .install import install, uninstall | ||
from .bkr2ipynb import main | ||
|
||
def install_subparser(subparser): | ||
install_parser = subparser.add_parser('install', help='installs beakerx extension') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. help='installs BeakerX extensions' |
||
install_parser.set_defaults(func = install) | ||
install_parser.add_argument("--prefix", | ||
help="location of the environment to install into", | ||
default=sys.prefix) | ||
return subparser | ||
|
||
def uninstall_subparser(subparser): | ||
uninstall_parser = subparser.add_parser('uninstall', help='uninstalls beakerx extension') | ||
uninstall_parser.set_defaults(func=lambda x : uninstall()) | ||
return subparser | ||
|
||
def bkr2ipynb_subparser(subparser): | ||
bkr2ipynb_parser = subparser.add_parser('bkr2ipynb', help='converts beaker notebooks to ipynb format') | ||
bkr2ipynb_parser.set_defaults(func=main) | ||
bkr2ipynb_parser.add_argument('notebooks', nargs='+', | ||
help="beaker notebooks to be converted. Enter *.bkr in case you want to convert all notebooks at once.") | ||
return subparser | ||
|
||
def init_parser(): | ||
version = 'beakerx %s' % (beakerx.__version__) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. print just the version do not include the name. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Additional context, the Python community standardized the output for versions in PEP 440. Here is what Django does, and notice they reference PEP 440: https://docs.djangoproject.com/en/2.0/ref/django-admin/#determining-the-version I see that my example from MarkUpUpDownDown puts the app name in the version string, so that's my bad for misleading you there. Sorry, @lmitusinski. |
||
|
||
parser = argparse.ArgumentParser() | ||
parser.add_argument('--version', action='version', version=version) | ||
parser.set_defaults(func=lambda x : subprocess.check_call(["jupyter", "notebook"])) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you do it this way, then there are 2 problems:
|
||
|
||
subparsers = parser.add_subparsers() | ||
install_subparser(subparsers) | ||
uninstall_subparser(subparsers) | ||
bkr2ipynb_subparser(subparsers) | ||
return parser | ||
|
||
def parse(): | ||
parser = init_parser() | ||
args = parser.parse_args() | ||
args.func(args) |
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.
banner