macros for Jupyter Notebooks
Project description
JPConvert
JPConvert is a simple tool to split up Jupyter Notebooks based on macros and remove unnecessary metadata.
Installation
JPConvert does not need any libraries. It is probably a good idea to use nbstripout
with it though.
The preferred way to use JPConvert is in a virtual environment:
python -m venv venv
source venv/bin/activate
Use pip to download and install JPConvert:
pip install jpconvert
Usage
python -m jpconvert <input> [<options>] [<output>]
If no input file is specified, stdin
is used instead. If no output file is specified, stdout
is used instead.
Macros and Options
Multiple macros can be used per cell. Only code cells with the macro matching the output options are kept. Macros themselves are removed from the code cells.
macro | option |
---|---|
#jp-practice |
--practice / -p |
#jp-teaching |
--teaching / -t |
#jp-solution |
--solution / -s |
One may decide what happens to code cells without any macros. By default, they are removed if --allow-skip
is not used.
Using --remove-empty
you can remove any empty cells.
Example
Image two code cells inside your notebook:
#jp-solution
a = a + 1
#jp-practice
a = ...
If you call JPConvert with the --practice
option, the first cell is removed and the second cell is kept:
a = ...
If you call JPConvert with the --solution
option, the first cell is kept and the second cell is removed:
a = a + 1
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for jpconvert-0.2.4-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c3e4469a65ff999c26212f8a7af576a33c9b910f356e49f8ea62a9b773604c5 |
|
MD5 | 163df90bed6d3762e46cc942c54ee656 |
|
BLAKE2b-256 | 5056accbfbec9228265354fee2e80e86610576a1372bbcc416171422aeb87663 |