nbcat 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nbcat-0.1.0/.github/workflows/ci.yml +56 -0
- nbcat-0.1.0/.gitignore +175 -0
- nbcat-0.1.0/LICENSE +21 -0
- nbcat-0.1.0/Makefile +45 -0
- nbcat-0.1.0/PKG-INFO +131 -0
- nbcat-0.1.0/README.md +88 -0
- nbcat-0.1.0/pyproject.toml +66 -0
- nbcat-0.1.0/src/nbcat/__init__.py +1 -0
- nbcat-0.1.0/src/nbcat/cli.py +73 -0
- nbcat-0.1.0/src/nbcat/nbcat.py +22 -0
- nbcat-0.1.0/src/nbcat/py.typed +0 -0
- nbcat-0.1.0/src/nbcat/settings.py +16 -0
- nbcat-0.1.0/tests/conftest.py +0 -0
- nbcat-0.1.0/tests/test_nbcat.py +36 -0
- nbcat-0.1.0/uv.lock +963 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
name: CI/CD
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
pull_request:
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
build:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v4
|
14
|
+
|
15
|
+
- name: Install uv
|
16
|
+
uses: astral-sh/setup-uv@v5
|
17
|
+
|
18
|
+
- name: Lint
|
19
|
+
run: make lint
|
20
|
+
|
21
|
+
- name: Test
|
22
|
+
run: make test
|
23
|
+
|
24
|
+
- name: Build
|
25
|
+
run: make build
|
26
|
+
|
27
|
+
- name: Upload build artifact
|
28
|
+
uses: actions/upload-artifact@v4
|
29
|
+
with:
|
30
|
+
name: build-dist
|
31
|
+
path: dist/
|
32
|
+
|
33
|
+
deploy:
|
34
|
+
if: ${{ github.ref == 'refs/heads/main' && success() }}
|
35
|
+
needs: build
|
36
|
+
runs-on: ubuntu-latest
|
37
|
+
environment: pypi
|
38
|
+
permissions:
|
39
|
+
id-token: write
|
40
|
+
steps:
|
41
|
+
- uses: actions/checkout@v4
|
42
|
+
|
43
|
+
- name: Install uv
|
44
|
+
uses: astral-sh/setup-uv@v5
|
45
|
+
|
46
|
+
- name: Download artifact from CI
|
47
|
+
uses: actions/download-artifact@v4
|
48
|
+
with:
|
49
|
+
name: build-dist
|
50
|
+
path: dist/
|
51
|
+
|
52
|
+
- name: List contents
|
53
|
+
run: ls -la dist/
|
54
|
+
|
55
|
+
- name: Publish
|
56
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
nbcat-0.1.0/.gitignore
ADDED
@@ -0,0 +1,175 @@
|
|
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
|
+
share/python-wheels/
|
24
|
+
*.egg-info/
|
25
|
+
.installed.cfg
|
26
|
+
*.egg
|
27
|
+
MANIFEST
|
28
|
+
|
29
|
+
# PyInstaller
|
30
|
+
# Usually these files are written by a python script from a template
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
32
|
+
*.manifest
|
33
|
+
*.spec
|
34
|
+
|
35
|
+
# Installer logs
|
36
|
+
pip-log.txt
|
37
|
+
pip-delete-this-directory.txt
|
38
|
+
|
39
|
+
# Unit test / coverage reports
|
40
|
+
htmlcov/
|
41
|
+
.tox/
|
42
|
+
.nox/
|
43
|
+
.coverage
|
44
|
+
.coverage.*
|
45
|
+
.cache
|
46
|
+
nosetests.xml
|
47
|
+
coverage.xml
|
48
|
+
*.cover
|
49
|
+
*.py,cover
|
50
|
+
.hypothesis/
|
51
|
+
.pytest_cache/
|
52
|
+
cover/
|
53
|
+
.test_results/
|
54
|
+
|
55
|
+
# Translations
|
56
|
+
*.mo
|
57
|
+
*.pot
|
58
|
+
|
59
|
+
# Django stuff:
|
60
|
+
*.log
|
61
|
+
local_settings.py
|
62
|
+
db.sqlite3
|
63
|
+
db.sqlite3-journal
|
64
|
+
|
65
|
+
# Flask stuff:
|
66
|
+
instance/
|
67
|
+
.webassets-cache
|
68
|
+
|
69
|
+
# Scrapy stuff:
|
70
|
+
.scrapy
|
71
|
+
|
72
|
+
# Sphinx documentation
|
73
|
+
docs/_build/
|
74
|
+
|
75
|
+
# PyBuilder
|
76
|
+
.pybuilder/
|
77
|
+
target/
|
78
|
+
|
79
|
+
# Jupyter Notebook
|
80
|
+
.ipynb_checkpoints
|
81
|
+
|
82
|
+
# IPython
|
83
|
+
profile_default/
|
84
|
+
ipython_config.py
|
85
|
+
|
86
|
+
# pyenv
|
87
|
+
# For a library or package, you might want to ignore these files since the code is
|
88
|
+
# intended to run in multiple environments; otherwise, check them in:
|
89
|
+
# .python-version
|
90
|
+
|
91
|
+
# pipenv
|
92
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
93
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
94
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
95
|
+
# install all needed dependencies.
|
96
|
+
#Pipfile.lock
|
97
|
+
|
98
|
+
# UV
|
99
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
100
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
101
|
+
# commonly ignored for libraries.
|
102
|
+
#uv.lock
|
103
|
+
|
104
|
+
# poetry
|
105
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
106
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
107
|
+
# commonly ignored for libraries.
|
108
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
109
|
+
#poetry.lock
|
110
|
+
|
111
|
+
# pdm
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
113
|
+
#pdm.lock
|
114
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
115
|
+
# in version control.
|
116
|
+
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
|
117
|
+
.pdm.toml
|
118
|
+
.pdm-python
|
119
|
+
.pdm-build/
|
120
|
+
|
121
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
122
|
+
__pypackages__/
|
123
|
+
|
124
|
+
# Celery stuff
|
125
|
+
celerybeat-schedule
|
126
|
+
celerybeat.pid
|
127
|
+
|
128
|
+
# SageMath parsed files
|
129
|
+
*.sage.py
|
130
|
+
|
131
|
+
# Environments
|
132
|
+
.env
|
133
|
+
.venv
|
134
|
+
env/
|
135
|
+
venv/
|
136
|
+
ENV/
|
137
|
+
env.bak/
|
138
|
+
venv.bak/
|
139
|
+
|
140
|
+
# Spyder project settings
|
141
|
+
.spyderproject
|
142
|
+
.spyproject
|
143
|
+
|
144
|
+
# Rope project settings
|
145
|
+
.ropeproject
|
146
|
+
|
147
|
+
# mkdocs documentation
|
148
|
+
/site
|
149
|
+
|
150
|
+
# mypy
|
151
|
+
.mypy_cache/
|
152
|
+
.dmypy.json
|
153
|
+
dmypy.json
|
154
|
+
|
155
|
+
# Pyre type checker
|
156
|
+
.pyre/
|
157
|
+
|
158
|
+
# pytype static type analyzer
|
159
|
+
.pytype/
|
160
|
+
|
161
|
+
# Cython debug symbols
|
162
|
+
cython_debug/
|
163
|
+
|
164
|
+
# PyCharm
|
165
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
166
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
167
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
168
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
169
|
+
#.idea/
|
170
|
+
|
171
|
+
# Ruff stuff:
|
172
|
+
.ruff_cache/
|
173
|
+
|
174
|
+
# PyPI configuration file
|
175
|
+
.pypirc
|
nbcat-0.1.0/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 Akop Kesheshyan
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
nbcat-0.1.0/Makefile
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
.EXPORT_ALL_VARIABLES: ;
|
2
|
+
.PHONY: all
|
3
|
+
.DEFAULT_GOAL: help
|
4
|
+
|
5
|
+
UV = uv
|
6
|
+
UVR = @$(UV) run --extra "dev"
|
7
|
+
RUFF = $(UVR) ruff
|
8
|
+
PYTEST = $(UVR) pytest
|
9
|
+
|
10
|
+
help:
|
11
|
+
@echo '================================================='
|
12
|
+
@echo '~~ List of available commands for this project ~~'
|
13
|
+
@echo '================================================='
|
14
|
+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-16s\033[0m %s\n", $$1, $$2}'
|
15
|
+
|
16
|
+
all: format lint test ## Lint, test and build package
|
17
|
+
|
18
|
+
test: ## Test package
|
19
|
+
$(PYTEST) -x -vv \
|
20
|
+
--junitxml=.test_results/test-results.xml \
|
21
|
+
--cov=src \
|
22
|
+
--cov-report=xml:.test_results/coverage.xml \
|
23
|
+
--cov-report=term
|
24
|
+
|
25
|
+
build: ## Build package
|
26
|
+
@$(UV) build
|
27
|
+
|
28
|
+
start: ## Run package
|
29
|
+
@$(UV) pip install -e .
|
30
|
+
@$(UVR) nbcat
|
31
|
+
|
32
|
+
deploy: build ## Publish package
|
33
|
+
$(UV) publish --token $(token)
|
34
|
+
|
35
|
+
lint: ## Run linter over code base and auto resole minor issues
|
36
|
+
$(RUFF) check --fix
|
37
|
+
|
38
|
+
format: ## Format the source code according to defined coding style
|
39
|
+
$(RUFF) format
|
40
|
+
|
41
|
+
clean: ## Remove all file artifacts
|
42
|
+
@rm -rf .venv/ dist/ build/ *.egg-info .pytest_cache/ .coverage coverage.xml
|
43
|
+
@find . -type f -name "*.py[co]" -delete
|
44
|
+
@find . -type d -name "__pycache__" -delete
|
45
|
+
@find . -name '*~' -delete
|
nbcat-0.1.0/PKG-INFO
ADDED
@@ -0,0 +1,131 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: nbcat
|
3
|
+
Version: 0.1.0
|
4
|
+
Summary: cat for jupyter notebooks
|
5
|
+
Project-URL: Homepage, https://github.com/akopdev/nbcat
|
6
|
+
Project-URL: Repository, https://github.com/akopdev/nbcat
|
7
|
+
Author-email: Akop Kesheshyan <devnull@akop.dev>
|
8
|
+
Maintainer-email: Akop Kesheshyan <devnull@akop.dev>
|
9
|
+
License: MIT License
|
10
|
+
|
11
|
+
Copyright (c) 2025 Akop Kesheshyan
|
12
|
+
|
13
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
14
|
+
of this software and associated documentation files (the "Software"), to deal
|
15
|
+
in the Software without restriction, including without limitation the rights
|
16
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
17
|
+
copies of the Software, and to permit persons to whom the Software is
|
18
|
+
furnished to do so, subject to the following conditions:
|
19
|
+
|
20
|
+
The above copyright notice and this permission notice shall be included in all
|
21
|
+
copies or substantial portions of the Software.
|
22
|
+
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
24
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
25
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
26
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
27
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
28
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
29
|
+
SOFTWARE.
|
30
|
+
License-File: LICENSE
|
31
|
+
Requires-Python: >=3.10
|
32
|
+
Requires-Dist: aiohttp
|
33
|
+
Requires-Dist: pydantic
|
34
|
+
Requires-Dist: rich
|
35
|
+
Provides-Extra: dev
|
36
|
+
Requires-Dist: aioresponses; extra == 'dev'
|
37
|
+
Requires-Dist: pytest; extra == 'dev'
|
38
|
+
Requires-Dist: pytest-asyncio; extra == 'dev'
|
39
|
+
Requires-Dist: pytest-cov; extra == 'dev'
|
40
|
+
Requires-Dist: pytest-mock; extra == 'dev'
|
41
|
+
Requires-Dist: ruff; extra == 'dev'
|
42
|
+
Description-Content-Type: text/markdown
|
43
|
+
|
44
|
+
# 📦 nbcat
|
45
|
+
|
46
|
+
cat for jupyter notebooks
|
47
|
+
|
48
|
+
[](./LICENSE)
|
49
|
+
[](https://github.com/akopdev/nbcat/actions)
|
50
|
+
|
51
|
+
---
|
52
|
+
|
53
|
+
## 🚀 Features
|
54
|
+
|
55
|
+
- ✅ Clean, minimal API
|
56
|
+
- 🧰 Easily extensible
|
57
|
+
- 🧪 Fully tested and type-annotated
|
58
|
+
- ⚡ Fast and lightweight
|
59
|
+
- 📦 Available on PyPI
|
60
|
+
|
61
|
+
---
|
62
|
+
|
63
|
+
## 📦 Installation
|
64
|
+
|
65
|
+
Install with [uv](https://github.com/astral-sh/uv)
|
66
|
+
|
67
|
+
```bash
|
68
|
+
uv pip install nbcat
|
69
|
+
```
|
70
|
+
|
71
|
+
To install the latest development version:
|
72
|
+
|
73
|
+
```bash
|
74
|
+
uv pip install git+https://github.com/akopdev/nbcat.git
|
75
|
+
```
|
76
|
+
|
77
|
+
---
|
78
|
+
|
79
|
+
## 🛠️ Quickstart
|
80
|
+
|
81
|
+
```python
|
82
|
+
# example of using the package
|
83
|
+
```
|
84
|
+
|
85
|
+
For more examples, check out the [`examples/`](./examples/) folder.
|
86
|
+
|
87
|
+
---
|
88
|
+
|
89
|
+
## 🧪 Testing & Development
|
90
|
+
|
91
|
+
Run the tests:
|
92
|
+
|
93
|
+
```bash
|
94
|
+
make test
|
95
|
+
```
|
96
|
+
|
97
|
+
Check code quality:
|
98
|
+
|
99
|
+
```bash
|
100
|
+
make lint
|
101
|
+
```
|
102
|
+
|
103
|
+
Format code:
|
104
|
+
|
105
|
+
```bash
|
106
|
+
make format
|
107
|
+
```
|
108
|
+
|
109
|
+
---
|
110
|
+
|
111
|
+
## 🙌 Contributing
|
112
|
+
|
113
|
+
Contributions are welcome! Please open an issue or [pull request](https://github.com/akopdev/nbcat/pulls).
|
114
|
+
|
115
|
+
---
|
116
|
+
|
117
|
+
## 📄 License
|
118
|
+
|
119
|
+
Distributed under the MIT License. See [`LICENSE`](./LICENSE) for more information.
|
120
|
+
|
121
|
+
---
|
122
|
+
|
123
|
+
## 🔗 Useful Links
|
124
|
+
|
125
|
+
- 📘 Documentation: _coming soon_
|
126
|
+
- 🐛 Issues: [GitHub Issues](https://github.com/akopdev/nbcat/issues)
|
127
|
+
- 🚀 Releases: [GitHub Releases](https://github.com/akopdev/nbcat/releases)
|
128
|
+
|
129
|
+
---
|
130
|
+
|
131
|
+
> Made with ❤️ by [Akop Kesheshyan](https://github.com/akopdev)
|
nbcat-0.1.0/README.md
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
# 📦 nbcat
|
2
|
+
|
3
|
+
cat for jupyter notebooks
|
4
|
+
|
5
|
+
[](./LICENSE)
|
6
|
+
[](https://github.com/akopdev/nbcat/actions)
|
7
|
+
|
8
|
+
---
|
9
|
+
|
10
|
+
## 🚀 Features
|
11
|
+
|
12
|
+
- ✅ Clean, minimal API
|
13
|
+
- 🧰 Easily extensible
|
14
|
+
- 🧪 Fully tested and type-annotated
|
15
|
+
- ⚡ Fast and lightweight
|
16
|
+
- 📦 Available on PyPI
|
17
|
+
|
18
|
+
---
|
19
|
+
|
20
|
+
## 📦 Installation
|
21
|
+
|
22
|
+
Install with [uv](https://github.com/astral-sh/uv)
|
23
|
+
|
24
|
+
```bash
|
25
|
+
uv pip install nbcat
|
26
|
+
```
|
27
|
+
|
28
|
+
To install the latest development version:
|
29
|
+
|
30
|
+
```bash
|
31
|
+
uv pip install git+https://github.com/akopdev/nbcat.git
|
32
|
+
```
|
33
|
+
|
34
|
+
---
|
35
|
+
|
36
|
+
## 🛠️ Quickstart
|
37
|
+
|
38
|
+
```python
|
39
|
+
# example of using the package
|
40
|
+
```
|
41
|
+
|
42
|
+
For more examples, check out the [`examples/`](./examples/) folder.
|
43
|
+
|
44
|
+
---
|
45
|
+
|
46
|
+
## 🧪 Testing & Development
|
47
|
+
|
48
|
+
Run the tests:
|
49
|
+
|
50
|
+
```bash
|
51
|
+
make test
|
52
|
+
```
|
53
|
+
|
54
|
+
Check code quality:
|
55
|
+
|
56
|
+
```bash
|
57
|
+
make lint
|
58
|
+
```
|
59
|
+
|
60
|
+
Format code:
|
61
|
+
|
62
|
+
```bash
|
63
|
+
make format
|
64
|
+
```
|
65
|
+
|
66
|
+
---
|
67
|
+
|
68
|
+
## 🙌 Contributing
|
69
|
+
|
70
|
+
Contributions are welcome! Please open an issue or [pull request](https://github.com/akopdev/nbcat/pulls).
|
71
|
+
|
72
|
+
---
|
73
|
+
|
74
|
+
## 📄 License
|
75
|
+
|
76
|
+
Distributed under the MIT License. See [`LICENSE`](./LICENSE) for more information.
|
77
|
+
|
78
|
+
---
|
79
|
+
|
80
|
+
## 🔗 Useful Links
|
81
|
+
|
82
|
+
- 📘 Documentation: _coming soon_
|
83
|
+
- 🐛 Issues: [GitHub Issues](https://github.com/akopdev/nbcat/issues)
|
84
|
+
- 🚀 Releases: [GitHub Releases](https://github.com/akopdev/nbcat/releases)
|
85
|
+
|
86
|
+
---
|
87
|
+
|
88
|
+
> Made with ❤️ by [Akop Kesheshyan](https://github.com/akopdev)
|
@@ -0,0 +1,66 @@
|
|
1
|
+
[project]
|
2
|
+
name = "nbcat"
|
3
|
+
version = "0.1.0"
|
4
|
+
description = "cat for jupyter notebooks"
|
5
|
+
authors = [
|
6
|
+
{ name = "Akop Kesheshyan", email = "devnull@akop.dev" }
|
7
|
+
]
|
8
|
+
maintainers = [
|
9
|
+
{ name = "Akop Kesheshyan", email = "devnull@akop.dev" }
|
10
|
+
]
|
11
|
+
license = {file = "LICENSE"}
|
12
|
+
readme = "README.md"
|
13
|
+
requires-python = ">=3.10"
|
14
|
+
dependencies = [
|
15
|
+
"aiohttp",
|
16
|
+
"pydantic",
|
17
|
+
"rich",
|
18
|
+
]
|
19
|
+
|
20
|
+
[project.optional-dependencies]
|
21
|
+
dev = [
|
22
|
+
"aioresponses",
|
23
|
+
"ruff",
|
24
|
+
"pytest",
|
25
|
+
"pytest-asyncio",
|
26
|
+
"pytest-mock",
|
27
|
+
"pytest-cov",
|
28
|
+
]
|
29
|
+
|
30
|
+
[project.urls]
|
31
|
+
Homepage = "https://github.com/akopdev/nbcat"
|
32
|
+
Repository = "https://github.com/akopdev/nbcat"
|
33
|
+
|
34
|
+
[project.scripts]
|
35
|
+
nbcat = "nbcat.cli:main"
|
36
|
+
|
37
|
+
[pytest]
|
38
|
+
mock_use_standalone_module = true
|
39
|
+
|
40
|
+
[tool.pytest.ini_options]
|
41
|
+
asyncio_default_fixture_loop_scope = "function"
|
42
|
+
testpaths = "tests/"
|
43
|
+
|
44
|
+
[tool.ruff]
|
45
|
+
exclude = [
|
46
|
+
".venv",
|
47
|
+
"build",
|
48
|
+
"dist",
|
49
|
+
"migrations",
|
50
|
+
"__init__.py"
|
51
|
+
]
|
52
|
+
include = ["*.py", "*.pyx"]
|
53
|
+
line-length = 100
|
54
|
+
|
55
|
+
[tool.ruff.lint]
|
56
|
+
select = ["E", "F", "W", "I", "D"]
|
57
|
+
ignore = [
|
58
|
+
"D100", "D101", "D102", "D103", "D104", "D105", "D106", "D107"
|
59
|
+
]
|
60
|
+
|
61
|
+
[tool.ruff.lint.pydocstyle]
|
62
|
+
convention = "numpy"
|
63
|
+
|
64
|
+
[build-system]
|
65
|
+
requires = ["hatchling"]
|
66
|
+
build-backend = "hatchling.build"
|
@@ -0,0 +1 @@
|
|
1
|
+
__version__ = "0.1.0"
|
@@ -0,0 +1,73 @@
|
|
1
|
+
import argparse
|
2
|
+
import asyncio
|
3
|
+
import sys
|
4
|
+
|
5
|
+
from pydantic import ValidationError
|
6
|
+
|
7
|
+
from . import __version__
|
8
|
+
from .settings import Settings
|
9
|
+
|
10
|
+
|
11
|
+
async def do_sample_command_1():
|
12
|
+
"""Run used defined command 1."""
|
13
|
+
|
14
|
+
|
15
|
+
async def do_sample_command_2():
|
16
|
+
"""Run user defined command 2."""
|
17
|
+
|
18
|
+
|
19
|
+
def main():
|
20
|
+
parser = argparse.ArgumentParser(
|
21
|
+
description="cat for jupyter notebooks",
|
22
|
+
argument_default=argparse.SUPPRESS,
|
23
|
+
)
|
24
|
+
parser.add_argument(
|
25
|
+
"--list_field", help="Example of multi value list separated by comma.", type=str
|
26
|
+
)
|
27
|
+
parser.add_argument(
|
28
|
+
"--version",
|
29
|
+
help="Print version information and quite",
|
30
|
+
action="version",
|
31
|
+
version=__version__,
|
32
|
+
)
|
33
|
+
|
34
|
+
# Commands
|
35
|
+
commands = parser.add_subparsers(title="Commands", dest="command")
|
36
|
+
|
37
|
+
# Sample command 1
|
38
|
+
sample_command_1 = commands.add_parser(
|
39
|
+
"sample_command_1",
|
40
|
+
help="Sample command description.",
|
41
|
+
argument_default=argparse.SUPPRESS,
|
42
|
+
)
|
43
|
+
|
44
|
+
sample_command_1.set_defaults(func=do_sample_command_1)
|
45
|
+
|
46
|
+
# Sample command 2
|
47
|
+
sample_command_2 = commands.add_parser(
|
48
|
+
"sample_command_2",
|
49
|
+
help="Sample command description.",
|
50
|
+
argument_default=argparse.SUPPRESS,
|
51
|
+
)
|
52
|
+
|
53
|
+
sample_command_2.set_defaults(func=do_sample_command_2)
|
54
|
+
|
55
|
+
try:
|
56
|
+
args = parser.parse_args()
|
57
|
+
settings = Settings(**vars(args))
|
58
|
+
except ValidationError as e:
|
59
|
+
error = e.errors(include_url=False, include_context=False)[0]
|
60
|
+
sys.exit(
|
61
|
+
"Wrong argument value passed ({}): {}".format(
|
62
|
+
error.get("loc", ("system",))[0], error.get("msg")
|
63
|
+
)
|
64
|
+
)
|
65
|
+
|
66
|
+
if args.command:
|
67
|
+
asyncio.run(args.func(settings))
|
68
|
+
else:
|
69
|
+
parser.print_help()
|
70
|
+
|
71
|
+
|
72
|
+
if __name__ == "__main__":
|
73
|
+
main()
|
@@ -0,0 +1,22 @@
|
|
1
|
+
from datetime import datetime
|
2
|
+
|
3
|
+
import aiohttp
|
4
|
+
|
5
|
+
|
6
|
+
async def my_func(name) -> str:
|
7
|
+
"""Get message from remote server."""
|
8
|
+
async with aiohttp.ClientSession() as session:
|
9
|
+
async with session.get("https://example.com/api.json", params={"name": name}) as response:
|
10
|
+
data = await response.json()
|
11
|
+
return data["message"]
|
12
|
+
|
13
|
+
|
14
|
+
def now() -> datetime:
|
15
|
+
"""Ready to mock method for date extraction."""
|
16
|
+
return datetime.now()
|
17
|
+
|
18
|
+
|
19
|
+
def get_time() -> str:
|
20
|
+
"""Return today's date."""
|
21
|
+
date = now()
|
22
|
+
return f"Today is {date.strftime('%A, %B %d, %Y')}"
|
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
from pydantic import BaseModel, model_validator
|
2
|
+
|
3
|
+
|
4
|
+
class Settings(BaseModel):
|
5
|
+
"""Validates cli arguments."""
|
6
|
+
|
7
|
+
field: str | None = None
|
8
|
+
list_field: list[str] = []
|
9
|
+
bool_field: bool = False
|
10
|
+
|
11
|
+
@model_validator(mode="before")
|
12
|
+
def parse_list_field(values: dict):
|
13
|
+
"""You can pass multiple values as a comma separated string."""
|
14
|
+
if isinstance(values.get("list_field"), str):
|
15
|
+
values["list_field"] = values.get("list_field").split(",")
|
16
|
+
return values
|
File without changes
|