Repository: vinayak-mehta/nbcommands Branch: master Commit: 5bc82cf9ca5c Files: 30 Total size: 57.7 KB Directory structure: gitextract_a61g6ghf/ ├── .gitignore ├── .readthedocs.yml ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── HISTORY.md ├── LICENSE ├── README.md ├── docs/ │ ├── Makefile │ ├── _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 ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] *$py.class # C extensions *.so # Distribution / packaging .Python build/ develop-eggs/ dist/ downloads/ eggs/ .eggs/ lib/ lib64/ parts/ sdist/ var/ wheels/ *.egg-info/ .installed.cfg *.egg MANIFEST # PyInstaller # Usually these files are written by a python script from a template # before PyInstaller builds the exe, so as to inject date/other infos into it. *.manifest *.spec # Installer logs pip-log.txt pip-delete-this-directory.txt # Unit test / coverage reports htmlcov/ .tox/ .coverage .coverage.* .cache nosetests.xml coverage.xml *.cover .hypothesis/ .pytest_cache/ # Translations *.mo *.pot # Django stuff: *.log local_settings.py db.sqlite3 # Flask stuff: instance/ .webassets-cache # Scrapy stuff: .scrapy # Sphinx documentation docs/_build/ # PyBuilder target/ # Jupyter Notebook .ipynb_checkpoints # pyenv .python-version # celery beat schedule file celerybeat-schedule # SageMath parsed files *.sage.py # Environments .env .venv env/ venv/ ENV/ env.bak/ venv.bak/ # Spyder project settings .spyderproject .spyproject # Rope project settings .ropeproject # mkdocs documentation /site # mypy .mypy_cache/ ================================================ FILE: .readthedocs.yml ================================================ # .readthedocs.yml # Read the Docs configuration file # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details # Required version: 2 # Build documentation in the docs/ directory with Sphinx sphinx: configuration: docs/conf.py # Build documentation with MkDocs #mkdocs: # configuration: mkdocs.yml # Optionally build your docs in additional formats such as PDF formats: - pdf # Optionally set the version of Python and requirements required to build your docs python: version: 3.8 install: - method: pip path: . extra_requirements: - dev ================================================ FILE: CODE_OF_CONDUCT.md ================================================ Be cordial or be on your way. --Kenneth Reitz https://www.kennethreitz.org/essays/be-cordial-or-be-on-your-way ================================================ FILE: CONTRIBUTING.md ================================================ # Contributor's Guide 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! 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. ## Code Of Conduct The following quote sums up the **Code Of Conduct**. > Be cordial or be on your way. --Kenneth Reitz 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. ## Your first contribution 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. ## Setting up a development environment To install the dependencies needed for development, you can use pip:
$ pip install conference-radar[dev]
Alternatively, you can clone the project repository, and install using pip:
$ pip install ".[dev]"
## Pull Requests ### Submit a pull request 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: 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. 2. Clone your fork of nbcommands from your GitHub account:
$ git clone https://www.github.com/[username]/nbcommands
3. Create a branch to hold your changes:
$ git checkout -b my-feature
Always branch out from `master` to work on your contribution. It's good practice to never work on the `master` branch! **Protip: `git stash` is a great way to save the work that you haven't committed yet, to move between branches.** 4. Work on your contribution. Add changed files using `git add` and then `git commit` them:
$ git add modified_files
$ git commit
5. Finally, push them to your GitHub fork:
$ git push -u origin my-feature
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. ### Work on your pull request It is recommended that your pull request complies with the following rules: - Make sure your code follows [pep8](http://pep8.org). You should [blacken](https://github.com/psf/black) your code. - Make sure your commit messages follow [the seven rules of a great git commit message](https://chris.beams.io/posts/git-commit/): - Separate subject from body with a blank line - Limit the subject line to 50 characters - Capitalize the subject line - Do not end the subject line with a period - Use the imperative mood in the subject line - Wrap the body at 72 characters - Use the body to explain what and why vs. how - 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. - 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:
$ python setup.py test
## Filing Issues [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. ### Bug Reports In bug reports, make sure you include: - Your operating system type and Python version:
import platform; print(platform.platform())
import sys; print('Python', sys.version)
- The complete traceback. Just adding the exception message or a part of the traceback won't help the maintainer fix your issue sooner. ================================================ FILE: HISTORY.md ================================================ Release History =============== master ------ 0.5.1 (2021-06-21) ------------------ - Minor documentation changes. 0.5.0 (2021-06-21) ------------------ **Improvements** - Support directories in nbgrep. [#26](https://github.com/vinayak-mehta/nbcommands/pull/26) by [Min RK](https://github.com/minrk). 0.4.0 (2020-08-01) ------------------ **Improvements** - [#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). - Add Sphinx docs! **Bugfixes** - [#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. 0.3.2 (2019-11-02) ------------------ **Bugfixes** - Fix black source check. Fix: [1d49970](https://github.com/vinayak-mehta/nbcommands/commit/1d4997076df3cd799e28cc9dcb94ef597dadd940). 0.3.1 (2019-11-02) ------------------ **Bugfixes** - [#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). 0.3.0 (2019-11-02) ------------------ **Improvements** - Add nbblack. ✨ 🍰 ✨ 0.2.2 (2019-11-01) ------------------
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/
0.2.1 (2019-11-01) ------------------ **Bugfixes** * Fix README links. 0.2.0 (2019-11-01) ------------------ **Improvements** * Add nbtouch, nbgrep, nbhead, nbtail and nbcat. 0.1.0 (2019-10-31) ------------------ * Birth! ================================================ FILE: LICENSE ================================================ Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright 2019 Vinayak Mehta Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ================================================ FILE: README.md ================================================

# nbcommands [![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) nbcommands bring the goodness of Unix commands to Jupyter notebooks. ## Installation You can simply use pip to install nbcommands:
$ pip install nbcommands
or conda:
$ conda install -c conda-forge nbcommands
## Usage nbcommands installs the following commands which let you interact with your Jupyter notebooks without spinning up a notebook server. - `nbtouch`: Update the access and modification times of each Jupyter notebook to the current time.
    $ nbtouch notebook1.ipynb notebook2.ipynb
![nbtouch](https://raw.githubusercontent.com/vinayak-mehta/nbcommands/master/docs/_static/nbtouch.gif) - `nbgrep`: Search for a pattern in Jupyter notebooks.
    $ nbgrep "os" notebook1.ipynb notebook2.ipynb
    $ nbgrep "os" directory/
![nbgrep](https://raw.githubusercontent.com/vinayak-mehta/nbcommands/master/docs/_static/nbgrep.gif) - `nbhead`: Print the first 5 cells of a Jupyter notebook to standard output.
    $ nbhead notebook1.ipynb
![nbhead](https://raw.githubusercontent.com/vinayak-mehta/nbcommands/master/docs/_static/nbhead.gif) Note: You can also specify the number of cells you want to print using the `-n` option.
    $ nbhead -n 10 notebook1.ipynb
- `nbtail`: Print the last 5 cells of a Jupyter notebook to standard output.
    $ nbtail notebook2.ipynb
![nbtail](https://raw.githubusercontent.com/vinayak-mehta/nbcommands/master/docs/_static/nbtail.gif) Note: You can also specify the number of cells you want to print using the `-n` option.
    $ nbtail -n 10 notebook2.ipynb
- `nbcat`: Concatenate Jupyter notebooks to standard output.
    $ nbcat notebook1.ipynb notebook2.ipynb
![nbcat](https://raw.githubusercontent.com/vinayak-mehta/nbcommands/master/docs/_static/nbcat.gif) Note: You can create a new notebook by concatenating multiple notebooks using the `-o` option.
    $ nbcat notebook1.ipynb notebook2.ipynb -o notebook3.ipynb
- `nbless`: Print a Jupyter notebook using a pager program.
    $ nbless notebook1.ipynb
![nbless](https://raw.githubusercontent.com/vinayak-mehta/nbcommands/master/docs/_static/nbless.gif) And some non-Unix goodness, - `nbblack`: Blacken Jupyter notebooks.
    $ nbblack notebook1.ipynb notebook2.ipynb
![nbblack](https://raw.githubusercontent.com/vinayak-mehta/nbcommands/master/docs/_static/nbblack.gif) --- Planned enhancements: - `nbstrip`: Strip outputs from Jupyter notebooks. - `nbdiff`: Find the diff between two Jupyter notebooks. - `nbecho`: Add a code cell to a Jupyter notebook. - `nbedit`: Interactively edit a Jupyter notebook. - `nbtime`: Run and time a Jupyter notebook. - `nbwc`: Print word count for a Jupyter notebook. ## Versioning nbcommands uses [Semantic Versioning](https://semver.org/). For the available versions, see the tags on this repository. ## License This project is licensed under the Apache License, see the [LICENSE](https://raw.githubusercontent.com/vinayak-mehta/nbcommands/master/LICENSE) file for details. ================================================ FILE: docs/Makefile ================================================ # Minimal makefile for Sphinx documentation # # You can set these variables from the command line, and also # from the environment for the first two. SPHINXOPTS ?= SPHINXBUILD ?= sphinx-build SOURCEDIR = . BUILDDIR = _build # Put it first so that "make" without argument is like "make help". help: @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) .PHONY: help Makefile # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). %: Makefile @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) ================================================ FILE: docs/_templates/hacks.html ================================================ ================================================ FILE: docs/_templates/sidebarintro.html ================================================

Useful Links

================================================ FILE: docs/_templates/sidebarlogo.html ================================================

================================================ FILE: docs/_themes/.gitignore ================================================ *.pyc *.pyo ================================================ FILE: docs/_themes/LICENSE ================================================ Copyright (c) 2010 by Armin Ronacher. Some rights reserved. Redistribution and use in source and binary forms of the theme, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission. We kindly ask you to only use these themes in an unmodified manner just for Flask and Flask-related products, not for unrelated projects. If you like the visual style and want to use it for your own projects, please consider making some larger changes to the themes (such as changing font faces, sizes, colors or margins). THIS THEME IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS THEME, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ================================================ FILE: docs/_themes/flask_theme_support.py ================================================ # flasky pygments style based on tango style from pygments.style import Style from pygments.token import ( Keyword, Name, Comment, String, Error, Number, Operator, Generic, Whitespace, Punctuation, Other, Literal, ) class FlaskyStyle(Style): background_color = "#f8f8f8" default_style = "" styles = { # No corresponding class for the following: # Text: "", # class: '' Whitespace: "underline #f8f8f8", # class: 'w' Error: "#a40000 border:#ef2929", # class: 'err' Other: "#000000", # class 'x' Comment: "italic #8f5902", # class: 'c' Comment.Preproc: "noitalic", # class: 'cp' Keyword: "bold #004461", # class: 'k' Keyword.Constant: "bold #004461", # class: 'kc' Keyword.Declaration: "bold #004461", # class: 'kd' Keyword.Namespace: "bold #004461", # class: 'kn' Keyword.Pseudo: "bold #004461", # class: 'kp' Keyword.Reserved: "bold #004461", # class: 'kr' Keyword.Type: "bold #004461", # class: 'kt' Operator: "#582800", # class: 'o' Operator.Word: "bold #004461", # class: 'ow' - like keywords Punctuation: "bold #000000", # class: 'p' # because special names such as Name.Class, Name.Function, etc. # are not recognized as such later in the parsing, we choose them # to look the same as ordinary variables. Name: "#000000", # class: 'n' Name.Attribute: "#c4a000", # class: 'na' - to be revised Name.Builtin: "#004461", # class: 'nb' Name.Builtin.Pseudo: "#3465a4", # class: 'bp' Name.Class: "#000000", # class: 'nc' - to be revised Name.Constant: "#000000", # class: 'no' - to be revised Name.Decorator: "#888", # class: 'nd' - to be revised Name.Entity: "#ce5c00", # class: 'ni' Name.Exception: "bold #cc0000", # class: 'ne' Name.Function: "#000000", # class: 'nf' Name.Property: "#000000", # class: 'py' Name.Label: "#f57900", # class: 'nl' Name.Namespace: "#000000", # class: 'nn' - to be revised Name.Other: "#000000", # class: 'nx' Name.Tag: "bold #004461", # class: 'nt' - like a keyword Name.Variable: "#000000", # class: 'nv' - to be revised Name.Variable.Class: "#000000", # class: 'vc' - to be revised Name.Variable.Global: "#000000", # class: 'vg' - to be revised Name.Variable.Instance: "#000000", # class: 'vi' - to be revised Number: "#990000", # class: 'm' Literal: "#000000", # class: 'l' Literal.Date: "#000000", # class: 'ld' String: "#4e9a06", # class: 's' String.Backtick: "#4e9a06", # class: 'sb' String.Char: "#4e9a06", # class: 'sc' String.Doc: "italic #8f5902", # class: 'sd' - like a comment String.Double: "#4e9a06", # class: 's2' String.Escape: "#4e9a06", # class: 'se' String.Heredoc: "#4e9a06", # class: 'sh' String.Interpol: "#4e9a06", # class: 'si' String.Other: "#4e9a06", # class: 'sx' String.Regex: "#4e9a06", # class: 'sr' String.Single: "#4e9a06", # class: 's1' String.Symbol: "#4e9a06", # class: 'ss' Generic: "#000000", # class: 'g' Generic.Deleted: "#a40000", # class: 'gd' Generic.Emph: "italic #000000", # class: 'ge' Generic.Error: "#ef2929", # class: 'gr' Generic.Heading: "bold #000080", # class: 'gh' Generic.Inserted: "#00A000", # class: 'gi' Generic.Output: "#888", # class: 'go' Generic.Prompt: "#745334", # class: 'gp' Generic.Strong: "bold #000000", # class: 'gs' Generic.Subheading: "bold #800080", # class: 'gu' Generic.Traceback: "bold #a40000", # class: 'gt' } ================================================ FILE: docs/conf.py ================================================ # -*- coding: utf-8 -*- # # nbcommands documentation build configuration file, created by # sphinx-quickstart on Tue Jul 19 13:44:18 2016. # # This file is execfile()d with the current directory set to its # containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration values have a default; values that are commented out # serve to show the default. import os import sys # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. # # sys.path.insert(0, os.path.abspath('..')) # Insert nbcommands's path into the system. sys.path.insert(0, os.path.abspath("..")) sys.path.insert(0, os.path.abspath("_themes")) import nbcommands # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. # # needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [] # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # # source_suffix = ['.rst', '.md'] source_suffix = ".rst" # The encoding of source files. # # source_encoding = 'utf-8-sig' # The master toctree document. master_doc = "index" # General information about the project. project = u"conference-radar" copyright = u"2021, Vinayak Mehta" author = u"Vinayak Mehta" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. # The short X.Y version. version = nbcommands.__version__ # The full version, including alpha/beta/rc tags. release = nbcommands.__version__ # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. language = None # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: # # today = '' # # Else, today_fmt is used as the format for a strftime call. # # today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path exclude_patterns = ["_build"] # The reST default role (used for this markup: `text`) to use for all # documents. # # default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. # # show_authors = False # The name of the Pygments (syntax highlighting) style to use. pygments_style = "flask_theme_support.FlaskyStyle" # A list of ignored prefixes for module index sorting. # modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. # keep_warnings = False # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = True # -- Options for HTML output ---------------------------------------------- # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. html_theme = "alabaster" # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. html_theme_options = { "show_powered_by": False, "github_user": "vinayak-mehta", "github_repo": "nbcommands", "github_banner": True, "show_related": False, "note_bg": "#FFF59C", } # Add any paths that contain custom themes here, relative to this directory. # html_theme_path = [] # The name for this set of Sphinx documents. # " v documentation" by default. # # html_title = None # A shorter title for the navigation bar. Default is the same as html_title. # # html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. # # html_logo = None # The name of an image file (relative to this directory) to use as a favicon of # the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. html_favicon = "_static/favicon.ico" # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". html_static_path = ["_static"] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied # directly to the root of the documentation. # # html_extra_path = [] # If not None, a 'Last updated on:' timestamp is inserted at every page # bottom, using the given strftime format. # The empty string is equivalent to '%b %d, %Y'. # # html_last_updated_fmt = None # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. html_use_smartypants = True # Custom sidebar templates, maps document names to template names. html_sidebars = { "index": [ "sidebarintro.html", "relations.html", "sourcelink.html", "searchbox.html", "hacks.html", ], "**": [ "sidebarlogo.html", "localtoc.html", "relations.html", "sourcelink.html", "searchbox.html", "hacks.html", ], } # Additional templates that should be rendered to pages, maps page names to # template names. # # html_additional_pages = {} # If false, no module index is generated. # # html_domain_indices = True # If false, no index is generated. # # html_use_index = True # If true, the index is split into individual pages for each letter. # # html_split_index = False # If true, links to the reST sources are added to the pages. html_show_sourcelink = False # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. html_show_sphinx = False # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. # # html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). # html_file_suffix = None # Language to be used for generating the HTML full-text search index. # Sphinx supports the following languages: # 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' # 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh' # # html_search_language = 'en' # A dictionary with options for the search language support, empty by default. # 'ja' uses this config value. # 'zh' user can custom change `jieba` dictionary path. # # html_search_options = {'type': 'default'} # The name of a javascript file (relative to the configuration directory) that # implements a search results scorer. If empty, the default will be used. # # html_search_scorer = 'scorer.js' # Output file base name for HTML help builder. htmlhelp_basename = "nbcommandsdoc" # -- Options for LaTeX output --------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). # # 'papersize': 'letterpaper', # The font size ('10pt', '11pt' or '12pt'). # # 'pointsize': '10pt', # Additional stuff for the LaTeX preamble. # # 'preamble': '', # Latex figure (float) alignment # # 'figure_align': 'htbp', } # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ ( master_doc, "nbcommands.tex", u"nbcommands documentation", u"Vinayak Mehta", "manual", ) ] # The name of an image file (relative to this directory) to place at the top of # the title page. # # latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. # # latex_use_parts = False # If true, show page references after internal links. # # latex_show_pagerefs = False # If true, show URL addresses after external links. # # latex_show_urls = False # Documents to append as an appendix to all manuals. # # latex_appendices = [] # It false, will not define \strong, \code, itleref, \crossref ... but only # \sphinxstrong, ..., \sphinxtitleref, ... To help avoid clash with user added # packages. # # latex_keep_old_macro_names = True # If false, no module index is generated. # # latex_domain_indices = True # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [(master_doc, "nbcommands", u"nbcommands documentation", [author], 1)] # If true, show URL addresses after external links. # # man_show_urls = False # -- Options for Texinfo output ------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ ( master_doc, "nbcommands", u"nbcommands documentation", author, "nbcommands", "One line description of project.", "Miscellaneous", ) ] # Documents to append as an appendix to all manuals. # # texinfo_appendices = [] # If false, no module index is generated. # # texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. # # texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. # # texinfo_no_detailmenu = False ================================================ FILE: docs/index.rst ================================================ .. nbcommands documentation master file, created by sphinx-quickstart on Sat Aug 1 03:02:35 2020. You can adapt this file completely to your liking, but it should at least contain the root `toctree` directive. nbcommands — Unix commands for Jupyter notebooks ================================================ .. image:: https://readthedocs.org/projects/nbcommands/badge/?version=latest :target: https://nbcommands.readthedocs.io/en/latest/ :alt: Documentation Status .. image:: https://img.shields.io/pypi/v/nbcommands.svg :target: https://pypi.org/project/nbcommands/ .. image:: https://img.shields.io/pypi/pyversions/nbcommands.svg :target: https://pypi.org/project/nbcommands/ .. image:: https://img.shields.io/badge/code%20style-black-000000.svg :target: https://github.com/ambv/black nbcommands bring the goodness of Unix commands to Jupyter notebooks. Installation ------------ You can simply use pip to install nbcommands:: $ pip install nbcommands or conda:: $ conda install -c conda-forge nbcommands Usage ----- nbcommands installs the following commands which let you interact with your Jupyter notebooks without spinning up a notebook server. nbtouch ^^^^^^^ Update the access and modification times of each Jupyter notebook to the current time, or create empty notebook files where none exist:: $ nbtouch notebook1.ipynb notebook2.ipynb .. image:: _static/nbtouch.gif nbgrep ^^^^^^ Search for a pattern in Jupyter notebooks:: $ nbgrep "os" notebook1.ipynb notebook2.ipynb $ nbgrep "os" directory/ .. image:: _static/nbgrep.gif nbhead ^^^^^^ Print the first 5 cells of a Jupyter notebook to standard output:: $ nbhead notebook1.ipynb .. image:: _static/nbhead.gif .. note:: You can also specify the number of cells you want to print using the ``-n`` option. nbtail ^^^^^^ Print the last 5 cells of a Jupyter notebook to standard output:: $ nbtail notebook2.ipynb .. image:: _static/nbtail.gif .. note:: You can also specify the number of cells you want to print using the ``-n`` option. nbcat ^^^^^ Concatenate Jupyter notebooks to standard output:: $ nbcat notebook1.ipynb notebook2.ipynb .. image:: _static/nbcat.gif .. note:: You can create a new notebook by concatenating multiple notebooks using the ``-o`` option. nbless ^^^^^^ Print a Jupyter notebook using a pager program:: $ nbless notebook1.ipynb .. image:: _static/nbless.gif And some non-Unix goodness, nbblack ^^^^^^^ Blacken Jupyter notebooks:: $ nbblack notebook1.ipynb notebook2.ipynb .. image:: _static/nbblack.gif --- Planned enhancements: - ``nbstrip``: Strip outputs from Jupyter notebooks. - ``nbdiff``: Find the diff between two Jupyter notebooks. - ``nbecho``: Add a code cell to a Jupyter notebook. - ``nbedit``: Interactively edit a Jupyter notebook. - ``nbtime``: Run and time a Jupyter notebook. - ``nbwc``: Print word count for a Jupyter notebook. Versioning ---------- nbcommands uses `Semantic Versioning `_. For the available versions, see the tags on the GitHub repository. License ------- This project is licensed under the Apache License, see the `LICENSE `_ file for details. ================================================ FILE: docs/make.bat ================================================ @ECHO OFF pushd %~dp0 REM Command file for Sphinx documentation if "%SPHINXBUILD%" == "" ( set SPHINXBUILD=sphinx-build ) set SOURCEDIR=. set BUILDDIR=_build if "%1" == "" goto help %SPHINXBUILD% >NUL 2>NUL if errorlevel 9009 ( echo. echo.The 'sphinx-build' command was not found. Make sure you have Sphinx echo.installed, then set the SPHINXBUILD environment variable to point echo.to the full path of the 'sphinx-build' executable. Alternatively you echo.may add the Sphinx directory to PATH. echo. echo.If you don't have Sphinx installed, grab it from echo.http://sphinx-doc.org/ exit /b 1 ) %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% goto end :help %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% :end popd ================================================ FILE: nbcommands/__init__.py ================================================ # -*- coding: utf-8 -*- from .__version__ import __version__ ================================================ FILE: nbcommands/__version__.py ================================================ # -*- coding: utf-8 -*- VERSION = (0, 5, 1) PRERELEASE = None # alpha, beta or rc REVISION = None def generate_version(version, prerelease=None, revision=None): version_parts = [".".join(map(str, version))] if prerelease is not None: version_parts.append("-{}".format(prerelease)) if revision is not None: version_parts.append(".{}".format(revision)) return "".join(version_parts) __title__ = "nbcommands" __description__ = "Unix commands for Jupyter notebooks." __url__ = "https://github.com/vinayak-mehta/nbcommands" __version__ = generate_version(VERSION, prerelease=PRERELEASE, revision=REVISION) __author__ = "Vinayak Mehta" __author_email__ = "vmehta94@gmail.com" __license__ = "Apache 2.0" ================================================ FILE: nbcommands/_black.py ================================================ # -*- coding: utf-8 -*- import re import black import click import nbformat from . import __version__ def _cells(nb): """Yield all cells in an nbformat-insensitive manner Source: https://github.com/kynan/nbstripout/blob/master/nbstripout/_utils.py#L27 """ if nb.nbformat < 4: for ws in nb.worksheets: for cell in ws.cells: yield cell else: for cell in nb.cells: yield cell @click.command(name="nbblack") @click.version_option(version=__version__) @click.argument("file", nargs=-1) @click.pass_context def _black(ctx, *args, **kwargs): """Blacken Jupyter notebooks.""" file_count = len(kwargs["file"]) black_file_count = 0 for file in kwargs["file"]: with open(file, "r") as f: nb = nbformat.read(f, as_version=4) black_flag = False pinfo_flag = False pattern = re.compile("^\?") # Source: https://neuralcoder.science/Black-Jupyter/ for cell in _cells(nb): if cell.cell_type == "code": source = cell.source source = re.sub("^%", "#%", source, flags=re.M) source = re.sub("^!", "#!", source, flags=re.M) if pattern.match(source): pinfo_flag = True source = "#" + source black_source = black.format_str(source, mode=black.FileMode()) black_source = re.sub("^#%", "%", black_source, flags=re.M) black_source = re.sub("^#!", "!", black_source, flags=re.M) if pinfo_flag: black_source = black_source[1:] black_source = black_source.strip() if cell.source != black_source: black_flag = True cell.source = black_source if black_flag: click.echo("reformatted {}".format(file)) black_file_count += 1 with open(file, "w") as f: nbformat.write(nb, f, version=4) click.echo("All done! ✨ 🍰 ✨") if black_file_count: s = "s" if black_file_count > 1 else "" click.echo("{} file{} reformatted.".format(black_file_count, s)) else: s = "s" if file_count > 1 else "" click.echo("{} file{} left unchanged.".format(file_count, s)) ================================================ FILE: nbcommands/_cat.py ================================================ # -*- coding: utf-8 -*- import os import click import nbformat from . import __version__ from .terminal import display @click.command(name="nbcat") @click.version_option(version=__version__) @click.option("-o", "--output", help="Output file path.") @click.argument("file", nargs=-1) @click.pass_context def cat(ctx, *args, **kwargs): """Concatenate Jupyter notebooks to standard output.""" # Source: https://github.com/jbn/nbmerge merged, metadata = None, [] for file in kwargs["file"]: with open(file, "r") as f: nb = nbformat.read(f, as_version=4) metadata.append(nb.metadata) if merged is None: merged = nb else: merged.cells.extend(nb.cells) merged_metadata = {} for meta in reversed(metadata): merged_metadata.update(meta) merged.metadata = merged_metadata if kwargs["output"] is not None: with open(kwargs["output"], "w") as f: nbformat.write(merged, f, version=4) else: click.echo("\n".join(display(merged.cells))) ================================================ FILE: nbcommands/_grep.py ================================================ # -*- coding: utf-8 -*- import pathlib import re import click import nbformat from colorama import Fore, Style from . import __version__ def color(s, c, style="bright"): color_map = { "black": Fore.BLACK, "red": Fore.RED, "green": Fore.GREEN, "yellow": Fore.YELLOW, "blue": Fore.BLUE, "magenta": Fore.MAGENTA, "cyan": Fore.CYAN, "white": Fore.WHITE, } style_map = { "dim": Style.DIM, "normal": Style.NORMAL, "bright": Style.BRIGHT, } return color_map[c] + style_map[style] + s + Style.RESET_ALL @click.command(name="nbgrep") @click.version_option(version=__version__) @click.argument("pattern") @click.argument("file", nargs=-1, type=click.Path(exists=True), required=True) @click.pass_context def grep(ctx, *args, **kwargs): """Search for a pattern in Jupyter notebooks.""" pattern = kwargs["pattern"] def collect_files(): """generator for paths FILE can be individual files or directories. If it's a directory, find all .ipynb files in the directory. """ for path in kwargs["file"]: path = pathlib.Path(path) if path.is_dir(): for filename in path.glob("**/*.ipynb"): yield filename else: yield path for file in collect_files(): filename = str(file) with file.open("r") as f: nb = nbformat.read(f, as_version=4) for cell_n, cell in enumerate(nb.cells): for line_n, line in enumerate(cell.source.split("\n")): search = re.search(pattern, line) if search is not None: first, last = search.span() match = color(line[first:last], "red") click.echo( color(":", "cyan").join( [ color(filename, "white", style="normal"), color("cell {}".format(cell_n + 1), "green"), color("line {}".format(line_n + 1), "green"), line.replace(pattern, match), ] ) ) ================================================ FILE: nbcommands/_head.py ================================================ # -*- coding: utf-8 -*- import click import nbformat from . import __version__ from .terminal import display @click.command(name="nbhead") @click.version_option(version=__version__) @click.option( "-n", "--lines", default=5, help="Print the first INTEGER lines instead of the first 5.", ) @click.argument("file") @click.pass_context def head(ctx, *args, **kwargs): """Print the first 5 cells of a Jupyter notebook to standard output.""" with open(kwargs["file"], "r") as f: nb = nbformat.read(f, as_version=4) n = kwargs["lines"] cells = nb.cells[:n] click.echo("\n".join(display(cells))) ================================================ FILE: nbcommands/_less.py ================================================ # -*- coding: utf-8 -*- import click import nbformat from . import __version__ from .terminal import display @click.command(name="nbless") @click.version_option(version=__version__) @click.argument("file", type=click.File("rb"), default="-") @click.pass_context def less(ctx, *args, **kwargs): """View the Jupyter notebook to standard output via a Pager""" nb = nbformat.read(kwargs["file"], as_version=4) click.echo_via_pager("\n".join(display(nb.cells))) ================================================ FILE: nbcommands/_tail.py ================================================ # -*- coding: utf-8 -*- import click import nbformat from . import __version__ from .terminal import display @click.command(name="nbtail") @click.version_option(version=__version__) @click.option( "-n", "--lines", default=5, help="Print the last INTEGER lines instead of the last 5.", ) @click.argument("file") @click.pass_context def tail(ctx, *args, **kwargs): """Print the last 5 cells of a Jupyter notebook to standard output.""" with open(kwargs["file"], "r") as f: nb = nbformat.read(f, as_version=4) n = kwargs["lines"] cells = nb.cells[-n:] click.echo("\n".join(display(cells))) ================================================ FILE: nbcommands/_touch.py ================================================ # -*- coding: utf-8 -*- import os from pathlib import Path import click import nbformat from . import __version__ @click.command(name="nbtouch") @click.version_option(version=__version__) @click.argument("file", nargs=-1) @click.pass_context def touch(ctx, *args, **kwargs): """Update the access and modification times of each Jupyter notebook to the current time. If FILE does not exist, it will be created as an empty notebook. """ for file in kwargs["file"]: if not os.path.exists(file): nb = nbformat.v4.new_notebook() with open(file, "w") as f: nbformat.write(nb, f, version=4) else: Path(file).touch() ================================================ FILE: nbcommands/terminal.py ================================================ # -*- coding: utf-8 -*- from colorama import Fore, Style from pygments import highlight from pygments.lexers import PythonLexer from pygments.formatters import TerminalTrueColorFormatter def display(cells): output = [] for cell in cells: prompt = "" # TODO: show more cell types if cell["cell_type"] == "code": execution_count = cell.get("execution_count") execution_count = execution_count and execution_count or " " prompt = ( Fore.GREEN + Style.BRIGHT + "In [{}]: ".format(execution_count) + Style.RESET_ALL ) code = highlight(cell.source, PythonLexer(), TerminalTrueColorFormatter()) output.append(prompt + code) return output ================================================ FILE: setup.py ================================================ # -*- coding: utf-8 -*- import os from setuptools import find_packages here = os.path.abspath(os.path.dirname(__file__)) about = {} with open(os.path.join(here, "nbcommands", "__version__.py"), "r") as f: exec(f.read(), about) with open("README.md", "r") as f: readme = f.read() requires = [ "black>=19.10b0", "Click>=7.0", "colorama>=0.4.1", "nbformat>=4.4.0", "Pygments>=2.4.2", ] dev_requires = ["Sphinx>=2.2.1"] dev_requires = dev_requires + requires def setup_package(): metadata = dict( name=about["__title__"], version=about["__version__"], description=about["__description__"], long_description=readme, long_description_content_type="text/markdown", url=about["__url__"], author=about["__author__"], author_email=about["__author_email__"], license=about["__license__"], packages=find_packages(exclude=("tests",)), install_requires=requires, extras_require={"dev": dev_requires}, entry_points={ "console_scripts": [ "nbblack = nbcommands._black:_black", "nbtouch = nbcommands._touch:touch", "nbgrep = nbcommands._grep:grep", "nbhead = nbcommands._head:head", "nbtail = nbcommands._tail:tail", "nbcat = nbcommands._cat:cat", "nbless = nbcommands._less:less", ] }, classifiers=[ # Trove classifiers # Full list: https://pypi.python.org/pypi?%3Aaction=list_classifiers "License :: OSI Approved :: Apache Software License", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", ], ) try: from setuptools import setup except ImportError: from distutils.core import setup setup(**metadata) if __name__ == "__main__": setup_package() ================================================ FILE: tests/test.ipynb ================================================ { "cells": [ { "cell_type": "code", "metadata": {}, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import os" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'/home/vinayak/dev/nbcommands/tests'" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "os.getcwd()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.9" } }, "nbformat": 4, "nbformat_minor": 2 } ================================================ FILE: tests/test_nbcommands.py ================================================