├── .gitignore ├── .readthedocs.yml ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── HISTORY.md ├── LICENSE ├── README.md ├── docs ├── Makefile ├── _static │ ├── favicon.ico │ ├── nbblack.gif │ ├── nbblack.png │ ├── nbcat.gif │ ├── nbcat.png │ ├── nbcommands.png │ ├── nbgrep.gif │ ├── nbgrep.png │ ├── nbhead.gif │ ├── nbhead.png │ ├── nbless.gif │ ├── nbtail.gif │ ├── nbtail.png │ ├── nbtouch.gif │ └── nbtouch.png ├── _templates │ ├── hacks.html │ ├── sidebarintro.html │ └── sidebarlogo.html ├── _themes │ ├── .gitignore │ ├── LICENSE │ └── flask_theme_support.py ├── conf.py ├── index.rst └── make.bat ├── nbcommands ├── __init__.py ├── __version__.py ├── _black.py ├── _cat.py ├── _grep.py ├── _head.py ├── _less.py ├── _tail.py ├── _touch.py └── terminal.py ├── setup.py └── tests ├── test.ipynb └── test_nbcommands.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | -------------------------------------------------------------------------------- /.readthedocs.yml: -------------------------------------------------------------------------------- 1 | # .readthedocs.yml 2 | # Read the Docs configuration file 3 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 4 | 5 | # Required 6 | version: 2 7 | 8 | # Build documentation in the docs/ directory with Sphinx 9 | sphinx: 10 | configuration: docs/conf.py 11 | 12 | # Build documentation with MkDocs 13 | #mkdocs: 14 | # configuration: mkdocs.yml 15 | 16 | # Optionally build your docs in additional formats such as PDF 17 | formats: 18 | - pdf 19 | 20 | # Optionally set the version of Python and requirements required to build your docs 21 | python: 22 | version: 3.8 23 | install: 24 | - method: pip 25 | path: . 26 | extra_requirements: 27 | - dev 28 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | Be cordial or be on your way. --Kenneth Reitz 2 | 3 | https://www.kennethreitz.org/essays/be-cordial-or-be-on-your-way 4 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributor's Guide 2 | 3 | If you're reading this, you're probably looking to contribute to nbcommands. *Time is the only real currency*, and the fact that you're considering spending some here is *very* generous of you. Thank you very much! 4 | 5 | This document will help you get started with contributing code, testing (future) and filing issues. If you have any questions, feel free to reach out to [Vinayak Mehta](https://vinayak-mehta.github.io), the author and maintainer. 6 | 7 | ## Code Of Conduct 8 | 9 | The following quote sums up the **Code Of Conduct**. 10 | 11 | > Be cordial or be on your way. --Kenneth Reitz 12 | 13 | As the [Requests Code Of Conduct](https://github.com/psf/requests/blob/master/CODE_OF_CONDUCT.md) states, **all contributions are welcome**, as long as everyone involved is treated with respect. 14 | 15 | ## Your first contribution 16 | 17 | A great way to start contributing to nbcommands is to pick an issue with the [good first issue](https://github.com/vinayak-mehta/nbcommands/labels/good%20first%20issue) label. If you're unable to find a good first issue, feel free to contact the maintainer. 18 | 19 | ## Setting up a development environment 20 | 21 | To install the dependencies needed for development, you can use pip: 22 | 23 |
 24 | $ pip install conference-radar[dev]
 25 | 
26 | 27 | Alternatively, you can clone the project repository, and install using pip: 28 | 29 |
 30 | $ pip install ".[dev]"
 31 | 
32 | 33 | ## Pull Requests 34 | 35 | ### Submit a pull request 36 | 37 | The preferred workflow for contributing to nbcommands is to fork the [project repository](https://github.com/vinayak-mehta/nbcommands) on GitHub, clone, develop on a branch and then finally submit a pull request. Here are the steps: 38 | 39 | 1. Fork the project repository. Click on the ‘Fork’ button near the top of the page. This creates a copy of the code under your account on the GitHub. 40 | 41 | 2. Clone your fork of nbcommands from your GitHub account: 42 | 43 |
 44 | $ git clone https://www.github.com/[username]/nbcommands
 45 | 
46 | 47 | 3. Create a branch to hold your changes: 48 | 49 |
 50 | $ git checkout -b my-feature
 51 | 
52 | 53 | Always branch out from `master` to work on your contribution. It's good practice to never work on the `master` branch! 54 | 55 | **Protip: `git stash` is a great way to save the work that you haven't committed yet, to move between branches.** 56 | 57 | 4. Work on your contribution. Add changed files using `git add` and then `git commit` them: 58 | 59 |
 60 | $ git add modified_files
 61 | $ git commit
 62 | 
63 | 64 | 5. Finally, push them to your GitHub fork: 65 | 66 |
 67 | $ git push -u origin my-feature
 68 | 
69 | 70 | Now it's time to go to the your fork of nbcommands and create a pull request! You can [follow these instructions](https://help.github.com/articles/creating-a-pull-request-from-a-fork/) to do this. 71 | 72 | ### Work on your pull request 73 | 74 | It is recommended that your pull request complies with the following rules: 75 | 76 | - Make sure your code follows [pep8](http://pep8.org). You should [blacken](https://github.com/psf/black) your code. 77 | 78 | - Make sure your commit messages follow [the seven rules of a great git commit message](https://chris.beams.io/posts/git-commit/): 79 | - Separate subject from body with a blank line 80 | - Limit the subject line to 50 characters 81 | - Capitalize the subject line 82 | - Do not end the subject line with a period 83 | - Use the imperative mood in the subject line 84 | - Wrap the body at 72 characters 85 | - Use the body to explain what and why vs. how 86 | 87 | - Please prefix the title of your pull request with [MRG] (Ready for Merge), if the contribution is complete and ready for a detailed review. An incomplete pull request's title should be prefixed with [WIP] (to indicate a work in progress), and changed to [MRG] when it's complete. A good [task list](https://blog.github.com/2013-01-09-task-lists-in-gfm-issues-pulls-comments/) in the PR description will ensure that other people get a better idea of what it proposes to do, which will also increase collaboration. 88 | 89 | - If contributing new functionality, make sure that you add a unit test for it, while making sure that all previous tests pass. nbcommands uses [pytest](https://docs.pytest.org/en/latest/) for testing (future). Tests can be run using: 90 | 91 |
 92 | $ python setup.py test
 93 | 
94 | 95 | ## Filing Issues 96 | 97 | [GitHub issues](https://github.com/vinayak-mehta/nbcommands/issues) are used to keep track of all issues and pull requests. Before opening an issue (which asks a question or reports a bug), please use GitHub search to look for existing issues (both open and closed) that may be similar. 98 | 99 | ### Bug Reports 100 | 101 | In bug reports, make sure you include: 102 | 103 | - Your operating system type and Python version: 104 | 105 |
106 | import platform; print(platform.platform())
107 | import sys; print('Python', sys.version)
108 | 
109 | 110 | - The complete traceback. Just adding the exception message or a part of the traceback won't help the maintainer fix your issue sooner. 111 | -------------------------------------------------------------------------------- /HISTORY.md: -------------------------------------------------------------------------------- 1 | Release History 2 | =============== 3 | 4 | master 5 | ------ 6 | 7 | 0.5.1 (2021-06-21) 8 | ------------------ 9 | 10 | - Minor documentation changes. 11 | 12 | 0.5.0 (2021-06-21) 13 | ------------------ 14 | 15 | **Improvements** 16 | 17 | - Support directories in nbgrep. [#26](https://github.com/vinayak-mehta/nbcommands/pull/26) by [Min RK](https://github.com/minrk). 18 | 19 | 0.4.0 (2020-08-01) 20 | ------------------ 21 | 22 | **Improvements** 23 | 24 | - [#3](https://github.com/vinayak-mehta/nbcommands/issues/3) Add nbless. [#4](https://github.com/vinayak-mehta/nbcommands/pull/4) by [Deepu Thomas Philip](https://github.com/deepu-tp). 25 | - Add Sphinx docs! 26 | 27 | **Bugfixes** 28 | 29 | - [#19](https://github.com/vinayak-mehta/nbcommands/issues/19) Fix KeyError when execution count is None. [#21](https://github.com/vinayak-mehta/nbcommands/pull/21) by Vinayak Mehta. 30 | 31 | 0.3.2 (2019-11-02) 32 | ------------------ 33 | 34 | **Bugfixes** 35 | 36 | - Fix black source check. Fix: [1d49970](https://github.com/vinayak-mehta/nbcommands/commit/1d4997076df3cd799e28cc9dcb94ef597dadd940). 37 | 38 | 0.3.1 (2019-11-02) 39 | ------------------ 40 | 41 | **Bugfixes** 42 | 43 | - [#9](https://github.com/vinayak-mehta/nbcommands/issues/9) nbblack does not ignore jupyter magic cell lines. Fix: [e8aa30b](https://github.com/vinayak-mehta/nbcommands/commit/e8aa30b7bc657d7c921eb633143b2a23a98c6901). 44 | 45 | 0.3.0 (2019-11-02) 46 | ------------------ 47 | 48 | **Improvements** 49 | 50 | - Add nbblack. ✨ 🍰 ✨ 51 | 52 | 0.2.2 (2019-11-01) 53 | ------------------ 54 | 55 |
56 | HTTPError: 400 Client Error: This filename has already been used, use a different version. See https://pypi.org/help/#file-name-reuse for url: https://upload.pypi.org/legacy/
57 | 
58 | 59 | 0.2.1 (2019-11-01) 60 | ------------------ 61 | 62 | **Bugfixes** 63 | 64 | * Fix README links. 65 | 66 | 0.2.0 (2019-11-01) 67 | ------------------ 68 | 69 | **Improvements** 70 | 71 | * Add nbtouch, nbgrep, nbhead, nbtail and nbcat. 72 | 73 | 0.1.0 (2019-10-31) 74 | ------------------ 75 | 76 | * Birth! 77 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2019 Vinayak Mehta 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 | # nbcommands 6 | 7 | [![image](https://readthedocs.org/projects/nbcommands/badge/?version=latest)](https://nbcommands.readthedocs.io/en/latest/) [![image](https://img.shields.io/pypi/v/nbcommands.svg)](https://pypi.org/project/nbcommands/) [![image](https://img.shields.io/pypi/pyversions/nbcommands.svg)](https://pypi.org/project/nbcommands/) [![image](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black) 8 | 9 | nbcommands bring the goodness of Unix commands to Jupyter notebooks. 10 | 11 | ## Installation 12 | 13 | You can simply use pip to install nbcommands: 14 | 15 |
 16 | $ pip install nbcommands
 17 | 
18 | 19 | or conda: 20 | 21 |
 22 | $ conda install -c conda-forge nbcommands
 23 | 
24 | 25 | ## Usage 26 | 27 | nbcommands installs the following commands which let you interact with your Jupyter notebooks without spinning up a notebook server. 28 | 29 | - `nbtouch`: Update the access and modification times of each Jupyter notebook to the current time. 30 | 31 |
 32 |     $ nbtouch notebook1.ipynb notebook2.ipynb
33 | ![nbtouch](https://raw.githubusercontent.com/vinayak-mehta/nbcommands/master/docs/_static/nbtouch.gif) 34 | 35 | - `nbgrep`: Search for a pattern in Jupyter notebooks. 36 | 37 |
 38 |     $ nbgrep "os" notebook1.ipynb notebook2.ipynb
 39 |     $ nbgrep "os" directory/
40 | ![nbgrep](https://raw.githubusercontent.com/vinayak-mehta/nbcommands/master/docs/_static/nbgrep.gif) 41 | 42 | - `nbhead`: Print the first 5 cells of a Jupyter notebook to standard output. 43 | 44 |
 45 |     $ nbhead notebook1.ipynb
46 | ![nbhead](https://raw.githubusercontent.com/vinayak-mehta/nbcommands/master/docs/_static/nbhead.gif) 47 | 48 | Note: You can also specify the number of cells you want to print using the `-n` option. 49 |
 50 |     $ nbhead -n 10 notebook1.ipynb
51 | 52 | - `nbtail`: Print the last 5 cells of a Jupyter notebook to standard output. 53 | 54 |
 55 |     $ nbtail notebook2.ipynb
56 | ![nbtail](https://raw.githubusercontent.com/vinayak-mehta/nbcommands/master/docs/_static/nbtail.gif) 57 | 58 | Note: You can also specify the number of cells you want to print using the `-n` option. 59 |
 60 |     $ nbtail -n 10 notebook2.ipynb
61 | 62 | - `nbcat`: Concatenate Jupyter notebooks to standard output. 63 | 64 |
 65 |     $ nbcat notebook1.ipynb notebook2.ipynb
66 | ![nbcat](https://raw.githubusercontent.com/vinayak-mehta/nbcommands/master/docs/_static/nbcat.gif) 67 | 68 | Note: You can create a new notebook by concatenating multiple notebooks using the `-o` option. 69 |
 70 |     $ nbcat notebook1.ipynb notebook2.ipynb -o notebook3.ipynb
71 | 72 | - `nbless`: Print a Jupyter notebook using a pager program. 73 | 74 |
 75 |     $ nbless notebook1.ipynb
76 | ![nbless](https://raw.githubusercontent.com/vinayak-mehta/nbcommands/master/docs/_static/nbless.gif) 77 | 78 | And some non-Unix goodness, 79 | 80 | - `nbblack`: Blacken Jupyter notebooks. 81 | 82 |
 83 |     $ nbblack notebook1.ipynb notebook2.ipynb
84 | ![nbblack](https://raw.githubusercontent.com/vinayak-mehta/nbcommands/master/docs/_static/nbblack.gif) 85 | 86 | --- 87 | 88 | Planned enhancements: 89 | 90 | - `nbstrip`: Strip outputs from Jupyter notebooks. 91 | - `nbdiff`: Find the diff between two Jupyter notebooks. 92 | - `nbecho`: Add a code cell to a Jupyter notebook. 93 | - `nbedit`: Interactively edit a Jupyter notebook. 94 | - `nbtime`: Run and time a Jupyter notebook. 95 | - `nbwc`: Print word count for a Jupyter notebook. 96 | 97 | ## Versioning 98 | 99 | nbcommands uses [Semantic Versioning](https://semver.org/). For the available versions, see the tags on this repository. 100 | 101 | ## License 102 | 103 | This project is licensed under the Apache License, see the [LICENSE](https://raw.githubusercontent.com/vinayak-mehta/nbcommands/master/LICENSE) file for details. 104 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /docs/_static/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinayak-mehta/nbcommands/5bc82cf9ca5ce03d0d11524d9cd081f1bc4cd768/docs/_static/favicon.ico -------------------------------------------------------------------------------- /docs/_static/nbblack.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinayak-mehta/nbcommands/5bc82cf9ca5ce03d0d11524d9cd081f1bc4cd768/docs/_static/nbblack.gif -------------------------------------------------------------------------------- /docs/_static/nbblack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinayak-mehta/nbcommands/5bc82cf9ca5ce03d0d11524d9cd081f1bc4cd768/docs/_static/nbblack.png -------------------------------------------------------------------------------- /docs/_static/nbcat.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinayak-mehta/nbcommands/5bc82cf9ca5ce03d0d11524d9cd081f1bc4cd768/docs/_static/nbcat.gif -------------------------------------------------------------------------------- /docs/_static/nbcat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinayak-mehta/nbcommands/5bc82cf9ca5ce03d0d11524d9cd081f1bc4cd768/docs/_static/nbcat.png -------------------------------------------------------------------------------- /docs/_static/nbcommands.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinayak-mehta/nbcommands/5bc82cf9ca5ce03d0d11524d9cd081f1bc4cd768/docs/_static/nbcommands.png -------------------------------------------------------------------------------- /docs/_static/nbgrep.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinayak-mehta/nbcommands/5bc82cf9ca5ce03d0d11524d9cd081f1bc4cd768/docs/_static/nbgrep.gif -------------------------------------------------------------------------------- /docs/_static/nbgrep.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinayak-mehta/nbcommands/5bc82cf9ca5ce03d0d11524d9cd081f1bc4cd768/docs/_static/nbgrep.png -------------------------------------------------------------------------------- /docs/_static/nbhead.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinayak-mehta/nbcommands/5bc82cf9ca5ce03d0d11524d9cd081f1bc4cd768/docs/_static/nbhead.gif -------------------------------------------------------------------------------- /docs/_static/nbhead.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinayak-mehta/nbcommands/5bc82cf9ca5ce03d0d11524d9cd081f1bc4cd768/docs/_static/nbhead.png -------------------------------------------------------------------------------- /docs/_static/nbless.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinayak-mehta/nbcommands/5bc82cf9ca5ce03d0d11524d9cd081f1bc4cd768/docs/_static/nbless.gif -------------------------------------------------------------------------------- /docs/_static/nbtail.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinayak-mehta/nbcommands/5bc82cf9ca5ce03d0d11524d9cd081f1bc4cd768/docs/_static/nbtail.gif -------------------------------------------------------------------------------- /docs/_static/nbtail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinayak-mehta/nbcommands/5bc82cf9ca5ce03d0d11524d9cd081f1bc4cd768/docs/_static/nbtail.png -------------------------------------------------------------------------------- /docs/_static/nbtouch.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinayak-mehta/nbcommands/5bc82cf9ca5ce03d0d11524d9cd081f1bc4cd768/docs/_static/nbtouch.gif -------------------------------------------------------------------------------- /docs/_static/nbtouch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinayak-mehta/nbcommands/5bc82cf9ca5ce03d0d11524d9cd081f1bc4cd768/docs/_static/nbtouch.png -------------------------------------------------------------------------------- /docs/_templates/hacks.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /docs/_templates/sidebarintro.html: -------------------------------------------------------------------------------- 1 | 6 |

7 | 9 |

10 | 11 |

Useful Links

12 | -------------------------------------------------------------------------------- /docs/_templates/sidebarlogo.html: -------------------------------------------------------------------------------- 1 | 6 |

7 | 9 |

-------------------------------------------------------------------------------- /docs/_themes/.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *.pyo -------------------------------------------------------------------------------- /docs/_themes/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2010 by Armin Ronacher. 2 | 3 | Some rights reserved. 4 | 5 | Redistribution and use in source and binary forms of the theme, with or 6 | without modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above 13 | copyright notice, this list of conditions and the following 14 | disclaimer in the documentation and/or other materials provided 15 | with the distribution. 16 | 17 | * The names of the contributors may not be used to endorse or 18 | promote products derived from this software without specific 19 | prior written permission. 20 | 21 | We kindly ask you to only use these themes in an unmodified manner just 22 | for Flask and Flask-related products, not for unrelated projects. If you 23 | like the visual style and want to use it for your own projects, please 24 | consider making some larger changes to the themes (such as changing 25 | font faces, sizes, colors or margins). 26 | 27 | THIS THEME IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 28 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 29 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 30 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 31 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 32 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 33 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 34 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 35 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 36 | ARISING IN ANY WAY OUT OF THE USE OF THIS THEME, EVEN IF ADVISED OF THE 37 | POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /docs/_themes/flask_theme_support.py: -------------------------------------------------------------------------------- 1 | # flasky pygments style based on tango style 2 | from pygments.style import Style 3 | from pygments.token import ( 4 | Keyword, 5 | Name, 6 | Comment, 7 | String, 8 | Error, 9 | Number, 10 | Operator, 11 | Generic, 12 | Whitespace, 13 | Punctuation, 14 | Other, 15 | Literal, 16 | ) 17 | 18 | 19 | class FlaskyStyle(Style): 20 | background_color = "#f8f8f8" 21 | default_style = "" 22 | 23 | styles = { 24 | # No corresponding class for the following: 25 | # Text: "", # class: '' 26 | Whitespace: "underline #f8f8f8", # class: 'w' 27 | Error: "#a40000 border:#ef2929", # class: 'err' 28 | Other: "#000000", # class 'x' 29 | Comment: "italic #8f5902", # class: 'c' 30 | Comment.Preproc: "noitalic", # class: 'cp' 31 | Keyword: "bold #004461", # class: 'k' 32 | Keyword.Constant: "bold #004461", # class: 'kc' 33 | Keyword.Declaration: "bold #004461", # class: 'kd' 34 | Keyword.Namespace: "bold #004461", # class: 'kn' 35 | Keyword.Pseudo: "bold #004461", # class: 'kp' 36 | Keyword.Reserved: "bold #004461", # class: 'kr' 37 | Keyword.Type: "bold #004461", # class: 'kt' 38 | Operator: "#582800", # class: 'o' 39 | Operator.Word: "bold #004461", # class: 'ow' - like keywords 40 | Punctuation: "bold #000000", # class: 'p' 41 | # because special names such as Name.Class, Name.Function, etc. 42 | # are not recognized as such later in the parsing, we choose them 43 | # to look the same as ordinary variables. 44 | Name: "#000000", # class: 'n' 45 | Name.Attribute: "#c4a000", # class: 'na' - to be revised 46 | Name.Builtin: "#004461", # class: 'nb' 47 | Name.Builtin.Pseudo: "#3465a4", # class: 'bp' 48 | Name.Class: "#000000", # class: 'nc' - to be revised 49 | Name.Constant: "#000000", # class: 'no' - to be revised 50 | Name.Decorator: "#888", # class: 'nd' - to be revised 51 | Name.Entity: "#ce5c00", # class: 'ni' 52 | Name.Exception: "bold #cc0000", # class: 'ne' 53 | Name.Function: "#000000", # class: 'nf' 54 | Name.Property: "#000000", # class: 'py' 55 | Name.Label: "#f57900", # class: 'nl' 56 | Name.Namespace: "#000000", # class: 'nn' - to be revised 57 | Name.Other: "#000000", # class: 'nx' 58 | Name.Tag: "bold #004461", # class: 'nt' - like a keyword 59 | Name.Variable: "#000000", # class: 'nv' - to be revised 60 | Name.Variable.Class: "#000000", # class: 'vc' - to be revised 61 | Name.Variable.Global: "#000000", # class: 'vg' - to be revised 62 | Name.Variable.Instance: "#000000", # class: 'vi' - to be revised 63 | Number: "#990000", # class: 'm' 64 | Literal: "#000000", # class: 'l' 65 | Literal.Date: "#000000", # class: 'ld' 66 | String: "#4e9a06", # class: 's' 67 | String.Backtick: "#4e9a06", # class: 'sb' 68 | String.Char: "#4e9a06", # class: 'sc' 69 | String.Doc: "italic #8f5902", # class: 'sd' - like a comment 70 | String.Double: "#4e9a06", # class: 's2' 71 | String.Escape: "#4e9a06", # class: 'se' 72 | String.Heredoc: "#4e9a06", # class: 'sh' 73 | String.Interpol: "#4e9a06", # class: 'si' 74 | String.Other: "#4e9a06", # class: 'sx' 75 | String.Regex: "#4e9a06", # class: 'sr' 76 | String.Single: "#4e9a06", # class: 's1' 77 | String.Symbol: "#4e9a06", # class: 'ss' 78 | Generic: "#000000", # class: 'g' 79 | Generic.Deleted: "#a40000", # class: 'gd' 80 | Generic.Emph: "italic #000000", # class: 'ge' 81 | Generic.Error: "#ef2929", # class: 'gr' 82 | Generic.Heading: "bold #000080", # class: 'gh' 83 | Generic.Inserted: "#00A000", # class: 'gi' 84 | Generic.Output: "#888", # class: 'go' 85 | Generic.Prompt: "#745334", # class: 'gp' 86 | Generic.Strong: "bold #000000", # class: 'gs' 87 | Generic.Subheading: "bold #800080", # class: 'gu' 88 | Generic.Traceback: "bold #a40000", # class: 'gt' 89 | } 90 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # nbcommands documentation build configuration file, created by 4 | # sphinx-quickstart on Tue Jul 19 13:44:18 2016. 5 | # 6 | # This file is execfile()d with the current directory set to its 7 | # containing dir. 8 | # 9 | # Note that not all possible configuration values are present in this 10 | # autogenerated file. 11 | # 12 | # All configuration values have a default; values that are commented out 13 | # serve to show the default. 14 | 15 | import os 16 | import sys 17 | 18 | # If extensions (or modules to document with autodoc) are in another directory, 19 | # add these directories to sys.path here. If the directory is relative to the 20 | # documentation root, use os.path.abspath to make it absolute, like shown here. 21 | # 22 | # sys.path.insert(0, os.path.abspath('..')) 23 | 24 | # Insert nbcommands's path into the system. 25 | sys.path.insert(0, os.path.abspath("..")) 26 | sys.path.insert(0, os.path.abspath("_themes")) 27 | 28 | import nbcommands 29 | 30 | 31 | # -- General configuration ------------------------------------------------ 32 | 33 | # If your documentation needs a minimal Sphinx version, state it here. 34 | # 35 | # needs_sphinx = '1.0' 36 | 37 | # Add any Sphinx extension module names here, as strings. They can be 38 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 39 | # ones. 40 | extensions = [] 41 | 42 | # Add any paths that contain templates here, relative to this directory. 43 | templates_path = ["_templates"] 44 | 45 | # The suffix(es) of source filenames. 46 | # You can specify multiple suffix as a list of string: 47 | # 48 | # source_suffix = ['.rst', '.md'] 49 | source_suffix = ".rst" 50 | 51 | # The encoding of source files. 52 | # 53 | # source_encoding = 'utf-8-sig' 54 | 55 | # The master toctree document. 56 | master_doc = "index" 57 | 58 | # General information about the project. 59 | project = u"conference-radar" 60 | copyright = u"2021, Vinayak Mehta" 61 | author = u"Vinayak Mehta" 62 | 63 | # The version info for the project you're documenting, acts as replacement for 64 | # |version| and |release|, also used in various other places throughout the 65 | # built documents. 66 | 67 | # The short X.Y version. 68 | version = nbcommands.__version__ 69 | # The full version, including alpha/beta/rc tags. 70 | release = nbcommands.__version__ 71 | 72 | # The language for content autogenerated by Sphinx. Refer to documentation 73 | # for a list of supported languages. 74 | # 75 | # This is also used if you do content translation via gettext catalogs. 76 | # Usually you set "language" from the command line for these cases. 77 | language = None 78 | 79 | # There are two options for replacing |today|: either, you set today to some 80 | # non-false value, then it is used: 81 | # 82 | # today = '' 83 | # 84 | # Else, today_fmt is used as the format for a strftime call. 85 | # 86 | # today_fmt = '%B %d, %Y' 87 | 88 | # List of patterns, relative to source directory, that match files and 89 | # directories to ignore when looking for source files. 90 | # This patterns also effect to html_static_path and html_extra_path 91 | exclude_patterns = ["_build"] 92 | 93 | # The reST default role (used for this markup: `text`) to use for all 94 | # documents. 95 | # 96 | # default_role = None 97 | 98 | # If true, '()' will be appended to :func: etc. cross-reference text. 99 | add_function_parentheses = True 100 | 101 | # If true, the current module name will be prepended to all description 102 | # unit titles (such as .. function::). 103 | add_module_names = True 104 | 105 | # If true, sectionauthor and moduleauthor directives will be shown in the 106 | # output. They are ignored by default. 107 | # 108 | # show_authors = False 109 | 110 | # The name of the Pygments (syntax highlighting) style to use. 111 | pygments_style = "flask_theme_support.FlaskyStyle" 112 | 113 | # A list of ignored prefixes for module index sorting. 114 | # modindex_common_prefix = [] 115 | 116 | # If true, keep warnings as "system message" paragraphs in the built documents. 117 | # keep_warnings = False 118 | 119 | # If true, `todo` and `todoList` produce output, else they produce nothing. 120 | todo_include_todos = True 121 | 122 | 123 | # -- Options for HTML output ---------------------------------------------- 124 | 125 | # The theme to use for HTML and HTML Help pages. See the documentation for 126 | # a list of builtin themes. 127 | html_theme = "alabaster" 128 | 129 | # Theme options are theme-specific and customize the look and feel of a theme 130 | # further. For a list of options available for each theme, see the 131 | # documentation. 132 | html_theme_options = { 133 | "show_powered_by": False, 134 | "github_user": "vinayak-mehta", 135 | "github_repo": "nbcommands", 136 | "github_banner": True, 137 | "show_related": False, 138 | "note_bg": "#FFF59C", 139 | } 140 | 141 | # Add any paths that contain custom themes here, relative to this directory. 142 | # html_theme_path = [] 143 | 144 | # The name for this set of Sphinx documents. 145 | # " v documentation" by default. 146 | # 147 | # html_title = None 148 | 149 | # A shorter title for the navigation bar. Default is the same as html_title. 150 | # 151 | # html_short_title = None 152 | 153 | # The name of an image file (relative to this directory) to place at the top 154 | # of the sidebar. 155 | # 156 | # html_logo = None 157 | 158 | # The name of an image file (relative to this directory) to use as a favicon of 159 | # the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 160 | # pixels large. 161 | html_favicon = "_static/favicon.ico" 162 | 163 | # Add any paths that contain custom static files (such as style sheets) here, 164 | # relative to this directory. They are copied after the builtin static files, 165 | # so a file named "default.css" will overwrite the builtin "default.css". 166 | html_static_path = ["_static"] 167 | 168 | # Add any extra paths that contain custom files (such as robots.txt or 169 | # .htaccess) here, relative to this directory. These files are copied 170 | # directly to the root of the documentation. 171 | # 172 | # html_extra_path = [] 173 | 174 | # If not None, a 'Last updated on:' timestamp is inserted at every page 175 | # bottom, using the given strftime format. 176 | # The empty string is equivalent to '%b %d, %Y'. 177 | # 178 | # html_last_updated_fmt = None 179 | 180 | # If true, SmartyPants will be used to convert quotes and dashes to 181 | # typographically correct entities. 182 | html_use_smartypants = True 183 | 184 | # Custom sidebar templates, maps document names to template names. 185 | html_sidebars = { 186 | "index": [ 187 | "sidebarintro.html", 188 | "relations.html", 189 | "sourcelink.html", 190 | "searchbox.html", 191 | "hacks.html", 192 | ], 193 | "**": [ 194 | "sidebarlogo.html", 195 | "localtoc.html", 196 | "relations.html", 197 | "sourcelink.html", 198 | "searchbox.html", 199 | "hacks.html", 200 | ], 201 | } 202 | 203 | # Additional templates that should be rendered to pages, maps page names to 204 | # template names. 205 | # 206 | # html_additional_pages = {} 207 | 208 | # If false, no module index is generated. 209 | # 210 | # html_domain_indices = True 211 | 212 | # If false, no index is generated. 213 | # 214 | # html_use_index = True 215 | 216 | # If true, the index is split into individual pages for each letter. 217 | # 218 | # html_split_index = False 219 | 220 | # If true, links to the reST sources are added to the pages. 221 | html_show_sourcelink = False 222 | 223 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 224 | html_show_sphinx = False 225 | 226 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 227 | html_show_copyright = True 228 | 229 | # If true, an OpenSearch description file will be output, and all pages will 230 | # contain a tag referring to it. The value of this option must be the 231 | # base URL from which the finished HTML is served. 232 | # 233 | # html_use_opensearch = '' 234 | 235 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 236 | # html_file_suffix = None 237 | 238 | # Language to be used for generating the HTML full-text search index. 239 | # Sphinx supports the following languages: 240 | # 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' 241 | # 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh' 242 | # 243 | # html_search_language = 'en' 244 | 245 | # A dictionary with options for the search language support, empty by default. 246 | # 'ja' uses this config value. 247 | # 'zh' user can custom change `jieba` dictionary path. 248 | # 249 | # html_search_options = {'type': 'default'} 250 | 251 | # The name of a javascript file (relative to the configuration directory) that 252 | # implements a search results scorer. If empty, the default will be used. 253 | # 254 | # html_search_scorer = 'scorer.js' 255 | 256 | # Output file base name for HTML help builder. 257 | htmlhelp_basename = "nbcommandsdoc" 258 | 259 | # -- Options for LaTeX output --------------------------------------------- 260 | 261 | latex_elements = { 262 | # The paper size ('letterpaper' or 'a4paper'). 263 | # 264 | # 'papersize': 'letterpaper', 265 | # The font size ('10pt', '11pt' or '12pt'). 266 | # 267 | # 'pointsize': '10pt', 268 | # Additional stuff for the LaTeX preamble. 269 | # 270 | # 'preamble': '', 271 | # Latex figure (float) alignment 272 | # 273 | # 'figure_align': 'htbp', 274 | } 275 | 276 | # Grouping the document tree into LaTeX files. List of tuples 277 | # (source start file, target name, title, 278 | # author, documentclass [howto, manual, or own class]). 279 | latex_documents = [ 280 | ( 281 | master_doc, 282 | "nbcommands.tex", 283 | u"nbcommands documentation", 284 | u"Vinayak Mehta", 285 | "manual", 286 | ) 287 | ] 288 | 289 | # The name of an image file (relative to this directory) to place at the top of 290 | # the title page. 291 | # 292 | # latex_logo = None 293 | 294 | # For "manual" documents, if this is true, then toplevel headings are parts, 295 | # not chapters. 296 | # 297 | # latex_use_parts = False 298 | 299 | # If true, show page references after internal links. 300 | # 301 | # latex_show_pagerefs = False 302 | 303 | # If true, show URL addresses after external links. 304 | # 305 | # latex_show_urls = False 306 | 307 | # Documents to append as an appendix to all manuals. 308 | # 309 | # latex_appendices = [] 310 | 311 | # It false, will not define \strong, \code, itleref, \crossref ... but only 312 | # \sphinxstrong, ..., \sphinxtitleref, ... To help avoid clash with user added 313 | # packages. 314 | # 315 | # latex_keep_old_macro_names = True 316 | 317 | # If false, no module index is generated. 318 | # 319 | # latex_domain_indices = True 320 | 321 | 322 | # -- Options for manual page output --------------------------------------- 323 | 324 | # One entry per manual page. List of tuples 325 | # (source start file, name, description, authors, manual section). 326 | man_pages = [(master_doc, "nbcommands", u"nbcommands documentation", [author], 1)] 327 | 328 | # If true, show URL addresses after external links. 329 | # 330 | # man_show_urls = False 331 | 332 | 333 | # -- Options for Texinfo output ------------------------------------------- 334 | 335 | # Grouping the document tree into Texinfo files. List of tuples 336 | # (source start file, target name, title, author, 337 | # dir menu entry, description, category) 338 | texinfo_documents = [ 339 | ( 340 | master_doc, 341 | "nbcommands", 342 | u"nbcommands documentation", 343 | author, 344 | "nbcommands", 345 | "One line description of project.", 346 | "Miscellaneous", 347 | ) 348 | ] 349 | 350 | # Documents to append as an appendix to all manuals. 351 | # 352 | # texinfo_appendices = [] 353 | 354 | # If false, no module index is generated. 355 | # 356 | # texinfo_domain_indices = True 357 | 358 | # How to display URL addresses: 'footnote', 'no', or 'inline'. 359 | # 360 | # texinfo_show_urls = 'footnote' 361 | 362 | # If true, do not generate a @detailmenu in the "Top" node's menu. 363 | # 364 | # texinfo_no_detailmenu = False 365 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. nbcommands documentation master file, created by 2 | sphinx-quickstart on Sat Aug 1 03:02:35 2020. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | nbcommands — Unix commands for Jupyter notebooks 7 | ================================================ 8 | 9 | .. image:: https://readthedocs.org/projects/nbcommands/badge/?version=latest 10 | :target: https://nbcommands.readthedocs.io/en/latest/ 11 | :alt: Documentation Status 12 | 13 | .. image:: https://img.shields.io/pypi/v/nbcommands.svg 14 | :target: https://pypi.org/project/nbcommands/ 15 | 16 | .. image:: https://img.shields.io/pypi/pyversions/nbcommands.svg 17 | :target: https://pypi.org/project/nbcommands/ 18 | 19 | .. image:: https://img.shields.io/badge/code%20style-black-000000.svg 20 | :target: https://github.com/ambv/black 21 | 22 | nbcommands bring the goodness of Unix commands to Jupyter notebooks. 23 | 24 | Installation 25 | ------------ 26 | 27 | You can simply use pip to install nbcommands:: 28 | 29 | $ pip install nbcommands 30 | 31 | or conda:: 32 | 33 | $ conda install -c conda-forge nbcommands 34 | 35 | Usage 36 | ----- 37 | 38 | nbcommands installs the following commands which let you interact with your Jupyter notebooks without spinning up a notebook server. 39 | 40 | nbtouch 41 | ^^^^^^^ 42 | 43 | Update the access and modification times of each Jupyter notebook to the current time, 44 | or create empty notebook files where none exist:: 45 | 46 | $ nbtouch notebook1.ipynb notebook2.ipynb 47 | 48 | .. image:: _static/nbtouch.gif 49 | 50 | nbgrep 51 | ^^^^^^ 52 | 53 | Search for a pattern in Jupyter notebooks:: 54 | 55 | $ nbgrep "os" notebook1.ipynb notebook2.ipynb 56 | $ nbgrep "os" directory/ 57 | 58 | .. image:: _static/nbgrep.gif 59 | 60 | nbhead 61 | ^^^^^^ 62 | 63 | Print the first 5 cells of a Jupyter notebook to standard output:: 64 | 65 | $ nbhead notebook1.ipynb 66 | 67 | .. image:: _static/nbhead.gif 68 | 69 | .. note:: You can also specify the number of cells you want to print using the ``-n`` option. 70 | 71 | nbtail 72 | ^^^^^^ 73 | 74 | Print the last 5 cells of a Jupyter notebook to standard output:: 75 | 76 | $ nbtail notebook2.ipynb 77 | 78 | .. image:: _static/nbtail.gif 79 | 80 | .. note:: You can also specify the number of cells you want to print using the ``-n`` option. 81 | 82 | nbcat 83 | ^^^^^ 84 | 85 | Concatenate Jupyter notebooks to standard output:: 86 | 87 | $ nbcat notebook1.ipynb notebook2.ipynb 88 | 89 | .. image:: _static/nbcat.gif 90 | 91 | .. note:: You can create a new notebook by concatenating multiple notebooks using the ``-o`` option. 92 | 93 | nbless 94 | ^^^^^^ 95 | 96 | Print a Jupyter notebook using a pager program:: 97 | 98 | $ nbless notebook1.ipynb 99 | 100 | .. image:: _static/nbless.gif 101 | 102 | And some non-Unix goodness, 103 | 104 | nbblack 105 | ^^^^^^^ 106 | 107 | Blacken Jupyter notebooks:: 108 | 109 | $ nbblack notebook1.ipynb notebook2.ipynb 110 | 111 | .. image:: _static/nbblack.gif 112 | 113 | --- 114 | 115 | Planned enhancements: 116 | 117 | - ``nbstrip``: Strip outputs from Jupyter notebooks. 118 | - ``nbdiff``: Find the diff between two Jupyter notebooks. 119 | - ``nbecho``: Add a code cell to a Jupyter notebook. 120 | - ``nbedit``: Interactively edit a Jupyter notebook. 121 | - ``nbtime``: Run and time a Jupyter notebook. 122 | - ``nbwc``: Print word count for a Jupyter notebook. 123 | 124 | Versioning 125 | ---------- 126 | 127 | nbcommands uses `Semantic Versioning `_. For the available versions, see the tags on the GitHub repository. 128 | 129 | License 130 | ------- 131 | 132 | This project is licensed under the Apache License, see the `LICENSE `_ file for details. 133 | -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | 13 | if "%1" == "" goto help 14 | 15 | %SPHINXBUILD% >NUL 2>NUL 16 | if errorlevel 9009 ( 17 | echo. 18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 19 | echo.installed, then set the SPHINXBUILD environment variable to point 20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 21 | echo.may add the Sphinx directory to PATH. 22 | echo. 23 | echo.If you don't have Sphinx installed, grab it from 24 | echo.http://sphinx-doc.org/ 25 | exit /b 1 26 | ) 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /nbcommands/__init__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from .__version__ import __version__ 4 | -------------------------------------------------------------------------------- /nbcommands/__version__.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | VERSION = (0, 5, 1) 4 | PRERELEASE = None # alpha, beta or rc 5 | REVISION = None 6 | 7 | 8 | def generate_version(version, prerelease=None, revision=None): 9 | version_parts = [".".join(map(str, version))] 10 | if prerelease is not None: 11 | version_parts.append("-{}".format(prerelease)) 12 | if revision is not None: 13 | version_parts.append(".{}".format(revision)) 14 | return "".join(version_parts) 15 | 16 | 17 | __title__ = "nbcommands" 18 | __description__ = "Unix commands for Jupyter notebooks." 19 | __url__ = "https://github.com/vinayak-mehta/nbcommands" 20 | __version__ = generate_version(VERSION, prerelease=PRERELEASE, revision=REVISION) 21 | __author__ = "Vinayak Mehta" 22 | __author_email__ = "vmehta94@gmail.com" 23 | __license__ = "Apache 2.0" 24 | -------------------------------------------------------------------------------- /nbcommands/_black.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import re 4 | 5 | import black 6 | import click 7 | import nbformat 8 | 9 | from . import __version__ 10 | 11 | 12 | def _cells(nb): 13 | """Yield all cells in an nbformat-insensitive manner 14 | 15 | Source: https://github.com/kynan/nbstripout/blob/master/nbstripout/_utils.py#L27 16 | """ 17 | if nb.nbformat < 4: 18 | for ws in nb.worksheets: 19 | for cell in ws.cells: 20 | yield cell 21 | else: 22 | for cell in nb.cells: 23 | yield cell 24 | 25 | 26 | @click.command(name="nbblack") 27 | @click.version_option(version=__version__) 28 | @click.argument("file", nargs=-1) 29 | @click.pass_context 30 | def _black(ctx, *args, **kwargs): 31 | """Blacken Jupyter notebooks.""" 32 | file_count = len(kwargs["file"]) 33 | black_file_count = 0 34 | 35 | for file in kwargs["file"]: 36 | with open(file, "r") as f: 37 | nb = nbformat.read(f, as_version=4) 38 | 39 | black_flag = False 40 | pinfo_flag = False 41 | pattern = re.compile("^\?") 42 | # Source: https://neuralcoder.science/Black-Jupyter/ 43 | for cell in _cells(nb): 44 | if cell.cell_type == "code": 45 | source = cell.source 46 | source = re.sub("^%", "#%", source, flags=re.M) 47 | source = re.sub("^!", "#!", source, flags=re.M) 48 | if pattern.match(source): 49 | pinfo_flag = True 50 | source = "#" + source 51 | black_source = black.format_str(source, mode=black.FileMode()) 52 | black_source = re.sub("^#%", "%", black_source, flags=re.M) 53 | black_source = re.sub("^#!", "!", black_source, flags=re.M) 54 | if pinfo_flag: 55 | black_source = black_source[1:] 56 | black_source = black_source.strip() 57 | if cell.source != black_source: 58 | black_flag = True 59 | cell.source = black_source 60 | 61 | if black_flag: 62 | click.echo("reformatted {}".format(file)) 63 | black_file_count += 1 64 | 65 | with open(file, "w") as f: 66 | nbformat.write(nb, f, version=4) 67 | 68 | click.echo("All done! ✨ 🍰 ✨") 69 | if black_file_count: 70 | s = "s" if black_file_count > 1 else "" 71 | click.echo("{} file{} reformatted.".format(black_file_count, s)) 72 | else: 73 | s = "s" if file_count > 1 else "" 74 | click.echo("{} file{} left unchanged.".format(file_count, s)) 75 | -------------------------------------------------------------------------------- /nbcommands/_cat.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import os 4 | 5 | import click 6 | import nbformat 7 | 8 | from . import __version__ 9 | from .terminal import display 10 | 11 | 12 | @click.command(name="nbcat") 13 | @click.version_option(version=__version__) 14 | @click.option("-o", "--output", help="Output file path.") 15 | @click.argument("file", nargs=-1) 16 | @click.pass_context 17 | def cat(ctx, *args, **kwargs): 18 | """Concatenate Jupyter notebooks to standard output.""" 19 | # Source: https://github.com/jbn/nbmerge 20 | merged, metadata = None, [] 21 | 22 | for file in kwargs["file"]: 23 | with open(file, "r") as f: 24 | nb = nbformat.read(f, as_version=4) 25 | 26 | metadata.append(nb.metadata) 27 | 28 | if merged is None: 29 | merged = nb 30 | else: 31 | merged.cells.extend(nb.cells) 32 | 33 | merged_metadata = {} 34 | for meta in reversed(metadata): 35 | merged_metadata.update(meta) 36 | merged.metadata = merged_metadata 37 | 38 | if kwargs["output"] is not None: 39 | with open(kwargs["output"], "w") as f: 40 | nbformat.write(merged, f, version=4) 41 | else: 42 | click.echo("\n".join(display(merged.cells))) 43 | -------------------------------------------------------------------------------- /nbcommands/_grep.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import pathlib 4 | import re 5 | 6 | import click 7 | import nbformat 8 | from colorama import Fore, Style 9 | 10 | from . import __version__ 11 | 12 | 13 | def color(s, c, style="bright"): 14 | color_map = { 15 | "black": Fore.BLACK, 16 | "red": Fore.RED, 17 | "green": Fore.GREEN, 18 | "yellow": Fore.YELLOW, 19 | "blue": Fore.BLUE, 20 | "magenta": Fore.MAGENTA, 21 | "cyan": Fore.CYAN, 22 | "white": Fore.WHITE, 23 | } 24 | style_map = { 25 | "dim": Style.DIM, 26 | "normal": Style.NORMAL, 27 | "bright": Style.BRIGHT, 28 | } 29 | 30 | return color_map[c] + style_map[style] + s + Style.RESET_ALL 31 | 32 | 33 | @click.command(name="nbgrep") 34 | @click.version_option(version=__version__) 35 | @click.argument("pattern") 36 | @click.argument("file", nargs=-1, type=click.Path(exists=True), required=True) 37 | @click.pass_context 38 | def grep(ctx, *args, **kwargs): 39 | """Search for a pattern in Jupyter notebooks.""" 40 | pattern = kwargs["pattern"] 41 | 42 | def collect_files(): 43 | """generator for paths 44 | 45 | FILE can be individual files or directories. 46 | If it's a directory, find all .ipynb files in the directory. 47 | """ 48 | for path in kwargs["file"]: 49 | path = pathlib.Path(path) 50 | if path.is_dir(): 51 | for filename in path.glob("**/*.ipynb"): 52 | yield filename 53 | else: 54 | yield path 55 | 56 | for file in collect_files(): 57 | filename = str(file) 58 | with file.open("r") as f: 59 | nb = nbformat.read(f, as_version=4) 60 | 61 | for cell_n, cell in enumerate(nb.cells): 62 | for line_n, line in enumerate(cell.source.split("\n")): 63 | search = re.search(pattern, line) 64 | if search is not None: 65 | first, last = search.span() 66 | match = color(line[first:last], "red") 67 | click.echo( 68 | color(":", "cyan").join( 69 | [ 70 | color(filename, "white", style="normal"), 71 | color("cell {}".format(cell_n + 1), "green"), 72 | color("line {}".format(line_n + 1), "green"), 73 | line.replace(pattern, match), 74 | ] 75 | ) 76 | ) 77 | -------------------------------------------------------------------------------- /nbcommands/_head.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import click 4 | import nbformat 5 | 6 | from . import __version__ 7 | from .terminal import display 8 | 9 | 10 | @click.command(name="nbhead") 11 | @click.version_option(version=__version__) 12 | @click.option( 13 | "-n", 14 | "--lines", 15 | default=5, 16 | help="Print the first INTEGER lines instead of the first 5.", 17 | ) 18 | @click.argument("file") 19 | @click.pass_context 20 | def head(ctx, *args, **kwargs): 21 | """Print the first 5 cells of a Jupyter notebook to standard output.""" 22 | with open(kwargs["file"], "r") as f: 23 | nb = nbformat.read(f, as_version=4) 24 | 25 | n = kwargs["lines"] 26 | cells = nb.cells[:n] 27 | click.echo("\n".join(display(cells))) 28 | -------------------------------------------------------------------------------- /nbcommands/_less.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import click 4 | import nbformat 5 | 6 | from . import __version__ 7 | from .terminal import display 8 | 9 | 10 | @click.command(name="nbless") 11 | @click.version_option(version=__version__) 12 | @click.argument("file", type=click.File("rb"), default="-") 13 | @click.pass_context 14 | def less(ctx, *args, **kwargs): 15 | """View the Jupyter notebook to standard output via a Pager""" 16 | 17 | nb = nbformat.read(kwargs["file"], as_version=4) 18 | click.echo_via_pager("\n".join(display(nb.cells))) 19 | -------------------------------------------------------------------------------- /nbcommands/_tail.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import click 4 | import nbformat 5 | 6 | from . import __version__ 7 | from .terminal import display 8 | 9 | 10 | @click.command(name="nbtail") 11 | @click.version_option(version=__version__) 12 | @click.option( 13 | "-n", 14 | "--lines", 15 | default=5, 16 | help="Print the last INTEGER lines instead of the last 5.", 17 | ) 18 | @click.argument("file") 19 | @click.pass_context 20 | def tail(ctx, *args, **kwargs): 21 | """Print the last 5 cells of a Jupyter notebook to standard output.""" 22 | with open(kwargs["file"], "r") as f: 23 | nb = nbformat.read(f, as_version=4) 24 | 25 | n = kwargs["lines"] 26 | cells = nb.cells[-n:] 27 | click.echo("\n".join(display(cells))) 28 | -------------------------------------------------------------------------------- /nbcommands/_touch.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import os 4 | from pathlib import Path 5 | 6 | import click 7 | import nbformat 8 | 9 | from . import __version__ 10 | 11 | 12 | @click.command(name="nbtouch") 13 | @click.version_option(version=__version__) 14 | @click.argument("file", nargs=-1) 15 | @click.pass_context 16 | def touch(ctx, *args, **kwargs): 17 | """Update the access and modification times of each Jupyter notebook to the current time. 18 | 19 | If FILE does not exist, it will be created as an empty notebook. 20 | """ 21 | for file in kwargs["file"]: 22 | if not os.path.exists(file): 23 | nb = nbformat.v4.new_notebook() 24 | with open(file, "w") as f: 25 | nbformat.write(nb, f, version=4) 26 | else: 27 | Path(file).touch() 28 | -------------------------------------------------------------------------------- /nbcommands/terminal.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | from colorama import Fore, Style 4 | 5 | from pygments import highlight 6 | from pygments.lexers import PythonLexer 7 | from pygments.formatters import TerminalTrueColorFormatter 8 | 9 | 10 | def display(cells): 11 | output = [] 12 | 13 | for cell in cells: 14 | prompt = "" 15 | # TODO: show more cell types 16 | if cell["cell_type"] == "code": 17 | execution_count = cell.get("execution_count") 18 | execution_count = execution_count and execution_count or " " 19 | prompt = ( 20 | Fore.GREEN 21 | + Style.BRIGHT 22 | + "In [{}]: ".format(execution_count) 23 | + Style.RESET_ALL 24 | ) 25 | code = highlight(cell.source, PythonLexer(), TerminalTrueColorFormatter()) 26 | output.append(prompt + code) 27 | 28 | return output 29 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | 3 | import os 4 | from setuptools import find_packages 5 | 6 | 7 | here = os.path.abspath(os.path.dirname(__file__)) 8 | about = {} 9 | with open(os.path.join(here, "nbcommands", "__version__.py"), "r") as f: 10 | exec(f.read(), about) 11 | 12 | with open("README.md", "r") as f: 13 | readme = f.read() 14 | 15 | 16 | requires = [ 17 | "black>=19.10b0", 18 | "Click>=7.0", 19 | "colorama>=0.4.1", 20 | "nbformat>=4.4.0", 21 | "Pygments>=2.4.2", 22 | ] 23 | dev_requires = ["Sphinx>=2.2.1"] 24 | dev_requires = dev_requires + requires 25 | 26 | 27 | def setup_package(): 28 | metadata = dict( 29 | name=about["__title__"], 30 | version=about["__version__"], 31 | description=about["__description__"], 32 | long_description=readme, 33 | long_description_content_type="text/markdown", 34 | url=about["__url__"], 35 | author=about["__author__"], 36 | author_email=about["__author_email__"], 37 | license=about["__license__"], 38 | packages=find_packages(exclude=("tests",)), 39 | install_requires=requires, 40 | extras_require={"dev": dev_requires}, 41 | entry_points={ 42 | "console_scripts": [ 43 | "nbblack = nbcommands._black:_black", 44 | "nbtouch = nbcommands._touch:touch", 45 | "nbgrep = nbcommands._grep:grep", 46 | "nbhead = nbcommands._head:head", 47 | "nbtail = nbcommands._tail:tail", 48 | "nbcat = nbcommands._cat:cat", 49 | "nbless = nbcommands._less:less", 50 | ] 51 | }, 52 | classifiers=[ 53 | # Trove classifiers 54 | # Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers 55 | "License :: OSI Approved :: Apache Software License", 56 | "Programming Language :: Python :: 3.6", 57 | "Programming Language :: Python :: 3.7", 58 | "Programming Language :: Python :: 3.8", 59 | "Programming Language :: Python :: 3.9", 60 | ], 61 | ) 62 | 63 | try: 64 | from setuptools import setup 65 | except ImportError: 66 | from distutils.core import setup 67 | 68 | setup(**metadata) 69 | 70 | 71 | if __name__ == "__main__": 72 | setup_package() 73 | -------------------------------------------------------------------------------- /tests/test.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "metadata": {}, 6 | "outputs": [], 7 | "source": [] 8 | }, 9 | { 10 | "cell_type": "code", 11 | "execution_count": 1, 12 | "metadata": {}, 13 | "outputs": [], 14 | "source": [ 15 | "import os" 16 | ] 17 | }, 18 | { 19 | "cell_type": "code", 20 | "execution_count": 2, 21 | "metadata": {}, 22 | "outputs": [ 23 | { 24 | "data": { 25 | "text/plain": [ 26 | "'/home/vinayak/dev/nbcommands/tests'" 27 | ] 28 | }, 29 | "execution_count": 2, 30 | "metadata": {}, 31 | "output_type": "execute_result" 32 | } 33 | ], 34 | "source": [ 35 | "os.getcwd()" 36 | ] 37 | }, 38 | { 39 | "cell_type": "code", 40 | "execution_count": null, 41 | "metadata": {}, 42 | "outputs": [], 43 | "source": [] 44 | } 45 | ], 46 | "metadata": { 47 | "kernelspec": { 48 | "display_name": "Python 3", 49 | "language": "python", 50 | "name": "python3" 51 | }, 52 | "language_info": { 53 | "codemirror_mode": { 54 | "name": "ipython", 55 | "version": 3 56 | }, 57 | "file_extension": ".py", 58 | "mimetype": "text/x-python", 59 | "name": "python", 60 | "nbconvert_exporter": "python", 61 | "pygments_lexer": "ipython3", 62 | "version": "3.6.9" 63 | } 64 | }, 65 | "nbformat": 4, 66 | "nbformat_minor": 2 67 | } 68 | -------------------------------------------------------------------------------- /tests/test_nbcommands.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vinayak-mehta/nbcommands/5bc82cf9ca5ce03d0d11524d9cd081f1bc4cd768/tests/test_nbcommands.py --------------------------------------------------------------------------------