Export #export cells from Jupytext (py:percent) files into clean modules
Project description
jtexport
Export only #export-tagged cells from Jupytext (py:percent) notebooks to a clean Python module tree under exports/.
Why?
Working in Jupyter Lab with Jupytext is great, but the # %% cell markers and exploratory cells aren't what you want in your final codebase. jtexport lets you mark just the relevant cells (#export) and build a clean module mirror for packaging/testing.
Usage
# Process one file
jtexport path/to/notebook.py
# Process a directory recursively
jtexport notebooks/
# Custom output directory and project root
jtexport notebooks/ --outdir build/exports --project-root .
# Keep magics, fail if a file has no export cells
jtexport . --keep-magics --fail-on-empty
## Example
Consider a Jupytext file nb/example.py like:
```python
# %%
#export
import math
def cos2(x):
return math.cos(2 * x)
# %%
print(cos2(1.0)) # dev-only cell
Running:
jtexport nb/example.py
Produces:
exports/nb/example.py
With contents similar to:
# This file was auto-generated by jtexport.
# Source: nb/example.py
import math
def cos2(x):
return math.cos(2 * x)
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jtexport-0.1.0.tar.gz.
File metadata
- Download URL: jtexport-0.1.0.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aca7918f448fd191099e9a35ef9a8fe5e06fd8202effa5b52eab6b778f5b77c7
|
|
| MD5 |
874b48e4f1512b4927be585a3138f8b8
|
|
| BLAKE2b-256 |
2e14efa6e7d4258f2b091d848d8ca1ebed8346c67bf0f4cdc65eb1e7c1f73703
|
File details
Details for the file jtexport-0.1.0-py3-none-any.whl.
File metadata
- Download URL: jtexport-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84085916a9de615ed85a2e10e35143a4c3cfe50b4feb3ff86a20e0d4e752605e
|
|
| MD5 |
d3c795d7a9b7b71b7159230496221604
|
|
| BLAKE2b-256 |
4bd8d827d480226ba88e24da50b8e496928ea3ac7594a24ed27c0d203eab733a
|