nbcat 0.1.0__py3-none-any.whl

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/__init__.py ADDED
@@ -0,0 +1 @@
1
+ __version__ = "0.1.0"
nbcat/cli.py ADDED
@@ -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()
nbcat/nbcat.py ADDED
@@ -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')}"
nbcat/py.typed ADDED
File without changes
nbcat/settings.py ADDED
@@ -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
@@ -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](https://img.shields.io/github/license/akopdev/nbcat)](./LICENSE)
49
+ [![Build](https://github.com/akopdev/nbcat/actions/workflows/ci.yml/badge.svg)](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)
@@ -0,0 +1,10 @@
1
+ nbcat/__init__.py,sha256=kUR5RAFc7HCeiqdlX36dZOHkUI5wI6V_43RpEcD8b-0,22
2
+ nbcat/cli.py,sha256=BeijbCAe1J3s7UgeKW_hdRdXvkg1jo6XaT4aPGKz-Yc,1802
3
+ nbcat/nbcat.py,sha256=eWgwOGCnOK6xQ1qC8Ku2vmQgPvA5Nx6mfdM8Ca3vU6w,580
4
+ nbcat/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ nbcat/settings.py,sha256=I6sGyVidPjW_76zq9mefnS2-vzRUKL87jSPluPe_SwQ,498
6
+ nbcat-0.1.0.dist-info/METADATA,sha256=Woo2Z2dx6A8vMsXE4k0cpYuTJ_llb1UVOqG8ENoGitE,3426
7
+ nbcat-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
8
+ nbcat-0.1.0.dist-info/entry_points.txt,sha256=a_byTgZyR_et6CxNcKCQlw1EHisUaIFRBRLh0tUQs2U,41
9
+ nbcat-0.1.0.dist-info/licenses/LICENSE,sha256=7GjUnahXdd5opdvlpJdb1BisLbiXt2iOFhzIUduhdkE,1072
10
+ nbcat-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.27.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ nbcat = nbcat.cli:main
@@ -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.