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 |
|---|---|---|---|---|---|---|
from __future__ import annotations
from collections import Counter
from typing import Any
from experiment_add.shared.text.answer_matching import contains_answer, exact_match, token_f1
SPECIAL_ZERO_STATUSES = {"parser_empty", "parser_failed", "api_failed", "context_too_long", "not_found"}
def answer_missing(page_t... | ef1026/ProSA | experiment_add/exp1_qa/metrics/qa_metrics.py | .py | bfca82b03b2b2d7d | 7.15 | 1 |
"""Answer-level relevance: does a chunk contain the gold answer span?
Pairs with :mod:`evidence_recall` to give two distinct retrieval-quality
signals: evidence (the parser preserved the surrounding sentence) vs answer
(the parser preserved at least the literal answer string).
"""
from __future__ import annotations
... | ef1026/ProSA | experiment_add/exp2_retrieval/metrics/answer_hit.py | .py | 2be3140ed90618d3 | 7.15 | 1 |
"""Evidence-level relevance: does a retrieved chunk contain the gold evidence span?
The check reuses ``contains_answer`` from the shared text utilities so that
evidence relevance and exp1's ``answer_missing`` use exactly the same
normalization (NFKC, lowercase, punctuation strip, whitespace collapse).
"""
from __futu... | ef1026/ProSA | experiment_add/exp2_retrieval/metrics/evidence_recall.py | .py | 185fcdcf186675c8 | 7.15 | 1 |
"""Generic retrieval metrics over per-query relevance lists.
A "hit" is a list of dicts with at least ``rank`` (1-indexed) and a relevance
flag. Two relevance flavours are computed independently:
* ``evidence_hit``: chunk text contains the gold evidence span.
* ``answer_hit``: chunk text contains the gold answer sp... | ef1026/ProSA | experiment_add/exp2_retrieval/metrics/retrieval_metrics.py | .py | 00e4a2a6c57522af | 7.15 | 1 |
"""BM25 page-internal retriever wrapper.
Each page becomes its own mini-corpus. Tokenization reuses the same
``normalize_answer`` pipeline as exp1's QA scoring so that retrieval and
answer-hit comparisons share an identical token space.
"""
from __future__ import annotations
from collections import defaultdict
from ... | ef1026/ProSA | experiment_add/exp2_retrieval/retrievers/bm25_retriever.py | .py | ec011cb07c27cc42 | 7.15 | 1 |
"""Dense retrieval wrapper around sentence-transformers.
The encoder is loaded lazily so that scripts which only need BM25 (e.g.,
audits) do not pay the import cost. Embeddings are stored row-aligned with
``chunk_ids`` and ``page_ids`` so page-internal retrieval is a simple boolean
mask + top-k over cosine similaritie... | ef1026/ProSA | experiment_add/exp2_retrieval/retrievers/dense_retriever.py | .py | 8a5a1b6ec7776eba | 7.15 | 1 |
"""Persistence helpers for BM25 and dense retrieval indexes.
Indexes are stored per (pipeline, condition) under
``experiment_add/outputs/exp2_retrieval/indexes/{pipeline}_{condition}/``.
"""
from __future__ import annotations
import json
import pickle
from dataclasses import dataclass
from pathlib import Path
from t... | ef1026/ProSA | experiment_add/exp2_retrieval/retrievers/index_io.py | .py | 885eaef8fb157576 | 7.15 | 1 |
"""Audit the chunked retrieval corpora.
Validates that:
* every page in the manifest is represented (or accounted for as empty/failed),
* the per-page chunk count distribution is sane (flag pages with < 3 chunks),
* on the *clean* corpora, the gold ``evidence_text`` is contained in at least
one chunk for the overwhe... | ef1026/ProSA | experiment_add/exp2_retrieval/scripts/audit_retrieval_corpus.py | .py | ac900ee37acbc7ff | 7.15 | 1 |
"""Frontend-only client SDK for the PySide application.
Legacy worker_host client code has been removed. The remaining helpers here
(filename derivation, unique-path, and a no-op shutdown hook) are still used
by the export/main-window code; ``get_backend_client`` was deleted because the
v2 supervisor is the only backe... | FelixJI/vibeocr-classic | apps/vibeocr-pyside/src/vibeocr/classic/client.py | .py | 61a6dbd646644f50 | 7 | 0 |
"""Worker 基类
提供统一的 Worker 抽象,支持取消操作和错误处理。
"""
import logging
from abc import abstractmethod
from typing import Any, TypeVar
from PySide6.QtCore import QThread, Signal
logger = logging.getLogger(__name__)
T = TypeVar("T")
class BaseWorker[T](QThread):
"""Worker 基类
提供通用的 Worker 功能:
- 取消操作
- 进度报告
... | FelixJI/vibeocr-classic | apps/vibeocr-pyside/src/vibeocr/classic/core/base_worker.py | .py | cf5e6e17e92c43b9 | 7 | 0 |
"""统一配置管理器
所有用户配置的唯一读写入口,提供统一的路径管理和 JSON 读写。
"""
import json
import logging
from pathlib import Path
from PySide6.QtCore import QObject
from vibeocr.classic.json_storage import write_json_atomic
logger = logging.getLogger(__name__)
class ConfigManager(QObject):
"""统一配置管理器单例
负责所有用户配置的读写、路径管理和版本迁移。
""... | FelixJI/vibeocr-classic | apps/vibeocr-pyside/src/vibeocr/classic/managers/config_manager.py | .py | 8c671c39c2d65fd4 | 7 | 0 |
"""依赖管理器
提供依赖检查和安装管理功能。
"""
import logging
from pathlib import Path
from PySide6.QtCore import QObject, QRunnable, QThreadPool, Signal
from vibeocr.classic.app_paths import get_state_root
from vibeocr.classic.runtime_installation import (
RuntimeInstallerClient,
RuntimeInstallerClientError,
)
logger = logg... | FelixJI/vibeocr-classic | apps/vibeocr-pyside/src/vibeocr/classic/managers/dependency_manager.py | .py | 3b492a0794cfa5ea | 7 | 0 |
"""布局管理器
负责窗口和分割器状态的持久化。
"""
import base64
import logging
from pathlib import Path
from typing import TYPE_CHECKING, Any
from PySide6.QtCore import QByteArray
from vibeocr.classic.json_storage import write_json_atomic
if TYPE_CHECKING:
from vibeocr.classic.managers.config_manager import ConfigManager
logger =... | FelixJI/vibeocr-classic | apps/vibeocr-pyside/src/vibeocr/classic/managers/layout_manager.py | .py | b85f988fe38a5519 | 7 | 0 |
"""Classic-owned OCR resume state for incrementally persisted PDF pages.
Version 1 sidecars remain under
``<product_root>/data/backend/ocr_sessions/<path-slug>.json`` so existing
portable installations can resume without moving or rewriting local state.
"""
from __future__ import annotations
import hashlib
import js... | FelixJI/vibeocr-classic | apps/vibeocr-pyside/src/vibeocr/classic/ocr_sidecar.py | .py | 4851718c2fd65a4f | 7 | 0 |
"""PySide 缩略图 RPC worker:并发取 PNG,主线程构造 QPixmap。
替代原 ThumbnailRenderWorker(持 doc + doc_lock)。进程化后主进程不持 fitz,
缩略图渲染走 IPC:queue 投页索引 → 线程池并发调 client.render_thumbnail(sid, page)
拿 PNG 字节 → emit thumbnail_ready(主线程 loadFromData 构 QPixmap)。
并发模型:单个 QThread.run() 持有一个 ThreadPoolExecutor(max_workers=N),
从 queue 取页索引提交到线程池并发渲... | FelixJI/vibeocr-classic | apps/vibeocr-pyside/src/vibeocr/classic/pyside/pdf_render_thumb_worker.py | .py | 5274910d7bea1e66 | 7 | 0 |
"""Settings-page runtime bridge for the PySide shell.
UI modules depend on this platform boundary instead of importing manager and
service implementations directly.
"""
from __future__ import annotations
def _config_manager():
"""Resolve the config singleton lazily to keep the shell import lightweight."""
f... | FelixJI/vibeocr-classic | apps/vibeocr-pyside/src/vibeocr/classic/pyside/settings_runtime.py | .py | d83ec83c6df7b69b | 7 | 0 |
"""日志服务模块"""
import logging
import os
import sys
import time
from logging.handlers import RotatingFileHandler
from pathlib import Path
from typing import TYPE_CHECKING
from PySide6.QtCore import QObject, Signal
from vibeocr.classic.app_paths import get_active_app_paths
from vibeocr.classic.logging_context import LO... | FelixJI/vibeocr-classic | apps/vibeocr-pyside/src/vibeocr/classic/services/log_service.py | .py | 80c1f6000dff9889 | 7 | 0 |
# src/vibeocr/ui/theme.py
"""唯一设计 token 源 + QSS 生成器(浅色主题)。
所有颜色、间距、圆角、字号、布局尺寸在此集中定义,QSS 通过 f-string 引用
token 生成,确保全应用配色一致。
"""
from __future__ import annotations
class Colors:
"""语义色 token(浅色单一套)"""
# 背景层
bg = "#f3f4f6"
surface = "#ffffff"
surface_alt = "#f9fafb"
# 文字
text = "#1f2937"
... | FelixJI/vibeocr-classic | apps/vibeocr-pyside/src/vibeocr/classic/ui/theme.py | .py | d197347b76e71ab6 | 7 | 0 |
#!/usr/bin/env python3
"""Regenerate the Homebrew formula with current PyPI checksums.
Usage: gen-formula.py [git-tag] (default: v<version from __init__.py>)
Pillow and pyusb build from source (brew supplies the image libraries);
pypdfium2 ships per-arch wheels because its sdist downloads a prebuilt pdfium
at build... | jackharvest/bt820-macos-driver | packaging/gen-formula.py | .py | 1e59e78b89f2daed | 7 | 0 |
"""USB transport for the BT820.
macOS 26 (Tahoe) removed raw CUPS queues, so we bypass CUPS and write straight
to the USB printer-class bulk endpoint.
"""
import os
import sys
import time
import usb.core
import usb.util
from . import VID, PID
EP_OUT, EP_IN = 0x01, 0x81
def _find_backend():
"""Locate libusb.
... | jackharvest/bt820-macos-driver | src/bt820/device.py | .py | 63ec412a52be7e68 | 7 | 0 |
"""TSPL job construction.
Verb set and defaults mirror what the stock Windows BT820Render.dll emits.
"""
from . import MEDIA_W_IN, MEDIA_H_IN, MEDIA_H
from .render import IMG_BYTES
def build(bw, height, density=8, speed=4, gap_mm=2.0, bline_mm=None, direction=0):
"""Wrap a 1-bit image in a complete TSPL print jo... | jackharvest/bt820-macos-driver | src/bt820/tspl.py | .py | b05d72ffe2e2f39d | 7 | 0 |
"""
core/ai_client.py — the shared, PROVIDER-AGNOSTIC tool-call helper for the AI recon engines
(ai_rules, ai_anomalies, ai_insights, ai_matcher).
It supports two provider families which, between them, reach almost every model — hosted or
open-source, cloud or self-hosted:
• anthropic — Anthropic's native Messages A... | himanshusharma75035-sudo/reconciliation-app | backend/core/ai_client.py | .py | 41fc239f8defc800 | 7 | 0 |
"""
core/ai_deident.py — the single de-identification choke-point for every AI call.
This app reconciles real money. Customer PII must never leave the process in an
AI request. This module is the ONLY place transaction rows are turned into an
AI-visible payload, and it is a strict ALLOWLIST: only match-relevant fields... | himanshusharma75035-sudo/reconciliation-app | backend/core/ai_deident.py | .py | 4d03e0de22795aa3 | 7 | 0 |
"""
core/ai_matcher.py — AI-assisted match suggestions (advisory, human-approved).
Given the unmatched bank and internal rows for a partner/date-range, this asks
Claude to propose likely bank↔internal pairs. It is ADVISORY ONLY:
• The model sees a DE-IDENTIFIED, allowlist-only payload (core.ai_deident) —
no acc... | himanshusharma75035-sudo/reconciliation-app | backend/core/ai_matcher.py | .py | b092023acc2d0eaa | 7 | 0 |
"""
core/config_audit.py — Additive config / entitlement change auditing.
Roadmap item 1.1. PURELY ADDITIVE: a SQLAlchemy ``before_flush`` listener that
writes an ``AuditLog`` row whenever a CONFIG / IDENTITY model is inserted,
updated, or deleted by a logged-in user. It only *observes* those tables and
only *adds* ... | himanshusharma75035-sudo/reconciliation-app | backend/core/config_audit.py | .py | 32d418bb729d9388 | 7 | 0 |
"""
core/ingestion_ledger.py
Append-only ingestion lineage ledger (roadmap 1.4 — additive).
`record_ingestion_event()` writes ONE IngestionEvent row in its OWN database
session/transaction and swallows every error, so logging can never block,
slow, or roll back an actual ingest. It is imported by BOTH ingest paths
(r... | himanshusharma75035-sudo/reconciliation-app | backend/core/ingestion_ledger.py | .py | 778e19d9618452ab | 7 | 0 |
"""
core/jobs.py
Lightweight in-process background job runner for long-running operations
(e.g. running reconciliation over a month of data) so the HTTP request
thread is not blocked and the UI does not time out.
A single ThreadPoolExecutor runs jobs; status/result are kept in memory.
Jobs are ephemeral (cleared on r... | himanshusharma75035-sudo/reconciliation-app | backend/core/jobs.py | .py | 9c46d8e71640e6ed | 7 | 0 |
"""
maker_checker.py — Tier 1 dual-control for manual recon actions.
When the system setting `maker_checker_enabled` is "true", manual matches /
overrides / SRC assignments made by NON-admin users are not executed directly:
they are queued as ApprovalRequest rows and only run when a different user
(with the right perm... | himanshusharma75035-sudo/reconciliation-app | backend/core/maker_checker.py | .py | dacd7aa613d5bbdf | 7 | 0 |
"""
core/recon_health.py
Recon-health watchdog (D2 — additive, read-only).
compute_recon_health() aggregates failure signals the dead EOD digest never
surfaced into one structured health report:
* failed ingests (1.4 ingestion ledger, status='failed')
* blocked re-uploads (1.4 ledger, status='blocke... | himanshusharma75035-sudo/reconciliation-app | backend/core/recon_health.py | .py | 98b1809a7e844162 | 7 | 0 |
"""
core/recycle_bin.py — soft delete + restore.
Deleting reconciliation rows used to be terminal: a Clear action issued a hard DELETE and
the only way back was a nightly DB dump. This module makes a Clear *reversible* — rows are
serialised into `recycle_bin` first, then deleted, and can be restored later.
REPORTING/... | himanshusharma75035-sudo/reconciliation-app | backend/core/recycle_bin.py | .py | a6c92e6017b364b9 | 7 | 0 |
"""Bluetooth Classic HID keyboard server.
Registers a HID service over D-Bus (so it shows up correctly during
pairing/discovery) and opens the two raw L2CAP sockets a Bluetooth HID
device needs:
- PSM 0x11 (17) - Control channel
- PSM 0x13 (19) - Interrupt channel (this is where keyboard reports go)
This mirrors... | oharsh/wireless-keyboard-bridge | src/hid_server.py | .py | 1d6acb311d800f9f | 7 | 0 |
"""evdev keycode -> USB HID usage ID mapping.
The Linux evdev keycodes emitted for a wired USB keyboard (via
`/dev/input/eventX`) are not the same numbers as the USB HID keyboard
usage IDs that go into a HID report. This table maps the evdev key name
(from `evdev.ecodes`) to its USB HID usage ID, per the USB HID Usage... | oharsh/wireless-keyboard-bridge | src/keymap.py | .py | 7aa3969f382b6b58 | 7 | 0 |
"""Entry point: read the wired keyboard's evdev events and relay them as
Bluetooth HID keyboard reports.
Run as root (needed for raw L2CAP sockets and /dev/input access):
sudo python3 src/relay.py
Set KEYBOARD_DEVICE to the /dev/input/eventX path for your wired
keyboard, or leave it unset to auto-detect the firs... | oharsh/wireless-keyboard-bridge | src/relay.py | .py | 33e305603b042fcf | 7 | 0 |
"""footer-note:页脚自定义留言插件(v1.2.0 示例插件)
演示插件系统的四种能力:
1. ctx.hook('init', cfg) —— 构建初始化时拿到完整配置(找注入点)
2. ctx.inject('footer_extra', html) —— 向页脚注入一段 HTML
3. ctx.add_global(name, value) —— 向全部模板暴露全局变量
4. ctx.register_shortcode(name, fn) —— 注册 markdown 短代码
启用方式:把本目录(plugins/footer-note)放进仓库根 plu... | techjiang/VeryGood | plugins/footer-note/plugin.py | .py | 1651874411dc8db6 | 7 | 0 |
"""post-stats:文章统计增强插件(v1.2.0 示例插件)
演示插件系统的另外两类能力:
1. ctx.hook('post_parsed', post) —— 每篇文章解析完后挂钩(可改 post 字段)
2. ctx.add_filter(name, fn) —— 注册 Jinja 过滤器,模板中 {{ value | filter }} 使用
能力:
· 给每篇文章计算「字数」(中英文混合统计),写入 post['word_count']
· 注册 | reading_time 过滤器:按字数估算阅读时长(分钟)
· 注册 | wc 过滤器:任意文本的字数
启用方式:放在... | techjiang/VeryGood | plugins/post-stats/plugin.py | .py | 76a7f206341cdf71 | 7 | 0 |
"""配置加载与规整:默认值 + 用户 config.yml 深合并。"""
from __future__ import annotations
import copy
from pathlib import Path
import yaml
BASE_DIR = Path(__file__).resolve().parent.parent # 仓库根目录
DEFAULTS = {
"site": {
"title": "VeryGood",
"subtitle": "",
"description": "",
"keywords": ["blog"... | techjiang/VeryGood | verygood/config.py | .py | 163d94d5aabdc309 | 7 | 0 |
"""内容解析:Front Matter + Markdown 正文 → 文章/页面模型。"""
from __future__ import annotations
import datetime as _dt
import re
from html import unescape as _unescape
from pathlib import Path
import yaml
FM_RE = re.compile(r"\A---\s*\n(.*?)\n---\s*\n?", re.S)
TAG_RE = re.compile(r"<[^>]+>")
WS_RE = re.compile(r"\s+")
_IMG_SRC_... | techjiang/VeryGood | verygood/content.py | .py | 7519ed729b1a4bf2 | 7 | 0 |
"""Markdown 渲染管线:扩展、代码高亮、语言标签、图片懒加载、短代码。"""
from __future__ import annotations
import html as _html
import re
import markdown as md
_IMG_RE = re.compile(r"<img\s([^>]*?)>", re.I)
_SRC_RE = re.compile(r'src="([^"]+)"', re.I)
_LAZY_ATTRS = 'loading="lazy" decoding="async"'
_PRE_RE = re.compile(r"(<pre[\s\S]*?</pre>)"... | techjiang/VeryGood | verygood/mdrender.py | .py | 934016c97d1b6842 | 7 | 0 |
"""插件系统(v1.3.0):
- 内置插件:verygood/plugins/*.py 或 verygood/plugins/*/plugin.py(开箱即用)
- 用户插件:仓库根 plugins/*/plugin.py 自动发现,或 config.plugins 显式列出
- 能力:短代码 / 钩子 / 模板注入 / 全局变量 / Jinja 过滤器 / 元信息 / 静态资源
- 隔离:单个钩子抛异常仅记日志,不中断构建
插件开发详见 docs/插件开发文档.md。
"""
from __future__ import annotations
import ast
import importlib.util
impor... | techjiang/VeryGood | verygood/plugins/__init__.py | .py | f08e8cff8f36adab | 7 | 0 |
"""内置插件:阅读时长 —— post_parsed 钩子示例。
在文章/卡片 Meta 中展示「预计阅读 N 分钟」。构建引擎已内置计算,
此插件演示如何在 post_parsed 阶段追加自定义字段。
"""
from __future__ import annotations
import re
_TAG_RE = re.compile(r"<[^>]+>")
def setup(ctx):
@ctx.hook("post_parsed")
def add_reading_meta(post):
text = _TAG_RE.sub(" ", post["body_html"])
... | techjiang/VeryGood | verygood/plugins/reading_time.py | .py | 6ff6aaa8bddbc48e | 7 | 0 |
"""VeryGood 内置插件:站点数据组件(v1.3.0)。
侧栏「站点数据」卡片:文章总数 / 全站字数 / 浏览量 / 访客数。
- 文章数与总字数为构建期静态值(服务端直出,无刷可见)
- 浏览量 / 访客数由不蒜子统计(busuanzi)运行时填充,不可达时本地 localStorage 兜底
- v1.4.4:移除无效的「加载耗时 / 访客地区」面板项与代码
本插件同时是 v1.3.0 插件生态的完整示范:
· 元信息(__title__ / __description__ / __version__ / __author__)
· hook('site_ready') 在站点模型就绪后注入组件骨架(直接... | techjiang/VeryGood | verygood/plugins/site-stats/plugin.py | .py | 48071d195d28e642 | 7 | 0 |
"""VeryGood 内置插件:右栏时钟 + 打字机微语卡片(v1.4.0)。
右栏新增两个小组件:
- 时间卡片(vg-clock):本地时间,秒级刷新,与服务端无依赖,纯前端。
- 微语卡片(vg-whisper):打字机效果逐条轮播短句,可暂停 / 继续。
配置(config.yml → site.rightbar):
- show_clock: true/false # 是否显示时间卡片,默认 true
- show_micro: true/false # 是否显示微语卡片,默认 true
- micro_notes: [ "短句1", ... ] # 自定义微语内容;不填则使用插件内... | techjiang/VeryGood | verygood/plugins/whisper/plugin.py | .py | 6cf0f4d3e5f90744 | 7 | 0 |
"""The unit a candidate source hands a candidate view (discussion #112).
The Chooser filters tuples of ``(icon, label, *payload)`` today, which is
enough for the three clipboard actions and for nothing else: a list of
strings can only ever be consumed by a list. The views under consideration
need more - an overlay ne... | crftwr/keyhac | keyhac/core/candidate.py | .py | b3ade08cc223dcdf | 7.39 | 5 |
"""Configuration file loading (ported from keyhac-mac keyhac_config.py)."""
import os
import shutil
class Config:
"""Loads ~/.keyhac/config.py, copying the template on first run."""
def __init__(self, config_path: str, template_path: str):
self.config_path = config_path
if not os.path.exis... | crftwr/keyhac | keyhac/core/config.py | .py | 4a22f35a29a27e1a | 7.39 | 5 |
"""Focus conditions.
Unifies keyhac-mac's FocusCondition (focus_path_pattern / custom function)
with keyhac-win's WindowKeymap matching (exe / class / title), behind the
portable Focus snapshot defined in keyhac.platform.base.
"""
import fnmatch
import traceback
from typing import Callable
from keyhac.platform.base ... | crftwr/keyhac | keyhac/core/focus.py | .py | 562a2e7b918138cb | 7.39 | 5 |
"""KeyCondition and KeyTable.
Ported from keyhac-mac keyhac_key.py; modifier comparison semantics shared
with keyhac-win (hash by vk only, L/R-agnostic equality via mod_eq).
"""
from keyhac.core.const import *
from keyhac.core.vk import KeyNames, get_key_names
from keyhac.core import log
logger = log.getLogger("Key"... | crftwr/keyhac | keyhac/core/key.py | .py | 335fda937f9c1c8f | 7.39 | 5 |
"""Console logging.
M1: log records go to an in-memory ring buffer (for the future PuiKit console
window) and are mirrored to stderr. Ported in spirit from keyhac-mac
keyhac_console.py; the SwiftTerm console is replaced by the ring buffer +
stderr until M2.
"""
import sys
import logging
import threading
from collect... | crftwr/keyhac | keyhac/core/log.py | .py | 1786002c4c01590d | 7.39 | 5 |
"""Pluggable query matching for the candidate window (discussion #112).
The same window filters material with very different properties - clipboard
text, snippet names, accessibility labels, key expressions - so how a query
is matched has to be a parameter, not a hard-coded ``in``.
**Shape.** A matcher compiles a que... | crftwr/keyhac | keyhac/core/matcher.py | .py | d9957e5265b46d10 | 7.39 | 5 |
"""Where Keyhac keeps config.py and the state files that live beside it.
One directory holds everything: ``config.py``, ``extensions/``,
``clipboard.json``, ``settings.json``. Three ways it is chosen, first match
winning:
1. **An explicit** ``--config PATH`` — the state files sit beside the named
config, so a san... | crftwr/keyhac | keyhac/core/paths.py | .py | 964ce720eaa92154 | 7.39 | 5 |
"""Where candidates come from (discussion #112).
A source is a value, not a subclass. That distinction is the whole point:
while the only way to offer a new kind of row was to override a method, every
new capability cost a whole action class *and a hotkey to reach it* - and a
hotkey is the scarce resource here, not c... | crftwr/keyhac | keyhac/core/source.py | .py | d68111e7cdeab3b5 | 7.39 | 5 |
"""Waiting for the UI to change - the primitive `sleep` is standing in for.
Nearly every step of an action that *acts* on the UI is "do something, then
wait for something to change": a modal opens, a modal closes, a page loads
after a pagination click, a dependent field re-renders, an application becomes
ready. Spell... | crftwr/keyhac | keyhac/core/wait.py | .py | a518d68652cd46c7 | 7.39 | 5 |
"""Keyhac 2 bootstrap.
Default mode opens the PuiKit console window; its backend runs the process's
native event loop and the keyboard hook shares it (CGEventTap source on the
same run loop on macOS; the GetMessage pump services WH_KEYBOARD_LL on
Windows). --no-ui keeps the M1 headless mode (bare native loop + stderr... | crftwr/keyhac | keyhac/main.py | .py | 365b85660dec43f3 | 7.39 | 5 |
"""macOS platform implementation (PyObjC)."""
def check_accessibility(prompt: bool = True) -> bool:
"""Check (and optionally prompt for) the Accessibility permission the
event tap requires."""
import ApplicationServices as AS
options = {AS.kAXTrustedCheckOptionPrompt: prompt}
return bool(AS.AXIsPr... | crftwr/keyhac | keyhac/platform/mac/__init__.py | .py | 5a842a57681cb655 | 7.39 | 5 |
"""macOS focus provider - Accessibility API via PyObjC.
Ported from keyhac-mac: KeyhacCore_UIElement.swift (focused element lookup)
and keyhac_focus.py (focus path string construction).
"""
from AppKit import NSWorkspace
import ApplicationServices as AS
from keyhac.platform.base import FocusProvider, Focus
from keyh... | crftwr/keyhac | keyhac/platform/mac/focus.py | .py | fd17e661a514a513 | 7.39 | 5 |
"""Single-instance guard - flock on a lock file, plus activating the running app.
Two Keyhac processes would each install a CGEventTap and both would act on
(and possibly re-inject) every key, so a second launch must not get as far as
installing one. LaunchServices already refuses to launch the same .app bundle
twice... | crftwr/keyhac | keyhac/platform/mac/instance.py | .py | fb711c6b084d0ea1 | 7.39 | 5 |
"""Convert a Django ``User`` instance into a :class:`z4j_core.models.User`.
The mapping is best-effort and tolerant of custom user models.
Required fields on the z4j model are filled with sensible defaults
when the Django user does not have them.
"""
from __future__ import annotations
import logging
from datetime im... | z4jdev/z4j-django | src/z4j_django/auth.py | .py | 91aa7bd3984f2e8f | 7 | 0 |
"""Build a :class:`z4j_core.models.Config` from Django settings + env vars.
Resolution priority (highest first):
1. ``Z4J_*`` environment variables
2. ``settings.Z4J`` dict in the user's Django settings module
3. Defaults declared on :class:`z4j_core.models.Config`
Why env vars beat the settings dict: production dep... | z4jdev/z4j-django | src/z4j_django/config.py | .py | d25ac3d6483da85c | 7 | 0 |
"""Django signal hooks for z4j_django.
Currently empty in v1: the only Django-specific signals we wire up
are ``post_save`` / ``post_delete`` on
``django_celery_beat.models.PeriodicTask``, but those live in
``z4j_celerybeat.signals`` because they belong to the scheduler
adapter, not the framework adapter.
This module... | z4jdev/z4j-django | src/z4j_django/signals.py | .py | ede0ecec4c704b7b | 7 | 0 |
"""Shared fixtures for z4j-django unit tests.
Configures a minimal Django settings module BEFORE any z4j_django
import happens, so the package's lazy ``django.conf.settings``
imports work in test isolation.
"""
from __future__ import annotations
import django
import pytest
from django.conf import settings
def _con... | z4jdev/z4j-django | tests/unit/conftest.py | .py | 2be61f4df34d8c20 | 7.5 | 0 |
"""Tests for ``z4j_django.discovery.collect_django_hints``."""
from __future__ import annotations
from z4j_core.models import DiscoveryHints
from z4j_django.discovery import collect_django_hints
class TestCollectHints:
def test_returns_discovery_hints_object(self) -> None:
hints = collect_django_hints()... | z4jdev/z4j-django | tests/unit/test_discovery.py | .py | 40487f277d64ced0 | 7.5 | 0 |
"""lädt f1-sessions aus dem cache und zieht bei bedarf eine ganze saison hinein"""
from __future__ import annotations
import csv
import shutil
import tempfile
import time
from datetime import datetime
from pathlib import Path
import fastf1
import matplotlib
matplotlib.use("Agg") # nur dateien st... | JanikSchala/f1-data-analysis | 01_grundlagen/p01_session_explorer_jede_session_der_f1_historie_la.py | .py | b1ca3854261b36ab | 7 | 0 |
"""baut event- und streckengeometrie-tabellen für den saison-kalender"""
from __future__ import annotations
import sys
import warnings
from pathlib import Path
# python legt beim skriptstart nur den ordner des skripts auf den pfad.
# das repo-wurzelverzeichnis fehlt dadurch und "import f1lab" scheitert hier.
# diese ... | JanikSchala/f1-data-analysis | 01_grundlagen/p02_saison_kalender_event_metadaten_als_datenbank.py | .py | b5dd064f58da5a6b | 7 | 0 |
"""clustert fahrstile per k-means auf pedal-/schaltstatistik und vergleicht das mit dtw-clustering auf rohen speed-spuren"""
from __future__ import annotations
import sys
import warnings
from itertools import combinations
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
import ma... | JanikSchala/f1-data-analysis | 09_machine_learning/p24_fahrstil_clustering_wer_faehrt_wie.py | .py | 0e0d9df4fb332b74 | 7 | 0 |
"""CLI mit Subcommands: weekend, pace, strategy, telemetry, report,
optimize, lap-sim, overtakes, traffic.
Aufruf, sobald installiert (siehe README): f1analyze weekend 2024 Monza
Ueberholschwierigkeit je Strecke und Startplatz-Paritaet sind bewusst
keine Subcommands. beide brauchen einen Season-Scan ueber Dutzende bi... | JanikSchala/f1-data-analysis | 10_data_engineering/f1analyze/f1analyze/cli.py | .py | e25d9721421e7cbf | 7 | 0 |
"""Fixtures gegen einen mitgelieferten FastF1-Cache-Ausschnitt, ohne
Netzzugriff.
offline=True laesst eine Session ohne vorhandenen Cache-Eintrag scheitern.
das ist schnell und eindeutig statt einer minutenlangen haengenden
Netzanfrage. siehe f1lab.session.enable_cache().
FIXTURE_CACHE zeigt bewusst auf tests/fixture... | JanikSchala/f1-data-analysis | 10_data_engineering/f1analyze/tests/conftest.py | .py | 2b761c1a570d964c | 7.5 | 0 |
#!/usr/bin/env python3
# Copyright Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT
"""Tests for read_status_json, the consumer read helper.
Standard-library only (unittest), matching the helper it exercises. The
fixture is the canonical schema reference shipped alongside the docs
(docs/status-json/status_... | ROCm/Quartz | scripts/consumer/tests/read_status_json_test.py | .py | c76cc9b0cf04165f | 7.5 | 0 |
#!/usr/bin/env python3
# Copyright Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT
"""Regenerate `rock_workflow_inventory.json` from the live rock repos.
Snapshots two things from ROCm/TheRock and ROCm/rockrel:
1. `repos`: the list of `.github/workflows/*.yml` filenames. This is the
source of truth `t... | ROCm/Quartz | scripts/receive_therock/tests/fixtures/refresh_rock_workflow_inventory.py | .py | a5fa7a878fb63fd9 | 7.5 | 0 |
# Copyright Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT
"""Producer<->receiver envelope contract test.
This is the seam the unit tests previously missed: the producer
(`scripts/notify_quartz/notify_quartz.py`) and the receiver
(`scripts/receive_therock/therock_parse_input.py`) were each tested in
isol... | ROCm/Quartz | scripts/receive_therock/tests/therock_contract_test.py | .py | 969b8a25bff7450d | 7.5 | 0 |
# Copyright Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT
"""End-to-end smoke test for the full receive pipeline.
Drives `therock_process_data.main` (parse -> enrich -> classify ->
update_status_json) over real-shaped `DISPATCH_PAYLOAD` fixtures, exercising
the whole nightly sequence: build/native leave... | ROCm/Quartz | scripts/receive_therock/tests/therock_e2e_smoke_test.py | .py | 42d2144ff2586597 | 7.5 | 0 |
#!/usr/bin/env python3
# Copyright Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT
"""Static sanity checks over the workflow classification registry.
Two families of check:
1. *Spec references a real workflow.* `derive_platform_and_pipeline` raises at
runtime when it meets an unregistered workflow, so... | ROCm/Quartz | scripts/receive_therock/tests/therock_workflow_registry_test.py | .py | c52cb1f6c404a84f | 7.5 | 0 |
# Copyright Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT
"""Enrich dispatch payloads with additional data from the GitHub API.
For completed workflow_run dispatches, re-fetches the full job list for the
dispatch's specific run attempt (via
`GET .../actions/runs/{run_id}/attempts/{run_attempt}/jobs`) on... | ROCm/Quartz | scripts/receive_therock/therock_enrich_data.py | .py | fbf9ad63105b0597 | 7 | 0 |
# Copyright Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT
"""Main entry point for processing TheRock CI dispatch payloads.
Orchestrates the receive pipeline:
1. Parse and validate the incoming JSON payload
2. Enrich with additional data from the GitHub API (fetches the
run's jobs onto `workflow... | ROCm/Quartz | scripts/receive_therock/therock_process_data.py | .py | 7db0c3aaf7f355d1 | 7 | 0 |
#!/usr/bin/env python
# Copyright Advanced Micro Devices, Inc.
# SPDX-License-Identifier: MIT
from collections import Counter
from collections.abc import Iterable
from therock_status_document import (
BuildRollup,
NativePackagesRollup,
Pipeline,
PipelineRollup,
PlatformSummary,
RunLeaf,
St... | ROCm/Quartz | scripts/receive_therock/therock_summary.py | .py | 74de13b659fa4548 | 7 | 0 |
"""One-shot, non-interactive AI queries -- used by the Practice Lab's "Analyze
Complexity" action, where a single request/response is what's needed, not a live
embedded terminal session (that's what claude_panel.py is for). Reuses the same
backend priority as the AI panel (ai_backend.detect()) but calls each one in
non... | mukund1312/mtdo | src/mtdo/ai_ask.py | .py | fcc924c0c74fd8e8 | 7 | 0 |
"""Picks which AI backends the assistant panel (claude_panel.py) can offer, so the
user is never stuck without one just because they don't have Claude Code installed.
list_available() is checked fresh every time C opens the picker (not cached at import
time, since installing something or exporting a key shouldn't requi... | mukund1312/mtdo | src/mtdo/ai_backend.py | .py | dc63015f034c0504 | 7 | 0 |
"""Embeds a live AI assistant session directly inside mtdo's Focus Mode, in the right
half of the row that opens up once the kanban board and stats/calendar panels are
hidden (the Learning Coach and, optionally, a practice terminal share that row too --
see app.py's #coach-claude-row). Runs the assistant in a real pty ... | mukund1312/mtdo | src/mtdo/claude_panel.py | .py | e549c27beca51301 | 7 | 0 |
"""Per-user config: where it lives, how it's loaded, and the first-run setup flow."""
import copy
import json
import os
import shutil
from datetime import datetime
import yaml
# APP_DIR is the one thing every other module in this package should derive its own
# ~/.mtdo-rooted paths from (import this module and use ap... | mukund1312/mtdo | src/mtdo/config.py | .py | 44534b4f53182b90 | 7 | 0 |
"""Guided setup: export the self-documenting goals_template.json, hand it (plus a fixed
prompt) to whatever AI the user already uses, then import the goals.json it hands back.
No questions asked in-app and no AI called by mtdo itself -- see app.py's
GuidedSetupScreen and gh47 (formerly the persona+Q&A wizard covered by... | mukund1312/mtdo | src/mtdo/plan_wizard.py | .py | 2ea78ba8c82ef500 | 7 | 0 |
"""A genuine, self-contained internet-radio player -- not a remote control like
music.py (which only ever forwards commands to whatever's already playing
externally). This owns real audio playback: it starts and stops its own
processes, decodes and streams actual audio, and reports real, live audio
levels for a genuine... | mukund1312/mtdo | src/mtdo/radio.py | .py | 47a84aac9f7fa27c | 7 | 0 |
"""Console-script entry point for `mtdo-sandbox`: a disposable place to test mtdo without
any risk to real ~/.mtdo data.
Bare `mtdo-sandbox` (no subcommand) shows a picker of named, saved instances -- pick one to
resume it, or start fresh. Either way the session runs against a *scratch* copy
(instance_store.py); on qu... | mukund1312/mtdo | src/mtdo/sandbox_entry.py | .py | c7f1effa69a59bea | 7 | 0 |
"""Cross-machine "what I'm working on" status line, one per person, stored as a single
status.json file in the private mukund1312/mtdo-bugs tracker repo (same repo bug_sync.py
uses) -- so `mtdo-sandbox dashboard` can show it from whichever machine it's run on.
Uses the GitHub Contents API directly via `gh api` rather ... | mukund1312/mtdo | src/mtdo/status_sync.py | .py | b877af54ae7dbee6 | 7 | 0 |
"""Minimal terminal chat REPL against the Anthropic, OpenAI, or Google (Gemini) API --
the "browser-free" AI backends (see ai_backend.py): real access to Claude, ChatGPT, or
Gemini without ever opening an actual browser tab, which is the point of keeping the
user inside the terminal. Deliberately bare-bones: one conver... | mukund1312/mtdo | src/mtdo/web_chat.py | .py | 5e2dda83e48dcea0 | 7 | 0 |
"""mtdo's config module reads MTDO_HOME into a module-level constant
(config.APP_DIR) at import time -- see config.py's own comment on that. That
means MTDO_HOME has to be set, and pointed at a scratch directory, before
`mtdo` is imported anywhere, by anything, in this process. pytest always
imports a directory's conft... | mukund1312/mtdo | tests/conftest.py | .py | c6d81bdd5e42a2ef | 7.5 | 0 |
"""Regression tests for gh18: the now-playing position froze instead of ticking in
real time for YouTube Music playing in a browser tab. Confirmed live against a real,
currently-playing WebKit (browser) MediaRemote session on a real machine before
writing any fix: kMRMediaRemoteNowPlayingInfoElapsedTime stayed at a lit... | mukund1312/mtdo | tests/test_music.py | .py | 250623275d2d0163 | 7.5 | 0 |
"""Regression tests for radio.py -- the internal internet-radio player added
alongside music.py's external-player remote control. No real subprocess, audio,
or network is ever touched here (same isolation strategy as test_music.py):
`subprocess.Popen` is mocked for start()/stop(), and the ffmpeg-stderr level
parser (_r... | mukund1312/mtdo | tests/test_radio.py | .py | 056762bd97dbd347 | 7.5 | 0 |
"""Baseline smoke tests -- the minimum a CI run should catch: the package
imports cleanly, and the app actually mounts and reaches its normal board
screen without raising, using the real sandbox-style flow (fresh MTDO_HOME,
first-run prompts included) rather than any mocked-out shortcut.
"""
from mtdo.app import Kanban... | mukund1312/mtdo | tests/test_smoke.py | .py | b381b08dddb14458 | 7.5 | 0 |
"""Tests for the Knowledge Vault's "paste a YouTube URL" -> AI notes + quiz
feature (gh23). Split deliberately by what needs network/yt-dlp and what doesn't:
- The caption text-cleanup logic (_vtt_to_text/_merge_overlap) is pure string
processing and runs unconditionally -- no network, no yt-dlp import needed. This
... | mukund1312/mtdo | tests/test_youtube_notes.py | .py | 1d06cfb701581be3 | 7.5 | 0 |
import requests
import pandas as pd
import MeCab
from wordcloud import WordCloud
import matplotlib.pyplot as plt
import matplotlib.font_manager as fm
import numpy as np
from collections import Counter
import os
import time
import re
import glob
from typing import List, Dict, Optional
from datetime import datetime
# 定数... | RyoMatsumura8/qiita-title-analyzer | qiita_analysis.py | .py | ea139c1ed924e521 | 7.15 | 1 |
"""Base model contract for local and remote model integrations.
This module defines the ModelResponse telemetry structure and the abstract
BaseModel interface used by model provider implementations.
"""
from abc import ABC, abstractmethod
from dataclasses import dataclass
@dataclass
class ModelResponse:
content... | potterheadk/An-Intelligent-System | models/base.py | .py | 75e29580a6d09a79 | 7 | 0 |
"""SQLite storage engine.
Provides SQLite persistence for Phase 0 telemetry trace logging, as well as
tables for Phase 1 codebase chunks and symbol metadata.
"""
import json
import sqlite3
from pathlib import Path
from typing import Any
from models.base import ModelResponse
from core.config import settings
class SQ... | potterheadk/An-Intelligent-System | storage/sqlite_store.py | .py | 247aa07d227c78e6 | 7 | 0 |
"""ONC credential handling for BoatPhone.
Resolution order, and it matters: **the process environment WINS over `.env`.**
An `ONC_TOKEN` exported in the shell or set by a scheduler overrides whatever a
checked-out `.env` happens to say, so a stale file can never quietly shadow the
credential you deliberately supplied.... | oceanhackweek/ohw26_proj_BoatPhone | boatphone/credentials.py | .py | a6f401f89b64ed73 | 7 | 0 |
"""Report which BoatPhone dependencies are present, and at what version.
Standard library only. Run:
python3 -m boatphone.env_audit # report, always exits 0
python3 -m boatphone.env_audit --strict # non-zero if a REQUIRED package is absent
Versions resolve via `importlib.metadata`, not `pkg.__vers... | oceanhackweek/ohw26_proj_BoatPhone | boatphone/env_audit.py | .py | fe9a762ae8cfd9bd | 7 | 0 |
"""Canonical filesystem locations for BoatPhone.
Standard library only -- see boatphone/__init__.py for why.
One definition of every directory, shared by every notebook (CLAUDE.md invariant 6:
no magic strings, one definition, source in a comment). `data/` is immutable
(docs/decisions/0001-raw-data-immutability.md); ... | oceanhackweek/ohw26_proj_BoatPhone | boatphone/paths.py | .py | 17f2013733f519f8 | 7 | 0 |
#!/usr/bin/env python3
"""B0-1: acquire and pin the external ONC model artefacts.
Runnable entry point. It DEFINES NOTHING SHARED (CLAUDE.md invariant 6): the
destination directories come from `boatphone.paths` (EXTERNAL_DIR,
ONC_MODEL_DIR, CHECKPOINT_DIR); this script only does the fetching and writes
the provenance ... | oceanhackweek/ohw26_proj_BoatPhone | scripts/fetch_onc_model.py | .py | f96252d8ee81e28d | 7 | 0 |
"""Building the briefing from analysed events.
One rule governs this stage: **a story without a model-written summary is dropped, not
published.** The alternative would be to fall back to the article's own headline and
summary, which reads fine and is exactly the failure the product exists to avoid — a
briefing that q... | Mani5266/ai-pulse | app/briefing/builder.py | .py | e8714c9feb06853e | 7 | 0 |
"""The briefing: the pipeline's output, as data.
A briefing is built once as a structured record and then rendered twice — to Telegram and
to HTML. Rendering from shared data rather than formatting twice is what keeps the two
outputs from drifting apart, and it is why the P8 timeline can re-render history without
re-r... | Mani5266/ai-pulse | app/briefing/models.py | .py | b49b3a73408f3bf5 | 7 | 0 |
"""Rendering a briefing as a static HTML page.
The public artefact. No framework, no build step, no JavaScript, no external requests: a
single self-contained file per day, which is what makes GitHub Pages a complete hosting
solution rather than a compromise.
The same escaping rule as the Telegram renderer applies, fo... | Mani5266/ai-pulse | app/briefing/render_html.py | .py | 2d9366b6bd043735 | 7 | 0 |
"""Rendering a briefing as a Telegram message.
Two constraints shape everything here.
**Length.** Telegram rejects a message over 4,096 characters, and the product promises a
sixty-second read, which is shorter still. The renderer therefore trims to a budget rather
than hoping the model was brief, and the trimming is... | Mani5266/ai-pulse | app/briefing/render_telegram.py | .py | 5e7f16bf69384f1a | 7 | 0 |
"""Typed configuration, loaded from the environment and an optional .env file.
Nothing in the application reads ``os.environ`` directly; everything goes through
:func:`get_settings`. That keeps configuration testable and makes the full set of knobs
discoverable in one place.
"""
from __future__ import annotations
fr... | Mani5266/ai-pulse | app/core/config.py | .py | abf0eab7cbf02c92 | 7 | 0 |
"""Core domain models.
These are the records the pipeline passes between stages and persists as NDJSON.
Fields that later phases populate are optional here, so a P1 record and a P4 record
can live in the same file without a migration.
"""
from __future__ import annotations
from datetime import UTC, datetime
from enu... | Mani5266/ai-pulse | app/core/models.py | .py | 6cdd32f63f81a0b7 | 7 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.