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 |
|---|---|---|---|---|---|---|
"""Characterization tests for ``navi_bench.relative_dates``.
This module has no prior test coverage even though it feeds ground-truth date generation
for resy, opentable, and google_flights via ``dates.py``'s ``resolve_placeholder_values``.
These tests pin the current, verified-correct output of ``parse_relative_date`... | yutori-ai/navi-bench | tests/test_relative_dates.py | .py | d3e86d451a308eee | 8.15 | 19 |
"""Tests for ``safe_update``, extracted from the ``try: await evaluator.update(...) except
Exception: log + continue`` pattern that ``demo.py``'s human-agent-loop and
``evaluation/eval_n1.py``'s N1 eval step each hand-rolled against a live page that can
navigate away or throw mid-update.
"""
import pytest
from navi_b... | yutori-ai/navi-bench | tests/test_safe_update.py | .py | c46ccecfcdf99692 | 8.15 | 19 |
"""Characterization tests for the per-action "details" strings rendered inside each
step's action card by ``generate_visualization_html``.
These pin the behavior of ``_build_action_detail_lines`` (one ``if "<key>" in action: ...``
per recognized action field, plus an ``action_type``-specific block for form-recording
a... | yutori-ai/navi-bench | tests/test_vis.py | .py | beffae4d7edcc22a | 7.15 | 19 |
import os
import datetime
def process_file(filename, keep_lines, output_dir):
"""处理单个文件:按 #genre# 分组去重 + 追加更新标记"""
with open(filename, "r", encoding="utf-8") as f:
lines = f.readlines()
# 按 "#genre#" 分组
groups = []
current_group = []
for line in lines:
if ",#genre#"... | xiaoran67/update | assets/simple/simple.py | .py | 7cafef179f35d606 | 7.48 | 8 |
#!/usr/bin/env python3
"""
m3u-dedupe.py
Remove duplicate URLs from .m3u/.m3u8 playlists while keeping the first occurrence's metadata.
Usage:
python3 m3u-dedupe.py playlist.m3u
python3 m3u-dedupe.py /path/to/dir # will process all .m3u/.m3u8 files in that dir
"""
from pathlib import Path
import sys
def n... | Mr-DS-ML-85/IPTV-98 | automated_scan/rm-dupe.py | .py | c69f695e029d8ceb | 7.62 | 16 |
import re
# Regex for sheet refs in formulas:
# 'Sheet Name'! — quoted (required when name has space/hyphen/etc)
# SheetName! — unquoted (alphanumeric + underscore only)
# Quoted names may contain escaped quotes (''), but we ignore that edge case here.
_QUOTED_SHEET_REF = re.compile(r"'([^'!]+)'!")
_UNQUOTE... | cas-team-analyst/team-analyst | .claude/skills/excel-formulas/assets/archived-formula-scripts/modules/formulas.py | .py | 8791ef003516f717 | 7.52 | 10 |
# Formula verification: opens Complete Analysis.xlsx in Excel via win32com,
# force-recalculates, and compares formula results against Values Only.
# Windows-only (requires pywin32 and Excel).
#
# Called by 6b-create-values-only.py at the end of its run on Windows.
# Can also be imported and called directly: from modul... | cas-team-analyst/team-analyst | .claude/skills/excel-formulas/assets/archived-formula-scripts/modules/verify_formulas.py | .py | 3ee24336b4c50f53 | 7.52 | 10 |
# Calculates various statistics that help actuaries spot patterns and anomalies in the claims
# data. Computes metrics like average claim severity, payment percentages, closure rates, and
# other diagnostic measures that inform decisions about future claim development.
"""
goal: Create diagnostics that will support LD... | cas-team-analyst/team-analyst | sample-data/sample-run/scripts/1c-diagnostics.py | .py | 19a40cef5361f032 | 7.52 | 10 |
# Calculates multiple types of averages (weighted, simple, excluding outliers) for the loss
# development factors using different time periods (3, 5, 10 years, or all available data). Also
# computes quality metrics like volatility and trends to help actuaries pick the best average.
"""
goal: Calculate LDF averages an... | cas-team-analyst/team-analyst | sample-data/sample-run/scripts/1d-ldf-averages.py | .py | 8f24321eeddc0f61 | 7.52 | 10 |
# Creates a formatted Excel workbook that displays all the claims data, development factors,
# diagnostics, and calculated averages in an organized layout. Actuaries review this workbook and
# manually enter their selected factors based on the information presented.
"""
goal: Create Chain Ladder Selections.xlsx for ac... | cas-team-analyst/team-analyst | sample-data/sample-run/scripts/2a-chainladder-create-excel.py | .py | bca3e087f12ab1fb | 7.52 | 10 |
# Refreshes only the selections section of the Excel workbook based on saved selections from a
# JSON file. Allows you to update the displayed selections without rebuilding the entire workbook,
# which is useful when you need to revert changes or apply selections from another source.
"""
goal: Update ONLY the selectio... | cas-team-analyst/team-analyst | sample-data/sample-run/scripts/2b-chainladder-update-selections.py | .py | b9c1b684b19cf434 | 7.52 | 10 |
# Refreshes only the tail factor selections section of the Excel workbook based on saved
# selections from JSON files. Allows you to update the displayed selections without rebuilding
# the entire workbook, which is useful when you need to revert changes or apply selections from
# another source.
"""
goal: Update O... | cas-team-analyst/team-analyst | sample-data/sample-run/scripts/2e-tail-update-selections.py | .py | 2c001c6c9f079a44 | 7.52 | 10 |
# Computes initial expected ultimates by multiplying expected loss rates and frequencies
# by exposure to get expected ultimate losses and claim counts for each period.
#
# Fallback behavior:
# If the expected loss rates file is not provided, this script derives expected rates
# from diagonal data and exposure, smoothe... | cas-team-analyst/team-analyst | sample-data/sample-run/scripts/3-ie-ultimates.py | .py | 8daacf6d36608578 | 7.52 | 10 |
# Creates a formatted Excel workbook displaying projected ultimate indications from multiple
# reserving methods (Chain Ladder, Bornhuetter-Ferguson, etc.) alongside prior selections.
# Actuaries review this workbook and manually enter their selected ultimate values and reasoning.
"""
goal: Create Ultimates.xlsx for a... | cas-team-analyst/team-analyst | sample-data/sample-run/scripts/5a-ultimates-create-excel.py | .py | eb50ee999c935f6c | 7.52 | 10 |
# Refreshes only the selections section of the Ultimates Excel workbook based on saved selections
# from the ultimates-ai-framework-loss.json, ultimates-ai-framework-count.json,
# ultimates-ai-open-ended-loss.json, and ultimates-ai-open-ended-count.json files.
# Allows you to update the displayed selections without ... | cas-team-analyst/team-analyst | sample-data/sample-run/scripts/5b-ultimates-update-selections.py | .py | 2e885a37d1198b36 | 7.52 | 10 |
"""
Script 5c: Generate Summary of Indications
Reads Ultimates.xlsx (with user or AI selections), calculates total reserves by category,
and outputs summary for PROGRESS.md and REPORT.md Section 2.
Usage (run from scripts/ directory):
cd scripts/
python 5c-summary-indications.py
Inputs:
../selections/Ult... | cas-team-analyst/team-analyst | sample-data/sample-run/scripts/5c-summary-indications.py | .py | 6c39f960b57ada08 | 7.52 | 10 |
import pathlib
import numpy as np
import pandas as pd
from openpyxl import load_workbook
from modules.xl_values import UNPAID_PROXY
# Preferred display order for method columns — discovered dynamically from projected-ultimates.csv.
_METHOD_COLS = [
("ultimate_cl", "Chain Ladder"),
("ultimate_ie", "Initial Ex... | cas-team-analyst/team-analyst | sample-data/sample-run/scripts/modules/analysis_loaders.py | .py | 31362b6c554be133 | 7.52 | 10 |
"""Validation utilities for triangle and related data."""
import pandas as pd
from typing import List, Optional
__all__ = [
'validate_triangle_data',
'validate_exposure_data',
'validate_combined_data',
'validate_prior_selections',
'validate_expected_loss_rates'
]
def validate_triangle_data(df: p... | cas-team-analyst/team-analyst | sample-data/sample-run/scripts/modules/validators.py | .py | cac35427cd08c499 | 7.52 | 10 |
import copy
import numpy as np
import pandas as pd
def _safe(v):
"""Convert NaN/NA to None so openpyxl writes a blank cell."""
if v is None:
return None
try:
if pd.isna(v):
return None
except (TypeError, ValueError):
pass
return v
def _to_py(v):
"""
C... | cas-team-analyst/team-analyst | sample-data/sample-run/scripts/modules/xl_utils.py | .py | ff91620426ca3b64 | 7.52 | 10 |
#!/usr/bin/env python3
"""Aggregate individual run results into benchmark summary statistics.
Reads grading.json files from run directories and produces:
- run_summary with mean, stddev, min, max for each metric
- delta between with_skill and without_skill configurations
Usage:
python aggregate_benchmark.py <benc... | ni-kismet/systemlink-cli | .github/skills/skill-creator/scripts/aggregate_benchmark.py | .py | 792e3909038fe2b3 | 7.42 | 6 |
#!/usr/bin/env python3
"""Generate an HTML report from run_loop.py output.
Takes the JSON output from run_loop.py and generates a visual HTML report
showing each description attempt with check/x for each test case.
Distinguishes between train and test queries.
"""
import argparse
import html
import json
import sys
fr... | ni-kismet/systemlink-cli | .github/skills/skill-creator/scripts/generate_report.py | .py | 287dba9a3fd8a801 | 7.42 | 6 |
#!/usr/bin/env python3
"""Create a distributable .skill archive from a skill folder.
Usage:
python utils/package_skill.py <path/to/skill-folder> [output-directory]
Example:
python utils/package_skill.py skills/public/my-skill
python utils/package_skill.py skills/public/my-skill ./dist
"""
import fnmatch
... | ni-kismet/systemlink-cli | .github/skills/skill-creator/scripts/package_skill.py | .py | 468fcdc00e01d1bb | 7.42 | 6 |
#!/usr/bin/env python3
"""Run the eval + improve loop until all pass or max iterations reached.
Combines run_eval.py and improve_description.py in a loop, tracking history
and returning the best description found. Supports train/test split to prevent
overfitting.
"""
import argparse
import json
import random
import s... | ni-kismet/systemlink-cli | .github/skills/skill-creator/scripts/run_loop.py | .py | a964aac97ed587d6 | 7.42 | 6 |
"""Builds Homebrew formula for slcli with platform-specific binaries."""
import subprocess
import sys
import tomllib
from pathlib import Path
ROOT = Path(__file__).parent.parent.resolve()
DIST = ROOT / "dist"
LINUX_TARBALL = DIST / "slcli-linux.tar.gz"
MACOS_TARBALL = DIST / "slcli-macos.tar.gz"
MACOS_INTEL_TARBALL =... | ni-kismet/systemlink-cli | scripts/build_homebrew.py | .py | cfebc851a89880cc | 7.42 | 6 |
"""Builds a Scoop manifest for the slcli Windows binary and writes it to dist/scoop-slcli.json."""
import sys
import tomllib
from pathlib import Path
ROOT = Path(__file__).parent.parent.resolve()
DIST = ROOT / "dist"
SLCLI_ZIP = DIST / "slcli.zip"
MANIFEST_TEMPLATE = ROOT / "scripts" / "scoop-slcli.json.j2"
DIST_MANI... | ni-kismet/systemlink-cli | scripts/build_scoop.py | .py | 393a17646bbca0ec | 7.42 | 6 |
"""Post-process a CycloneDX SBOM to improve sbomqs quality score.
Enriches the SBOM generated by cyclonedx-py with:
- Metadata: authors, supplier, lifecycle, data license
- Component licenses from installed package metadata
- Component suppliers from author metadata
- Component hashes from distribution files
- Compone... | ni-kismet/systemlink-cli | scripts/enrich_sbom.py | .py | b89b52fe94834ae2 | 7.42 | 6 |
#!/usr/bin/env python3
"""Script to install shell completion for slcli."""
import os
import subprocess
import sys
from pathlib import Path
def install_bash_completion():
"""Install bash completion."""
home = Path.home()
# Try common bash completion directories
completion_dirs = [
home / ".ba... | ni-kismet/systemlink-cli | scripts/install_completion.py | .py | 76ee7cea17563a04 | 7.42 | 6 |
"""Convenience script to run style linting and formatting.
Default (no flags):
- Run style guide lint checks (non-modifying)
- Run black in check mode (no file changes)
With --fix:
- Run style guide lint checks (still non-modifying; separate fixer not provided)
- Run black to auto-format the codebase
... | ni-kismet/systemlink-cli | scripts/lint.py | .py | 18b1b3c0abfadf5c | 7.42 | 6 |
"""Generate and build a temporary hosted Angular webapp as a smoke test."""
import argparse
import subprocess
import sys
import tempfile
from pathlib import Path
from typing import Sequence
def _run_command(command: Sequence[str], cwd: Path | None = None) -> None:
"""Run a command and exit immediately if it fail... | ni-kismet/systemlink-cli | scripts/smoke_test_webapp.py | .py | 69e3a8e30fb84bda | 7.92 | 6 |
"""Repository-local replacement for the ni-python-styleguide command."""
from __future__ import annotations
import argparse
import subprocess
import sys
from pathlib import Path
from typing import Sequence
REPO_ROOT = Path(__file__).resolve().parent.parent
FLAKE8_CONFIG = REPO_ROOT / ".flake8"
PYPROJECT = REPO_ROOT ... | ni-kismet/systemlink-cli | scripts/styleguide.py | .py | c6a4db9a4f1612a1 | 7.42 | 6 |
"""Helpers for Towncrier-based versioning and changelog releases."""
from __future__ import annotations
import argparse
import subprocess
import sys
import tomllib
from pathlib import Path
from typing import Iterable, Optional, Sequence
from packaging.version import Version
PATCH_BUMP_TYPES = {"patch", "doc", "misc... | ni-kismet/systemlink-cli | scripts/towncrier_release.py | .py | 8d3fd89e885853c5 | 7.42 | 6 |
"""Unified table formatters for all CLI resource types."""
from datetime import datetime
from typing import Any, Callable, Dict, List, Optional
def format_templates_table(template: Dict[str, Any]) -> List[str]:
"""Format template data for table display."""
name = template.get("name", "Unknown")
version =... | ni-kismet/systemlink-cli | slcli/cli_formatters.py | .py | 4a1ad4d916e74141 | 7.42 | 6 |
"""Common utility functions for all CLI commands."""
import os
import sys
from typing import Any, Callable, Dict, List, Optional
import click
import questionary
import requests
from .rich_output import print_json, render_table
from .utils import ExitCodes, handle_api_error
def is_interactive_environment() -> bool:... | ni-kismet/systemlink-cli | slcli/cli_utils.py | .py | b576a018601e115b | 7.42 | 6 |
"""Shell completion functionality for slcli."""
import os
import subprocess
from pathlib import Path
from typing import Any, Dict, List, Optional
import click
def get_cli_commands_dynamically() -> Dict[str, List[str]]:
"""Extract commands and subcommands from the CLI structure dynamically.
Returns:
... | ni-kismet/systemlink-cli | slcli/completion_click.py | .py | 2989c63fed4b4fe8 | 7.42 | 6 |
"""Configuration management for slcli."""
import json
import os
from pathlib import Path
from typing import Dict, Optional
def get_config_file_path() -> Path:
"""Get the path to the slcli configuration file."""
# Use XDG_CONFIG_HOME if set, otherwise use ~/.config
if "XDG_CONFIG_HOME" in os.environ:
... | ni-kismet/systemlink-cli | slcli/config.py | .py | b5d54ffb572fcba4 | 7.42 | 6 |
"""CLI commands for managing example configurations."""
import json
import sys
from pathlib import Path
from typing import Any, Dict, List, Optional
import click
from .example_loader import ExampleLoader
from .example_provisioner import ExampleProvisioner, ProvisioningAction, ProvisioningResult
from .universal_handl... | ni-kismet/systemlink-cli | slcli/example_click.py | .py | 341152e7a7536bdb | 7.42 | 6 |
"""Load and validate example configurations."""
from pathlib import Path
from typing import Any, Dict, List, Optional
import yaml # type: ignore
class ExampleLoader:
"""Load and validate example configurations from local examples/ directory."""
# Supported schema versions
SUPPORTED_SCHEMA_VERSIONS = {... | ni-kismet/systemlink-cli | slcli/example_loader.py | .py | 3e874d70ff994ee5 | 7.42 | 6 |
"""CLI commands for the slcli MCP server.
Provides 'slcli mcp serve' and 'slcli mcp install' subcommands.
"""
import json
import platform
import shutil
import sys
from pathlib import Path
from typing import Any, Dict, List, Optional
import click
from .utils import ExitCodes
DEFAULT_STREAMABLE_HTTP_PORT = 8765
de... | ni-kismet/systemlink-cli | slcli/mcp_click.py | .py | 019d9627fa1d736c | 7.42 | 6 |
#!/usr/bin/env python3
"""
Cerberus host writer -- a careful, GENERIC UDS write driver over the Teensy USB serial.
Flow: read-before -> show plan -> confirm -> (10 03 extended session) ->
2E write -> read-back verify.
This is NOT a Component-Protection recipe. You supply the target ID, DID, and data,... | dspl1236/CerberusCAN | host/cerberus_write.py | .py | fe35414b1e499f0d | 7.45 | 7 |
"""
K-line (KW1281 / KWP2000) DTC + module decode — the VAG fault-LOCATION namespace.
This is SEPARATE from the CAN/UDS path: UDS service 0x19 returns SAE J2012 3-byte
codes (Pxxxx-FT), decoded by decode_dtc() in cerberus_console.py. K-line ECUs
(KW1281 0xFC / KWP2000 0x18) report a 16-bit VAG fault-location number in... | dspl1236/CerberusCAN | host/kline_decode.py | .py | 95622f6a02d750be | 7.45 | 7 |
"""
kwp_to_bin — reassemble a KWP2000 memory-read dump into a flat firmware image.
A KWP/UDS ReadMemoryByAddress (service 0x23) dump is a stream of addressed blocks.
Capturing those over the bus (Cerberus K-line / Head 3) gives you a `.kwp`-style file
of `[addr][len][data]` records; this maps them back into one contig... | dspl1236/CerberusCAN | host/kwp_to_bin.py | .py | ee4abf4538b66f91 | 7.45 | 7 |
"""
SAE J2012 / ISO 15031-6 generic OBD-II DTC text + ISO 14229 failure-type-byte meanings.
For the CAN/UDS path (service 0x19): a 3-byte DTC decodes to an SAE code (Pxxxx/Cxxxx/
Bxxxx/Uxxxx) + a failure-type byte (the "-XX"). This adds the English text. This is the
SAE namespace — SEPARATE from the VAG fault-location... | dspl1236/CerberusCAN | host/sae_decode.py | .py | af7a93d0fa4630cb | 7.45 | 7 |
"""
The-Gargantuas-Video-Editor - Main Application
AI-Powered Video Editing Suite - 100% Free!
"""
import warnings
import gradio as gr
import sys
import os
from pathlib import Path
import json
# Silence Gradio video conversion warnings (expected behavior)
warnings.filterwarnings('ignore', message='Video does not have ... | TheGargantuas/The-Gargantuas-Video-Editor | main.py | .py | f292ea865a01626d | 7.42 | 6 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
AI Background Remover Tab
Uses AI models to automatically remove backgrounds from images
"""
import gradio as gr
import logging
from pathlib import Path
from typing import Optional, Tuple
import numpy as np
from PIL import Image, ImageDraw
import tempfile
logger = lo... | TheGargantuas/The-Gargantuas-Video-Editor | tabs/background_remover_tab.py | .py | 625827b3c9f0c1ae | 7.42 | 6 |
"""
Face Enhancement Tab
AI-powered face and image enhancement without upscaling
"""
import os
import logging
import gradio as gr
from pathlib import Path
from typing import Optional, Tuple
import cv2
import numpy as np
from utils.detail_enhancer import DetailEnhancer, get_detail_model_choices
logger = logging.getLogg... | TheGargantuas/The-Gargantuas-Video-Editor | tabs/face_enhance_tab.py | .py | 3cd56c411e775ddf | 7.42 | 6 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
AI Image to Video Tab
Uses Stable Video Diffusion to generate videos from images
"""
import gradio as gr
import logging
from pathlib import Path
from typing import Optional, Tuple
from PIL import Image
import tempfile
import time
from datetime import datetime
logger ... | TheGargantuas/The-Gargantuas-Video-Editor | tabs/img_to_video_tab.py | .py | f5c467ac2e5c585e | 7.42 | 6 |
"""
Support Tab
Shows information about supporting the free app
"""
import gradio as gr
from config.config import (
YOUTUBE_CHANNEL_URL,
YOUTUBE_CHANNEL_HANDLE,
YOUTUBE_PLAYLIST_ID,
YOUTUBE_PLAYLIST_URL,
YOUTUBE_SUBSCRIBE_URL
)
class SupportTab:
"""Displays support information and YouTube cha... | TheGargantuas/The-Gargantuas-Video-Editor | tabs/support_tab.py | .py | f4ac415160765cc6 | 7.42 | 6 |
"""
Custom Gradio Theme
Amber, Red, Gray, Black, and White color scheme
"""
from gradio.themes.base import Base
from gradio.themes.utils import colors, fonts, sizes
import base64
from pathlib import Path
class CustomTheme(Base):
"""Custom theme with amber, red, gray, black, and white colors"""
def __init... | TheGargantuas/The-Gargantuas-Video-Editor | theme/custom_theme.py | .py | 859539e8679875fe | 7.42 | 6 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
API Key Manager with Encryption
Handles secure storage and retrieval of API keys
"""
import os
import base64
from pathlib import Path
from cryptography.fernet import Fernet
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.pbkdf... | TheGargantuas/The-Gargantuas-Video-Editor | utils/api_key_manager.py | .py | 1f792c65d156f999 | 7.42 | 6 |
"""
Audio countdown generator - adds beeps before audio starts
"""
import numpy as np
from scipy.io import wavfile
import subprocess
from pathlib import Path
import tempfile
def generate_beep(frequency=800, duration=0.15, sample_rate=44100):
"""Generate a beep tone"""
t = np.linspace(0, duration, int(sample_r... | TheGargantuas/The-Gargantuas-Video-Editor | utils/audio_countdown.py | .py | e7f9c88bd1676a17 | 7.42 | 6 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Dependency Compatibility Patch
Automatically resolves version conflicts between packages
"""
import subprocess
import sys
import logging
from typing import List, Tuple
logger = logging.getLogger(__name__)
# Define compatible versions for conflicting packages
COMPAT... | TheGargantuas/The-Gargantuas-Video-Editor | utils/dependency_patch.py | .py | 45c27deaacf9ea96 | 7.42 | 6 |
"""Detail enhancement utilities for post-upscaling image refinement."""
from __future__ import annotations
import logging
import shutil
from pathlib import Path
from typing import Dict, List, Optional, Tuple
import sys
import types
from urllib.parse import urlparse
import numpy as np
try: # pragma: no cover - opti... | TheGargantuas/The-Gargantuas-Video-Editor | utils/detail_enhancer.py | .py | 6f67b57031539fec | 7.42 | 6 |
"""
Device Manager
Handles device selection and management for AI models (CPU, CUDA GPU, MPS)
"""
import torch
import platform
class DeviceManager:
"""Manages compute device selection"""
def __init__(self):
self.available_devices = self._detect_devices()
self.current_device = self._get_de... | TheGargantuas/The-Gargantuas-Video-Editor | utils/device_manager.py | .py | 2a63058231e101e2 | 7.42 | 6 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
The Gargantuas Hybrid LipSync
Advanced lip-sync pipeline combining Wav2Lip GAN with face enhancement
"""
import logging
import cv2
import numpy as np
from pathlib import Path
from typing import Optional, Callable
import subprocess
import sys
import shutil
import tempf... | TheGargantuas/The-Gargantuas-Video-Editor | utils/hybrid_lipsync.py | .py | 7db73f52ea7dd72c | 7.42 | 6 |
"""
Internationalization (i18n) Manager
Gestisce le traduzioni dell'applicazione
"""
import json
import logging
from pathlib import Path
from typing import Dict, Any, Optional
logger = logging.getLogger(__name__)
class I18nManager:
"""Gestisce traduzioni e localizzazione"""
AVAILABLE_LANGUAGES = {
... | TheGargantuas/The-Gargantuas-Video-Editor | utils/i18n.py | .py | cd7f0a1b8cfa463b | 7.42 | 6 |
"""
LivePortrait checkpoint downloader
"""
import logging
from pathlib import Path
logger = logging.getLogger(__name__)
def download_liveportrait_checkpoints(pretrained_weights_dir):
"""
Download LivePortrait pretrained weights from HuggingFace using Python API
Args:
pretrained_weights_dir: ... | TheGargantuas/The-Gargantuas-Video-Editor | utils/liveportrait_downloader.py | .py | 1b51a24829a0e933 | 7.42 | 6 |
"""
Patch automatico per LivePortrait - Fix compatibilità NumPy 2.0+
Simile al patch di SadTalker, assicura compatibilità con NumPy 2.0+
rimuovendo gli alias deprecati np.float, np.int, np.bool
"""
import logging
from pathlib import Path
import re
logger = logging.getLogger(__name__)
def patch_liveportrait_numpy_c... | TheGargantuas/The-Gargantuas-Video-Editor | utils/liveportrait_patch.py | .py | dbff635eb1ca22f4 | 7.42 | 6 |
"""Utilities and HTTP client for the public Gradio upscaling API."""
from __future__ import annotations
import base64
import io
import json
import mimetypes
from pathlib import Path
from typing import Any
import numpy as np
import requests
from PIL import Image
UPSCALE_API_NAME = "upscale_image"
MODELS_API_NAME = ... | TheGargantuas/The-Gargantuas-Video-Editor | utils/remote_upscale.py | .py | cdcd397363eb0e48 | 7.42 | 6 |
"""
Patch automatico per SadTalker - Fix compatibilità NumPy 2.0+
NumPy 2.0 ha rimosso gli alias deprecati np.float, np.int, np.bool
Questo script applica automaticamente le correzioni necessarie ai file di SadTalker
"""
import logging
from pathlib import Path
import re
logger = logging.getLogger(__name__)
def pat... | TheGargantuas/The-Gargantuas-Video-Editor | utils/sadtalker_patch.py | .py | ebb5efe1855628f4 | 7.42 | 6 |
"""
Temporary Files Manager
Handles creation and cleanup of temporary files and directories
"""
import shutil
import atexit
from pathlib import Path
from config.config import TEMP_DIR
class TempManager:
"""Manages temporary files and directories"""
def __init__(self):
self.temp_dir = TEMP_DIR
... | TheGargantuas/The-Gargantuas-Video-Editor | utils/temp_manager.py | .py | 6b454c2b6eaddee7 | 7.42 | 6 |
#!/usr/bin/env python3
"""Fail if the committed tree drifts from the vendored specs.
Three checks, one job:
1. **Models vs ``spec/openapi.yaml``.** Regenerates the models into a temp file
and diffs against the committed one, so a spec edit without a regen (or a
hand-edit of the generated file) is caught. Mirror... | Comfy-Org/comfy-python-sdk | scripts/check_drift.py | .py | a18b67779282bc2e | 7.5 | 9 |
#!/usr/bin/env python3
"""Fail CI if the tree contains markers that only make sense in an internal
(private) context — this repo is public.
This is a lightweight regression guard, not a secrets scanner: it looks for
categories of internal-only references (ticket-style IDs, internal
collaboration-tool links, and repo n... | Comfy-Org/comfy-python-sdk | scripts/check_public_repo_hygiene.py | .py | 305f7545250c41d2 | 7.5 | 9 |
"""Streaming ``multipart/form-data`` body construction.
OpenAPI codegen routinely buffers an entire upload into memory to build the
request body; this module is the hand-written alternative the contract calls for.
The body is produced as a generator of byte chunks that reads the file part
lazily, and — when the file s... | Comfy-Org/comfy-python-sdk | src/comfy_low/_multipart.py | .py | 1e175a408f028329 | 7.5 | 9 |
"""The shared error envelope mapped to a typed exception per ``code``.
This is the ``comfy_low`` (protocol) view of errors: one class per documented
error ``code``, plus a fallback. ``comfy_sdk`` re-raises these as its own
idiomatic exceptions where it adds value (e.g. ``JobFailed`` carrying node
details), but the pro... | Comfy-Org/comfy-python-sdk | src/comfy_low/errors.py | .py | 0cd62385a0e491bb | 7.5 | 9 |
"""Sans-IO Server-Sent-Events decoding.
The decoder is pure and line-driven: feed it decoded text lines one at a time and
it yields complete events. Both the sync and async transports drive the same
decoder, so the wire-format parsing lives in exactly one place (the IO — reading
lines off a sync or async body — is the... | Comfy-Org/comfy-python-sdk | src/comfy_low/sse.py | .py | b1ca67b7f08f5f26 | 7.5 | 9 |
"""Sans-IO core shared by the sync and async clients.
Everything here is pure decision logic — no network, no awaiting — so the sync
and async layers stay a thin IO shell over one implementation of the rules:
terminal-state detection, adaptive poll backoff, idempotency-key minting, the
``core/ASSET`` reference shape, ... | Comfy-Org/comfy-python-sdk | src/comfy_sdk/_core.py | .py | 483e6088327e7163 | 7.5 | 9 |
"""Local blake3 content hashing.
The hash is computed client-side purely as a *dedup hint* — the server always
recomputes it from the received bytes and that value is authoritative. We stream
the file in chunks so hashing a multi-GB input never buffers it whole.
"""
from __future__ import annotations
from typing imp... | Comfy-Org/comfy-python-sdk | src/comfy_sdk/_hashing.py | .py | 9810121232d9cb48 | 7.5 | 9 |
"""Content-addressed asset handles and their constructors.
``client.assets.from_*`` returns a **lazy** :class:`Asset` handle: no network at
construction. On first use (``commit``/``as_reference``/submit) the handle hashes
its bytes locally with blake3, probes the server's dedup fast-path
(``HEAD by-hash`` then ``from-... | Comfy-Org/comfy-python-sdk | src/comfy_sdk/assets.py | .py | 81e49a03512442f8 | 7.5 | 9 |
"""The clients integrators import: :class:`Comfy` (sync) and :class:`AsyncComfy`.
Both expose the same surface — ``assets`` / ``workflows`` / ``jobs`` constructor
namespaces, the ``models`` namespace, plus ``submit`` / ``run`` — over a shared
sans-IO core. Every namespace is bound to the client's own transport, so the... | Comfy-Org/comfy-python-sdk | src/comfy_sdk/client.py | .py | 18ed3cf5835c4d6f | 7.5 | 9 |
"""Idiomatic ``comfy_sdk`` exceptions.
These wrap the protocol-level ``comfy_low.ApiError`` codes with names an
integrator catches directly (``JobFailed``, ``QueueFull``, ...). ``to_sdk_error``
maps a raised ``ApiError`` to the right subclass; anything unmapped stays a
``ComfyError`` carrying the original code.
"""
f... | Comfy-Org/comfy-python-sdk | src/comfy_sdk/exceptions.py | .py | b461e963bd648556 | 7.5 | 9 |
"""The ``models`` namespace — ``client.models`` on an existing client.
Reached from a client you already constructed (``Comfy().models`` /
``AsyncComfy().models``) rather than built on its own, so it uses that client's
credentials, transport and timeout: one connection pool, one credential, one
place to configure both... | Comfy-Org/comfy-python-sdk | src/comfy_sdk/models.py | .py | de77b29fc3ed2a12 | 7.5 | 9 |
"""Workflow construction and mutation.
A :class:`Workflow` is a thin, local wrapper over the raw API-format graph. The
graph stays a freely-mutable ``dict`` (``wf.json``); ``set_input`` is sugar for
``wf.json[node][\"inputs\"][field] = value`` that also accepts an asset handle
(substituted into a ``core/ASSET`` object... | Comfy-Org/comfy-python-sdk | src/comfy_sdk/workflows.py | .py | 6bac44e428f33497 | 7.5 | 9 |
"""A stdlib-only stub of the Comfy API v2 server, run in a background thread.
Keeps the SDK's own test suite independent of a real v2 server or proxy. Each
test configures ``server.state`` to drive a specific scenario (dedup hit, hash
mismatch, queue-full-then-ok, SSE reconnect, ...); the ``server`` fixture points
the... | Comfy-Org/comfy-python-sdk | tests/conftest.py | .py | b0fe3864c7ee28a2 | 7 | 9 |
"""Asset upload lifecycle: dedup fast-path, streaming upload, hash-mismatch."""
from __future__ import annotations
import io
from datetime import datetime, timezone
import pytest
from comfy_sdk import Comfy, HashMismatch, NotFound
def test_dedup_fast_path_skips_upload(server, tmp_path) -> None:
# Pre-seed the... | Comfy-Org/comfy-python-sdk | tests/test_assets.py | .py | 43e40817ce405864 | 8 | 9 |
"""The async client mirrors the sync surface against the same stub server."""
from __future__ import annotations
import asyncio
import io
import pytest
import comfy_sdk.client as _client_module
from comfy_sdk import AsyncComfy, MissingAsset, NotFound, Progress, StatusChange
def _wf(client: AsyncComfy):
return... | Comfy-Org/comfy-python-sdk | tests/test_async.py | .py | 23255a00b96b5d5b | 7 | 9 |
"""Per-surface authentication: self-hosted needs no key; Cloud/serverless need one.
Locks in the core claim documented on ``Comfy``/``AsyncComfy`` (and in the
README): a client built with no ``api_key`` must send **no** ``Authorization``
header at all — not an empty one, none — because a self-hosted proxy has no
auth ... | Comfy-Org/comfy-python-sdk | tests/test_auth_headers.py | .py | 061ded195bc74b3c | 8 | 9 |
"""The bearer token must never leak to a host a signed download URL redirects to.
``GET /assets/{id}/content`` may serve bytes directly or ``302``-redirect to a
signed URL on a different host (a CDN or blob-storage origin, for example — see
``comfy_sdk/outputs.py``). ``httpx`` (with ``follow_redirects=True``, as the
t... | Comfy-Org/comfy-python-sdk | tests/test_content_redirect_security.py | .py | 6c1ac0575477cb25 | 8 | 9 |
"""Range-aware download and core/ASSET substitution into the workflow graph."""
from __future__ import annotations
import io
import pytest
from comfy_sdk import Comfy
from comfy_sdk._core import find_asset_handles, substitute_asset_handles
def _wf(client: Comfy):
return client.workflows.from_json({"3": {"clas... | Comfy-Org/comfy-python-sdk | tests/test_download_and_workflows.py | .py | 3be6ef54f4360903 | 8 | 9 |
"""How an error response on the wire becomes a typed exception.
`to_sdk_error` mapping the server's 404 codes to the typed `NotFound`, and
`error_from_envelope` reading the two body shapes this API answers in.
"""
from __future__ import annotations
import pytest
from comfy_low.errors import ApiError, QueueFull, err... | Comfy-Org/comfy-python-sdk | tests/test_error_mapping.py | .py | d0026b8289572c7b | 8 | 9 |
"""Typed-event construction for the event kinds the stub server never emits.
The stub only drives progress/preview/output/status frames with well-formed
data; the `log` event type and the preview base64-decode guard had no coverage.
"""
from __future__ import annotations
from comfy_low.sse import RawEvent
from comfy... | Comfy-Org/comfy-python-sdk | tests/test_event_types.py | .py | 10bd2791f896571a | 8 | 9 |
"""Typed SSE events and live reconnect-with-no-replay."""
from __future__ import annotations
from comfy_sdk import AsyncComfy, Comfy, OutputReady, Progress, StatusChange
def _wf(client: Comfy):
return client.workflows.from_json({"3": {"class_type": "KSampler", "inputs": {}}})
def test_typed_events_stream_to_t... | Comfy-Org/comfy-python-sdk | tests/test_events.py | .py | 3cdbe20ed2609914 | 8 | 9 |
"""Job.get_workflow() / AsyncJob.get_workflow() — GET /api/v2/jobs/{id}/workflow.
The stub server in conftest.py stands in for the real endpoint.
"""
from __future__ import annotations
import pytest
from comfy_sdk import AsyncComfy, Comfy, JobWorkflow, NotFound
def _wf(client: Comfy | AsyncComfy):
return clie... | Comfy-Org/comfy-python-sdk | tests/test_job_workflow.py | .py | d01abdaeb2e0f209 | 8 | 9 |
"""Job submission and lifecycle: poll-authoritative run, idempotent replay,
backpressure retry, and error -> typed-exception mapping.
"""
from __future__ import annotations
import time
import pytest
import comfy_sdk.client as _client_module
from comfy_low.errors import IdempotencyKeyReuse as LowIdempotencyKeyReuse
... | Comfy-Org/comfy-python-sdk | tests/test_jobs.py | .py | 31959d1ffab0e215 | 8 | 9 |
"""Low-layer decoding primitives: the SSE decoder and multipart size probe.
The suite only ever feeds the decoder well-formed JSON from the stub server, so
its comment/blank/malformed-frame branches were dark; and every upload test
passes an explicit `file_size`, so the size-probe fallback never ran.
"""
from __futur... | Comfy-Org/comfy-python-sdk | tests/test_low_decoding.py | .py | 03584e57665c4e7c | 8 | 9 |
"""``client.models`` — the model namespace on the existing client.
What makes it a namespace rather than a second client object: it is reachable
from a client you already constructed, and it reads that client's *live*
configuration — credentials, base URL, transport, timeout — instead of a copy
taken at construction. ... | Comfy-Org/comfy-python-sdk | tests/test_models_namespace.py | .py | 54e46cee8704ef0c | 8 | 9 |
"""The router binding is the vendored contract's, not this repo's.
Two things are read straight out of ``spec/router-openapi.yaml`` rather than
restated here:
* the closed error set it declares as ``x-comfy-error-types`` -- one entry per
wire value, each with the ``meaning`` prose the exception docstrings
reprodu... | Comfy-Org/comfy-python-sdk | tests/test_router_spec_contract.py | .py | aafc6e5d91a15062 | 8 | 9 |
"""Spec coverage: every operationId in spec/openapi.yaml must have a transport
function on both the sync and async ``comfy_low`` transports.
"""
from __future__ import annotations
from pathlib import Path
import pytest
import yaml
import comfy_low
from comfy_low.transport import AsyncComfyLow, ComfyLow
SPEC = Path... | Comfy-Org/comfy-python-sdk | tests/test_spec_coverage.py | .py | e49807e23d478741 | 8 | 9 |
"""events() must recover from a silently-stalled ("zombie") SSE connection
instead of blocking forever — a read-idle timeout trips, and the poll fallback
takes over. Regression for the long-job SSE hang."""
from __future__ import annotations
import time
import httpx
from comfy_low import transport
from comfy_sdk im... | Comfy-Org/comfy-python-sdk | tests/test_sse_idle.py | .py | 07b200ec255e0c92 | 8 | 9 |
"""The bearer token must never leak to a host other than the configured
``base_url``.
``job.urls.self`` / ``job.urls.events`` / ``job.urls.cancel`` are server-returned
absolute URLs that ``Job.refresh()`` / ``events()`` / ``cancel()`` hand straight
to the transport (see ``comfy_sdk/jobs.py``). Before this fix, ``_Prep... | Comfy-Org/comfy-python-sdk | tests/test_transport_security.py | .py | f676f552028d1280 | 8 | 9 |
"""The SDK identifies itself via ``User-Agent`` on every request (request
metadata, not telemetry — no phone-home), so adoption is measurable
server-side. An optional ``client_info`` lets an integration attribute its
own traffic via an ``app/{name}`` token, without clobbering the base identity.
"""
from __future__ imp... | Comfy-Org/comfy-python-sdk | tests/test_user_agent.py | .py | a7a648007a0e7f0a | 8 | 9 |
# Tlamatini Author Banner - do not remove
r"""
PLAYWRIGHTER LAUNCHER for the visible harnesses.
Angela, 2026-08-12: *"perhaps are you using Playwrighter or your shit?"* - the
harnesses were driving raw `playwright.sync_api` themselves. This is the
equivalent of `shoter_shot.py` for the browser: it copies the PLAYWRIGH... | XAIHT/Tlamatini | .claude/skills/tlamatini-daily-chat-test/harness/playwrighter_run.py | .py | 446193bdba6073c0 | 8.1 | 15 |
"""Dedicated metrics server for Prometheus scraping.
This module provides a separate FastAPI server for serving Prometheus metrics
on a dedicated port, keeping metrics separate from the main application.
"""
import asyncio
import contextlib
import logging
import os
import uvicorn
from fastapi import FastAPI
from fas... | SchweizerischeBundesbahnen/strictdoc-service | app/metrics_server.py | .py | c2c08ffbf1ec1833 | 7.48 | 8 |
"""Prometheus metrics collectors for StrictDoc service.
This module provides Prometheus metric collectors including counters, histograms,
gauges, and info metrics for monitoring export operations.
"""
import os
from prometheus_client import Counter, Gauge, Histogram, Info
from app.constants import VALID_EXPORT_FORM... | SchweizerischeBundesbahnen/strictdoc-service | app/prometheus_metrics.py | .py | 300e1b31caaf39c6 | 7.48 | 8 |
"""Utilities for input sanitization in the StrictDoc service."""
import re
def sanitize_for_logging(text: str, max_length: int = 1000) -> str:
"""
Sanitize text for safe logging by:
- Converting non-string input to string
- Removing all control characters
- Replacing newlines with spaces
- Tr... | SchweizerischeBundesbahnen/strictdoc-service | app/sanitization.py | .py | 7cd04cc9cae95d8d | 7.48 | 8 |
"""Internal metrics tracking for StrictDoc service.
This module provides thread-safe metrics tracking for export operations,
including counters, timing, and error rate calculations.
"""
import threading
import time
from dataclasses import dataclass, field
@dataclass
class StrictDocMetrics:
"""Thread-safe metric... | SchweizerischeBundesbahnen/strictdoc-service | app/strictdoc_metrics.py | .py | b3286763dd20eeae | 7.48 | 8 |
"""StrictDoc service application module."""
import argparse
import logging
import os
import sys
# Create a custom logger
logger = logging.getLogger(__name__)
# Constants
DEFAULT_PORT = 9083
def configure_logging() -> None:
"""Configure logging based on environment variable."""
log_level = os.getenv("LOG_LE... | SchweizerischeBundesbahnen/strictdoc-service | app/strictdoc_service_application.py | .py | 4a36460496f59cc6 | 7.48 | 8 |
"""Test configuration and fixtures."""
import logging
import time
from collections.abc import Generator
from dataclasses import dataclass
from http import HTTPStatus
import docker
import pytest
import requests
from _pytest.fixtures import FixtureRequest
from docker.errors import DockerException
from fastapi.testclien... | SchweizerischeBundesbahnen/strictdoc-service | tests/conftest.py | .py | 08a1e24634ce06a7 | 7.98 | 8 |
"""Export test configuration and fixtures."""
import logging
import time
from collections.abc import Generator
from http import HTTPStatus
import docker
import pytest
import requests
from docker.errors import DockerException
from fastapi.testclient import TestClient
from app.strictdoc_controller import app
# Create... | SchweizerischeBundesbahnen/strictdoc-service | tests/export/conftest.py | .py | 8f02bedc0831d931 | 7.98 | 8 |
"""Integration tests for the export functionality using a real Docker container."""
import io
import zipfile
from http import HTTPStatus
import pytest
from tests.conftest import TestParameters
def test_version_endpoint(test_parameters: TestParameters) -> None:
"""Test that the version endpoint returns informat... | SchweizerischeBundesbahnen/strictdoc-service | tests/export/test_integration.py | .py | a152e3eae4a83b54 | 7.98 | 8 |
"""Tests for the dedicated metrics server."""
from unittest.mock import AsyncMock, patch
import pytest
from fastapi.testclient import TestClient
import app.metrics_server
from app.strictdoc_metrics import get_strictdoc_metrics, reset_strictdoc_metrics
@pytest.fixture(autouse=True)
def reset_metrics():
"""Reset... | SchweizerischeBundesbahnen/strictdoc-service | tests/test_metrics_server.py | .py | 3483f22bcb9af7da | 7.98 | 8 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.