nanb


Namenanb JSON
Version 0.1.1 PyPI version JSON
download
home_page
SummaryNot A NoteBook
upload_time2023-11-18 20:30:32
maintainer
docs_urlNone
author
requires_python>=3.9
license
keywords
VCS
bugtrack_url
requirements aiohttp aiosignal anyio async-timeout attrs charset-normalizer click frozenlist idna importlib-metadata linkify-it-py markdown-it-py mdit-py-plugins mdurl msgpack multidict Pygments rich sniffio textual textual-dev toml tree-sitter tree-sitter-languages typing_extensions uc-micro-py watchfiles yarl zipp
Travis-CI No Travis.
coveralls test coverage No coveralls.
            nanb - Not A NoteBook
=====================

Jupyter-style execution with plain Python files, in the terminal.

![screenshot](https://github.com/enotodden/nanb/blob/09570785cb135ccbb74ba787f1177b54639786d2/nanb_screenshot.png)

Example:

```python

# My Notebook
# ===========
#
# Welcome to my **not-a-notebook**!
#
# Here is a description, and some bullet points:
# - foo
# - bar
# - baz
#
# Here is a code block:
# ```python
# print("hello world")
# ```
#
# Here is a table:
# | foo | bar |
# |-----|-----|
# | 1   | 2   |
# | 3   | 4   |
#


# --- Do some imports
import os
import json


# --- Set a var
hello_abc = "Hello ABC!"

# --- Print it
print(hello_abc)

# ---
# This cell has no name, which is also fine
print("Hello world")
```

## Installation

```shell
$ pip install nanb
```


## Running a file

```shell
$ nanb run ./myfile.py
```

## Why?

Jupyter notbooks are great, but they are not regular Python files, and can be hard to work with in your editor of choice.

This project is an attempt at providing a stateful REPL-like execution environment for vanilla Python,
in the terminal, with regular source files that you edit using the editor/IDE of your choice.

## Cell syntax

Like in jupyter, a file used in nanb is divided into cells that can be executed independently.

Code cells are marked using `# ---`
```python
# ---
print('Hello world')
```

Markdown cells are just regular comments using `# %%%` to indicate their beginning:
```python
# %%%
# ## This is an H2 
# - These
# - Are 
# - List 
# - Items
```

Code cells can also have labels:

```python
# --- Do stuff
do_stuff()
```

## Configuring nanb

nanb can be configured by adding a toml configuration file in `$HOME/.nanb/nanb.toml`.

### Default config:

```

cell_name_max = 20

[keybindings]
quit = "q"
restart_kernel = "ctrl+r"
copy = "y"
clear_cell_output = "c"
interrupt = "i"
run_all = "ctrl+a"
clear_all = "ctrl+x"

[server]
log_file = "/tmp/nanb_server.log"
socket_prefix = "/tmp/nanb_socket_"

[code]
theme = "github-dark"
background = "#1a1a1a"

[output]
theme = "vscode_dark"
line_numbers = false

[tr]
action_quit = "Quit"
action_restart_kernel = "Restart Kernel"
action_copy = "Copy"
action_clear_cell_output = "Clear Cell Output"
action_interrupt = "Interrupt"
action_help = "Help"
action_run_cell = "Run Cell"
action_run_all = "Run All"
action_clear_all = "Clear All"
action_close = "Close"
state_running = "RUNNING"
state_pending = "PENDING"
dh_keybindings = "Keybindings"
dh_key = "Key"
dh_action = "Action"
kb_quit = "Quit the application"
kb_restart_kernel = "Restart the kernel"
kb_copy = "Copy selected output"
kb_clear_cell_output = "Clear the output of the current cell"
kb_interrupt = "Interrupt the current execution"
kb_run_cell = "Run the current cell"
kb_run_all = "Run all cells"
kb_clear_all = "Clear all cells"
kb_help = "Show this help screen"
kb_arrows = "Move between cells"
kb_close_help = "Close the help screen"

```


### Config options:

- `server`: Config options for the server/kernel that actually runs your code.
    - `log_file`: Specifies where to write the server log to.
    - `prefix`: Sets where to put the socket file the main application uses to communicate with the server.
- `code`: Settings for displaying code.
    - `theme`: Pygments theme used to render code. See https://pygments.org/demo/ for available options.
    - `background`: The background color used for code cells.
- `output`: Settings for the output pane.
    - `theme`: Available options: `'dracula', 'github_light', 'monokai', 'vscode_dark'`.
    - `line_numbers`: Wether to display line numbers in the output.
- `keybindings`:
    - `quit`: Key combination used to quit the application.
    - `restart_kernel`: Key combination used to kill the code execution server and start a new one.
    - `copy`: Key combination used to copy selected text from the output.
    - `clear_cell_output`: Key combination used to clear a single cell of output.
    - `interrupt`: Key combination used to interrupt current execution.
    - `run_all`: Run all cells.
    - `clear_all:` = Clear output from all cells.
- `tr`: Strings/translations used to render state info and help text.
- `cell_name_max`: Sets the max number of characters cell names/labels are displayed with.


### Custom CSS:
Since nanb uses textual, it is also possible to override the looks using custom CSS.

If the file `~/.nanb/nanb.css` exists, it's content will be appended to the default css on startup.

See https://textual.textualize.io/guide/CSS/ for more information.



## Q&A

### Does nanb support editing code?

No. The idea is providing an environment for execution, letting you use your own editor to write code.

### Does nanb support jupyter style magic?

No, as that would make your files behave differently in nanb vs running your files using the regular python commmand.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "nanb",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": "",
    "keywords": "",
    "author": "",
    "author_email": "Espen Notodden <espen@enotodden.com>",
    "download_url": "",
    "platform": null,
    "description": "nanb - Not A NoteBook\n=====================\n\nJupyter-style execution with plain Python files, in the terminal.\n\n![screenshot](https://github.com/enotodden/nanb/blob/09570785cb135ccbb74ba787f1177b54639786d2/nanb_screenshot.png)\n\nExample:\n\n```python\n\n# My Notebook\n# ===========\n#\n# Welcome to my **not-a-notebook**!\n#\n# Here is a description, and some bullet points:\n# - foo\n# - bar\n# - baz\n#\n# Here is a code block:\n# ```python\n# print(\"hello world\")\n# ```\n#\n# Here is a table:\n# | foo | bar |\n# |-----|-----|\n# | 1   | 2   |\n# | 3   | 4   |\n#\n\n\n# --- Do some imports\nimport os\nimport json\n\n\n# --- Set a var\nhello_abc = \"Hello ABC!\"\n\n# --- Print it\nprint(hello_abc)\n\n# ---\n# This cell has no name, which is also fine\nprint(\"Hello world\")\n```\n\n## Installation\n\n```shell\n$ pip install nanb\n```\n\n\n## Running a file\n\n```shell\n$ nanb run ./myfile.py\n```\n\n## Why?\n\nJupyter notbooks are great, but they are not regular Python files, and can be hard to work with in your editor of choice.\n\nThis project is an attempt at providing a stateful REPL-like execution environment for vanilla Python,\nin the terminal, with regular source files that you edit using the editor/IDE of your choice.\n\n## Cell syntax\n\nLike in jupyter, a file used in nanb is divided into cells that can be executed independently.\n\nCode cells are marked using `# ---`\n```python\n# ---\nprint('Hello world')\n```\n\nMarkdown cells are just regular comments using `# %%%` to indicate their beginning:\n```python\n# %%%\n# ## This is an H2 \n# - These\n# - Are \n# - List \n# - Items\n```\n\nCode cells can also have labels:\n\n```python\n# --- Do stuff\ndo_stuff()\n```\n\n## Configuring nanb\n\nnanb can be configured by adding a toml configuration file in `$HOME/.nanb/nanb.toml`.\n\n### Default config:\n\n```\n\ncell_name_max = 20\n\n[keybindings]\nquit = \"q\"\nrestart_kernel = \"ctrl+r\"\ncopy = \"y\"\nclear_cell_output = \"c\"\ninterrupt = \"i\"\nrun_all = \"ctrl+a\"\nclear_all = \"ctrl+x\"\n\n[server]\nlog_file = \"/tmp/nanb_server.log\"\nsocket_prefix = \"/tmp/nanb_socket_\"\n\n[code]\ntheme = \"github-dark\"\nbackground = \"#1a1a1a\"\n\n[output]\ntheme = \"vscode_dark\"\nline_numbers = false\n\n[tr]\naction_quit = \"Quit\"\naction_restart_kernel = \"Restart Kernel\"\naction_copy = \"Copy\"\naction_clear_cell_output = \"Clear Cell Output\"\naction_interrupt = \"Interrupt\"\naction_help = \"Help\"\naction_run_cell = \"Run Cell\"\naction_run_all = \"Run All\"\naction_clear_all = \"Clear All\"\naction_close = \"Close\"\nstate_running = \"RUNNING\"\nstate_pending = \"PENDING\"\ndh_keybindings = \"Keybindings\"\ndh_key = \"Key\"\ndh_action = \"Action\"\nkb_quit = \"Quit the application\"\nkb_restart_kernel = \"Restart the kernel\"\nkb_copy = \"Copy selected output\"\nkb_clear_cell_output = \"Clear the output of the current cell\"\nkb_interrupt = \"Interrupt the current execution\"\nkb_run_cell = \"Run the current cell\"\nkb_run_all = \"Run all cells\"\nkb_clear_all = \"Clear all cells\"\nkb_help = \"Show this help screen\"\nkb_arrows = \"Move between cells\"\nkb_close_help = \"Close the help screen\"\n\n```\n\n\n### Config options:\n\n- `server`: Config options for the server/kernel that actually runs your code.\n    - `log_file`: Specifies where to write the server log to.\n    - `prefix`: Sets where to put the socket file the main application uses to communicate with the server.\n- `code`: Settings for displaying code.\n    - `theme`: Pygments theme used to render code. See https://pygments.org/demo/ for available options.\n    - `background`: The background color used for code cells.\n- `output`: Settings for the output pane.\n    - `theme`: Available options: `'dracula', 'github_light', 'monokai', 'vscode_dark'`.\n    - `line_numbers`: Wether to display line numbers in the output.\n- `keybindings`:\n    - `quit`: Key combination used to quit the application.\n    - `restart_kernel`: Key combination used to kill the code execution server and start a new one.\n    - `copy`: Key combination used to copy selected text from the output.\n    - `clear_cell_output`: Key combination used to clear a single cell of output.\n    - `interrupt`: Key combination used to interrupt current execution.\n    - `run_all`: Run all cells.\n    - `clear_all:` = Clear output from all cells.\n- `tr`: Strings/translations used to render state info and help text.\n- `cell_name_max`: Sets the max number of characters cell names/labels are displayed with.\n\n\n### Custom CSS:\nSince nanb uses textual, it is also possible to override the looks using custom CSS.\n\nIf the file `~/.nanb/nanb.css` exists, it's content will be appended to the default css on startup.\n\nSee https://textual.textualize.io/guide/CSS/ for more information.\n\n\n\n## Q&A\n\n### Does nanb support editing code?\n\nNo. The idea is providing an environment for execution, letting you use your own editor to write code.\n\n### Does nanb support jupyter style magic?\n\nNo, as that would make your files behave differently in nanb vs running your files using the regular python commmand.\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "Not A NoteBook",
    "version": "0.1.1",
    "project_urls": {
        "Bug Tracker": "https://github.com/enotodden/nanb/issues",
        "Homepage": "https://github.com/enotodden/nanb"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "80a3c84636aa4a1bed6ed0140f266ea38a64c2d7faa5afb84262dc0a1107b050",
                "md5": "8bf5c9c0e24e2bb80fff2758ee0dea6c",
                "sha256": "9d3bf0e18c633bcbde52146f8828b62c114c78a2b1f7aa5022a0286636556fbc"
            },
            "downloads": -1,
            "filename": "nanb-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8bf5c9c0e24e2bb80fff2758ee0dea6c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 20118,
            "upload_time": "2023-11-18T20:30:32",
            "upload_time_iso_8601": "2023-11-18T20:30:32.438184Z",
            "url": "https://files.pythonhosted.org/packages/80/a3/c84636aa4a1bed6ed0140f266ea38a64c2d7faa5afb84262dc0a1107b050/nanb-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-18 20:30:32",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "enotodden",
    "github_project": "nanb",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "aiohttp",
            "specs": [
                [
                    "==",
                    "3.8.5"
                ]
            ]
        },
        {
            "name": "aiosignal",
            "specs": [
                [
                    "==",
                    "1.3.1"
                ]
            ]
        },
        {
            "name": "anyio",
            "specs": [
                [
                    "==",
                    "4.0.0"
                ]
            ]
        },
        {
            "name": "async-timeout",
            "specs": [
                [
                    "==",
                    "4.0.3"
                ]
            ]
        },
        {
            "name": "attrs",
            "specs": [
                [
                    "==",
                    "23.1.0"
                ]
            ]
        },
        {
            "name": "charset-normalizer",
            "specs": [
                [
                    "==",
                    "3.3.0"
                ]
            ]
        },
        {
            "name": "click",
            "specs": [
                [
                    "==",
                    "8.1.7"
                ]
            ]
        },
        {
            "name": "frozenlist",
            "specs": [
                [
                    "==",
                    "1.4.0"
                ]
            ]
        },
        {
            "name": "idna",
            "specs": [
                [
                    "==",
                    "3.4"
                ]
            ]
        },
        {
            "name": "importlib-metadata",
            "specs": [
                [
                    "==",
                    "6.8.0"
                ]
            ]
        },
        {
            "name": "linkify-it-py",
            "specs": [
                [
                    "==",
                    "2.0.2"
                ]
            ]
        },
        {
            "name": "markdown-it-py",
            "specs": [
                [
                    "==",
                    "3.0.0"
                ]
            ]
        },
        {
            "name": "mdit-py-plugins",
            "specs": [
                [
                    "==",
                    "0.4.0"
                ]
            ]
        },
        {
            "name": "mdurl",
            "specs": [
                [
                    "==",
                    "0.1.2"
                ]
            ]
        },
        {
            "name": "msgpack",
            "specs": [
                [
                    "==",
                    "1.0.7"
                ]
            ]
        },
        {
            "name": "multidict",
            "specs": [
                [
                    "==",
                    "6.0.4"
                ]
            ]
        },
        {
            "name": "Pygments",
            "specs": [
                [
                    "==",
                    "2.16.1"
                ]
            ]
        },
        {
            "name": "rich",
            "specs": [
                [
                    "==",
                    "13.5.3"
                ]
            ]
        },
        {
            "name": "sniffio",
            "specs": [
                [
                    "==",
                    "1.3.0"
                ]
            ]
        },
        {
            "name": "textual",
            "specs": [
                [
                    "==",
                    "0.38.1"
                ]
            ]
        },
        {
            "name": "textual-dev",
            "specs": [
                [
                    "==",
                    "1.2.1"
                ]
            ]
        },
        {
            "name": "toml",
            "specs": [
                [
                    "==",
                    "0.10.2"
                ]
            ]
        },
        {
            "name": "tree-sitter",
            "specs": [
                [
                    "==",
                    "0.20.2"
                ]
            ]
        },
        {
            "name": "tree-sitter-languages",
            "specs": [
                [
                    "==",
                    "1.7.0"
                ]
            ]
        },
        {
            "name": "typing_extensions",
            "specs": [
                [
                    "==",
                    "4.8.0"
                ]
            ]
        },
        {
            "name": "uc-micro-py",
            "specs": [
                [
                    "==",
                    "1.0.2"
                ]
            ]
        },
        {
            "name": "watchfiles",
            "specs": [
                [
                    "==",
                    "0.20.0"
                ]
            ]
        },
        {
            "name": "yarl",
            "specs": [
                [
                    "==",
                    "1.9.2"
                ]
            ]
        },
        {
            "name": "zipp",
            "specs": [
                [
                    "==",
                    "3.17.0"
                ]
            ]
        }
    ],
    "lcname": "nanb"
}
        
Elapsed time: 0.15187s