# nci_ipynb
This work was inspired from [ipynbname](https://pypi.org/project/ipynbname).
When run in a Jupyter notebook, simply returns the notebook filename or the full path to the notebook.
I created this to help with automating posting blog posts written in Jupyter notebooks directly to
GitHub Pages.
You would think there was already some built-in way to access the current notebook name, but it took many hours
of searching for a way to do it. As it seems many others did, I tried using Javascript, but the async nature of
JS meant that it was unreliable. Finally I stumbled on this [post](https://forums.fast.ai/t/jupyter-notebook-enhancements-tips-and-tricks/17064/39).
I have refactored the code there so a user can get either the name or path, but credit for most of the code
goes to the author of this post, thanks!
## Examples
Get the notebook name:
```python
import nci_ipynb
nb_fname = nci_ipynb.name()
```
Get the full path to the notebook:
```python
import nci_ipynb
nb_path = nci_ipynb.path()
```
Get the root directory to the notebook:
```python
import nci_ipynb
nb_path = nci_ipynb.dir()
```
## Limitations
Note that this only reliably works when running a notebook in a browser. So it does not currently work for things like nbconvert or papermill.
For VS Code there is a [workaround](https://github.com/msm1089/ipynbname/issues/17#issuecomment-1293269863).
Raw data
{
"_id": null,
"home_page": "https://github.com/nci/nci_ipynb",
"name": "nci-ipynb",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.4",
"maintainer_email": "",
"keywords": "jupyter,notebook,filename",
"author": "Edison Guo",
"author_email": "edison.guo@anu.edu.au",
"download_url": "https://files.pythonhosted.org/packages/85/1b/2451e64d5f3310a7649fd9093f123f1a9604011c9baae065c7f0af72cd04/nci_ipynb-2023.11.0.3.tar.gz",
"platform": null,
"description": "# nci_ipynb\n\nThis work was inspired from [ipynbname](https://pypi.org/project/ipynbname).\n\nWhen run in a Jupyter notebook, simply returns the notebook filename or the full path to the notebook.\nI created this to help with automating posting blog posts written in Jupyter notebooks directly to\nGitHub Pages.\n\nYou would think there was already some built-in way to access the current notebook name, but it took many hours\nof searching for a way to do it. As it seems many others did, I tried using Javascript, but the async nature of\nJS meant that it was unreliable. Finally I stumbled on this [post](https://forums.fast.ai/t/jupyter-notebook-enhancements-tips-and-tricks/17064/39).\nI have refactored the code there so a user can get either the name or path, but credit for most of the code\ngoes to the author of this post, thanks!\n\n## Examples\n\nGet the notebook name:\n\n```python\nimport nci_ipynb\nnb_fname = nci_ipynb.name()\n```\n\nGet the full path to the notebook:\n\n```python\nimport nci_ipynb\nnb_path = nci_ipynb.path()\n```\n\nGet the root directory to the notebook:\n\n```python\nimport nci_ipynb\nnb_path = nci_ipynb.dir()\n```\n\n## Limitations\n\nNote that this only reliably works when running a notebook in a browser. So it does not currently work for things like nbconvert or papermill.\n\nFor VS Code there is a [workaround](https://github.com/msm1089/ipynbname/issues/17#issuecomment-1293269863).\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Simply returns either notebook filename or the full path to the notebook when run from Jupyter notebook in browser.",
"version": "2023.11.0.3",
"project_urls": {
"Homepage": "https://github.com/nci/nci_ipynb"
},
"split_keywords": [
"jupyter",
"notebook",
"filename"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "97ac32afd602d3fd8cd001d910747c7953c37c82cb564aeddcf40f027c057a60",
"md5": "75a7c2d3968a8cd528bd1cd9e1dfb5cb",
"sha256": "7b4d916568308b89c7efd6bd8fc1abe601511a1c521cec7ca3b9b33019813568"
},
"downloads": -1,
"filename": "nci_ipynb-2023.11.0.3-py3-none-any.whl",
"has_sig": false,
"md5_digest": "75a7c2d3968a8cd528bd1cd9e1dfb5cb",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.4",
"size": 4525,
"upload_time": "2023-11-10T22:50:06",
"upload_time_iso_8601": "2023-11-10T22:50:06.818026Z",
"url": "https://files.pythonhosted.org/packages/97/ac/32afd602d3fd8cd001d910747c7953c37c82cb564aeddcf40f027c057a60/nci_ipynb-2023.11.0.3-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "851b2451e64d5f3310a7649fd9093f123f1a9604011c9baae065c7f0af72cd04",
"md5": "3325060eb0e881602c4227ce7739165a",
"sha256": "656963dc1e5a6fad1e8d863e336ba7c6066250387822ddcd94e7e61b55c1e43c"
},
"downloads": -1,
"filename": "nci_ipynb-2023.11.0.3.tar.gz",
"has_sig": false,
"md5_digest": "3325060eb0e881602c4227ce7739165a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.4",
"size": 4435,
"upload_time": "2023-11-10T22:50:08",
"upload_time_iso_8601": "2023-11-10T22:50:08.415044Z",
"url": "https://files.pythonhosted.org/packages/85/1b/2451e64d5f3310a7649fd9093f123f1a9604011c9baae065c7f0af72cd04/nci_ipynb-2023.11.0.3.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-10 22:50:08",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "nci",
"github_project": "nci_ipynb",
"github_not_found": true,
"lcname": "nci-ipynb"
}