kribton 1.0.1__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.
kribton-1.0.1/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+
2
+
3
+ Copyright 2026 Ahmed Abdelkhaliq
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
kribton-1.0.1/PKG-INFO ADDED
@@ -0,0 +1,65 @@
1
+ Metadata-Version: 2.4
2
+ Name: kribton
3
+ Version: 1.0.1
4
+ Summary: A high-performance web framework for Python.
5
+ Author-email: Ahmed Abdelkhaliq <abdelkhaliqqq@gmail.com>
6
+ Classifier: Intended Audience :: Developers
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.8
9
+ Classifier: Programming Language :: Python :: 3.9
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Requires-Python: >=3.8
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: alembic>=1.18.5
19
+ Requires-Dist: sqlalchemy>=2.0.51
20
+ Requires-Dist: pydantic>=2.13.4
21
+ Requires-Dist: typer>=0.26.7
22
+ Requires-Dist: questionary>=2.1.1
23
+ Requires-Dist: rich>=15.0.0
24
+ Requires-Dist: uvicorn>=0.49.0
25
+ Requires-Dist: click>=8.4.2
26
+ Requires-Dist: greenlet>=3.5.2
27
+ Requires-Dist: jinja2>=3.1.6
28
+ Requires-Dist: mako>=1.3.12
29
+ Requires-Dist: prompt-toolkit>=3.0.52
30
+ Requires-Dist: typing-extensions>=4.15.0
31
+ Dynamic: license-file
32
+
33
+
34
+ ![Logo](https://ik.imagekit.io/cin2tn3bj/kribton_logo.png)
35
+ ## Kribton - A performative Python Web Framework
36
+
37
+ Kribton is a modern, high-performance, web framework for building APIs with Python.
38
+
39
+ ## Features
40
+
41
+ - **Lighting Fast**: Very high performance.
42
+ - **Auto Documentation**: You register endpoints, Kribton generates the documenations.
43
+ - **Easy**: Designed to be easy to use and learn, easy documentation.
44
+ - **Friendly**: Coming from Django, FastAPI or even Flask? still suitable for you.
45
+
46
+ ## Installation
47
+
48
+ Just run the pip command and you're all set!
49
+
50
+ ```bash
51
+ pip install kribton.py
52
+ ```
53
+
54
+
55
+ ## Usage/Examples
56
+
57
+ Creating a project using Kribton
58
+
59
+ ```bash
60
+ kribton init
61
+ ```
62
+ ## Authors
63
+
64
+ - [@abde1khaliq](https://www.github.com/abde1khaliq)
65
+
@@ -0,0 +1,33 @@
1
+
2
+ ![Logo](https://ik.imagekit.io/cin2tn3bj/kribton_logo.png)
3
+ ## Kribton - A performative Python Web Framework
4
+
5
+ Kribton is a modern, high-performance, web framework for building APIs with Python.
6
+
7
+ ## Features
8
+
9
+ - **Lighting Fast**: Very high performance.
10
+ - **Auto Documentation**: You register endpoints, Kribton generates the documenations.
11
+ - **Easy**: Designed to be easy to use and learn, easy documentation.
12
+ - **Friendly**: Coming from Django, FastAPI or even Flask? still suitable for you.
13
+
14
+ ## Installation
15
+
16
+ Just run the pip command and you're all set!
17
+
18
+ ```bash
19
+ pip install kribton.py
20
+ ```
21
+
22
+
23
+ ## Usage/Examples
24
+
25
+ Creating a project using Kribton
26
+
27
+ ```bash
28
+ kribton init
29
+ ```
30
+ ## Authors
31
+
32
+ - [@abde1khaliq](https://www.github.com/abde1khaliq)
33
+
@@ -0,0 +1,46 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "kribton"
7
+ version = "1.0.1" # bump version before uploading
8
+ authors = [
9
+ { name="Ahmed Abdelkhaliq", email="abdelkhaliqqq@gmail.com" },
10
+ ]
11
+ description = "A high-performance web framework for Python."
12
+ readme = "README.md"
13
+ requires-python = ">=3.8"
14
+ dependencies = [
15
+ "alembic>=1.18.5",
16
+ "sqlalchemy>=2.0.51",
17
+ "pydantic>=2.13.4",
18
+ "typer>=0.26.7",
19
+ "questionary>=2.1.1",
20
+ "rich>=15.0.0",
21
+ "uvicorn>=0.49.0",
22
+ "click>=8.4.2",
23
+ "greenlet>=3.5.2",
24
+ "jinja2>=3.1.6",
25
+ "mako>=1.3.12",
26
+ "prompt-toolkit>=3.0.52",
27
+ "typing-extensions>=4.15.0"
28
+ ]
29
+ classifiers = [
30
+ "Intended Audience :: Developers",
31
+ "Programming Language :: Python :: 3",
32
+ "Programming Language :: Python :: 3.8",
33
+ "Programming Language :: Python :: 3.9",
34
+ "Programming Language :: Python :: 3.10",
35
+ "Programming Language :: Python :: 3.11",
36
+ "Programming Language :: Python :: 3.12",
37
+ "License :: OSI Approved :: MIT License",
38
+ "Operating System :: OS Independent",
39
+ ]
40
+
41
+ [project.scripts]
42
+ kribton = "cli.main:app"
43
+
44
+ [tool.setuptools.packages.find]
45
+ where = ["src"]
46
+ include = ["kribton*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,7 @@
1
+ from kribton.core import Konda
2
+ from kribton.router import Router
3
+ from kribton.route import Route
4
+ from kribton.request import Request
5
+ from kribton.response import Response
6
+
7
+ __all__ = ["Konda", "Router", "Route", "Request", "Response"]
@@ -0,0 +1,30 @@
1
+ from kribton.request import Request
2
+ from kribton.response import Response
3
+ from kribton.route import Route
4
+
5
+
6
+ class Konda:
7
+ def __init__(self, title=None, description=None):
8
+ self.title = title
9
+ self.description = description
10
+ self.routers = []
11
+ self.routes = []
12
+
13
+ def add_router(self, router):
14
+ self.routers.append(router)
15
+ self.routes.extend(router.routes)
16
+
17
+ def add_route(self, path, handler):
18
+ self.routes.append(Route(path, handler))
19
+
20
+ async def __call__(self, scope, receive, send):
21
+ request = Request(scope, receive)
22
+
23
+ for route in self.routes:
24
+ if route.matches(scope):
25
+ response = await route.handler(request)
26
+ await response.send(send)
27
+ return
28
+
29
+ response = Response("Not Found", status=404)
30
+ await response.send(send)
@@ -0,0 +1,3 @@
1
+ from kribton.db.asyncio.database import AsyncDatabase
2
+
3
+ __all__ = ["AsyncDatabase"]
@@ -0,0 +1,44 @@
1
+ from contextlib import asynccontextmanager
2
+ from sqlalchemy import text
3
+ from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker, create_async_engine
4
+
5
+ from kribton.db.asyncio.query_manager import AsyncQueryManager
6
+ from kribton.db.base_database import BaseDatabaseConfig
7
+ from kribton.models.base import BaseModel
8
+
9
+
10
+ class AsyncDatabase(BaseDatabaseConfig):
11
+ def __init__(self, url: str, **kwargs):
12
+ super().__init__(url, **kwargs)
13
+ self._engine = create_async_engine(self.url, **self._engine_kwargs())
14
+ self._session_factory = async_sessionmaker(
15
+ self._engine, expire_on_commit=False, class_=AsyncSession
16
+ )
17
+
18
+ BaseModel._db = self
19
+
20
+ def _make_manager(self, cls):
21
+ return AsyncQueryManager(cls, self)
22
+
23
+ @asynccontextmanager
24
+ async def session(self):
25
+ session = self._session_factory()
26
+ try:
27
+ yield session
28
+ await session.commit()
29
+ except Exception:
30
+ await session.rollback()
31
+ raise
32
+ finally:
33
+ await session.close()
34
+
35
+ async def health_check(self) -> bool:
36
+ try:
37
+ async with self._engine.connect() as conn:
38
+ await conn.execute(text("SELECT 1"))
39
+ return True
40
+ except Exception:
41
+ return False
42
+
43
+ async def close(self) -> None:
44
+ await self._engine.dispose()
@@ -0,0 +1,12 @@
1
+ from sqlalchemy import select
2
+ from kribton.db.base_query_manager import BaseQueryManager
3
+
4
+ class AsyncQueryManager(BaseQueryManager):
5
+ async def all(self):
6
+ async with self.db.session() as session:
7
+ result = await session.execute(select(self.model))
8
+ rows = result.scalars().all()
9
+ return [self.serialize(row) for row in rows]
10
+
11
+ def serialize(self, obj):
12
+ return {c.name: getattr(obj, c.name) for c in obj.__table__.columns}
@@ -0,0 +1,28 @@
1
+ class BaseDatabaseConfig:
2
+ def __init__(
3
+ self,
4
+ url: str,
5
+ pool_size: int = 5,
6
+ max_overflow: int = 10,
7
+ pool_timeout: int = 30,
8
+ pool_recycle: int = 1800,
9
+ echo: bool = False,
10
+ ):
11
+ self.url = url
12
+ self.pool_size = pool_size
13
+ self.max_overflow = max_overflow
14
+ self.pool_timeout = pool_timeout
15
+ self.pool_recycle = pool_recycle
16
+ self.echo = echo
17
+ self._engine = None
18
+ self._session_factory = None
19
+
20
+ def _engine_kwargs(self):
21
+ return dict(
22
+ pool_size=self.pool_size,
23
+ max_overflow=self.max_overflow,
24
+ pool_timeout=self.pool_timeout,
25
+ pool_recycle=self.pool_recycle,
26
+ pool_pre_ping=True,
27
+ echo=self.echo,
28
+ )
@@ -0,0 +1,4 @@
1
+ class BaseQueryManager:
2
+ def __init__(self, model, db):
3
+ self.model = model
4
+ self.db = db
@@ -0,0 +1,5 @@
1
+ from kribton.models.base import BaseModel
2
+
3
+ __all__ = [
4
+ "BaseModel",
5
+ ]
@@ -0,0 +1,29 @@
1
+ from typing import ClassVar
2
+ from sqlalchemy.orm import DeclarativeBase
3
+
4
+
5
+ class QueryManagerDescriptor:
6
+ """Resolves the query manager at access time, not at import time."""
7
+
8
+ def __get__(self, obj, cls):
9
+ if cls is None:
10
+ return self
11
+ if BaseModel._db is None:
12
+ raise RuntimeError(
13
+ f"Database not initialized. Create AsyncDatabase before accessing "
14
+ f"{cls.__name__}.objects"
15
+ )
16
+ manager = BaseModel._db._make_manager(cls)
17
+ setattr(cls, "_objects_cache", manager)
18
+ return manager
19
+
20
+
21
+ class BaseModel(DeclarativeBase):
22
+ _registry: ClassVar[list[type]] = []
23
+ _db: ClassVar = None
24
+ objects = QueryManagerDescriptor()
25
+
26
+ def __init_subclass__(cls, **kwargs):
27
+ super().__init_subclass__(**kwargs)
28
+ if hasattr(cls, "__tablename__"):
29
+ BaseModel._registry.append(cls)
@@ -0,0 +1,31 @@
1
+ import json
2
+
3
+
4
+ class Request:
5
+ def __init__(self, scope, receive):
6
+ self._scope = scope
7
+ self._receive = receive
8
+ self._body = None
9
+ self.path = self._scope["path"]
10
+ self.method = self._scope["method"]
11
+ self.headers = [
12
+ (m.decode(), n.decode()) for m, n in self._scope.get("headers", [])
13
+ ]
14
+
15
+ async def body(self):
16
+ if self._body is None:
17
+ chunks = []
18
+ while True:
19
+ message = await self._receive()
20
+ if message["type"] == "http.request":
21
+ chunks.append(message.get("body", b""))
22
+ if not message.get("more_body", False):
23
+ break
24
+ self._body = b"".join(chunks)
25
+ return self._body
26
+
27
+ async def json(self):
28
+ try:
29
+ return json.loads((await self.body()).decode("utf-8"))
30
+ except Exception:
31
+ return {}
@@ -0,0 +1,30 @@
1
+ import json
2
+
3
+ class Response:
4
+ def __init__(self, content, status=200, headers=None):
5
+ if isinstance(content, (dict, list)):
6
+ self.content = json.dumps(content).encode("utf-8")
7
+ self.headers = headers or [(b"content-type", b"application/json")]
8
+ elif isinstance(content, str):
9
+ self.content = content.encode("utf-8")
10
+ self.headers = headers or [(b"content-type", b"text/plain")]
11
+ elif isinstance(content, (bytes, bytearray)):
12
+ self.content = content
13
+ self.headers = headers or [(b"content-type", b"application/octet-stream")]
14
+ else:
15
+ self.content = str(content).encode("utf-8")
16
+ self.headers = headers or [(b"content-type", b"text/plain")]
17
+
18
+ self.status = status
19
+
20
+ async def send(self, send):
21
+ headers = [[m, n] for (m, n) in self.headers]
22
+ await send({
23
+ "type": "http.response.start",
24
+ "status": self.status,
25
+ "headers": headers,
26
+ })
27
+ await send({
28
+ "type": "http.response.body",
29
+ "body": self.content,
30
+ })
@@ -0,0 +1,7 @@
1
+ class Route:
2
+ def __init__(self, path, handler):
3
+ self.path = path
4
+ self.handler = handler
5
+
6
+ def matches(self, scope):
7
+ return self.path == scope["path"]
@@ -0,0 +1,9 @@
1
+ from kribton.route import Route
2
+
3
+
4
+ class Router:
5
+ def __init__(self):
6
+ self.routes = []
7
+
8
+ def append_route(self, path, handler):
9
+ self.routes.append(Route(path, handler))
@@ -0,0 +1,65 @@
1
+ Metadata-Version: 2.4
2
+ Name: kribton
3
+ Version: 1.0.1
4
+ Summary: A high-performance web framework for Python.
5
+ Author-email: Ahmed Abdelkhaliq <abdelkhaliqqq@gmail.com>
6
+ Classifier: Intended Audience :: Developers
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Programming Language :: Python :: 3.8
9
+ Classifier: Programming Language :: Python :: 3.9
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Requires-Python: >=3.8
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Requires-Dist: alembic>=1.18.5
19
+ Requires-Dist: sqlalchemy>=2.0.51
20
+ Requires-Dist: pydantic>=2.13.4
21
+ Requires-Dist: typer>=0.26.7
22
+ Requires-Dist: questionary>=2.1.1
23
+ Requires-Dist: rich>=15.0.0
24
+ Requires-Dist: uvicorn>=0.49.0
25
+ Requires-Dist: click>=8.4.2
26
+ Requires-Dist: greenlet>=3.5.2
27
+ Requires-Dist: jinja2>=3.1.6
28
+ Requires-Dist: mako>=1.3.12
29
+ Requires-Dist: prompt-toolkit>=3.0.52
30
+ Requires-Dist: typing-extensions>=4.15.0
31
+ Dynamic: license-file
32
+
33
+
34
+ ![Logo](https://ik.imagekit.io/cin2tn3bj/kribton_logo.png)
35
+ ## Kribton - A performative Python Web Framework
36
+
37
+ Kribton is a modern, high-performance, web framework for building APIs with Python.
38
+
39
+ ## Features
40
+
41
+ - **Lighting Fast**: Very high performance.
42
+ - **Auto Documentation**: You register endpoints, Kribton generates the documenations.
43
+ - **Easy**: Designed to be easy to use and learn, easy documentation.
44
+ - **Friendly**: Coming from Django, FastAPI or even Flask? still suitable for you.
45
+
46
+ ## Installation
47
+
48
+ Just run the pip command and you're all set!
49
+
50
+ ```bash
51
+ pip install kribton.py
52
+ ```
53
+
54
+
55
+ ## Usage/Examples
56
+
57
+ Creating a project using Kribton
58
+
59
+ ```bash
60
+ kribton init
61
+ ```
62
+ ## Authors
63
+
64
+ - [@abde1khaliq](https://www.github.com/abde1khaliq)
65
+
@@ -0,0 +1,22 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/kribton/__init__.py
5
+ src/kribton/core.py
6
+ src/kribton/request.py
7
+ src/kribton/response.py
8
+ src/kribton/route.py
9
+ src/kribton/router.py
10
+ src/kribton.egg-info/PKG-INFO
11
+ src/kribton.egg-info/SOURCES.txt
12
+ src/kribton.egg-info/dependency_links.txt
13
+ src/kribton.egg-info/entry_points.txt
14
+ src/kribton.egg-info/requires.txt
15
+ src/kribton.egg-info/top_level.txt
16
+ src/kribton/db/base_database.py
17
+ src/kribton/db/base_query_manager.py
18
+ src/kribton/db/asyncio/__init__.py
19
+ src/kribton/db/asyncio/database.py
20
+ src/kribton/db/asyncio/query_manager.py
21
+ src/kribton/models/__init__.py
22
+ src/kribton/models/base.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ kribton = cli.main:app
@@ -0,0 +1,13 @@
1
+ alembic>=1.18.5
2
+ sqlalchemy>=2.0.51
3
+ pydantic>=2.13.4
4
+ typer>=0.26.7
5
+ questionary>=2.1.1
6
+ rich>=15.0.0
7
+ uvicorn>=0.49.0
8
+ click>=8.4.2
9
+ greenlet>=3.5.2
10
+ jinja2>=3.1.6
11
+ mako>=1.3.12
12
+ prompt-toolkit>=3.0.52
13
+ typing-extensions>=4.15.0
@@ -0,0 +1 @@
1
+ kribton