{ "info": { "author": "Marc Wouts", "author_email": "marc.wouts@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Console", "Framework :: Jupyter", "Intended Audience :: Science/Research", "Programming Language :: Python", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Text Processing :: Markup" ], "description": "# Jupyter notebooks from/to Python or R scripts\n\n[![Pypi](https://img.shields.io/pypi/v/nbsrc.svg)](https://pypi.python.org/pypi/nbsrc)\n[![Pypi](https://img.shields.io/pypi/l/nbsrc.svg)](https://pypi.python.org/pypi/nbsrc)\n[![Build Status](https://travis-ci.com/mwouts/nbsrc.svg?branch=master)](https://travis-ci.com/mwouts/nbsrc)\n[![codecov.io](https://codecov.io/github/mwouts/nbsrc/coverage.svg?branch=master)](https://codecov.io/github/mwouts/nbsrc?branch=master)\n![pylint Score](https://mperlet.github.io/pybadge/badges/9.6.svg)\n[![pyversions](https://img.shields.io/pypi/pyversions/nbsrc.svg)](https://pypi.python.org/pypi/nbsrc)\n[![Binder](https://mybinder.org/badge.svg)](https://mybinder.org/v2/gh/mwouts/nbrmd/master?filepath=demo)\n\nJupyter notebooks are complex files, that contain source code, metadata, and\nrich outputs. Here we offer a simple and complementary format for Jupyter\nnotebooks, as pure python (or R) companion scripts.\n\nThe resulting python scripts are perfect candidates for\nkeeping notebooks under version control. They can be\nedited outside of Jupyter, using\nyour favorite text editor, or even standard merge tools if you wish to merge\nmultiple contributions to a notebook.\n\nWith the `nbsrc` package, any python or R script can be loaded as a notebook\nin Jupyter. If a classical `ipynb` notebook with a matching name exists,\noutputs for matching inputs are reconstructed. And, if you associate python\nand jupyter files as recommended below, when a `ipynb` notebook opens, the\ncorresponding inputs are taken from the `py` file, which you may have updated\noutside of Jupyter.\n\n## Can I have a demo?\n\nSure. Try our package on [binder](https://mybinder.org/v2/gh/mwouts/nbrmd/master?filepath=demo)!\nThere, you will be able\n- to open and execute arbitrary python files as notebooks (give a try to\nthe matplotlib demo named `filled_step.py`)\n- to open a notebook, then edit the companion python script, and reload the notebook,\nto find up-to-date inputs in Jupyter.\n\n## How does the python version look like?\n\nBelow is an example of a Jupyter notebook, together with its python representation.\n\nWe have hundreds of tests that ensure that\n- Round trip conversion: python to notebook to python, is identity\n- Round trip conversion, starting from a Jupyter notebook, preserves source\nand metadata, not outputs. In some occasions (consecutive blank lines in\ncode cells), cells may be splitted into smaller ones.\n\nPython [notebook](https://mybinder.org/v2/gh/mwouts/nbrmd/master?filepath=tests/python_notebook_sample.py) in Jupyter | Python [script](https://github.com/mwouts/nbrmd/blob/master/tests/python_notebook_sample.py)\n:--------------------------:|:-----------------------:\n![](https://raw.githubusercontent.com/mwouts/nbsrc/master/img/python_notebook.png) | ![](https://raw.githubusercontent.com/mwouts/nbsrc/master/img/python_source.png)\n\nThe representation of notebooks as R scripts follows the [standard](https://rmarkdown.rstudio.com/articles_report_from_r_script.html) for that language.\n\n## How do I activate the companion script?\n\n- generate a jupyter config, if you don't have one yet, with `jupyter notebook --generate-config`\n- edit the config and include the below:\n```python\nc.NotebookApp.contents_manager_class = 'nbrmd.RmdFileContentsManager'\nc.ContentsManager.default_nbrmd_formats = 'ipynb,py'\n```\n\nThen, make sure you have the [`nbrmd`](https://github.com/mwouts/nbrmd)\npackage up-to-date, and re-start jupyter, i.e. run\n```bash\npip install nbrmd --upgrade\njupyter notebook\n```\n\nWith the above configuration, every Jupyter notebook will have a companion\n`.py` script. And every `.py` script that you edit in Jupyter\nwill have a companion `.ipynb` notebook.\n\nIf you prefer the `.ipynb` notebook not to be created by Jupyter when a `.py`\nscript is edited, set\n```\nc.ContentsManager.default_nbrmd_formats = ''\n```\n(as the default value is `ipynb`). Outputs for scripts, however,\nwill not be saved any more.\n\n## Per notebook configuration\n\nWith the above configuration, every notebook will have a companion `.py` file.\n\nIf you prefer that the companion script be generated only for a few notebooks,\nthen remove the `c.ContentsManager.default_nbrmd_formats` line from Jupyter's\nconfiguration, and instead edit the notebook metadata as follows:\n```\n{\n \"kernelspec\": {\n \"name\": \"python3\",\n (...)\n },\n \"language_info\": {\n (...)\n },\n \"nbrmd_formats\": \"ipynb,py\"\n}\n```\n\nAccepted formats are: `.ipynb`, `.Rmd`, `.py` and `.R`.\n\nIn case you want both `.py` and `.Rmd`, please note that the\norder matters: the first non-`.ipynb` extension\nis the one used as the reference source for notebook inputs.\n\n## What is the difference between `nbsrc` and `nbrmd`?\n\n[`nbrmd`](https://github.com/mwouts/nbrmd)\nis a python package that represents Jupyter notebooks as R markdown\nfiles. It is also where notebooks as python scripts are implemented. But\nI felt notebooks as scripts deserved a standalone documentation, and\nthat's the main reason for having the `nbsrc` package.\n\nYou don't actually need the `nbsrc` package unless you want the command line\nconversion tools.\n\n## Command line conversion\n\nThe `nbsrc` package provides a `nbsrc` script that converts Jupyter notebooks\n to R or python scripts, and vice-versa.\n \nInstall it with \n```\npip install nbsrc --upgrade\n```\n\nand then use it as:\n```bash\nnbsrc jupyter.ipynb # this prints the `.py` or `.R` alternative\nnbsrc jupyter.ipynb -i # this creates a jupyter.py or jupyter.R file\nnbsrc jupyter.py -i # and this, a jupyter.ipynb file\nnbsrc jupyter.py -i -p # update the jupyter.ipynb file and preserve outputs that correspond to unchanged inputs\n```\n\nAlternatively, the `nbsrc` package provides two `nbconvert` exporters that you can use with\n```bash\nnbconvert jupyter.ipynb --to pynotebook\nnbconvert jupyter.ipynb --to rnotebook\n```", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/mwouts/nbsrc", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "nbsrc", "package_url": "https://pypi.org/project/nbsrc/", "platform": "", "project_url": "https://pypi.org/project/nbsrc/", "project_urls": { "Homepage": "https://github.com/mwouts/nbsrc" }, "release_url": "https://pypi.org/project/nbsrc/0.4.5/", "requires_dist": null, "requires_python": "", "summary": "Jupyter notebooks from/to python and R scripts", "version": "0.4.5" }, "last_serial": 4103499, "releases": { "0.3.0": [ { "comment_text": "", "digests": { "md5": "484fd82128777a253c6b6fa0c69789d5", "sha256": "32d0cdead3bf0ada74a54529ed484566df293f5bdfea80237739eaae52c026ae" }, "downloads": -1, "filename": "nbsrc-0.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "484fd82128777a253c6b6fa0c69789d5", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7188, "upload_time": "2018-07-17T23:30:00", "url": "https://files.pythonhosted.org/packages/02/bb/f1b95f237c473638620e9192317a6085256925101bbcc38138e1cb174b68/nbsrc-0.3.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "0f37c83a6f82a4502202aeeb78acb7bf", "sha256": "98b63d921003bd092d9616bb799991ca8b27be7c5dca228ff7caa383a69cc4b0" }, "downloads": -1, "filename": "nbsrc-0.3.0.tar.gz", "has_sig": false, "md5_digest": "0f37c83a6f82a4502202aeeb78acb7bf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6537, "upload_time": "2018-07-17T23:30:02", "url": "https://files.pythonhosted.org/packages/74/73/aefbfacd28a2fc81426667c5e654df46c5af32f0e10ea6382d359396018c/nbsrc-0.3.0.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "e0edf9ac35f6c5bc9b821dd55d7e9f46", "sha256": "92877b0f4f1865cf8973035bead23afcf57b0a43fc92608563c6018118b2155d" }, "downloads": -1, "filename": "nbsrc-0.4.0-py3-none-any.whl", "has_sig": false, "md5_digest": "e0edf9ac35f6c5bc9b821dd55d7e9f46", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7817, "upload_time": "2018-07-18T23:19:23", "url": "https://files.pythonhosted.org/packages/d7/ec/1ca0041763694feb1b857f3b533a1f9149aa5afe63a77c23a0a98a2de249/nbsrc-0.4.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "6de823f270779096af21e045a79eb7f6", "sha256": "180322f093f771f541873e6dae59234821b82d91c08401daa83f37cc626c62ea" }, "downloads": -1, "filename": "nbsrc-0.4.0.tar.gz", "has_sig": false, "md5_digest": "6de823f270779096af21e045a79eb7f6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7249, "upload_time": "2018-07-18T23:19:24", "url": "https://files.pythonhosted.org/packages/1d/5f/a3c023f359c2a399c0f4a7eb8c0eef5b4e12a16dc58b35406255aefb6234/nbsrc-0.4.0.tar.gz" } ], "0.4.3": [ { "comment_text": "", "digests": { "md5": "187d5e3eb91ea304f7cb73f0fede3f20", "sha256": "4031e0e154db57361b40f114ebe77505bb428d7b164ff0287efaa88e909cf8d9" }, "downloads": -1, "filename": "nbsrc-0.4.3.tar.gz", "has_sig": false, "md5_digest": "187d5e3eb91ea304f7cb73f0fede3f20", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8175, "upload_time": "2018-07-26T00:25:25", "url": "https://files.pythonhosted.org/packages/9d/4a/5ac8af7d03dfd32bdda6ec65ef1da3852fee3b8036d07fc4512179b6678d/nbsrc-0.4.3.tar.gz" } ], "0.4.4": [ { "comment_text": "", "digests": { "md5": "35945f239277c4eb883140421b59afb2", "sha256": "ecb01c695f281872b96aaaa65f1c317ee9d68c894ee73d3be109201b7195ac1f" }, "downloads": -1, "filename": "nbsrc-0.4.4.tar.gz", "has_sig": false, "md5_digest": "35945f239277c4eb883140421b59afb2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 8238, "upload_time": "2018-07-26T06:55:17", "url": "https://files.pythonhosted.org/packages/a3/3e/367c097982993858994614f097f8beba2843f26666dcf1b1872662c1fd25/nbsrc-0.4.4.tar.gz" } ], "0.4.5": [ { "comment_text": "", "digests": { "md5": "1ddfdee8561c1b74ccdf363484a1b1d4", "sha256": "a8b0ca6a48cd2fbcdda7e74ccf5532a36dc66537b82b3fb509c772f48e331715" }, "downloads": -1, "filename": "nbsrc-0.4.5.tar.gz", "has_sig": false, "md5_digest": "1ddfdee8561c1b74ccdf363484a1b1d4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7954, "upload_time": "2018-07-26T08:22:34", "url": "https://files.pythonhosted.org/packages/0f/22/38564fd59d7ad928942dcb442597c5b392e12b6d39c51beb3717826705bc/nbsrc-0.4.5.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1ddfdee8561c1b74ccdf363484a1b1d4", "sha256": "a8b0ca6a48cd2fbcdda7e74ccf5532a36dc66537b82b3fb509c772f48e331715" }, "downloads": -1, "filename": "nbsrc-0.4.5.tar.gz", "has_sig": false, "md5_digest": "1ddfdee8561c1b74ccdf363484a1b1d4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7954, "upload_time": "2018-07-26T08:22:34", "url": "https://files.pythonhosted.org/packages/0f/22/38564fd59d7ad928942dcb442597c5b392e12b6d39c51beb3717826705bc/nbsrc-0.4.5.tar.gz" } ] }