file_path stringlengths 3 280 | file_language stringclasses 66
values | content stringlengths 1 1.04M | repo_name stringlengths 5 92 | repo_stars int64 0 154k | repo_description stringlengths 0 402 | repo_primary_language stringclasses 108
values | developer_username stringlengths 1 25 | developer_name stringlengths 0 30 | developer_company stringlengths 0 82 |
|---|---|---|---|---|---|---|---|---|---|
authx_extra/__init__.py | Python | """Extra utilities for authx, including session, profiler & caching ✨"""
__version__ = "1.2.0"
| yezz123/authx-extra | 7 | Extra utilities for authx, including session, profiler & caching ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
authx_extra/addons/expiry.py | Python | from typing import Callable, Optional
import pytz
from authx._internal import end_of_day, end_of_week, tz_now, utc
from authx_extra.extra._cache import HTTPCache
class HTTPExpiry:
@staticmethod
async def get_ttl(
ttl_in_seconds: Optional[int] = None,
end_of_day: bool = True,
end_of_w... | yezz123/authx-extra | 7 | Extra utilities for authx, including session, profiler & caching ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
authx_extra/addons/keys.py | Python | from typing import Any, List, Optional
from authx_extra.extra._cache import HTTPCache
class HTTPKeys:
@staticmethod
async def generate_key(
key: str,
config: HTTPCache,
obj: Optional[Any] = None,
obj_attr: Optional[str] = None,
) -> str:
"""Converts a raw key passe... | yezz123/authx-extra | 7 | Extra utilities for authx, including session, profiler & caching ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
authx_extra/cache.py | Python | import json
from functools import wraps
from typing import Any, Callable, List, Optional, Tuple, Union
import redis
from authx._internal import log_error, log_info
from authx_extra.addons.expiry import HTTPExpiry
from authx_extra.addons.keys import HTTPKeys
from authx_extra.extra._cache import HTTPCache
class HTTPC... | yezz123/authx-extra | 7 | Extra utilities for authx, including session, profiler & caching ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
authx_extra/extra/_cache.py | Python | import redis
from authx._internal._logger import log_debug
from authx._internal._utils import utc
from pytz import timezone
class HTTPCache:
redis_url: str
namespace: str
tz: timezone
@classmethod
def init(
cls,
redis_url: str,
tz: timezone = utc,
namespace: str = ... | yezz123/authx-extra | 7 | Extra utilities for authx, including session, profiler & caching ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
authx_extra/extra/_memory.py | Python | import time
from typing import Any, Optional
class MemoryIO:
raw_memory_store: dict[str, dict[str, Any]]
"""
MemoryIO is a class that implements the IO interface for the session store.
It is used to store session data in memory.
"""
def __init__(self) -> None:
"""Initialize an insta... | yezz123/authx-extra | 7 | Extra utilities for authx, including session, profiler & caching ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
authx_extra/metrics.py | Python | import functools
import os
import time
import typing
import prometheus_client
from fastapi import FastAPI, Request
from prometheus_client.multiprocess import MultiProcessCollector
from starlette.middleware.base import BaseHTTPMiddleware
from starlette.responses import Response
class MetricsMiddleware(BaseHTTPMiddlew... | yezz123/authx-extra | 7 | Extra utilities for authx, including session, profiler & caching ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
authx_extra/oauth2.py | Python | import datetime
import json
import logging
import typing
import urllib.request
import jose.jwt
from authx.exceptions import InvalidToken
from fastapi.requests import HTTPConnection
from fastapi.responses import JSONResponse
from fastapi.websockets import WebSocket
from starlette.types import ASGIApp, Receive, Scope, S... | yezz123/authx-extra | 7 | Extra utilities for authx, including session, profiler & caching ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
authx_extra/profiler.py | Python | import codecs
import time
from logging import getLogger
from typing import Optional
from pyinstrument import Profiler, renderers
from starlette.requests import Request
from starlette.routing import Router
from starlette.types import ASGIApp, Message, Receive, Scope, Send
logger = getLogger("profiler")
class Profile... | yezz123/authx-extra | 7 | Extra utilities for authx, including session, profiler & caching ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
authx_extra/session.py | Python | import uuid
from http.cookies import SimpleCookie
from authx._internal import SignatureSerializer
from starlette.middleware.base import BaseHTTPMiddleware, RequestResponseEndpoint
from starlette.requests import Request
from starlette.responses import Response
from authx_extra.extra._memory import MemoryIO
class Ses... | yezz123/authx-extra | 7 | Extra utilities for authx, including session, profiler & caching ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
scripts/clean.sh | Shell | #!/bin/sh -e
rm -f `find . -type f -name '*.py[co]' `
rm -f `find . -type f -name '*~' `
rm -f `find . -type f -name '.*~' `
rm -f `find . -type f -name .coverage`
rm -f `find . -type f -name ".coverage.*"`
rm -rf `find . -name __pycache__`
rm -rf `find . -type d -name '*.egg-info' `
rm -rf `find . -type d -name 'pip-... | yezz123/authx-extra | 7 | Extra utilities for authx, including session, profiler & caching ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
scripts/docker.sh | Shell | #!/usr/bin/env bash
set -e
set -x
echo "ENV=${ENV}"
echo "REDIS_URL=${REDIS_URL}"
export PYTHONPATH=.
# Check if Redis container is already running
if [[ "$(docker inspect -f '{{.State.Running}}' redis 2>/dev/null)" == "true" ]]; then
echo "Redis container is already running. Running tests again..."
# Run tests... | yezz123/authx-extra | 7 | Extra utilities for authx, including session, profiler & caching ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
scripts/format.sh | Shell | #!/usr/bin/env bash
set -e
set -x
pre-commit run --all-files --verbose --show-diff-on-failure
| yezz123/authx-extra | 7 | Extra utilities for authx, including session, profiler & caching ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
scripts/lint.sh | Shell | #!/usr/bin/env bash
set -e
set -x
mypy --show-error-codes authx_extra
| yezz123/authx-extra | 7 | Extra utilities for authx, including session, profiler & caching ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
scripts/requirements.sh | Shell | #!/usr/bin/env bash
uv lock --upgrade
| yezz123/authx-extra | 7 | Extra utilities for authx, including session, profiler & caching ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/extra/test_memory.py | Python | from time import time
import pytest
from authx_extra.extra._memory import MemoryIO
@pytest.fixture
def memory_io():
return MemoryIO()
@pytest.mark.asyncio
async def test_create_store(memory_io):
session_id = "123"
store = await memory_io.create_store(session_id)
assert store == {}
assert memor... | yezz123/authx-extra | 7 | Extra utilities for authx, including session, profiler & caching ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/test_cache.py | Python | import os
from datetime import datetime
import redis
from fastapi import FastAPI, Request, Response
from fastapi.responses import JSONResponse
from fastapi.testclient import TestClient
from authx_extra.cache import HTTPCache, cache, invalidate_cache
REDIS_URL = os.environ.get("REDIS_URL", "redis://localhost:6379/2")... | yezz123/authx-extra | 7 | Extra utilities for authx, including session, profiler & caching ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/test_keys.py | Python | import os
import pytest
import redis
from authx_extra.addons.keys import HTTPKeys
from authx_extra.cache import HTTPCache
REDIS_URL = os.environ.get("REDIS_URL", "redis://localhost:6379/3")
redis_client = redis.Redis.from_url(REDIS_URL)
class TestHTTPKeys:
@pytest.mark.asyncio
async def test_generate_keys(... | yezz123/authx-extra | 7 | Extra utilities for authx, including session, profiler & caching ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/test_method_cache.py | Python | import os
import pytest
import redis
from authx_extra.cache import HTTPCache, cache
REDIS_URL = os.environ.get("REDIS_URL", "redis://localhost:6379/2")
redis_client = redis.Redis.from_url(REDIS_URL)
HTTPCache.init(redis_url=REDIS_URL, namespace="test_namespace")
@cache(key="cache.me", ttl_in_seconds=360)
async de... | yezz123/authx-extra | 7 | Extra utilities for authx, including session, profiler & caching ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/test_metrics.py | Python | import pytest
from fastapi import FastAPI, Response
from fastapi.testclient import TestClient
from prometheus_client.parser import text_string_to_metric_families
from authx_extra.metrics import MetricsMiddleware, get_metrics
@pytest.fixture(autouse=True)
def env(monkeypatch):
"""Run tests with 'PROMETHEUS_MULTIP... | yezz123/authx-extra | 7 | Extra utilities for authx, including session, profiler & caching ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/test_oauth2.py | Python | import datetime
import unittest
import jose.jwt
from starlette.applications import Starlette
from starlette.middleware.cors import CORSMiddleware
from starlette.testclient import TestClient
from starlette.websockets import WebSocketDisconnect
from authx_extra.oauth2 import MiddlewareOauth2, _get_keys
def case_1(**k... | yezz123/authx-extra | 7 | Extra utilities for authx, including session, profiler & caching ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/test_profiler.py | Python | import json
import os
import sys
from io import StringIO
import pytest
from fastapi import FastAPI
from fastapi.responses import JSONResponse
from fastapi.testclient import TestClient
from authx_extra.profiler import ProfilerMiddleware
class ConsoleOutputRedirect:
def __init__(self, fp):
self.fp = fp
... | yezz123/authx-extra | 7 | Extra utilities for authx, including session, profiler & caching ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/test_session_middleware.py | Python | import time
from unittest.mock import Mock
import pytest
from starlette.applications import Starlette
from starlette.requests import Request
from starlette.responses import PlainTextResponse, Response
from starlette.routing import Route
from starlette.testclient import TestClient
from authx_extra.extra._memory import... | yezz123/authx-extra | 7 | Extra utilities for authx, including session, profiler & caching ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/test_skip_session_header_check_dict.py | Python | from unittest.mock import Mock
import pytest
from authx_extra.session import SessionMiddleware
@pytest.fixture
def middleware():
return SessionMiddleware(
app=None,
secret_key="test",
skip_session_header={"header_name": "X-TESTAPI-Skip", "header_value": "skip"},
)
def test_skip_ses... | yezz123/authx-extra | 7 | Extra utilities for authx, including session, profiler & caching ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/test_skip_session_header_check_list.py | Python | from unittest.mock import Mock
import pytest
from authx_extra.session import SessionMiddleware
@pytest.fixture
def middleware():
return SessionMiddleware(
app=None,
secret_key="test",
skip_session_header=[
{"header_name": "X-APITEST-Skip", "header_value": "skip"},
... | yezz123/authx-extra | 7 | Extra utilities for authx, including session, profiler & caching ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
src/api.rs | Rust | use std::collections::HashMap;
#[derive(serde::Serialize)]
#[allow(non_camel_case_types)]
pub enum DockerErrorMessageType {
BLOB_UNKNOWN,
BLOB_UPLOAD_INVALID,
BLOB_UPLOAD_UNKNOWN,
DIGEST_INVALID,
MANIFEST_BLOB_UNKNOWN,
MANIFEST_INVALID,
MANIFEST_UNKNOWN,
MANIFEST_UNVERIFIED,
NAME_IN... | yezz123/dockerust | 9 | 🦀 Functional Docker registry server in pure Rust. | Rust | yezz123 | Yasser Tahiri | Yezz LLC. |
src/constants.rs | Rust | /// JWT auth token lifetime
pub const AUTH_TOKENS_DURATION: u64 = 300;
| yezz123/dockerust | 9 | 🦀 Functional Docker registry server in pure Rust. | Rust | yezz123 | Yasser Tahiri | Yezz LLC. |
src/docker.rs | Rust | #[derive(serde::Deserialize, Clone)]
#[allow(non_snake_case)]
pub struct DockerBlobRef {
pub mediaType: String,
pub digest: String,
pub size: Option<usize>,
}
#[allow(non_snake_case)]
#[derive(serde::Deserialize, Clone)]
pub struct DockerManifest {
pub schemaVersion: usize,
pub mediaType: String,
... | yezz123/dockerust | 9 | 🦀 Functional Docker registry server in pure Rust. | Rust | yezz123 | Yasser Tahiri | Yezz LLC. |
src/lib.rs | Rust | pub mod api;
pub mod constants;
pub mod docker;
pub mod read_file_stream;
pub mod server;
pub mod storage;
pub mod utils;
| yezz123/dockerust | 9 | 🦀 Functional Docker registry server in pure Rust. | Rust | yezz123 | Yasser Tahiri | Yezz LLC. |
src/main.rs | Rust | use std::io::{Error, ErrorKind};
use std::path::{Path, PathBuf};
use std::process;
use bcrypt::DEFAULT_COST;
use dockerust::server;
use dockerust::server::{Credentials, ServerConfig};
use dockerust::storage::clean_storage;
use dockerust::utils::{rand_str, request_input};
fn show_usage() {
let args = std::env::ar... | yezz123/dockerust | 9 | 🦀 Functional Docker registry server in pure Rust. | Rust | yezz123 | Yasser Tahiri | Yezz LLC. |
src/read_file_stream.rs | Rust | use std::io::Read;
use std::path::Path;
use std::pin::Pin;
use std::task::{Context, Poll};
use actix_web::web::Bytes;
use futures::Stream;
const CHUNK_SIZE: u64 = 1024 * 1024 * 50; // 50 MB
pub struct ReadFileStream {
file_size: u64,
processed: usize,
file: std::fs::File,
error: bool,
}
impl ReadFil... | yezz123/dockerust | 9 | 🦀 Functional Docker registry server in pure Rust. | Rust | yezz123 | Yasser Tahiri | Yezz LLC. |
src/server.rs | Rust | use actix_web::body::SizedStream;
use actix_web::http::Method;
use actix_web::web::Data;
use actix_web::{web, App, HttpRequest, HttpResponse, HttpResponseBuilder, HttpServer};
use base64::{engine::general_purpose as b64decoder, Engine as _};
use futures::StreamExt;
use jsonwebtoken::{encode, Validation};
use regex::Reg... | yezz123/dockerust | 9 | 🦀 Functional Docker registry server in pure Rust. | Rust | yezz123 | Yasser Tahiri | Yezz LLC. |
src/storage.rs | Rust | use std::io::ErrorKind;
use std::path::{Path, PathBuf};
use std::str::FromStr;
use crate::docker::{DockerBlobRef, DockerManifest, DockerManifestOrManifestList};
const BASE_PATH: &str = "docker/registry/v2/";
#[derive(Debug, Eq, PartialEq)]
pub struct BlobReference {
alg: String,
hash: String,
}
impl BlobRef... | yezz123/dockerust | 9 | 🦀 Functional Docker registry server in pure Rust. | Rust | yezz123 | Yasser Tahiri | Yezz LLC. |
src/utils.rs | Rust | //! Utilities
use std::io::{stdin, stdout, ErrorKind, Write};
use std::path::Path;
use std::process::Command;
use std::time::{SystemTime, UNIX_EPOCH};
use rand::distributions::Alphanumeric;
use rand::{thread_rng, Rng};
/// Create an empty file and all its parent directories
pub fn create_empty_file(path: &Path) -> s... | yezz123/dockerust | 9 | 🦀 Functional Docker registry server in pure Rust. | Rust | yezz123 | Yasser Tahiri | Yezz LLC. |
docs/css/custom.css | CSS | .termynal-comment {
color: #4a968f;
font-style: italic;
display: block;
}
.termy {
/* For right to left languages */
direction: ltr;
}
.termy [data-termynal] {
white-space: pre-wrap;
}
/* Right to left languages */
code {
direction: ltr;
display: inline-block;
}
| yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
docs/css/termynal.css | CSS | /**
* termynal.js
*
* @author Ines Montani <ines@ines.io>
* @version 0.0.1
* @license MIT
*/
:root {
--color-bg: #252a33;
--color-text: #eee;
--color-text-subtle: #a2a2a2;
}
[data-termynal] {
width: 750px;
max-width: 100%;
background: var(--color-bg);
color: var(--color-text);
/* font-size: 18px... | yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
docs/js/custom.js | JavaScript | function setupTermynal() {
document.querySelectorAll(".use-termynal").forEach((node) => {
node.style.display = "block";
new Termynal(node, {
lineDelay: 500,
});
});
const progressLiteralStart = "---> 100%";
const promptLiteralStart = "$ ";
const customPromptLiteralStart = "# ";
const termy... | yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
docs/js/termynal.js | JavaScript | /**
* termynal.js
* A lightweight, modern and extensible animated terminal window, using
* async/await.
*
* @author Ines Montani <ines@ines.io>
* @version 0.0.1
* @license MIT
*/
"use strict";
/** Generate a terminal widget. */
class Termynal {
/**
* Construct the widget's settings.
* @param {(string|... | yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
ormdantic/__init__.py | Python | """asynchronous ORM that uses pydantic models to represent database tables ✨"""
__version__ = "1.7.0"
from ormdantic.orm import Ormdantic
__all__ = ["Ormdantic"]
| yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
ormdantic/generator/__init__.py | Python | from ormdantic.generator._crud import OrmCrud as CRUD
from ormdantic.generator._lazy import generate as Generator
from ormdantic.generator._table import OrmTableGenerator as Table
__all__ = ["Table", "CRUD", "Generator"]
| yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
ormdantic/generator/_crud.py | Python | """Handle table interactions for a model."""
from typing import Any, Generic
from pypika import Order
from pypika.queries import QueryBuilder
from sqlalchemy import text
from sqlalchemy.ext.asyncio import AsyncEngine, AsyncSession, async_sessionmaker
from ormdantic.generator._field import OrmField
from ormdantic.gen... | yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
ormdantic/generator/_field.py | Python | """Module for building queries from field data."""
from typing import Any
from pypika import Field, Order
from pypika.functions import Count
from pypika.queries import Query, QueryBuilder, Table
from ormdantic.handler import py_type_to_sql
from ormdantic.models import Map, OrmTable
class OrmField:
"""Build SQL... | yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
ormdantic/generator/_lazy.py | Python | import contextlib
import datetime
import random
import types
import typing
from enum import Enum
from typing import Any, Type
from uuid import UUID, uuid4
import pydantic
from pydantic import BaseModel
from pydantic.fields import ModelField
from ormdantic.handler import (
GetTargetLength,
RandomDatetimeValue,... | yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
ormdantic/generator/_query.py | Python | from pypika import PostgreSQLQuery, Query, Table
from pypika.dialects import PostgreSQLQueryBuilder
from pypika.queries import QueryBuilder
from ormdantic.handler import py_type_to_sql
from ormdantic.models import Map
from ormdantic.types import ModelType
class OrmQuery:
"""Build SQL queries for model CRUD opera... | yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
ormdantic/generator/_serializer.py | Python | import json
from types import NoneType
from typing import Any, Generic, get_args
from pydantic import BaseModel, Field
from sqlalchemy.engine import CursorResult
from ormdantic.models import Map, OrmTable
from ormdantic.types import ModelType, SerializedType
class ResultSchema(BaseModel):
"""Model to describe t... | yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
ormdantic/generator/_table.py | Python | """Module providing OrmTableGenerator."""
import uuid
from datetime import date, datetime
from types import UnionType
from typing import Any, get_args, get_origin
from pydantic import BaseModel
from pydantic.fields import ModelField
from sqlalchemy import (
JSON,
Boolean,
Column,
Date,
DateTime,
... | yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
ormdantic/handler/__init__.py | Python | from ormdantic.handler.errors import (
ConfigurationError,
MismatchingBackReferenceError,
MustUnionForeignKeyError,
TypeConversionError,
UndefinedBackReferenceError,
)
from ormdantic.handler.helper import (
Model_Instance,
TableName_From_Model,
py_type_to_sql,
)
from ormdantic.handler.ra... | yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
ormdantic/handler/errors.py | Python | from typing import Type
import sqlalchemy
class ConfigurationError(Exception):
"""Raised for mal-configured database models or schemas."""
def __init__(self, msg: str):
super().__init__(msg)
class UndefinedBackReferenceError(ConfigurationError):
"""Raised when a back reference is missing from ... | yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
ormdantic/handler/helper.py | Python | """Utility functions used throughout the project."""
import json
from typing import Any, Type
from uuid import UUID
from pydantic import BaseModel
from ormdantic.models.models import Map
from ormdantic.types import ModelType
def TableName_From_Model(model: Type[ModelType], table_map: Map) -> str:
"""Get a tabl... | yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
ormdantic/handler/random.py | Python | import datetime
import math
import random
import string
from pydantic.fields import ModelField
from ormdantic.types import AnyNumber, default_max_length
def _random_str_value(model_field: ModelField) -> str:
"""Get a random string."""
target_length = _get_target_length(
model_field.field_info.min_le... | yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
ormdantic/handler/snake.py | Python | import re
from typing import Union
def snake(string: str) -> str:
"""Return a version of the string in `snake_case`` format."""
return "_".join(w.lower() for w in get_words(string))
def get_words(string: str) -> list[str]:
"""Get a list of the words in a string in the order they appear."""
words = [... | yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
ormdantic/models/__init__.py | Python | from ormdantic.models.models import Map, OrmTable, Relationship, Result
__all__ = [
"Relationship",
"OrmTable",
"Map",
"Result",
]
| yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
ormdantic/models/models.py | Python | from typing import Generic, Type
from pydantic import BaseModel, Field
from pydantic.generics import GenericModel
from ormdantic.types import ModelType
class Result(GenericModel, Generic[ModelType]):
"""Search result object."""
offset: int
limit: int
data: list[ModelType]
class Relationship(BaseM... | yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
ormdantic/orm.py | Python | """Module providing a way to create ORM models and schemas"""
from types import UnionType
from typing import Callable, ForwardRef, Type, get_args, get_origin
from pydantic.fields import ModelField
from sqlalchemy import MetaData
from sqlalchemy.ext.asyncio import create_async_engine
from ormdantic.generator import C... | yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
ormdantic/types/__init__.py | Python | """Provides ModelType TypeVar used throughout lib."""
from ormdantic.types.base import (
AnyNumber,
ModelType,
SerializedType,
default_max_length,
)
__all__ = ["ModelType", "SerializedType", "AnyNumber", "default_max_length"]
| yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
ormdantic/types/base.py | Python | from numbers import Number
from typing import TypeAlias, TypeVar
from pydantic import BaseModel
# ModelType is a TypeVar that is bound to BaseModel, so it can only be used
# with subclasses of BaseModel.
ModelType = TypeVar("ModelType", bound=BaseModel)
# SerializedType is a TypeVar that is bound to dict, so it can ... | yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
scripts/clean.sh | Shell | #!/bin/sh -e
rm -f `find . -type f -name '*.py[co]' `
rm -f `find . -type f -name '*~' `
rm -f `find . -type f -name '.*~' `
rm -f `find . -type f -name .coverage`
rm -f `find . -type f -name ".coverage.*"`
rm -rf `find . -name __pycache__`
rm -rf `find . -type d -name '*.egg-info' `
rm -rf `find . -type d -name 'pip-... | yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
scripts/docs_build.sh | Shell | #!/usr/bin/env bash
set -e
set -x
# Build the docs
mkdocs build -d build
| yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
scripts/docs_serve.sh | Shell | #!/usr/bin/env bash
set -e
set -x
# Serve the docs
mkdocs serve --livereload
| yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
scripts/format.sh | Shell | #!/usr/bin/env bash
set -e
set -x
pre-commit run --all-files --verbose --show-diff-on-failure
| yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
scripts/integration.sh | Shell | #!/usr/bin/env bash
set -e
set -x
echo "ENV=${ENV}"
export PYTHONPATH=.
python3 tests/integration/demo.py
| yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
scripts/lint.sh | Shell | #!/usr/bin/env bash
set -e
set -x
mypy --show-error-codes ormdantic
| yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
scripts/requirements.sh | Shell | #!/usr/bin/env bash
refresh-lockfiles() {
echo "Updating requirements/*.txt files using uv"
find requirements/ -name '*.txt' ! -name 'all.txt' -type f -delete
uv pip compile requirements/linting.in -o requirements/linting.txt
uv pip compile requirements/testing.in -o requirements/testing.txt
uv pip compile r... | yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
scripts/test.sh | Shell | #!/usr/bin/env bash
set -e
set -x
echo "ENV=${ENV}"
export PYTHONPATH=.
pytest --cov=ormdantic --cov-report=xml
| yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/integration/demo.py | Python | import asyncio
from functools import wraps
from uuid import UUID, uuid4
from decouple import config
from pydantic import BaseModel, Field
from ormdantic import Ormdantic
connection = config("DATABASE_URL")
db = Ormdantic(connection)
@db.table(pk="id", indexed=["name"])
class Flavor(BaseModel):
"""A coffee flav... | yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/test_errors.py | Python | from __future__ import annotations
import asyncio
import unittest
from typing import Callable
from uuid import UUID, uuid4
import pytest
import sqlalchemy
from decouple import config
from pydantic import BaseModel, Field
from sqlalchemy import MetaData
from ormdantic import Ormdantic
from ormdantic.handler import (
... | yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/test_generator.py | Python | from __future__ import annotations
import datetime
import types
from collections import OrderedDict
from enum import Enum, auto
from uuid import UUID, uuid4
from pydantic import BaseModel, Field
from ormdantic.generator import Generator
class Flavor(Enum):
"""Coffee flavors."""
MOCHA = auto()
VANILLA ... | yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/test_orm.py | Python | from __future__ import annotations
import asyncio
import unittest
from datetime import date, datetime
from typing import Any
from uuid import UUID, uuid4
from decouple import config
from pydantic import BaseModel, Field
from pypika import Order
from ormdantic import Ormdantic
URL = config("DATABASE_URL")
connectio... | yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/test_otm_relations.py | Python | from __future__ import annotations
import asyncio
import unittest
from uuid import UUID, uuid4
from decouple import config
from pydantic import BaseModel, Field
from ormdantic import Ormdantic
URL = config("DATABASE_URL")
connection = URL
database = Ormdantic(connection)
@database.table(pk="id", back_references=... | yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/test_snake.py | Python | from unittest import TestCase
from ormdantic.handler.snake import get_words
class SnakeTest(TestCase):
def __init__(self, *args) -> None: # type: ignore
self.snake_sample = "hello_yezz_data_happy"
super().__init__(*args)
def test_get_words_from_snake(self) -> None:
self.assertEqual(... | yezz123/ormdantic | 150 | Asynchronous ORM that uses pydantic models to represent database tables ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
pagidantic/__init__.py | Python | """
Pagidantic is a Python package for pagination using Pydantic.
It's easy to use, lightweight, and easy to integrate with existing projects.
It helps in creating efficient pagination solution with minimal code, while maintaining type checking and data validation with Pydantic.
"""
__version__ = "2.0.0"
from pagid... | yezz123/pagidantic | 16 | Pagination using Pydantic. Easy to use, lightweight, and easy to integrate with existing projects 💡 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
pagidantic/dict.py | Python | from typing import Any, Dict, List
from pagidantic.paginator import Paginator
class PagidanticDict(Paginator):
"""
Initialize a Paginator for paginating a dictionary.
:param object_list: The dictionary to be paginated.
:type object_list: dict
:param page_limit: Number of items per page.
:typ... | yezz123/pagidantic | 16 | Pagination using Pydantic. Easy to use, lightweight, and easy to integrate with existing projects 💡 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
pagidantic/factory.py | Python | from typing import Type
from pydantic.dataclasses import dataclass
from pagidantic.dict import PagidanticDict
from pagidantic.paginator import Paginator
from pagidantic.set import PagidanticSet
@dataclass
class PagidanticFactory:
"""A factory class for creating paginator instances based on the type of objects t... | yezz123/pagidantic | 16 | Pagination using Pydantic. Easy to use, lightweight, and easy to integrate with existing projects 💡 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
pagidantic/page.py | Python | from typing import Sequence
class Page:
"""
A Page object, which contains a list of objects and some additional information such as the current page number and
the paginator instance.
"""
def __init__(
self, object_list: Sequence[object], page_number: int, paginator: object
):
... | yezz123/pagidantic | 16 | Pagination using Pydantic. Easy to use, lightweight, and easy to integrate with existing projects 💡 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
pagidantic/pagidantic.py | Python | from typing import Any, List, Set, Tuple, Type, Union
from pagidantic.factory import PagidanticFactory
from pagidantic.paginator import Paginator
def pagidantic(
object_list: Union[
list[List[Any]],
tuple[Tuple[Any]],
dict[Any, Any],
set[Set[Any]],
],
page_limit: int = 10,... | yezz123/pagidantic | 16 | Pagination using Pydantic. Easy to use, lightweight, and easy to integrate with existing projects 💡 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
pagidantic/paginator.py | Python | import math
from functools import cached_property
from typing import Any, Dict, Generator, List, Sequence, Set, Tuple, Union
from pydantic.dataclasses import dataclass
from pagidantic.page import Page
@dataclass
class Paginator:
"""
Objects paginator. Should be initialised using paginate function.
Argu... | yezz123/pagidantic | 16 | Pagination using Pydantic. Easy to use, lightweight, and easy to integrate with existing projects 💡 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
pagidantic/set.py | Python | from typing import Any, List
from pagidantic.paginator import Paginator
class PagidanticSet(Paginator):
"""
Initialize a Paginator for paginating a set.
:param object_list: The set to be paginated.
:type object_list: dict
:param page_limit: Number of items per page.
:type page_limit: int, op... | yezz123/pagidantic | 16 | Pagination using Pydantic. Easy to use, lightweight, and easy to integrate with existing projects 💡 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
scripts/clean.sh | Shell | #!/bin/sh -e
rm -f `find . -type f -name '*.py[co]' `
rm -f `find . -type f -name '*~' `
rm -f `find . -type f -name '.*~' `
rm -f `find . -type f -name .coverage`
rm -f `find . -type f -name ".coverage.*"`
rm -rf `find . -name __pycache__`
rm -rf `find . -type d -name '*.egg-info' `
rm -rf `find . -type d -name 'pip-... | yezz123/pagidantic | 16 | Pagination using Pydantic. Easy to use, lightweight, and easy to integrate with existing projects 💡 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
scripts/example.sh | Shell | #!/usr/bin/env bash
set -e
set -x
echo "ENV=${ENV}"
export PYTHONPATH=.
python tests/example/example.py
| yezz123/pagidantic | 16 | Pagination using Pydantic. Easy to use, lightweight, and easy to integrate with existing projects 💡 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
scripts/format.sh | Shell | #!/usr/bin/env bash
set -e
set -x
pre-commit run --all-files --verbose --show-diff-on-failure
| yezz123/pagidantic | 16 | Pagination using Pydantic. Easy to use, lightweight, and easy to integrate with existing projects 💡 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
scripts/lint.sh | Shell | #!/usr/bin/env bash
set -e
set -x
mypy --show-error-codes pagidantic
| yezz123/pagidantic | 16 | Pagination using Pydantic. Easy to use, lightweight, and easy to integrate with existing projects 💡 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
scripts/test.sh | Shell | #!/usr/bin/env bash
set -e
set -x
echo "ENV=${ENV}"
export PYTHONPATH=.
pytest --cov=pagidantic --cov-report=term-missing --cov-fail-under=80
| yezz123/pagidantic | 16 | Pagination using Pydantic. Easy to use, lightweight, and easy to integrate with existing projects 💡 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
scripts/test_html.sh | Shell | #!/usr/bin/env bash
set -e
set -x
echo "ENV=${ENV}"
export PYTHONPATH=.
pytest --cov=pagidantic --cov=tests --cov-report=html
| yezz123/pagidantic | 16 | Pagination using Pydantic. Easy to use, lightweight, and easy to integrate with existing projects 💡 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/conftest.py | Python | import pytest
from pagidantic import PagidanticDict, PagidanticSet, Paginator, pagidantic
def dict_to_list(dict_object: dict) -> list[dict]:
"""Transform dict to list of dicts."""
return [{k: v} for k, v in dict_object.items()]
@pytest.fixture()
def list_of_int() -> list[int]:
"""Generate list of integ... | yezz123/pagidantic | 16 | Pagination using Pydantic. Easy to use, lightweight, and easy to integrate with existing projects 💡 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/example/example.py | Python | import json
from pagidantic import pagidantic
# retrieve data from generated.json file and convert it to python object
with open("tests/example/generated.json") as f:
object_list = json.load(f)
pagination = pagidantic(object_list, page_limit=2, start_page=0)
# get current returned page
def get_current_page()... | yezz123/pagidantic | 16 | Pagination using Pydantic. Easy to use, lightweight, and easy to integrate with existing projects 💡 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/test_pagidantic_factory.py | Python | from pagidantic import PagidanticDict, PagidanticFactory, PagidanticSet, Paginator
def get_paginator(object_list):
factory = PagidanticFactory(type(object_list).__name__)
return factory.get_paginator()
class TestPaginatorFactory:
"""Tests for PaginatorFactory."""
def test_factory_result(self):
... | yezz123/pagidantic | 16 | Pagination using Pydantic. Easy to use, lightweight, and easy to integrate with existing projects 💡 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/test_pagidantic_paginator.py | Python | from pagidantic import Paginator
class TestListOfDictPaginator:
"""Tests for paginator object with list of dict as input."""
def test_init(self, second_paginator: Paginator, list_of_dict: list[dict]):
assert second_paginator.object_list == list_of_dict
assert second_paginator.page_limit == 3
... | yezz123/pagidantic | 16 | Pagination using Pydantic. Easy to use, lightweight, and easy to integrate with existing projects 💡 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/test_pagidantic_paginator_default.py | Python | import pytest
from pydantic import ValidationError
from pagidantic import Paginator, pagidantic
class TestDefaultPaginator:
"""Tests for Paginator object."""
def test_pagidantic_init(self):
"""Test pagidantic function initial values."""
assert pagidantic(object_list=[], page_limit=5, start_p... | yezz123/pagidantic | 16 | Pagination using Pydantic. Easy to use, lightweight, and easy to integrate with existing projects 💡 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/test_pagidantic_proxy.py | Python | import pytest
from conftest import dict_to_list
from pagidantic import PagidanticDict, PagidanticSet
class TestPaginatorDictProxy:
"""Tests for Test PagidanticDict"""
def test_init(self, paginator_dict_proxy: PagidanticDict, dict_data: dict):
"""Validate init assigment."""
assert paginator_d... | yezz123/pagidantic | 16 | Pagination using Pydantic. Easy to use, lightweight, and easy to integrate with existing projects 💡 | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
pgqb/__init__.py | Python | """A simple SQL query builder for PostgreSQL."""
from __future__ import annotations
__version__ = "0.1.0"
__all__ = (
"As",
"BIGINT",
"BIGSERIAL",
"BIT",
"BOOLEAN",
"BOX",
"BYTEA",
"CHAR",
"CIDR",
"CIRCLE",
"Column",
"Column",
"DATE",
"DOUBLE",
"Delete",
... | yezz123/pgqb | 7 | Typed Python PostgreSQL query builder ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
pgqb/_snake.py | Python | import re
from typing import Union
def to_snake(string: str) -> str:
"""
Return a version of the string in `snake_case` format.
Args:
string: The string to convert to snake_case.
Returns:
The string in snake_case format.
"""
return "_".join(w.lower() for w in get_words(string... | yezz123/pgqb | 7 | Typed Python PostgreSQL query builder ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
pgqb/builder.py | Python | """Query building functions for pgqb.
This module provides a set of classes and functions for building SQL queries
in a Pythonic way. It includes support for various SQL operations such as
SELECT, INSERT, UPDATE, DELETE, JOIN, WHERE, ORDER BY, LIMIT, and OFFSET.
"""
from __future__ import annotations
import abc
impo... | yezz123/pgqb | 7 | Typed Python PostgreSQL query builder ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
pgqb/types.py | Python | """PostgreSQL types for pgqb query builder library.
This module contains classes for PostgreSQL data types. The classes are
used to specify the type of a column in a table. The classes are used to
generate the SQL for creating a table.
From the docs: https://www.postgresql.org/docs/current/datatype.html
"""
from __f... | yezz123/pgqb | 7 | Typed Python PostgreSQL query builder ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
scripts/clean.sh | Shell | #!/usr/bin/env bash
rm -f `find . -type f -name '*.py[co]' `
rm -f `find . -type f -name '*~' `
rm -f `find . -type f -name '.*~' `
rm -f `find . -type f -name .coverage`
rm -f `find . -type f -name coverage.xml`
rm -f `find . -type f -name ".coverage.*"`
rm -rf `find . -name __pycache__`
rm -rf `find . -type d -name ... | yezz123/pgqb | 7 | Typed Python PostgreSQL query builder ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
scripts/format.sh | Shell | #!/usr/bin/env bash
set -e
set -x
pre-commit run --all-files --verbose --show-diff-on-failure
| yezz123/pgqb | 7 | Typed Python PostgreSQL query builder ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
scripts/mypy.sh | Shell | #!/usr/bin/env bash
set -e
set -x
mypy --show-error-codes pgqb
| yezz123/pgqb | 7 | Typed Python PostgreSQL query builder ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
scripts/tests.sh | Shell | #!/usr/bin/env bash
set -e
set -x
echo "ENV=${ENV}"
export PYTHONPATH=.
pytest --cov=pgqb --cov-report=xml
| yezz123/pgqb | 7 | Typed Python PostgreSQL query builder ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/test_builder.py | Python | import enum
import uuid
from typing import Any
import pytest
from pgqb import (
Column,
Table,
and_,
and_not,
delete_from,
insert_into,
join,
left_join,
or_,
or_not,
right_join,
select,
update,
)
class MyEnum(enum.Enum):
"""Test enum."""
OPTION = "option"... | yezz123/pgqb | 7 | Typed Python PostgreSQL query builder ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/test_snake.py | Python | import pytest
from pgqb import _snake as snake
@pytest.mark.parametrize(
"input_str, expected_output",
[
("PotatoHumanAlien", ["Potato", "Human", "Alien"]),
("Potato.Human.Alien", ["Potato", "Human", "Alien"]),
("Potato-Human-Alien", ["Potato", "Human", "Alien"]),
("Potato/Hum... | yezz123/pgqb | 7 | Typed Python PostgreSQL query builder ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
tests/test_types.py | Python | import inspect
import pytest
from pgqb import (
BIGINT,
BIGSERIAL,
BIT,
BOOLEAN,
BOX,
BYTEA,
CHAR,
CIDR,
CIRCLE,
DATE,
DOUBLE,
INET,
INTEGER,
INTERVAL,
JSON,
JSONB,
LINE,
LSEG,
MACADDR,
MACADDR8,
MONEY,
NUMERIC,
PATH,
PG_L... | yezz123/pgqb | 7 | Typed Python PostgreSQL query builder ✨ | Python | yezz123 | Yasser Tahiri | Yezz LLC. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.