-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
ENH: Open a notebook from the command line #1686
Conversation
log=self.log, notebook_dir=os.path.dirname(file_to_run)) | ||
else: | ||
self.notebook_manager = NotebookManager(config=self.config, | ||
log=self.log) |
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.
Let's do this differently.
Add self.file_to_run as a traitlet, and add this to the end of parse_command_line:
if self.extra_args:
self.file_to_run = os.path.abspath(self.extra_args[0])
self.config.NotebookManager.notebook_dir = os.path.dirname(self.file_to_run)
Then the block above in init_configurables need not change at all.
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.
Thanks for the comment. Fixed.
How does it behave with non-ipynb-ending files ? |
new=2) | ||
|
||
if len(self.file_to_run) > 0: | ||
filename = os.path.basename(self.file_to_run).split('.ipynb')[0] |
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.
you can use os.path.split(filename)
to return a two-tuple of (base, ext):
filename, _ = os.path.split(os.path.basename(self.file_to_run))
Also, there's no need to check len directly, you can just do: if self.file_to_run:
. The same above for if self.extra_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.
Fixed that.
Agreed, there's no need to check len
, but some people prefer not to use implicit checks. I should've checked the rest of IPython's code to stick to the standard style.
This commit lets you open notebook files from the command line, just like ipython can open (run) python files. For example: ipython notebook foo.ipynb Fixes #945.
@Carreau currently, it just spawns a server in the |
ENH: Open a notebook from the command line open notebook files from the command line, just like ipython can open (run) python files. For example: ipython notebook foo.ipynb closes #945
ENH: Open a notebook from the command line open notebook files from the command line, just like ipython can open (run) python files. For example: ipython notebook foo.ipynb closes ipython#945
This commit lets you open notebook files from the command line, just
like ipython can open (run) python files. For example:
Fixes #945.