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
"""Pure, import-clean formatting logic for the supporters page. Extracted from ``docs.gen_supporters`` so it can be unit-tested without a ``config.json`` or any GitHub session. Imports stdlib only — no ``.config`` or ``.project`` coupling. """ from datetime import datetime from typing import Mapping, TypedDict CONTR...
esphome/esphome-release
esphomerelease/supporters.py
.py
471a07c67784c43e
7.5
9
import datetime import os import subprocess import time import threading import queue import shlex import sys import click import requests from .config import CONFIG from .model import Branch, Version from .exceptions import EsphomeReleaseError def copy_clipboard(text): """Copy some text to clipboard. Used...
esphome/esphome-release
esphomerelease/util.py
.py
8497e2331f010ee5
7.5
9
"""Shared fixtures for tests that exercise :mod:`esphomerelease.cutting`. ``cutting`` imports ``.project``, which instantiates every ``Project`` at import time and asserts each configured path is a directory. The ``cutting`` fixture writes a temp ``config.json`` whose paths point at real directories so the module is i...
esphome/esphome-release
tests/conftest.py
.py
e52bc8330e6e7880
8
9
"""Tests for figuring out the base (previous) version for cut/publish. ``_default_base_version`` derives the changelog base from the version being released so the first step of a cut/publish no longer paginates the repo's entire release history; only first-beta/first-release fall back to a single ``releases/latest`` l...
esphome/esphome-release
tests/test_base_version.py
.py
0a4f7e8a98296b6b
7
9
"""Tests for the automatic changelog page management on esphome.io. Cutting the first beta creates the cycle's changelog page skeleton (header, import, a featured-components table drafted from ImgTable rows added to the components index since the base release) and inserts the beta notice block; cutting the stable rele...
esphome/esphome-release
tests/test_beta_notice.py
.py
af0a3b03e4375889
7
9
"""Tests for the release notes blog post management on esphome.io. The first beta creates the cycle's blog post skeleton (dated the release Wednesday after user confirmation) next to the changelog page; later betas keep the beta notice on it, the stable release removes the notice, and cuts of pre-blog cycles (no post ...
esphome/esphome-release
tests/test_blog_post.py
.py
bc662acec53e40e8
8
9
"""Tests for changelog PR-inclusion logic. ``changelog_filter`` is deliberately import-clean (only ``.model``), so these run without a configured working copy or any GitHub objects. """ from esphomerelease.changelog_filter import resolve_changelog_labels from esphomerelease.model import Version # A non-patch head, s...
esphome/esphome-release
tests/test_changelog_filter.py
.py
6e5edbe5d0d5e53f
7
9
"""Tests for the ``check_docs_prs.py`` script's fan-out over linked PRs. The script lives at the repo root (not inside the package), so it is loaded from its file path. Linked esphome PRs are deduplicated across docs PRs and fetched concurrently: one ``gh`` call per unique PR number. Flagging is bidirectional. A docs...
esphome/esphome-release
tests/test_check_docs_prs.py
.py
72b06248f7d7cd13
8
9
"""Tests for propagating the docs ``current`` branch into ``next``/``beta``. Docs fixes for the released version land on ``current``, so every cut first merges it into ``next`` and ``beta``. ``propagate_docs_current_branch`` pushes that merge immediately: a merge left sitting locally makes the next ``git pull`` on the...
esphome/esphome-release
tests/test_docs_branch_propagation.py
.py
199f37d65142be8e
7
9
"""Tests for docs/code PR-link extraction and pairing. ``docs_pr_links`` is deliberately import-clean (stdlib ``re`` only), so these run without a configured working copy or any GitHub objects. """ from esphomerelease.docs_pr_links import ( extract_docs_pr_numbers, extract_esphome_pr_numbers, is_confirmed...
esphome/esphome-release
tests/test_docs_pr_links.py
.py
0fc435f9b4a2cb63
7
9
"""Tests for ``docs.gen_supporters`` and its parallel fetch helpers. ``docs`` imports ``.project``, which instantiates every ``Project`` at import time and asserts each configured path is a directory. The ``docs_mod`` fixture writes a temp ``config.json`` whose paths point at real directories so the modules are import...
esphome/esphome-release
tests/test_gen_supporters.py
.py
e991b4b1a6241f4f
8
9
"""Tests for resolving the GitHub token at runtime. ``esphomerelease.github`` no longer reads a long-lived personal access token out of ``config.json``. It asks the GitHub CLI for its stored OAuth token via ``gh auth token`` and only falls back to the now-optional ``github_token`` config key, so nothing keeps a secret...
esphome/esphome-release
tests/test_github_token.py
.py
67b54c1affd4da84
7
9
"""Tests for the ``labels`` subcommand's label listing and lookup logic. ``commands`` imports ``.project``, which instantiates every ``Project`` at import time and asserts each configured path is a directory. The ``commands`` fixture writes a temp ``config.json`` whose paths point at real directories so the modules ar...
esphome/esphome-release
tests/test_labels_command.py
.py
83b44105d9b3dbe0
8
9
"""Tests for the ``next-beta-prs`` subcommand. The command lists the PRs on the cycle milestone that the next beta cut would cherry-pick: merged PRs without the ``cherry-picked`` label, in merge order. ``commands`` imports ``.project``, which instantiates every ``Project`` at import time and asserts each configured p...
esphome/esphome-release
tests/test_next_beta_prs.py
.py
d0f179b04e42ea89
7
9
"""Tests for esphomerelease.util.execute_command error handling. util.py imports ``.config``, which loads ``config.json`` at import time. The ``util`` fixture chdir's into a tmp dir with an empty config so the module is importable without a real working copy (mirrors the import-safe test pattern used elsewhere in this...
esphome/esphome-release
tests/test_util_execute_command.py
.py
7f019da069ce68e6
8
9
""" These methods are utilities to parse Tira's Model from the protobuf files into a database. """ import logging from typing import TYPE_CHECKING from google.protobuf.text_format import Parse from tqdm import tqdm from .. import model as modeldb from ..proto import TiraClientWebMessages_pb2 as modelpb from ..util i...
tira-io/tira
application/src/tira_app/data/data.py
.py
b5924284bce33874
7.65
19
""" This file contains miscellaneous and **unversioned** endpoints (e.g., the /health or /info). """ import json from django.conf import settings from django.urls import path from rest_framework import status from rest_framework.decorators import api_view, authentication_classes, permission_classes from rest_framewor...
tira-io/tira
application/src/tira_app/endpoints/misc.py
.py
8a7c8443e6c8732f
7.65
19
import logging import os from flask import Flask, session, request, url_for from qwc_services_core.tenant_handler import TenantHandler, \ TenantPrefixMiddleware, TenantSessionInterface AUTH_PATH = os.environ.get('AUTH_PATH', '/auth') # Flask application app = Flask(__name__) app.secret_key = 'test' app.wsgi_app...
qwc-services/qwc-services-core
middleware-test.py
.py
c7e773a7c7e49c93
7.04
11
from flask_restx import Api as BaseApi from collections import OrderedDict from werkzeug.datastructures import MultiDict from flask_restx.reqparse import Argument import os class Api(BaseApi): """Custom Flask-RESTPlus Api subclass for overriding default root route NOTE: endpoint of route '/' must be named '...
qwc-services/qwc-services-core
qwc_services_core/api.py
.py
70e55471975baf68
7.54
11
def app_nocache(app): """ Adds various cache-disabling headers to all responses returned by the application :param Flask app: A flask application """ @app.after_request def add_header(r): r.headers["Cache-Control"] = "no-cache, no-store, must-revalidate, max-age=0" r.headers...
qwc-services/qwc-services-core
qwc_services_core/app.py
.py
beefab726750d8b9
7.04
11
"""Authentication helper functions """ import os import re from flask import request from .jwt import jwt_manager from flask_jwt_extended import jwt_required, get_jwt_identity # Accept user name passed in Basic Auth header # (password has to checkded before!) ALLOW_BASIC_AUTH_USER = os.environ.get('ALLOW_BASIC_AUTH_U...
qwc-services/qwc-services-core
qwc_services_core/auth.py
.py
db57a0fe85ffc359
7.54
11
import time import copy class ExpiringDict: """Dict for values where each key will expire after some time.""" def __init__(self): """Constructor""" self.cache = {} def set(self, key, value, duration=300): """Store value under key until expiry. :param str key: Key for val...
qwc-services/qwc-services-core
qwc_services_core/cache.py
.py
d17346a79fa9fcbb
7.54
11
import os from flask_login import UserMixin from sqlalchemy import MetaData from sqlalchemy.ext.automap import automap_base from sqlalchemy.orm import Session, backref, relationship from werkzeug.security import generate_password_hash, check_password_hash class ConfigModels(): """ConfigModels class Provide S...
qwc-services/qwc-services-core
qwc_services_core/config_models.py
.py
978471b6f73cb800
7.54
11
import os import json from flask_jwt_extended import JWTManager, unset_jwt_cookies from flask import redirect, request from jwt.exceptions import PyJWTError def jwt_manager(app, api=None): """Setup Flask-JWT-Extended extension for services with authenticated access""" # https://flask-jwt-extended.readt...
qwc-services/qwc-services-core
qwc_services_core/jwt.py
.py
be0a7bfa0b613f20
7.54
11
import os import re from flask import json from werkzeug.utils import safe_join class RuntimeConfig: '''Runtime configuration helper class ''' @staticmethod def config_file_path(service, tenant): """Return path to permissions JSON file for a tenant. :param str servcie: Service name ...
qwc-services/qwc-services-core
qwc_services_core/runtime_config.py
.py
cb025fa3f6d97394
7.54
11
import glob import json import os class Translator: """Class for translating strings via json files""" def __init__(self, app, request): """Constructor. :param object app: The Flask app :param object request: The Flask requst """ supported_locales = list(map( ...
qwc-services/qwc-services-core
qwc_services_core/translator.py
.py
631f8ac963c71466
7.54
11
"""Inspect an ordered image set with the base install; prints roots, aliases, and payloads. Opens two distinct in-memory images plus a third byte-identical source through the multi-image ``open_images`` API. No LLM or optional dependency is required: the plan runs against the built-in Pillow backend. Byte-identical so...
yashimwong/penampakan
examples/08_multi_image.py
.py
f6a1ec14496bdc7a
7.48
8
"""Shared dispatch helpers for application-supplied callables.""" from __future__ import annotations import asyncio import functools import inspect from collections.abc import Awaitable, Callable from typing import TypeVar, cast _T = TypeVar("_T") # A partial cannot wrap itself, but a subclass could misreport ``fun...
yashimwong/penampakan
src/penampakan/_callables.py
.py
cb564825310a201f
7.48
8
"""Vision backend adapter for application callables.""" from __future__ import annotations import asyncio from collections.abc import Awaitable, Callable from penampakan._callables import call_async_or_thread from penampakan.models import ( BackendDescriptor, BackendImage, CaptionRequest, DetectionRe...
yashimwong/penampakan
src/penampakan/backends/callable.py
.py
5a380e5548f6151b
7.48
8
from __future__ import annotations import math import re import sys from pathlib import Path from typing import Literal from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validator if sys.version_info >= (3, 11): from typing import Self else: from typing_extensions import Self from .m...
yashimwong/penampakan
src/penampakan/config.py
.py
37b3dcdb30957cc1
7.48
8
"""Shared deterministic encoding for normalized image assets.""" from __future__ import annotations import hashlib from io import BytesIO from PIL.Image import Image as PillowImage CANONICAL_PNG_COMPRESSION_LEVEL = 6 def encode_canonical_png(image: PillowImage) -> bytes: """Encode caller-owned normalized pixe...
yashimwong/penampakan
src/penampakan/image/canonical.py
.py
d977b948a4c987be
7.48
8
"""Deterministic normalized and pixel geometry operations.""" from __future__ import annotations import math from dataclasses import dataclass from penampakan.models import Box, Point NORMALIZED_TOLERANCE = 1e-6 @dataclass(frozen=True, slots=True) class PixelBox: """A non-empty rectangle using exclusive right...
yashimwong/penampakan
src/penampakan/image/geometry.py
.py
49c41979db960ba2
7.48
8
"""Adapter-private Anthropic Messages API request building, parsing, and classification. Every Messages-API detail lives here so the public ``AnthropicTextLLM`` class exposes only ``TextLLM`` contracts. One capability table decides which strict structured-output path a model supports, so no prefix conditionals appear ...
yashimwong/penampakan
src/penampakan/llms/_anthropic_transport.py
.py
14745a372ca54a43
7.48
8
"""Shared provider-adapter lifecycle, schema caching, and output finalization. Every provider adapter reuses this module so ownership, idempotent closing, schema compilation, and post-validation behave identically across providers. Nothing here imports an optional provider SDK. """ from __future__ import annotations ...
yashimwong/penampakan
src/penampakan/llms/_base.py
.py
02dc652ed282bd11
7.48
8
"""Adapter-private OpenAI Responses-API request shaping, parsing, and classification. The public :class:`penampakan.llms.openai.OpenAITextLLM` exposes only the provider-neutral ``TextLLM`` contracts; every Responses-specific detail lives here. Nothing in this module imports the optional ``openai`` package at import ti...
yashimwong/penampakan
src/penampakan/llms/_openai_transport.py
.py
b7ffa9a95608b8ca
7.48
8
"""One shared provider retry implementation with a total monotonic deadline. Every adapter routes its single provider call through :func:`call_with_retries` so retry accounting, deadline enforcement, and redaction are identical across providers. Only connection failures, timeouts, 429, and 5xx are retried; schema, ref...
yashimwong/penampakan
src/penampakan/llms/_retry.py
.py
c1b44a9626d141f4
7.48
8
"""Anthropic Messages API text language model adapter with strict structured output.""" from __future__ import annotations from collections.abc import Mapping from typing import Final, Literal, Protocol, cast from penampakan.errors import ConfigurationError from penampakan.llms._anthropic_transport import ( PROV...
yashimwong/penampakan
src/penampakan/llms/anthropic.py
.py
4626f856c092fc79
7.48
8
"""Text language model adapter for application callables.""" from __future__ import annotations import asyncio from collections.abc import Awaitable, Callable from penampakan._callables import call_async_or_thread from penampakan.models import LLMRequest, LLMResponse CompleteCallable = Callable[ [LLMRequest], ...
yashimwong/penampakan
src/penampakan/llms/callable.py
.py
a4c119f38b94b1d7
7.48
8
"""Optional LiteLLM text-LLM adapter with capability-checked schema enforcement. The LiteLLM package is imported during construction only, so this module stays importable on a base install. LiteLLM normalizes many providers onto the OpenAI-compatible request surface, so the compiled OpenAI strict subset is the strict ...
yashimwong/penampakan
src/penampakan/llms/litellm.py
.py
afef5009686795cf
7.48
8
"""OpenAI Responses-API text language-model adapter.""" from __future__ import annotations from collections.abc import Awaitable, Callable, Mapping from typing import Any, Literal, cast from penampakan.errors import ConfigurationError from penampakan.llms._base import ( ProviderLifecycle, SchemaCompilerCache...
yashimwong/penampakan
src/penampakan/llms/openai.py
.py
b5083fd5ff1c22f1
7.48
8
"""Deterministic process-local perception caching primitives.""" from __future__ import annotations import asyncio import hashlib import json from collections import OrderedDict from collections.abc import Awaitable, Callable from contextlib import suppress from dataclasses import dataclass from typing import ClassVa...
yashimwong/penampakan
src/penampakan/perception/cache.py
.py
2cfec4a262d9a333
7.48
8
"""Typed declarations and executors for bounded visual tools.""" from __future__ import annotations import inspect import re from collections.abc import Awaitable, Callable from dataclasses import dataclass, field from typing import Protocol from PIL.Image import Image as PillowImage from pydantic import BaseModel ...
yashimwong/penampakan
src/penampakan/perception/registry.py
.py
51f04d24fe03c776
7.48
8
# The MIT License (MIT) # # Copyright (c) 2026 Chris J Daly (github user cjdaly) # # 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...
cjdaly/CircuitDungeon
Chapter_6/game/hardware.py
.py
1849f0136e4ef213
7.42
6
# The MIT License (MIT) # # Copyright (c) 2026 Chris J Daly (github user cjdaly) # # 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...
cjdaly/CircuitDungeon
Chapter_6/game/level_loader.py
.py
823f28aa7fbd6ae9
7.42
6
# The MIT License (MIT) # # Copyright (c) 2026 Chris J Daly (github user cjdaly) # # 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...
cjdaly/CircuitDungeon
Chapter_6/game/util.py
.py
c54752cc8f732fdb
7.42
6
import random MAX_ROLLS = "MAX_ROLLS" MAX_SIDES = "MAX_SIDES" MAX_DICE = "MAX_DICE" MAX_CHARS = "MAX_CHARS" INVALID = "INVALID" class RollParser: ''' Class to parse individual NdN±N(a|d) roll strings ''' def __init__(self, **kwargs): self.roll_string = kwargs.get("roll","1d20")...
corpnewt/pymodules
dice.py
.py
8bb36d020529af4e
7.48
8
""" Copyright 2019 Ipregistry (https://ipregistry.co). 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 https://www.apache.org/licenses/LICENSE-2.0 Unless required by app...
ipregistry/ipregistry-python
ipregistry/util.py
.py
bdcaac048c451c7a
7.6
15
""" Copyright 2019 Ipregistry (https://ipregistry.co). 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 https://www.apache.org/licenses/LICENSE-2.0 Unless required by app...
ipregistry/ipregistry-python
tests/test_async_client.py
.py
7ea3520d60234b76
7.1
15
""" Copyright 2019 Ipregistry (https://ipregistry.co). 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 https://www.apache.org/licenses/LICENSE-2.0 Unless required by app...
ipregistry/ipregistry-python
tests/test_cache.py
.py
7bbbf1ceebb80010
7.1
15
""" Copyright 2019 Ipregistry (https://ipregistry.co). 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 https://www.apache.org/licenses/LICENSE-2.0 Unless required by app...
ipregistry/ipregistry-python
tests/test_config.py
.py
91446fd8f93f3487
8.1
15
""" Copyright 2019 Ipregistry (https://ipregistry.co). 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 https://www.apache.org/licenses/LICENSE-2.0 Unless required by app...
ipregistry/ipregistry-python
tests/test_model.py
.py
adcddc0c74e863dc
8.1
15
""" Copyright 2019 Ipregistry (https://ipregistry.co). 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 https://www.apache.org/licenses/LICENSE-2.0 Unless required by app...
ipregistry/ipregistry-python
tests/test_request.py
.py
b1d0a3e9a215c4e4
7.1
15
"""Core module for serial communication of module data package format This module implements methods to read and write packets in the data package format. When communicating, the transferring and receiving of command/data/result are all wrapped in data package format. The packets take the shape of package to be sent a...
cerebrohivetech/adafruit-fingerprint
adafruit_fingerprint/core.py
.py
3f3305dacea7d3dc
7.42
6
"""Internal Exception classes used by package These classes subclass the base Exception class Classes _______ MissingPortException(Exception) SerialReadException(Exception) UnknownConfirmationCodeException(Exception) """ class MissingPortException(Exception): """ Exception raised when the port param is mis...
cerebrohivetech/adafruit-fingerprint
adafruit_fingerprint/exceptions.py
.py
b8629681354c1776
7.42
6
""" The shared car model: a tiny state dict {"x", "y", "heading", "speed"} and apply_input, the pure function that advances it one step. Kept as plain data + a pure function (rather than a stateful class) on purpose: it is exactly the shape gale.net.PredictionBuffer expects (see its usage in src/states/PlayState.py), s...
R3mmurd/Gale
examples/circuit/src/car.py
.py
0b65d19eef1dcde1
7.48
8
""" A small helper that advances through a list of waypoints, exposing a Kinematic target that a Seek/Arrive steering behavior can be built against once and reused for the whole path, since only the target's position is mutated as the path is followed. Adapted from examples/nightwatch/src/path_follower.py for the AI ra...
R3mmurd/Gale
examples/circuit/src/path_follower.py
.py
d5efce565e9ed4d4
7.48
8
""" The circuit itself: a small rectangular oval (an outer rect minus an inner one, so the driveable surface is the ring between them), plus the waypoints AI racers path-follow around it and the finish line used for lap counting. Every function here is a pure function of its arguments (no randomness, no wall-clock tim...
R3mmurd/Gale
examples/circuit/src/track.py
.py
dc0c6ac7325e04d5
7.48
8
import pygame from gale.ai.blackboard import Blackboard from gale.ecs import SystemScheduler, World from gale.input_handler import InputData from gale.state import BaseState from gale.text import render_text import settings from src.components import ( BallTag, Fatigue, PlayerTag, Position, Radius...
R3mmurd/Gale
examples/futsal/src/states/PlayState.py
.py
69bf0f4bcfd84a44
7.48
8
""" The bulk, data-oriented half of the match: gale.ecs.System subclasses that process every matching entity in one pass every frame, run in order by a gale.ecs.SystemScheduler. They know nothing about "team AI" or "roles" -- MovementSystem only ever looks at Position/Velocity, FatigueSystem only at Fatigue/Velocity, a...
R3mmurd/Gale
examples/futsal/src/systems.py
.py
15dcac49519109c6
7.48
8
import pygame from gale.physics.shapes import PolygonShape from gale.physics.world import World import settings class Terrain: """ A chain of static polygon segments following settings.terrain_height, each a small convex quad down to a common baseline. """ def __init__(self, world: World) -> No...
R3mmurd/Gale
examples/hillclimb/src/Terrain.py
.py
dde20a23aad4cb00
7.48
8
from typing import List, Tuple import pygame import settings from src.Torch import Torch class Room: """ A single, fixed layout: an outer wall, a handful of interior pillars to walk around, two torches to find, and an exit tile tucked in the far corner. """ START_POSITION: Tuple[float, floa...
R3mmurd/Gale
examples/lantern/src/Room.py
.py
5b9f676f9b267361
7.48
8
import pygame from gale.physics.shapes import BoxShape from gale.physics.world import World import settings class Player: def __init__(self, world: World, x: float, y: float) -> None: self.body = world.create_dynamic_body( x, y, BoxShape(settings.PLAYER_SIZE, settings.PLAYER_SIZE, friction=0...
R3mmurd/Gale
examples/leap/src/Player.py
.py
eeac8175670b4dc1
7.48
8
from typing import Dict from .helpers import generate_attribute_string class Behavior: """Represent Behavior config of huesyncbox.""" def __init__(self, raw, request) -> None: self._raw = raw self._request = request async def _put(self, data: Dict) -> None: await self._request("p...
mvdwetering/aiohuesyncbox
aiohuesyncbox/behavior.py
.py
dfd90abb28f0bc2c
7.42
6
from .helpers import generate_attribute_string class Wifi: """Represent wifi status""" def __init__(self, raw) -> None: self._raw = raw @property def ssid(self) -> str: """Wifi SSID""" return self._raw["ssid"] @property def strength(self) -> int: """ ...
mvdwetering/aiohuesyncbox
aiohuesyncbox/device.py
.py
1f6236c12015d614
7.42
6
"""Aiohuesyncbox errors.""" import logging logger = logging.getLogger(__name__) class AiohuesyncboxException(Exception): """Base error for aiohuesyncbox.""" class RequestError(AiohuesyncboxException): """Unable to fulfill request. Raised when host or API cannot be reached. """ class Unauthorize...
mvdwetering/aiohuesyncbox
aiohuesyncbox/errors.py
.py
57531c5f5690dc5d
7.42
6
from typing import Dict, Optional from .helpers import generate_attribute_string class SyncMode: """Sync mode. Only intensity for now so one class is enough""" def __init__(self, raw) -> None: self._raw = raw @property def intensity(self) -> str: """Intensity of the mode (subtle, mod...
mvdwetering/aiohuesyncbox
aiohuesyncbox/execution.py
.py
8d0d29362b9a486c
7.42
6
from typing import Dict from .helpers import generate_attribute_string INPUTS = ["input1", "input2", "input3", "input4"] class Input: def __init__(self, raw: Dict) -> None: self._raw = raw @property def name(self) -> str: """Friendly name of the input.""" return self._raw["name"]...
mvdwetering/aiohuesyncbox
aiohuesyncbox/hdmi.py
.py
b78016fee8685889
7.42
6
from typing import Dict, List from .helpers import generate_attribute_string class Group: """Represent a group on the Hue bridge""" def __init__(self, id: str, raw) -> None: self._id = id self._raw = raw @property def id(self) -> str: """Id of the group.""" return sel...
mvdwetering/aiohuesyncbox
aiohuesyncbox/hue.py
.py
eb9b3c862fc4cbd0
7.42
6
from django.conf import settings from django.db.models.signals import post_delete, post_save from django.dispatch import receiver from django.urls import reverse from django.utils.translation import gettext as _ from home.services.feed import invalidate_feed_cache_on_change from zzz.utils import get_site_domain from ...
soma115/Wikikracja
board/signals.py
.py
eb1aa0f2968f4216
7.45
7
# -*- coding: utf-8 -*- """ Created the 25/04/2023 @author: Sebastien Weber """ import copy from pathlib import Path import re from packaging.version import Version, InvalidVersion import numpy as np from qtpy import QtCore, QtWidgets from qtpy.QtCore import QLocale, Qt, QModelIndex from qtpy import API_NAME if AP...
PyMoDAQ/pymodaq_plugin_manager
src/pymodaq_plugin_manager/utils.py
.py
0d4b6b030a280be1
7.42
6
import copy import logging from typing import Any from qtoggleserver.conf import settings from qtoggleserver.utils import json as json_utils from qtoggleserver.utils.cmd import run_get_cmd from qtoggleserver.utils.conf import DottedDict logger = logging.getLogger(__name__) _metadata_entries: DottedDict = DottedDic...
qtoggle/qtoggleserver
qtoggleserver/conf/metadata.py
.py
28bca693da0eacd0
7.6
15
import abc from enum import IntEnum from qtoggleserver.core.typing import Attributes, NullablePortValue from .exceptions import ExpressionEvalException DEP_ASAP = "asap" DEP_SECOND = "second" DEP_MINUTE = "minute" DEP_HOUR = "hour" DEP_DAY = "day" DEP_MONTH = "month" DEP_YEAR = "year" class Role(IntEnum): ""...
qtoggle/qtoggleserver
qtoggleserver/core/expressions/base.py
.py
908ce2be84539298
7.6
15
# Standard Library import logging # Third Party from eve_sde.models import Region, SolarSystem, Stargate # Alliance Auth from allianceauth.services.hooks import get_extension_logger logger = get_extension_logger(__name__) # EVE's SDE bakes space type into the solar system id range rather than a # flag: wormhole sys...
Solar-Helix-Independent-Transport/allianceauth-corp-tools
corptools/api/spacemap.py
.py
d7a4c2152e69f08b
7.42
6
import logging from discord.colour import Color from discord.embeds import Embed from discord.ext import commands from corptools.models import MapJumpBridge, MapSystem from corptools.providers import routes logger = logging.getLogger(__name__) class Routes(commands.Cog): """ Route! """ def __init_...
Solar-Helix-Independent-Transport/allianceauth-corp-tools
corptools/cogs/routes.py
.py
2cf1239e4655d80a
7.42
6
#!/usr/bin/env python3 """Wrapper script for AOP-Wiki RDF conversion. Constructs a PipelineConfig from CLI arguments and calls the pipeline main() function. No exec(), no string replacement. """ import argparse from pathlib import Path from aopwiki_rdf.config import PipelineConfig from aopwiki_rdf.pipeline import ma...
marvinm2/AOPWikiRDF
run_conversion.py
.py
2654974a3cf609e1
7.56
12
"""Regenerate data-test/iri-label-fixture.ttl by REAL writer emission. Phase 8 / Plan 08-03 (D-09). The flag-on label fixture feeds the property audit so the regenerated chemical + gene-association SHACL shapes gain an rdfs:label constraint sourced from genuine emission (never hand-authored) -- mirroring the Phase-7 p...
marvinm2/AOPWikiRDF
scripts/generate_iri_label_fixture.py
.py
0b8dce661fbeef9e
7.56
12
"""Generate SHACL shape files from audit-results.json. This script reads the property population audit and generates data-driven SHACL shapes with severity thresholds based on actual population rates. """ import json import os import sys import textwrap # Common prefixes for all shape files COMMON_PREFIXES = """\ @p...
marvinm2/AOPWikiRDF
scripts/generate_shapes.py
.py
6da6a0627ef029d6
7.56
12
"""SPARQL-based property population audit for AOP-Wiki RDF output files. Loads each TTL file, discovers rdf:type values and their instance counts, then for each type finds all properties with population percentages. Classifies each property severity for SHACL shape generation. Output: human-readable table to stdout +...
marvinm2/AOPWikiRDF
scripts/property_audit.py
.py
1ffbb94faacc29f1
7.56
12
"""Run SHACL validation of AOP-Wiki RDF output against shape definitions. Validates each data file against its relevant shapes: - AOPWikiRDF.ttl: AOP, KeyEvent, KER, Stressor, Chemical, GeneAssociation shapes - AOPWikiRDF-Enriched.ttl: EnrichedXref shape Results: - shacl-report.ttl: Full SHACL validation report - sha...
marvinm2/AOPWikiRDF
scripts/run_shacl_validation.py
.py
44f1922613b61f16
7.56
12
"""Dynamic HGNC gene data download with assertion guard and static fallback.""" import logging from pathlib import Path import requests logger = logging.getLogger(__name__) def download_hgnc_data( url: str, cache_path: Path, timeout: int = 30, max_retries: int = 3, min_genes: int = 19000, ) -> ...
marvinm2/AOPWikiRDF
src/aopwiki_rdf/hgnc/download.py
.py
12a28c3f8308c3da
7.56
12
"""Aho-Corasick automaton for gene-name matching. Replaces a nested loop that tested all ~45,000 genes against every text, using a ``genedict2`` of every token pre-expanded with all 49 combinations of leading and trailing delimiter -- 7.4 million materialised strings, and a scan cost proportional to (genes x tokens x ...
marvinm2/AOPWikiRDF
src/aopwiki_rdf/mapping/automaton.py
.py
e7014f895f434b0d
7.56
12
"""Chemical mapper module. Enriches chemical data with BridgeDb cross-references by batch-mapping CAS numbers to ChEBI, ChemSpider, PubChem, DrugBank, HMDB, KEGG, LIPID MAPS, ChEMBL, and Wikidata identifiers. Extracted from AOP-Wiki_XML_to_RDF_conversion.py chemical mapping section. """ import logging import reques...
marvinm2/AOPWikiRDF
src/aopwiki_rdf/mapping/chemical_mapper.py
.py
7af02bcdf241d396
7.56
12
"""Inverted ``xref_iri -> name`` label maps for external/component IRIs. Phase 8 infrastructure (Plan 08-01). This module is the one genuinely-new design element of the external-IRI labeling phase: it turns the pipeline's already-built, already-trusted in-memory dicts (``geneiddict`` + ``symbol_lookup`` for genes, ``c...
marvinm2/AOPWikiRDF
src/aopwiki_rdf/mapping/iri_labels.py
.py
5e7cab19c26a9ad7
7.56
12
"""Release identity for the generated dataset. Two distinct things get versioned in this repo and conflating them is what produced the six-year-stale ``pav:version "1.3"`` in the served RDF: * the **dataset** -- a weekly snapshot, identified by the AOP-Wiki XML export it was built from. This is what ``pav:version``...
marvinm2/AOPWikiRDF
src/aopwiki_rdf/provenance.py
.py
6d63365422e608ea
7.56
12
"""Shared helper functions for the AOP-Wiki RDF pipeline. Extracted from AOP-Wiki_XML_to_RDF_conversion.py (lines 46-280). No module-level side effects. No logging.basicConfig(). No network calls. """ import logging import re import time import requests logger = logging.getLogger(__name__) # --- Constants / Compil...
marvinm2/AOPWikiRDF
src/aopwiki_rdf/utils.py
.py
7686dbb1a0d99836
7.56
12
#!/usr/bin/env python3 """ Analyze chemical processing volume and current performance bottleneck. """ import xml.etree.ElementTree as ET import requests import time from pathlib import Path def analyze_chemical_volume(): """Analyze chemical processing requirements and current performance""" # Find the mo...
marvinm2/AOPWikiRDF
tests/debug/analyze_chemical_volume.py
.py
d4fca8fdbe257b40
8.06
12
"""Integration tests for the ARR-AOP filter stage. Exercises `_stage_filter_arr_aops` against a real parse of the sample fixture (which contains one BY-SA AOP and one ARR AOP) to confirm: - default `filter_arr_aops=False` keeps all AOPs in aopdict; - `filter_arr_aops=True` drops ARR-licensed AOPs only. """ from path...
marvinm2/AOPWikiRDF
tests/integration/test_arr_filter.py
.py
6e6eefa1bed64f51
7.06
12
"""COMPAT-01 byte-identity guard for the flag-off (production) output. Phase 7 adds PROV-O activities + a primacy flag + a confidence-policy assertion to the genes file, all gated behind ``enable_bern2``. The flag stays ``False`` in production this phase, so the genes and main TTL files MUST stay byte-identical to the...
marvinm2/AOPWikiRDF
tests/integration/test_compat_flag_off.py
.py
07645d65c1629b3a
8.06
12
"""Integration tests for the coverage ratchet (XML-02 / XML-03). * ``test_fixed_gaps_emit`` — XML-02: each fixed gap element now emits its triple(s) in writer output. Depends on the Plan 03 parser/writer gap-fix. * ``test_additive`` — XML-02: gap fixes are additive, the total triple count does not drop versus a gr...
marvinm2/AOPWikiRDF
tests/integration/test_coverage_ratchet.py
.py
534d931d60265ca9
8.06
12
"""Integration test for KER NER union wiring (D-08), flag-on, fully offline. Mirrors the flag-on genes-write + rdflib re-parse pattern in tests/unit/test_bern2_pipeline.py, but for the KER branch of ``_apply_bern2_enrichment``: with a mocked BERN2 KER mapper returning a gene for a KER, running the union build + genes ...
marvinm2/AOPWikiRDF
tests/integration/test_ker_ner.py
.py
e78655e1ed6f068f
8.06
12
"""End-to-end integration test against the live BERN2 + BridgeDb services. Skipped automatically when either service is unreachable, so the suite still passes in offline CI. Hits the hosted BERN2 API at bern2.korea.ac.kr and BridgeDb at webservice.bridgedb.org. """ import os import socket from pathlib import Path im...
marvinm2/AOPWikiRDF
tests/integration/test_ner_el_mapper_live.py
.py
1fc2d6acd670bfbf
8.06
12
"""Integration tests for output separation verification. Tests validate that the four-file output split maintains expected invariants: - Pure AOPWikiRDF.ttl has no chemical/protein cross-reference triples - AOPWikiRDF-Enriched.ttl is valid Turtle with only cross-reference predicates - VoID metadata declares subsets, l...
marvinm2/AOPWikiRDF
tests/integration/test_output_separation.py
.py
498f08743bc15b54
8.06
12
"""Triple-for-triple regression test: modularized pipeline vs monolith. Runs both pipelines against the same AOP-Wiki XML and compares sorted NTriples output for all three TTL files. Blank node labels are normalized before comparison. Usage: python -m pytest tests/integration/test_regression.py -x -s # or sta...
marvinm2/AOPWikiRDF
tests/integration/test_regression.py
.py
2180846431fd8182
8.06
12
"""Integration tests for SHACL validation of AOP-Wiki RDF output. Tests verify that SHACL shapes correctly validate the RDF data files and that validation completes within acceptable time limits. """ import os import subprocess import sys import time import pytest PROJECT_ROOT = os.path.dirname(os.path.dirname(os.p...
marvinm2/AOPWikiRDF
tests/integration/test_shacl_validation.py
.py
0fb2d2c4a29049b9
7.06
12
""" Clock Segment ESP8266 - a very simple four-digit timepiece Version: 1.2.3 Author: smittytone Copyright: 2022, Tony Smith Licence: MIT """ """ Imports """ import usocket as socket import ustruct as struct import ujson as json import network from micropython import const from machine import I2C, Pin, RTC fro...
smittytone/FeatherClock
archive/clock-segment-esp8266.py
.py
840dfc59887c6997
7.48
8
''' Clock RP2040 Segment A very simple four-digit timepiece Version: 1.5.0 Author: smittytone Copyright: 2026 Tony Smith Licence: MIT ''' # ********** IMPORTS ********** import json import board import busio from digitalio import DigitalInOut, Direction, Pull from rtc import RTC from time import localtime, s...
smittytone/FeatherClock
experimental/clock-segment-trinkey-rp2040.py
.py
fc3a188935533dc0
7.48
8
""" This module contains base classes that define interfaces and contain code common to sub-classes, to avoid code duplication. """ # Copyright 2018-2026 CNRS and fairgraph authors and/or their employers # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance...
apdavison/fairgraph
fairgraph/base.py
.py
d316a2c0757bcd76
7.52
10
""" This module provides the Collection class, an extension to the openMINDS Collection that knows how to upload metadata to the KG. """ # Copyright 2018-2026 CNRS and fairgraph authors and/or their employers # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compl...
apdavison/fairgraph
fairgraph/collection.py
.py
e4236e7127f4e308
7.52
10
""" This module provides the EmbeddedMetadata class, which is the base class for representations of structured metadata that do not have their own identifier, but are rather embedded within another metadata instance. """ # Copyright 2018-2026 CNRS and fairgraph authors and/or their employers # Licensed under the Apac...
apdavison/fairgraph
fairgraph/embedded.py
.py
cfc8024a8f67cf19
7.52
10
""" Helpers for introspecting a module to discover and configure its KG classes. These are used by the per-domain ``fairgraph.openminds`` submodules to expose module-scoped ``list_kg_classes()``, ``list_embedded_metadata_classes()`` and ``set_error_handling()`` functions. """ # Copyright 2018-2026 CNRS and fairgraph ...
apdavison/fairgraph
fairgraph/introspection.py
.py
37428a96728a310a
8.02
10