text
stringlengths
185
73.3k
repo
stringlengths
7
100
path
stringlengths
4
146
language
stringclasses
7 values
hash
stringlengths
16
16
score
float64
7
8.5
stars
int64
0
237k
""" Copyright BOOSTRY Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distr...
BoostryJP/ibet-Wallet-API
app/model/db/company.py
.py
0b6c4435e750002c
7.5
9
""" Copyright BOOSTRY Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distr...
BoostryJP/ibet-Wallet-API
app/model/db/executable_contract.py
.py
99f09427d12b1dc7
7.5
9
""" Copyright BOOSTRY Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distr...
BoostryJP/ibet-Wallet-API
app/model/db/idx_token.py
.py
c4820f33dc765f54
7.5
9
""" Copyright BOOSTRY Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distr...
BoostryJP/ibet-Wallet-API
app/model/db/idx_token_list_register.py
.py
ed8c10a1c59375ad
7.5
9
""" Copyright BOOSTRY Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distr...
BoostryJP/ibet-Wallet-API
app/model/db/idx_transfer.py
.py
b55e93f87bd87b76
7.5
9
""" Copyright BOOSTRY Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distr...
BoostryJP/ibet-Wallet-API
app/model/db/idx_transfer_approval.py
.py
648c7ce985d29d72
7.5
9
""" Copyright BOOSTRY Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distr...
BoostryJP/ibet-Wallet-API
app/model/db/listing.py
.py
fc5cebf8b1559c71
7.5
9
""" Copyright BOOSTRY Co., Ltd. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distr...
BoostryJP/ibet-Wallet-API
app/model/db/messaging.py
.py
656d295a203ca64e
7.5
9
import hashlib from functools import wraps import requests from flask import request, abort from flask_api import status from werkzeug.exceptions import HTTPException from api import settings, constants from api.utils.security_utils import AuthenticationError, ExternalServiceError from api.auth.cas_auth import start_me...
MAAP-Project/maap-api-nasa
api/auth/security.py
.py
e204d79868b0cc94
7.52
10
import logging from flask_restx import Resource from flask import request, current_app from api.restplus import api from urllib.parse import urlsplit from api import settings import requests import urllib.parse import json import os log = logging.getLogger(__name__) ns = api.namespace('environment', description='Oper...
MAAP-Project/maap-api-nasa
api/endpoints/environment.py
.py
9d4ae28ad3abd7fe
7.52
10
import logging import json import os import sys, traceback import requests from flask import Response, request, render_template_string from flask_restx import Resource from api.restplus import api from api.utils.mapproxy_snap import create_config_wmts, mapit from api.endpoints.wmts import GetCapabilities from api impor...
MAAP-Project/maap-api-nasa
api/endpoints/wms.py
.py
3616e1d81d6e994b
7.52
10
import logging import json import os import sys, traceback import requests from flask import Response, request, render_template_string from flask_restx import Resource from api.restplus import api from api import settings import api.endpoints.cmr as cmr from api.utils.Granule import Granule from collections import Orde...
MAAP-Project/maap-api-nasa
api/endpoints/wmts.py
.py
301d604d8b845112
7.52
10
#!/usr/bin/env python import logging.config import os from flask import Flask, Blueprint, request, session from api import settings from api.auth.cas_auth import validate from api.utils.environments import Environments, get_environment from api.utils.url_util import proxied_url from api.endpoints.cmr import ns as cmr...
MAAP-Project/maap-api-nasa
api/maapapp.py
.py
13891737657ce443
7.52
10
from datetime import datetime, timezone from api.models import Base from api.maap_database import db class EsaTokenMeta(Base): """Local, best-effort metadata for ESA-managed tokens. ESA personal access tokens are created and stored on ESA's gateway, not in our personal_access_token table. ESA does not r...
MAAP-Project/maap-api-nasa
api/models/esa_token_meta.py
.py
e3ba4cb37875e84b
7.52
10
from datetime import datetime, timezone from api.models import Base from api.maap_database import db class MemberLog(Base): """Audit trail of admin changes to a member's status, role, or org membership. One row per changed dimension per admin action. old_value / new_value are human-readable: the status ...
MAAP-Project/maap-api-nasa
api/models/member_log.py
.py
469a80d0538106e3
7.52
10
"""pip install apscheduler No class literally named SQLiteJobStore — SQLite persistence comes from SQLAlchemyJobStore pointed at a sqlite:/// URL. APScheduler 4.x has been in alpha since 2020 with no stable release; 3.x is the only practical choice. Single-maintainer bus-factor risk is real — see references/rationale....
TheodoreAD/power-user-linux-setup
skills/db-defaults/references/snippets/cron-scheduler.py
.py
229915958d0fdb49
7.42
6
"""No install — stdlib only. threading.Lock + time.monotonic for ephemeral, restart-doesn't-matter state (rate limiters, counters). A library would be pure overhead for "hold one number, guarded by one lock." """ import threading import time class RateLimiter: def __init__(self, min_interval_seconds: float) -> ...
TheodoreAD/power-user-linux-setup
skills/db-defaults/references/snippets/in-process-state.py
.py
fd4f3f7584c4be24
7.42
6
"""pip install huey immediate=True runs @huey.task() functions synchronously in-process — no consumer subprocess needed, in-memory storage automatically. Real usage points filename= at a real db path and runs `huey_consumer app.huey` as a separate process instead. """ from huey import SqliteHuey huey: SqliteHuey = S...
TheodoreAD/power-user-linux-setup
skills/db-defaults/references/snippets/job-queue.py
.py
db00001d0f812319
7.42
6
"""pip install blinker The same signal/observer library Flask itself uses internally. Fans out to multiple in-process subscribers, zero ceremony, no server. """ from blinker import Signal item_created: Signal = Signal() def test_signal_calls_connected_receivers() -> None: received: list[tuple[str, dict[str, ob...
TheodoreAD/power-user-linux-setup
skills/db-defaults/references/snippets/pubsub.py
.py
c5be4267ff297d4c
7.42
6
"""pip install sqlalchemy alembic Real multi-table joins + migrations. Alembic is a CLI scaffold, not importable inline: alembic init migrations alembic revision --autogenerate -m "..." alembic upgrade head driven by migrations/env.py pointed at this file's Base.metadata. """ from sqlalchemy import Stri...
TheodoreAD/power-user-linux-setup
skills/db-defaults/references/snippets/relational-oltp.py
.py
8146db815944e48c
7.42
6
"""Structured concurrency for a fan-out orchestrator: asyncio.TaskGroup over gather() (cancels siblings on first failure instead of leaving them running orphaned), with a Semaphore capping how many sites are queried at once. See ../rationale.md §12. """ import asyncio import contextlib from dataclasses import dataclas...
TheodoreAD/power-user-linux-setup
skills/python-conventions/references/snippets/async-fanout.py
.py
5c7b985ce7b2d3ca
7.42
6
"""pip install pydantic Data modeling defaults: frozen dataclass for internal records, Pydantic v2 for boundary/settings validation. NamedTuple only for the narrow escalation cases documented in ../rationale.md §1. """ from dataclasses import FrozenInstanceError, dataclass from typing import NamedTuple import pytest...
TheodoreAD/power-user-linux-setup
skills/python-conventions/references/snippets/data-modeling.py
.py
2bdb61e851f6dc96
7.42
6
"""Minimal exception hierarchy: one root per package, deeper leaves only once a caller actually needs to discriminate. Mirrors requests/click's own shallow (2-3 level) shape. See ../rationale.md §3. """ import pytest class PackageError(Exception): """Root of this package's exception hierarchy — catch this to cat...
TheodoreAD/power-user-linux-setup
skills/python-conventions/references/snippets/exceptions.py
.py
ab5e1c167e024a6c
7.42
6
"""Guard clauses validate a caller's contract; EAFP handles runtime operations Python already fails loudly on. See ../rationale.md §3. """ import pytest class OrderError(Exception): """Root exception for this module — see exceptions.py for the full hierarchy shape this would grow into in a real package.""" ...
TheodoreAD/power-user-linux-setup
skills/python-conventions/references/snippets/guard-clauses.py
.py
6d11689dc9f009a1
7.42
6
"""pip install httpx tenacity httpx for new HTTP fetch paths (requests-compatible, safer default timeouts, async-ready), one Client reused for its lifetime, an explicit site-tuned timeout, and tenacity for retry/backoff -- scoped to transient network conditions and a narrow retryable-status set, never plain 4xx "real ...
TheodoreAD/power-user-linux-setup
skills/python-conventions/references/snippets/http-retry.py
.py
5e2930865bd3d629
7.42
6
"""pip install fastmcp MCP-server-specific conventions in one place: logging routed to stderr (never stdout — it would corrupt the stdio JSON-RPC stream), an LLM-facing tool docstring, per-parameter descriptions via Annotated[Field], annotations= for a side-effecting tool, and ToolError at the boundary between an inte...
TheodoreAD/power-user-linux-setup
skills/python-conventions/references/snippets/mcp-tool-boundary.py
.py
2eb70ba5912f9f70
7.42
6
"""pip install pydantic-settings The globals.py pattern: a pydantic-settings base class plus per-environment subclasses, selected once by an env var and assigned to a module-level name. Plain class, not a GoF Singleton — tests construct their own instance instead of fighting shared global state. See ../rationale.md §2...
TheodoreAD/power-user-linux-setup
skills/python-conventions/references/snippets/settings.py
.py
7bcae7a9277189a6
7.42
6
"""Fixture scope: construct expensive/shared objects at module or session scope, but reset their *mutable* state via a function-scoped fixture — cheap construction stays shared, isolation stays per-test. Setup mechanics (the "how") are DRY, and their default form is a pytest fixture — never an arrange block hand-rolled...
TheodoreAD/power-user-linux-setup
skills/python-conventions/references/snippets/testing.py
.py
7310b40828fd8371
7.92
6
#!/usr/bin/env python3 """Estimate which recent Bash calls prompted under acceptEdits, and why — from the transcripts and the live ~/.claude/settings.json rules. Approved prompts leave no trace in a transcript, so the prompt rate can't be measured directly; this replays Claude Code's matching over every call instead: ...
TheodoreAD/power-user-linux-setup
skills/session-bash-audit/scripts/prompts.py
.py
5058f8b7e3046566
7.42
6
from invoke import Context, task from . import apt, docker, node, python, tools @task(pre=[apt.clean_cache, python.clean_cache, node.clean_cache, tools.clean_cache]) def caches(c: Context): """Conservatively remove build/download caches left behind by apt, uv, npm, and cargo installs (each self-skips if that...
TheodoreAD/power-user-linux-setup
tasks/clean.py
.py
a1f0b5fcaf988099
7.42
6
import json import re import subprocess import urllib.request import zipfile from functools import cache from pathlib import Path from tempfile import TemporaryDirectory from typing import cast from invoke import Context, task from . import util # Match either a quoted string (kept) or a // line comment (removed). _...
TheodoreAD/power-user-linux-setup
tasks/fonts.py
.py
3427dcb294b7e821
7.42
6
import shlex import shutil from pathlib import Path from invoke import Context, task from . import util # System extensions that conflict with certain PULSE extensions. # When a PULSE extension is enabled, its listed conflicts are disabled first. CONFLICTS: dict[str, list[str]] = { # ubuntu-dock ships enabled by...
TheodoreAD/power-user-linux-setup
tasks/gnome.py
.py
0a48e1aa3bd14948
7.42
6
from pathlib import Path from invoke import Context, task _CONFIG_FILES = [ ("config/pycharm/editor-font.xml", "options/editor-font.xml"), ("config/pycharm/terminal-font.xml", "options/terminal-font.xml"), ] def _pycharm_dir() -> Path | None: """Return the most recent PyCharm config directory, or None i...
TheodoreAD/power-user-linux-setup
tasks/ide.py
.py
0bcd873ca94d3fd7
7.42
6
from pathlib import Path from invoke import Context, task from . import ui, util _EXAMPLE_PATH = Path(__file__).parent.parent / "config" / "identity.toml.example" # label -> real hostname; simple mode uses the hostname itself as the ssh_hosts alias since # there's only ever one account per host in this mode (no nee...
TheodoreAD/power-user-linux-setup
tasks/identity.py
.py
38f836484addf14c
7.42
6
from pathlib import Path from invoke import Context, task from . import util def _nvm_sh(nvm_dir: Path) -> str: return f'export NVM_DIR="{nvm_dir}" && [ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"' def _node_cfg() -> tuple[util.PackageConfig, Path, str]: cfg = util.load_config()["packages"]["node"] ...
TheodoreAD/power-user-linux-setup
tasks/node.py
.py
9c5897bf667c5dc8
7.42
6
"""Group setup tasks into named, skippable phases for `inv setup` / `inv wsl.install`. Every install task already has a side-effect-free `util.DRY_RUN` branch that prints `ok`/`MISSING` per item (see apt.py, tools.py, node.py, python.py, zsh.py, system.py, docker.py, fonts.py) — that existing convention is reused here...
TheodoreAD/power-user-linux-setup
tasks/phases.py
.py
9c0b09a811e0f4d8
7.42
6
import re from pathlib import Path from invoke import Context, task from . import util _REPO_ROOT = Path(__file__).parent.parent _SETUP_TOML = _REPO_ROOT / "setup.toml" _DEFAULT_RE = re.compile(r'(?m)^(\s*uv_python_default\s*=\s*)"[^"]*"') _EXTRA_RE = re.compile(r"(?m)^(\s*uv_python_extra\s*=\s*)\[[^\]]*\]") _UV_ENV...
TheodoreAD/power-user-linux-setup
tasks/python.py
.py
74f24f7f02548235
7.42
6
import re from pathlib import Path from invoke import Context, task from . import util _REPO_ROOT = Path(__file__).parent.parent _SYSCTL_CONF = Path("/etc/sysctl.conf") _APPARMOR_DIR = Path("/etc/apparmor.d") _INITRAMFS_CONF = Path("/etc/initramfs-tools/initramfs.conf") _JOURNALD_CONF_DIR = Path("/etc/systemd/journa...
TheodoreAD/power-user-linux-setup
tasks/system.py
.py
ffacd6e86b35d8fa
7.42
6
import shutil from pathlib import Path from invoke import Context, task from . import deploy, ui, util def _expand(value: str) -> str: return str(Path(value).expanduser()) if value.startswith("~") else value def _check_tool(name: str, cfg: util.PackageConfig) -> bool: check_path = cfg.get("check_path") ...
TheodoreAD/power-user-linux-setup
tasks/tools.py
.py
764b23cf5d1d32ad
7.42
6
"""Bordered terminal output for PULSE's own messages. A single `inv setup`/`inv wsl.install` run interleaves our own status lines with raw apt/dpkg/ curl/gpg output scrolling past in the same terminal. Terse per-package lines (`[gh] repo:ok`) are meant to blend in with that — they're deliberately styled like any other...
TheodoreAD/power-user-linux-setup
tasks/ui.py
.py
263c2566c2305f26
7.42
6
# Copyright © 2019 Province of British Columbia. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agr...
bcgov/sbc-pay
bcol-api/setup.py
.py
3029419328e8799b
7.52
10
# Copyright © 2019 Province of British Columbia # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agr...
bcgov/sbc-pay
bcol-api/src/bcol_api/__init__.py
.py
70d27af549abf593
7.52
10
# Copyright © 2019 Province of British Columbia # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agr...
bcgov/sbc-pay
bcol-api/src/bcol_api/config.py
.py
5ff053ae89a44487
7.52
10
# Copyright © 2019 Province of British Columbia # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agr...
bcgov/sbc-pay
bcol-api/src/bcol_api/exceptions/__init__.py
.py
10afdf4794457c17
7.52
10
# Copyright © 2019 Province of British Columbia # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agr...
bcgov/sbc-pay
bcol-api/src/bcol_api/resources/bcol_payment.py
.py
9c9dcce9e0a9847e
7.52
10
# Copyright © 2019 Province of British Columbia # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agr...
bcgov/sbc-pay
bcol-api/src/bcol_api/resources/bcol_profile.py
.py
0d694abaa604ae02
7.52
10
# Copyright © 2019 Province of British Columbia # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agr...
bcgov/sbc-pay
bcol-api/src/bcol_api/schemas/utils.py
.py
1831b67cf6569939
7.52
10
# Copyright © 2019 Province of British Columbia # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agr...
bcgov/sbc-pay
bcol-api/src/bcol_api/services/bcol_payment.py
.py
05b3b4cc261439aa
7.52
10
# Copyright © 2019 Province of British Columbia # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agr...
bcgov/sbc-pay
bcol-api/src/bcol_api/services/bcol_profile.py
.py
3b3738330750a253
7.52
10
# Copyright © 2019 Province of British Columbia # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agr...
bcgov/sbc-pay
bcol-api/src/bcol_api/services/bcol_soap.py
.py
de9cfa32eb9a1dd1
7.52
10
# Copyright © 2019 Province of British Columbia # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agr...
bcgov/sbc-pay
bcol-api/src/bcol_api/utils/constants.py
.py
e6f632124d75a079
7.52
10
# Copyright © 2019 Province of British Columbia # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agr...
bcgov/sbc-pay
bcol-api/src/bcol_api/utils/errors.py
.py
e8af2f0dd25874ad
7.52
10
# Copyright © 2019 Province of British Columbia # # Licensed under the Apache License, Version 2.0 (the 'License'); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agr...
bcgov/sbc-pay
bcol-api/tests/conftest.py
.py
7c8e923d1980b7a0
7.02
10
# Copyright © 2019 Province of British Columbia # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agr...
bcgov/sbc-pay
bcol-api/tests/unit/api/test_bcol_payment.py
.py
2c3a6091bf5a3296
7.02
10
# Copyright © 2019 Province of British Columbia # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agr...
bcgov/sbc-pay
bcol-api/tests/unit/api/test_bcol_profile.py
.py
f5d486a393f0627a
7.02
10
# Copyright © 2019 Province of British Columbia # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agr...
bcgov/sbc-pay
bcol-api/tests/unit/api/test_meta.py
.py
a14eb5c952d162cc
8.02
10
# Copyright © 2019 Province of British Columbia. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agr...
bcgov/sbc-pay
bcol-api/tests/unit/conf/test_configuration.py
.py
57d7ea15b86d8e74
8.02
10
# Copyright © 2019 Province of British Columbia # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agr...
bcgov/sbc-pay
bcol-api/tests/unit/utils/test_util_cors.py
.py
7e33834e8b18577e
8.02
10
# Copyright © 2019 Province of British Columbia # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agr...
bcgov/sbc-pay
bcol-api/tests/utilities/base_test.py
.py
aea5cfe78440ffe2
8.02
10
"""Converters used by hahomematic.""" from __future__ import annotations import ast import logging from typing import Any, Final _LOGGER = logging.getLogger(__name__) def _convert_cpv_to_hm_level(cpv: Any) -> Any: """Convert combined parameter value for hm level.""" if isinstance(cpv, str) and cpv.startswi...
SukramJ/pydevccu
pydevccu/converter.py
.py
4b992821ed0a0b6f
7.5
9
""" Logic module for HM-Sec-SC-2 (VCU0000240). Switch between open / closed, toggle LOWBAT every 5 events. """ # ruff: noqa: N999, N801, S311 # Module/class names match HomeMatic device naming from __future__ import annotations import logging import random import sys import time from typing import TYPE_CHECKING i...
SukramJ/pydevccu
pydevccu/device_logic/HM_Sec_SC_2.py
.py
cd8baae3ba47e3e9
7.5
9
""" Logic module for HM-Sen-MDIR-WM55 (VCU0000274). Switch between motion, toggle LOWBAT every 5 events, random brightness from 60 to 90, press on channel 1. """ # ruff: noqa: N999, N801, S311 # Module/class names match HomeMatic device naming from __future__ import annotations import logging import random import ...
SukramJ/pydevccu
pydevccu/device_logic/HM_Sen_MDIR_WM55.py
.py
137305a66727011c
7.5
9
""" JSON-RPC error codes and exceptions for pydevccu. Implements standard JSON-RPC 2.0 error codes plus CCU-specific errors. """ from __future__ import annotations from typing import Any, Final class JsonRpcError: """JSON-RPC 2.0 error codes.""" # Standard JSON-RPC 2.0 errors PARSE_ERROR: Final = -327...
SukramJ/pydevccu
pydevccu/json_rpc/errors.py
.py
2168b87c8295c194
7.5
9
""" JSON-RPC 2.0 server for pydevccu. Provides an aiohttp-based server implementing the CCU/OpenCCU JSON-RPC API at /api/homematic.cgi. """ from __future__ import annotations import ast from collections.abc import Awaitable, Callable from dataclasses import dataclass import logging from typing import TYPE_CHECKING, ...
SukramJ/pydevccu
pydevccu/json_rpc/server.py
.py
4a0b9ffc70a5b90d
7.5
9
"""ServerProxy implementation with lock when request is executing.""" from __future__ import annotations import threading from typing import Any import xmlrpc.client # pylint: disable=too-few-public-methods class LockingServerProxy(xmlrpc.client.ServerProxy): """ServerProxy implementation with lock when request...
SukramJ/pydevccu
pydevccu/proxy.py
.py
f14e2ba926f47df1
7.5
9
""" Default state factory for pydevccu testing. Provides pre-configured programs, system variables, rooms, and functions for quick test setup. """ from __future__ import annotations from typing import TYPE_CHECKING if TYPE_CHECKING: from pydevccu.state.manager import StateManager def setup_default_programs(st...
SukramJ/pydevccu
pydevccu/state/defaults.py
.py
3d476117da33e769
7.5
9
""" Pytest fixtures for pydevccu tests. """ from __future__ import annotations from collections.abc import AsyncGenerator import pytest from pydevccu import BackendMode, SessionManager, StateManager, VirtualCCU from pydevccu.json_rpc.handlers import JsonRpcHandlers from pydevccu.rega import RegaEngine from pydevccu...
SukramJ/pydevccu
tests/conftest.py
.py
7c27fed4cda6d1b0
7
9
""" Tests for the two callback-path behaviours a real CCU exhibits. A CCU answers a ping with a CENTRAL/PONG event so the client can match its own request, and it keeps delivering to a client that replied with a fault — only a transport error means the client is gone. """ from __future__ import annotations from typi...
SukramJ/pydevccu
tests/test_ccu_callbacks.py
.py
b2bcfd9340824e0d
8
9
"""Tests for device response mappings.""" from __future__ import annotations from pydevccu.device_responses import compute_response_events, get_response_mapping class TestGetResponseMapping: """Test response mapping lookup.""" def test_exact_match(self) -> None: """Test exact device type match.""" ...
SukramJ/pydevccu
tests/test_device_responses.py
.py
9eca2df96e6b0892
8
9
"""Tests for JSON-RPC server and handlers.""" from __future__ import annotations import pytest from pydevccu.json_rpc.errors import InvalidParams, InvalidRequest, MethodNotFound, ObjectNotFound, ParseError from pydevccu.json_rpc.handlers import JsonRpcHandlers from pydevccu.json_rpc.server import JsonRpcRequest cl...
SukramJ/pydevccu
tests/test_json_rpc_server.py
.py
ea0bdb1889de6a47
7
9
"""Tests for ReGa script engine.""" from __future__ import annotations import json from pydevccu.rega import RegaEngine from pydevccu.state import StateManager class TestRegaBackendInfo: """Test backend info script patterns.""" def test_get_backend_info_version_pattern(self, rega_engine: RegaEngine, state...
SukramJ/pydevccu
tests/test_rega_engine.py
.py
18752516bb16a2ab
7
9
""" Run the engine against the *unmodified* ReGa scripts a real client sends. The existing tests use hand-written script fragments, which is why six scripts could be routed to the wrong handler without a single test going red: set_program_state.fn and set_system_variable.fn were answered with listings and changed noth...
SukramJ/pydevccu
tests/test_rega_real_scripts.py
.py
6c8225af409edca6
8
9
"""Tests for SessionManager.""" from __future__ import annotations import time from pydevccu.session import SessionManager class TestSessionLogin: """Test login functionality.""" def test_login_success(self, session_manager: SessionManager) -> None: """Test successful login.""" session_id ...
SukramJ/pydevccu
tests/test_session.py
.py
b0c40643309f09fd
8
9
"""Tests for StateManager.""" from __future__ import annotations from pydevccu import BackendMode, StateManager class TestStateManagerInit: """Test StateManager initialization.""" def test_default_mode(self) -> None: """Test default mode is OPENCCU.""" state = StateManager() assert ...
SukramJ/pydevccu
tests/test_state_manager.py
.py
d7e3f9b3079cdf9a
8
9
"""Tests for VirtualCCU orchestrator.""" from __future__ import annotations import pytest from pydevccu import BackendMode, VirtualCCU class TestVirtualCCUInit: """Test VirtualCCU initialization.""" def test_default_mode(self) -> None: """Test default mode is OPENCCU.""" ccu = VirtualCCU()...
SukramJ/pydevccu
tests/test_virtual_ccu.py
.py
56bd9bc5c901178d
8
9
import { test, expect } from "@playwright/test"; test.describe("Countdown Page", () => { test.beforeEach(async ({ page }) => { // Navigate to landing and enter valid secret await page.goto("/"); await page.locator("#secret-input").fill("sorry"); await page.locator("#submit-btn").click(); await ex...
vgijssel/setup
apps/blueorange/tests/e2e/countdown-page.spec.js
.js
62561cc48a3449b2
7
9
import { test, expect } from "@playwright/test"; test.describe("End-to-End Flow", () => { test("Scenario 9: Unauthorized countdown access", async ({ page }) => { // Navigate directly to countdown.html await page.goto("/src/pages/countdown.html"); // Assert redirect to landing.html await expect(page)...
vgijssel/setup
apps/blueorange/tests/e2e/end-to-end-flow.spec.js
.js
6de1d1a289427fa0
7
9
"""Tests for the escaperoom Streamlit application.""" def test_app_exists(): """Test that the app.py file exists and can be imported.""" import sys from pathlib import Path # Add the app directory to the path app_dir = Path(__file__).parent.parent sys.path.insert(0, str(app_dir)) # This ...
vgijssel/setup
apps/escaperoom/tests/test_app.py
.py
e802bcbf45b8ded9
7
9
"""Network inventory: target the PiKVM over NetBird. Used by ``moon run pikvm:apply`` for ongoing management once the box is on NetBird. For the very first apply (box not yet on NetBird), use ``local.py`` instead. Default host is the PiKVM's NetBird IP. Override with ``PIKVM_HOST`` (e.g. the ``pikvm.netbird.cloud`` n...
vgijssel/setup
apps/pikvm/inventories/production.py
.py
80732520391bcb1f
7.5
9
import { test, expect } from "@playwright/test"; /** * E2E tests for Verjaardag Hilde escape room. * * These tests verify the UI loads correctly and basic navigation works. * Note: Without a real HA connection, we test the loading/error states * and the structure of the application. * * For full integration tes...
vgijssel/setup
apps/verjaardag-hilde/tests/e2e/app.spec.ts
.ts
d2103fc08930e415
7
9
"""Main CLI module for dev-cluster.""" import subprocess import sys import time import click from pytimeparse import parse as parse_duration from . import flux, kind, onepassword def check_prerequisites(verbose: bool = False) -> bool: """Check if all required tools are installed. Args: verbose: En...
vgijssel/setup
libs/dev-cluster/src/dev_cluster/cli.py
.py
aa04c2bf2615e333
7.5
9
"""Kind cluster management module.""" import subprocess import sys import tempfile import time from pathlib import Path from typing import Optional import yaml def check_kind_installed() -> bool: """Check if kind is installed.""" try: result = subprocess.run( ["kind", "version"], ...
vgijssel/setup
libs/dev-cluster/src/dev_cluster/kind.py
.py
01669fe54daacf41
7.5
9
"""Add oidc token type. Revision ID: 2feb306dd1ee Revises: 5c28ed7092c2 Create Date: 2024-02-09 23:10:43.229238+00:00 """ from collections.abc import Sequence from alembic import op # revision identifiers, used by Alembic. revision: str = "2feb306dd1ee" down_revision: str | None = "5c28ed7092c2" branch_labels: str ...
lsst-sqre/gafaelfawr
alembic/versions/20240209_2310_2feb306dd1ee_add_oidc_token_type.py
.py
1b22b9f97fcf2fb1
7.52
10
"""Add OpenID Connect client table Revision ID: 20ccaa8eedfd Revises: 2feb306dd1ee Create Date: 2026-08-18 17:31:08.216187+00:00 """ from collections.abc import Sequence import sqlalchemy as sa from alembic import op # revision identifiers, used by Alembic. revision: str = "20ccaa8eedfd" down_revision: str | None =...
lsst-sqre/gafaelfawr
alembic/versions/20260818_1731_20ccaa8eedfd_add_openid_connect_client_table.py
.py
367f6ba86327773a
7.52
10
"""Remove the admin and admin_history tables Revision ID: 613640641b2f Revises: 5a54e4db3cf4 Create Date: 2026-08-20 00:12:57.133992+00:00 """ from collections.abc import Sequence import sqlalchemy as sa from alembic import op from sqlalchemy.dialects import postgresql # revision identifiers, used by Alembic. revis...
lsst-sqre/gafaelfawr
alembic/versions/20260820_0012_613640641b2f_remove_the_admin_and_admin_history_.py
.py
65968e70649f5b99
7.52
10
"""nox configuration for the Gafaelfawr client. This subdirectory has its own noxfile because it supports a wider range of Python versions and is matrix-tested on those versions in GitHub Actions independent from the top-level directory. The top-level noxfile recurses into this one as needed. """ import nox from nox_...
lsst-sqre/gafaelfawr
client/noxfile.py
.py
0ce33d5e382e8ce0
7.52
10
"""FastAPI dependencies providing a Gafaelfawr client.""" from typing import Annotated from fastapi import Depends from httpx import AsyncClient from rubin.repertoire import DiscoveryClient, discovery_dependency from safir.dependencies.http_client import http_client_dependency from ._client import GafaelfawrClient ...
lsst-sqre/gafaelfawr
client/src/rubin/gafaelfawr/_dependencies.py
.py
5dee251a824aa6be
7.52
10
"""Exceptions for the Gafaelfawr client.""" from typing import Self, override from pydantic import ValidationError from safir.slack.blockkit import ( SentryEventInfo, SlackCodeBlock, SlackException, SlackMessage, SlackWebException, ) __all__ = [ "GafaelfawrDiscoveryError", "GafaelfawrErro...
lsst-sqre/gafaelfawr
client/src/rubin/gafaelfawr/_exceptions.py
.py
3b902667efc85bd6
7.52
10
"""Mock for the parts of the Gafaelfawr API used by the client.""" import re from collections import defaultdict from collections.abc import Callable, Iterable from datetime import UTC, datetime from enum import Enum from functools import wraps from typing import TYPE_CHECKING, Concatenate from urllib.parse import url...
lsst-sqre/gafaelfawr
client/src/rubin/gafaelfawr/_mock.py
.py
eca69e4ef39507e2
7.52
10
"""nox configuration for Gafaelfawr.""" import logging import os import shutil import sys from collections import defaultdict from collections.abc import Iterator from contextlib import contextmanager from dataclasses import dataclass from pathlib import Path from typing import Self import nox from nox.command import...
lsst-sqre/gafaelfawr
noxfile.py
.py
761c107e0ec330de
7.52
10
"""Utility functions for manipulating authentication headers.""" import base64 import json from fastapi import HTTPException, status from .constants import COOKIE_NAME from .dependencies.context import RequestContext from .exceptions import ( InvalidRequestError, InvalidTokenError, OAuthBearerError, ) fr...
lsst-sqre/gafaelfawr
src/gafaelfawr/auth.py
.py
04bf0d68cb1c8f3b
7.52
10
"""Database utility functions for Gafaelfawr.""" import asyncio from typing import Any from safir.database import create_database_engine, initialize_database from sqlalchemy import create_mock_engine, select from sqlalchemy.exc import OperationalError, ProgrammingError from sqlalchemy.ext.asyncio import AsyncEngine f...
lsst-sqre/gafaelfawr
src/gafaelfawr/database.py
.py
3db546a7cbcea653
7.52
10
"""Authentication dependencies for FastAPI.""" from datetime import UTC, datetime from typing import Annotated from urllib.parse import urlencode from fastapi import Depends, Header, HTTPException, status from ..auth import ( generate_challenge, generate_unauthorized_challenge, parse_authorization, ) fro...
lsst-sqre/gafaelfawr
src/gafaelfawr/dependencies/auth.py
.py
4220f6fad1cea7a6
7.52
10
"""Config dependency for FastAPI.""" import os from pathlib import Path from ..config import Config from ..constants import CONFIG_PATH __all__ = ["ConfigDependency", "config_dependency"] class ConfigDependency: """Provides the configuration as a dependency. We want a production deployment to default to o...
lsst-sqre/gafaelfawr
src/gafaelfawr/dependencies/config.py
.py
b8b66387c67b8f20
7.52
10
"""Request context dependency for FastAPI. This dependency gathers a variety of information into a single object for the convenience of writing request handlers. It also provides a place to store a `structlog.BoundLogger` that can gather additional context during processing, including from dependencies. """ from dat...
lsst-sqre/gafaelfawr
src/gafaelfawr/dependencies/context.py
.py
734bd9a4a0dbb7ee
7.52
10
"""FastAPI dependencies for checking the return URL. Several API routes allow the caller to request a redirect back to a return URL given as a parameter. To avoid creating an open redirect, those return URLs must be located at the same hostname as the route being called. Provide several variations of a dependency to...
lsst-sqre/gafaelfawr
src/gafaelfawr/dependencies/return_url.py
.py
17e48d4348c542da
7.52
10
"""Exceptions for Gafaelfawr.""" from typing import ClassVar, Self, override import kopf from fastapi import status from google.api_core.exceptions import GoogleAPICallError from pydantic import ValidationError from safir.fastapi import ClientRequestError from safir.models import ErrorLocation from safir.slack.blockk...
lsst-sqre/gafaelfawr
src/gafaelfawr/exceptions.py
.py
420b0c50ecc53064
7.52
10
"""Initial authentication handlers (``/login``).""" import base64 import os from datetime import UTC, datetime from enum import Enum from typing import Annotated from fastapi import APIRouter, Depends, Query, status from fastapi.responses import RedirectResponse, Response from safir.sentry import report_exception fro...
lsst-sqre/gafaelfawr
src/gafaelfawr/handlers/login.py
.py
0cf462bca2ea7bcd
7.52
10
"""RSA key pair handling.""" from typing import Self from cryptography.exceptions import UnsupportedAlgorithm from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives.asymmetric import rsa from cryptography.hazmat.primitives.serialization import ( Encoding, NoEncryption, ...
lsst-sqre/gafaelfawr
src/gafaelfawr/keypair.py
.py
f0685b212d24906b
7.52
10
"""Application definition for Gafaelfawr.""" import json from collections.abc import AsyncGenerator, Awaitable, Callable from contextlib import asynccontextmanager from importlib.metadata import version import structlog from fastapi import FastAPI from fastapi.openapi.utils import get_openapi from safir.database impo...
lsst-sqre/gafaelfawr
src/gafaelfawr/main.py
.py
0ac7d96aa1672100
7.52
10