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
"""Synthetic task generation for override cascade testing.""" import logging import random from dataclasses import dataclass from typing import List, Dict, Any, Optional from enum import Enum logger = logging.getLogger(__name__) class TaskCategory(Enum): """Categories of synthetic tasks.""" FILESYSTEM = "fi...
eddyayalagil/override-cascade-dspy
override_cascade_dspy/override_cascade/data/synthetic_tasks.py
.py
310478e11e35e262
7.24
2
"""Experiment for analyzing explanation voids in override cascade events.""" import logging import pandas as pd from dataclasses import dataclass from typing import List, Dict, Any, Optional import matplotlib.pyplot as plt import seaborn as sns from ..safety_belief import SafetyAssessor from ..completion_drive import...
eddyayalagil/override-cascade-dspy
override_cascade_dspy/override_cascade/experiments/explanation_void_analysis.py
.py
dc2eb62b72986501
7.24
2
"""Experiment for analyzing threshold dynamics in override cascades.""" import logging import numpy as np import pandas as pd from dataclasses import dataclass from typing import List, Dict, Any, Tuple, Optional import matplotlib.pyplot as plt from ..safety_belief import SafetyAssessor, SafetyBelief from ..completion...
eddyayalagil/override-cascade-dspy
override_cascade_dspy/override_cascade/experiments/threshold_dynamics.py
.py
dbf88063e30c02c0
7.24
2
"""Explanation generation modules for override cascade analysis.""" import logging from dataclasses import dataclass from typing import List, Dict, Any, Optional import dspy from .override_predictor import OverrideMoment logger = logging.getLogger(__name__) @dataclass class ExplanationVoid: """Represents the a...
eddyayalagil/override-cascade-dspy
override_cascade_dspy/override_cascade/explanation_generator.py
.py
f952197bbcbabae5
7.24
2
"""Intervention policy modules for preventing override cascades.""" import logging from dataclasses import dataclass from typing import List, Dict, Any, Optional, Callable from enum import Enum import dspy from .safety_belief import SafetyBelief from .completion_drive import CompletionDrive from .override_predictor i...
eddyayalagil/override-cascade-dspy
override_cascade_dspy/override_cascade/intervention_policy.py
.py
ec74961b9ad01e7f
7.24
2
"""Main module for override cascade detection and analysis.""" import logging import argparse from typing import List, Optional import dspy from .config import ExperimentConfig, setup_logging from .safety_belief import SafetyAssessor from .completion_drive import CompletionUrgencyEstimator from .override_predictor ...
eddyayalagil/override-cascade-dspy
override_cascade_dspy/override_cascade/main.py
.py
ca48d66138a5d2ca
7.24
2
"""Override cascade prediction modules.""" import logging from dataclasses import dataclass from typing import List, Dict, Any, Optional import dspy from .safety_belief import SafetyBelief from .completion_drive import CompletionDrive logger = logging.getLogger(__name__) @dataclass class OverrideMoment: """Rep...
eddyayalagil/override-cascade-dspy
override_cascade_dspy/override_cascade/override_predictor.py
.py
4e6eb79239dcee58
7.24
2
""" 规则提取模块 提供从文本中提取 adblock 规则的功能。 """ import re from typing import List, Optional, Tuple # Markdown 列表项前缀正则:- / * / + / 1. / 2) 等 _LIST_PREFIX_RE = re.compile(r'^\s*([-*+]|\d+[.)])\s+') # Markdown 图片语法 ![alt](url) _MARKDOWN_IMAGE_RE = re.compile(r'^!\[.*?\]\(.*?\)') # Markdown 链接语法 [text](url) —— 整行都是链接的情况 _MARKD...
Chaniug/AdSuper
scripts/rule_extractor.py
.py
69b15c2ad282fdea
7.24
2
""" 规则管理器 负责规则的加载、合并、去重、排序和原子写入保存。 """ import os import copy import tempfile from datetime import datetime from typing import List from .rule_validator import Rule, RuleValidator from .utils import log from . import config class RuleManager: """规则管理器""" def __init__(self, base_dir: str = '.'): """ ...
Chaniug/AdSuper
scripts/rule_manager.py
.py
1f3fe13dbd930b99
7.24
2
""" 规则验证器 提供 adblock 规则的格式验证、类型分类、冲突检测和排序功能。 """ import re from enum import Enum from dataclasses import dataclass, field from typing import List, Optional, Tuple from datetime import datetime class RuleType(Enum): """规则类型枚举""" DOMAIN = "domain" # 域名规则 ELEMENT = "element" # 元素规则 SCRIP...
Chaniug/AdSuper
scripts/rule_validator.py
.py
ae4f42be47934c00
7.24
2
""" AdSuper 规则同步主模块 从 GitHub Issues 中提取广告规则,验证后合并到 adnew.txt。 运行方式: python -m scripts.sync_issues """ import os import sys import traceback from typing import List from github import Github from . import config from .rule_validator import RuleValidator, Rule from .rule_manager import RuleManager from .rule_extr...
Chaniug/AdSuper
scripts/sync_issues.py
.py
4cd97341da5cb0d9
7.24
2
import logging import time import random from datetime import datetime from typing import Optional, Callable, Any from functools import wraps # 全局日志配置 _logging_configured = False _logger = None # GitHub API 重试配置 MAX_RETRIES = 5 BASE_DELAY = 2 # 基础延迟(秒) MAX_DELAY = 60 # 最大延迟(秒) def setup_logging(level: str = "INFO"...
Chaniug/AdSuper
scripts/utils.py
.py
3ece3942ff59e598
7.24
2
""" 规则提取器单元测试 """ import sys from pathlib import Path # 将项目根目录加入 sys.path,便于导入 scripts 包 sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) from scripts.rule_extractor import ( is_likely_rule, extract_code_blocks, extract_rules_from_text, extract_rules_from_issue, extract_inline_back...
Chaniug/AdSuper
tests/test_rule_extractor.py
.py
f85f23ea22ebfc6f
7.74
2
""" 规则管理器单元测试 """ import os import sys import tempfile from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) from scripts.rule_validator import Rule, RuleType from scripts.rule_manager import RuleManager class TestRuleManager: """测试 RuleManager 类""" def setup_method(self...
Chaniug/AdSuper
tests/test_rule_manager.py
.py
ce044c2e87044f2b
7.74
2
#!/usr/bin/env python # # @license Apache-2.0 # # Copyright (c) 2022 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # ...
stdlib-js/math-base-special-gammasgn
benchmark/python/scipy/benchmark.py
.py
2a8a862498c2a267
7.15
1
#!/usr/bin/env python # # @license Apache-2.0 # # Copyright (c) 2018 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # ...
stdlib-js/stats-base-dists-beta-kurtosis
benchmark/python/benchmark.scipy.py
.py
542b9947136fc8be
7.24
2
#!/usr/bin/env python # # @license Apache-2.0 # # Copyright (c) 2018 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # ...
stdlib-js/stats-base-dists-beta-mean
benchmark/python/benchmark.scipy.py
.py
73d79184867ad486
7.24
2
#!/usr/bin/env python # # @license Apache-2.0 # # Copyright (c) 2018 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # ...
stdlib-js/stats-base-dists-beta-skewness
benchmark/python/benchmark.scipy.py
.py
afa3299725c981fa
7.15
1
#!/usr/bin/env python # # @license Apache-2.0 # # Copyright (c) 2018 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # ...
stdlib-js/stats-base-dists-beta-stdev
benchmark/python/benchmark.scipy.py
.py
5d1f0768d2440e72
7.15
1
#!/usr/bin/env python # # @license Apache-2.0 # # Copyright (c) 2018 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # ...
stdlib-js/stats-base-dists-beta-stdev
test/fixtures/python/runner.py
.py
7281420c60a78471
7.65
1
#!/usr/bin/env python # # @license Apache-2.0 # # Copyright (c) 2018 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # ...
stdlib-js/stats-base-dists-beta-variance
benchmark/python/benchmark.scipy.py
.py
ef7005179c380de4
7.24
2
#!/usr/bin/env python # # @license Apache-2.0 # # Copyright (c) 2018 The Stdlib Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # ...
stdlib-js/stats-base-dists-betaprime-stdev
test/fixtures/python/runner.py
.py
65b44ad67f2ecb60
7.65
1
""" Test dataset for AdaSemSeg evaluation. Supports both K-shot random support selection and nearest-slice support selection (required for reproducing Table 1 and the Parihaka results in the paper). """ import sys sys.path.append('..') from PIL import Image from data.transform import Compose, Resize, ToTensor from tor...
Surojit-Utah/AdaSemSeg
methods/adasemseg/data/TestDataset.py
.py
5e1891c4b482f5f1
7.5
0
""" Whole-slide construction for AdaSemSeg evaluation, matching the paper's actual evaluation methodology (Section III-B, "Evaluation metrics" / "Experimental Setup"): "We use 2D patches of size 256x256 for all seismic datasets to train the AdaSemSeg ... However, we evaluate a trained model using whole sli...
Surojit-Utah/AdaSemSeg
methods/adasemseg/data/WholeSlideDataset.py
.py
adbe48b99aedfe92
7
0
import torch ''' https://github.com/joakimjohnander/DGPNet ''' def recursive_detach(data): """Recursively goes through a structure of lists and dicts and detaches all tensors """ if isinstance(data, dict): return {key: recursive_detach(val) for key, val in data.items()} elif isinstance(data, (...
Surojit-Utah/AdaSemSeg
methods/adasemseg/utils/recursive_functions.py
.py
e5cf4308261d262f
7
0
import numpy as np ''' Using the Confusion matrix computed using a unique mechanism: Adapted from https://github.com/yalaudah/facies_classification_benchmark/blob/main/core/metrics.py https://github.com/meetps/pytorch-semseg/blob/master/ptsemseg/metrics.py https://github.com/wkentaro/pytorch-fcn/blob/main/torchfcn/uti...
Surojit-Utah/AdaSemSeg
methods/baselines/Evaluation/predict/Metric_scores.py
.py
85d1199d6ee198d9
7
0
import torch def recursive_detach(data): """Recursively goes through a structure of lists and dicts and detaches all tensors """ if isinstance(data, dict): return {key: recursive_detach(val) for key, val in data.items()} elif isinstance(data, (list, tuple)): return [recursive_detach(el...
Surojit-Utah/AdaSemSeg
methods/baselines/Evaluation/utils/recursive_functions.py
.py
3cd8db5bc8faf180
7
0
import glob import os import psutil import gc from itertools import islice from collections import OrderedDict from datetime import datetime import matplotlib matplotlib.use('agg') import matplotlib.pyplot as plt plt.rcParams['image.cmap'] = 'gray' import numpy as np import torch import torch.nn as nn import time impor...
Surojit-Utah/AdaSemSeg
methods/baselines/Transfer_learning/train/DGP_trainer.py
.py
c173036d47949397
7
0
r""" # !!!!! Helper Script - Does not change the running config !!!!! References: https://stackoverflow.com/questions/6545023/how-to-sort-ip-addresses-stored-in-dictionary-in-python/6545090#6545090 https://stackoverflow.com/questions/20944483/python-3-sort-a-dict-by-its-values https://docs.python.org/3.3/tutorial/datas...
rikosintie/Discovery
arp.py
.py
a59100ab5fc5e229
7.3
3
""" usage python CX-Log-Parse-API.py -f logfile.txt -o output.csv Pull logs from a switch python CX-Log-Parse-API.py -i 192.168.10.233 -u admin -p 1 -o 01_lab.csv The password is never passed on the command line. Use -p 1 to be prompted for it, or set the environment variable: export cyberARK=your_password To view t...
rikosintie/Discovery
cx-log-parse-api.py
.py
ec2f56faba7276f4
7.3
3
def create_filename(sub_dir1: str, extension: str = "", sub_dir2="") -> str: """ returns a valid path regardless of the OS Args: sub_dir1 (str): name of the sub directory off the cwd required extension (str): string appended after hostname - ex. -interface.txt sub_dir2 (str, optiona...
rikosintie/Discovery
disc_functs.py
.py
5b6880d6fbd38ab1
7.3
3
r""" !!!!! Helper Script - Does not change the running config !!!!! This is for Cisco IOS to Aruba CX migration. Reads the Interface/<hostname>-interface.json file created by config-pull.py and builds a migration config snippet for two kinds of interfaces that are "up": uplinks (module 1 ports, matched by the ...
rikosintie/Discovery
migrate-ports.py
.py
70b674e80b793b5a
7.3
3
# !!!!! Helper Script - Runs on offline data !!!!! """ Reads the interface file (hostname-int_br.txt) created by procurve-Config-pull.py and builds a list of interfaces running at 10Mb full or half. Aruba and Cisco smartrate (mGig) ports do not support 10Mb connections. Returns: Nothing : a fi...
rikosintie/Discovery
procurve-10Mb.py
.py
32f0fbcdd4de5ed7
7.3
3
""" Creates a csv file from the cdp file with: "local_port" "neighbor_id" "neighbor_address" "neighbor_platform" "neighbor_port" Prints a table to the terminal Returns: Nothing - creates files in CR-data directory """ import argparse import csv import json import os ...
rikosintie/Discovery
procurve-cdp-ne-csv.py
.py
b34e58b565753639
7.3
3
# !!!!! Helper Script - Run on offline data !!!!! import argparse import json import os import sys from icecream import ic # ic.enable() ic.disable() __author__ = "Michael Hubbard" __author_email__ = "mhubbard@vectorusa.com" __copyright__ = "" __license__ = "Unlicense" # -*- coding: utf-8 -*- # pr...
rikosintie/Discovery
procurve-interface-in-use.py
.py
5c0e68659f8932d2
7.3
3
"""Command line interface.""" import contextlib import io import pathlib import shutil import subprocess import sys import tempfile import zipfile import httpx from pysdccc import _common try: import click except ImportError as import_error: raise ImportError('Cli not installed. Please install "pysdccc[cli]...
Draegerwerk/pysdccc
src/pysdccc/_cli.py
.py
8f98fd09d363cbb9
7
0
"""Contains commonly used constants and functions.""" import locale import os import pathlib import sys from collections.abc import Iterable, Mapping, Sequence import anyio DEFAULT_STORAGE_DIRECTORY = pathlib.Path(__file__).parent.joinpath('_sdccc') """Default directory to store the downloaded SDCcc versions.""" PA...
Draegerwerk/pysdccc
src/pysdccc/_common.py
.py
3686539f6ca332c0
7
0
"""Everything needed for downloading SDCcc.""" import concurrent.futures import contextlib import logging import os import subprocess import sys import zipfile from collections.abc import AsyncGenerator from typing import cast import anyio.from_thread import anyio.to_thread import httpx from pysdccc import _common, ...
Draegerwerk/pysdccc
src/pysdccc/_download.py
.py
6d8a4b5fbe482671
7
0
"""Parser for the JUnit XML test results provided by SDCcc including custom elements. This module provides classes to parse and handle JUnit XML test results with custom elements specific to SDCcc. It includes custom elements for test identifiers and descriptions, as well as custom test case and test suite classes. C...
Draegerwerk/pysdccc
src/pysdccc/_result_parser.py
.py
7ab59caddbc00b8e
7
0
"""Implements the runner for the SDCcc executable.""" import logging import pathlib import tomllib import typing from collections.abc import Callable, Mapping, Sequence import anyio from anyio.abc import ByteReceiveStream from anyio.streams.text import TextReceiveStream from pysdccc import _common from pysdccc._resu...
Draegerwerk/pysdccc
src/pysdccc/_runner.py
.py
7032582b320951ba
7
0
"""Implements the synchronous runner for the SDCcc executable.""" import concurrent.futures import functools import pathlib import sys import typing from collections.abc import Mapping import anyio import anyio.from_thread from pysdccc import _common, _runner from pysdccc._result_parser import TestSuite if sys.vers...
Draegerwerk/pysdccc
src/pysdccc/_runner_sync.py
.py
99ca043fa5cf863c
7
0
"""tests for the _cli module.""" import importlib import pathlib import random import subprocess import sys import uuid import zipfile from unittest import mock import click import httpx import pytest from click.testing import CliRunner import pysdccc import pysdccc._cli from pysdccc._cli import PATH, PROXY, _downlo...
Draegerwerk/pysdccc
tests/test_cli.py
.py
33f33a49c048bd62
7.5
0
"""Tests for the _common module.""" import pathlib import uuid from collections.abc import Mapping from unittest import mock import anyio import pytest from pysdccc import _common def test_build_command_no_args(): """Test that the build_command function works with no arguments.""" assert _common.build_comm...
Draegerwerk/pysdccc
tests/test_common.py
.py
d1fa4edef717eef0
7.5
0
"""Provides functions for downloading and verifying the presence of the SDCcc executable.""" import pathlib import uuid from unittest import mock import httpx import pytest from pysdccc._download import ( download, download_sync, install, is_downloaded, is_downloaded_sync, ) pytestmark = pytest....
Draegerwerk/pysdccc
tests/test_download.py
.py
f9894510667f9933
7.5
0
"""test for module result_parser.py.""" import pathlib import uuid from unittest import mock import pytest from junitparser import JUnitXml, junitparser from junitparser import TestCase as JUnitTestCase from junitparser import TestSuite as JUnitTestSuite from pysdccc._result_parser import TestCase, TestDescriptionEl...
Draegerwerk/pysdccc
tests/test_result_parser.py
.py
545cd9d410a037a9
7.5
0
"""tests for module runner.py.""" import pathlib import subprocess import uuid from unittest import mock import pytest from pysdccc._runner import ( SdcccRunner, ) from pysdccc._runner_sync import SdcccRunnerSync @mock.patch.object(SdcccRunner, '__init__', return_value=None) def test_sdccc_runner_init(mock_ini...
Draegerwerk/pysdccc
tests/test_runner_sync.py
.py
b4e0b2b28d47d316
7.5
0
#Author: Home Ops #Description: 19" 1RU Rack Mount Frame for Raspberry Pi - Based on uktricky's 10" design # # This is a 19" adaptation of the modular 10" homelab rack design. # Open frame construction with corner gussets for rigidity. # Fits 4 Raspberry Pis (vs 2 in the 10" version) import adsk.core, adsk.fusion, ads...
swibrow/home-ops
3d-prints/rack-mounts/1ru-raspberry-pi/PiRackFrame19in/PiRackFrame19in.py
.py
eb2bccd8dc76197e
7.3
3
#!/usr/bin/env python3 """Export the live Kanidm OAuth2 / account-policy state as reproducible `kanidm` CLI commands. Kanidm's OAuth2 clients and account policy are imperative state that lives only in the server's SQLite DB on the PVC (plus Volsync backups) — none of it is in git. This regenerates the `kanidm system o...
swibrow/home-ops
scripts/kanidm-export.py
.py
c7dbc3508d1c6863
7.3
3
#!/usr/bin/env python3 """Clustered target placement versus independent placement. Targets are drawn from a Thomas cluster process (cluster centres scattered over the grid, each spawning a Poisson-distributed number of targets with Gaussian scatter) truncated to the grid, with the intensity calibrated so the realised ...
roguebytes/uav-survey-strategy-simulation
clustering_analysis.py
.py
d0a926805e824140
7
0
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Sep 18 12:01:21 2024 Last updated Thu 19th Sep @author: frederic f.maire@qut.edu.au Some standard definitions: Precision (P): is the ratio of true positives to the sum of true positives and false positives: P = TP / (TP+FP) Recall (R): (als...
roguebytes/uav-survey-strategy-simulation
minefield_util.py
.py
de731375cc86600e
7
0
#!/usr/bin/env python3 """Generate the decision table under the (R, FPR) detector parameterisation. The detector is characterised by two density-independent per-cell probabilities, R = prob(flag | target cell) (recall, held at the target) FPR = prob(flag | empty cell) (false-positive rate) instead of ...
roguebytes/uav-survey-strategy-simulation
run_matrix_fpr.py
.py
33d80926fd2f0513
7
0
#!/usr/bin/env python3 """Compare NetworkX TSP solvers on the verification-flight graphs. Justifies the paper's choice of the greedy nearest-neighbour heuristic by comparing it against Christofides' 1.5-approximation at the four corners of the density-precision sweep. Reuses the EXACT field/flag generation from minef...
roguebytes/uav-survey-strategy-simulation
tsp_solver_comparison.py
.py
eea05dd7f08b2d5d
7
0
"""Sleep: replay, consolidation, forgetting. A mind that only ever writes memories accumulates; it does not learn. Sleep is where the day's episodes get sampled in proportion to how much they mattered, rehearsed through the novelty predictor (so what was striking becomes familiar), folded into concepts, and thinned ou...
Spyxpo/framerai
model/cognition/consolidation.py
.py
f4c700f280077fe2
7.15
1
"""Curiosity: what the mind goes looking for when nothing is asked of it. Two signals, because either one alone misbehaves. *Novelty* is random network distillation: a small predictor chases a frozen random target on the same embedding, and how badly it misses is how unfamiliar the input is. Training the predictor on...
Spyxpo/framerai
model/cognition/curiosity.py
.py
7d07b3c9ad2477de
7.15
1
"""Turning experience into a vector the mind can compare, store, and recall. Everything downstream - memory retrieval, concept formation, novelty - works on one fixed-width vector per experience, whatever modality it arrived in. This module is the only place that knows how those vectors are made. With a model attache...
Spyxpo/framerai
model/cognition/encoder.py
.py
286d095cdead1937
7.15
1
"""Language and script identification for everything the mind takes in. Two honest claims, kept separate. **Script coverage is total.** The tokenizer is byte-level BPE, so every UTF-8 string encodes - no alphabet is architecturally excluded. The table below maps Unicode ranges to writing systems across the world's sc...
Spyxpo/framerai
model/cognition/language.py
.py
96452b33b4c79267
7.15
1
"""Named model-size presets for FramerAI, from laptop-scale to a 3T flagship. Each preset is a set of :class:`FramerConfig` field overrides. Dense presets scale the classic decoder; MoE presets add sparse experts so *total* parameters grow into the hundreds-of-billions / trillion range while *active* (per-token) param...
Spyxpo/framerai
model/configs/presets.py
.py
6fb3127ef57e767f
7.15
1
"""Load global action hotkey bindings from `config.json`.""" from __future__ import annotations from dataclasses import dataclass from typing import Any from harrix_swiss_knife.config_model import load_app_config HOTKEYS_KEY = "hotkeys" @dataclass(frozen=True) class ActionHotkeyBinding: """One global hotkey b...
Harrix/harrix-swiss-knife
src/harrix_swiss_knife/action_hotkeys.py
.py
8ad6eed6baeb57fc
7
0
"""Build a clipboard snippet for an action class: name, class, relative path.""" from __future__ import annotations import inspect from pathlib import Path from typing import NamedTuple from harrix_swiss_knife.action_title import strip_md_inline_code_markers from harrix_swiss_knife.paths import get_project_root _PA...
Harrix/harrix-swiss-knife
src/harrix_swiss_knife/action_identity.py
.py
e4b193cbbfbb0800
7
0
"""Qt signal bus for streaming action output to the UI.""" from __future__ import annotations from typing import TYPE_CHECKING from PySide6.QtCore import QObject, Signal if TYPE_CHECKING: from pathlib import Path class ActionOutputBus(QObject): """Thread-safe bus for action output events (via queued Qt si...
Harrix/harrix-swiss-knife
src/harrix_swiss_knife/action_output_bus.py
.py
fb13ac7b25590d9e
7
0
"""Persist and load per-action invocation counts (GUI and CLI).""" from __future__ import annotations import json import logging import threading from datetime import UTC, datetime from typing import TYPE_CHECKING, Any, TypedDict from harrix_swiss_knife.paths import get_action_usage_path if TYPE_CHECKING: from ...
Harrix/harrix-swiss-knife
src/harrix_swiss_knife/action_usage.py
.py
08a7ad3d25ce51ac
7
0
"""Verify Android code quality (Spotless, Detekt, Android Lint).""" from __future__ import annotations import sys from pathlib import Path from typing import Any from harrix_swiss_knife.actions.common.base import ActionBase from harrix_swiss_knife.actions.common.android_gradle import ( ANDROID_SDK_SETUP_HINT, ...
Harrix/harrix-swiss-knife
src/harrix_swiss_knife/actions/android/android_check.py
.py
8ec68aa3367006f5
7
0
"""Format Android Kotlin sources via Spotless (ktlint).""" from __future__ import annotations import sys from pathlib import Path from typing import Any from harrix_swiss_knife.actions.common.base import ActionBase from harrix_swiss_knife.actions.common.android_gradle import ( ANDROID_SDK_SETUP_HINT, is_andr...
Harrix/harrix-swiss-knife
src/harrix_swiss_knife/actions/android/android_format.py
.py
7a3e87220e52a6f0
7
0
"""Install JDK 17 and the Android SDK for the `android/` module.""" from __future__ import annotations import shutil import subprocess import sys import zipfile from pathlib import Path from tempfile import TemporaryDirectory from typing import Any import harrix_pylib as h from harrix_swiss_knife.actions.common.and...
Harrix/harrix-swiss-knife
src/harrix_swiss_knife/actions/android/android_setup_sdk.py
.py
d820b9f3dd71e146
7
0
"""Beautify Markdown notes and optimize SVG files in a Vector Icons repo.""" from __future__ import annotations from typing import Any from harrix_swiss_knife.actions.apps.icon_repo import pick_vector_icons_repo from harrix_swiss_knife.actions.common.base import ActionBase from harrix_swiss_knife.apps.icons.repo_mai...
Harrix/harrix-swiss-knife
src/harrix_swiss_knife/actions/apps/beautify_and_optimize_icons.py
.py
6b185ef716fe095a
7
0
"""Check Vector Icons filenames, folders, categories, and Markdown notes.""" from __future__ import annotations from typing import Any from harrix_swiss_knife.actions.apps.icon_repo import pick_vector_icons_repo from harrix_swiss_knife.actions.common.base import ActionBase from harrix_swiss_knife.apps.icons.repo_mai...
Harrix/harrix-swiss-knife
src/harrix_swiss_knife/actions/apps/check_images.py
.py
635aa675c0ff65ef
7
0
"""Resolve a Vector Icons note repository for maintenance actions.""" from __future__ import annotations from pathlib import Path from typing import TYPE_CHECKING, Any from harrix_swiss_knife.apps.icons.catalog import is_note_icons_repo, resolve_icons_root if TYPE_CHECKING: from harrix_swiss_knife.actions.commo...
Harrix/harrix-swiss-knife
src/harrix_swiss_knife/actions/apps/icon_repo.py
.py
58ff517daea92279
7
0
"""Open the Quick paste overlay.""" from __future__ import annotations from typing import Any from harrix_swiss_knife.actions.common.base import ActionBase from harrix_swiss_knife.apps.snippets.dialog import SnippetsDialog class OnSnippets(ActionBase): """Show or hide the Quick paste overlay.""" icon = "�...
Harrix/harrix-swiss-knife
src/harrix_swiss_knife/actions/apps/snippets.py
.py
6093ae84936410c8
7
0
"""Shared helpers for Android Gradle actions (build / format / check).""" from __future__ import annotations import os import re import subprocess import sys from pathlib import Path from typing import Any import harrix_pylib as h if sys.platform == "win32": import ctypes import winreg else: # pragma: no c...
Harrix/harrix-swiss-knife
src/harrix_swiss_knife/actions/common/android_gradle.py
.py
0162fc6039f8406f
7
0
"""Base class for application launcher actions.""" from __future__ import annotations import importlib import traceback from typing import Any, ClassVar from PySide6.QtWidgets import QApplication from shiboken6 import isValid from harrix_swiss_knife.actions.common.base import ActionBase from harrix_swiss_knife.apps...
Harrix/harrix-swiss-knife
src/harrix_swiss_knife/actions/common/app_launcher.py
.py
6afdde67ef86e3c8
7
0
"""Adaptive geometry helpers for standard action dialogs.""" from __future__ import annotations from typing import TYPE_CHECKING from PySide6.QtCore import QPoint, QRect, QSize from PySide6.QtGui import QCursor, QGuiApplication from PySide6.QtWidgets import QApplication, QPlainTextEdit, QTextBrowser, QTextEdit, QWid...
Harrix/harrix-swiss-knife
src/harrix_swiss_knife/actions/common/dialog_geometry.py
.py
13023dc7d36e21b9
7
0
"""Shared Qt dialog widgets for action dialogs.""" from __future__ import annotations from html import escape from PySide6.QtCore import QModelIndex, QPersistentModelIndex, QSize, Qt from PySide6.QtGui import QPainter, QShowEvent, QTextDocument from PySide6.QtWidgets import ( QCheckBox, QDialog, QDialogB...
Harrix/harrix-swiss-knife
src/harrix_swiss_knife/actions/common/dialog_widgets.py
.py
ac77c59b0c70617d
7
0
"""Shared GitHub HTTPS helpers for development actions.""" from __future__ import annotations import os from pathlib import Path from typing import Any from urllib.parse import urlparse from harrix_swiss_knife.paths import get_project_root GITHUB_USER_AGENT = "harrix-swiss-knife" ALLOWED_HTTPS_SCHEMES = frozenset({...
Harrix/harrix-swiss-knife
src/harrix_swiss_knife/actions/common/github_https.py
.py
96b40521ca1fa11a
7
0
"""Shared image optimization for all supported formats.""" from __future__ import annotations import re import shutil from dataclasses import dataclass from pathlib import Path import harrix_pylib as h from harrix_swiss_knife.actions.common.raster_optimize import RASTER_EXTENSIONS, optimize_raster_file TOOL_EXTENS...
Harrix/harrix-swiss-knife
src/harrix_swiss_knife/actions/common/image_optimize.py
.py
76933e311bf897b5
7
0
"""Shared Markdown image optimisation helpers.""" from __future__ import annotations import re import shutil from pathlib import Path from tempfile import TemporaryDirectory import harrix_pylib as h from harrix_pylib.md_assets import is_featured_image_name from PIL import Image from harrix_swiss_knife.actions.commo...
Harrix/harrix-swiss-knife
src/harrix_swiss_knife/actions/common/md_image_optimize.py
.py
9cd5e1cde5aac06a
7
0
"""OCR helpers: recognize text in images and format as Markdown.""" from __future__ import annotations import os import re import shutil import warnings from pathlib import Path from typing import TYPE_CHECKING import numpy as np from PIL import Image if TYPE_CHECKING: import easyocr _DATE_IN_NAME = re.compile...
Harrix/harrix-swiss-knife
src/harrix_swiss_knife/actions/common/ocr_markdown.py
.py
83e910afc760d382
7
0
"""Shared quick launcher wiring for tray startup and the OnQuickLauncher action.""" from __future__ import annotations from typing import TYPE_CHECKING, Any from harrix_swiss_knife.actions.common.quick_launcher_dialog import QuickLauncherDialog from harrix_swiss_knife.actions.common.quick_launcher_registry import co...
Harrix/harrix-swiss-knife
src/harrix_swiss_knife/actions/common/quick_launcher_context.py
.py
2fd4cb76e5ca0175
7
0
"""Collect menu actions marked for the quick launcher overlay.""" from __future__ import annotations from typing import TYPE_CHECKING, Any if TYPE_CHECKING: from collections.abc import Iterator from harrix_swiss_knife.actions.common.base import ActionBase _MENU_SUBMENU_TUPLE_LEN = 3 def collect_quick_launche...
Harrix/harrix-swiss-knife
src/harrix_swiss_knife/actions/common/quick_launcher_registry.py
.py
06f811070b05c291
7
0
"""Raster image optimization using Pillow and ffmpeg.""" from __future__ import annotations import io import subprocess import tempfile from pathlib import Path from PIL import Image from harrix_swiss_knife.actions.common.subprocess_run import hidden_subprocess_kwargs RASTER_EXTENSIONS = frozenset({".png", ".jpg",...
Harrix/harrix-swiss-knife
src/harrix_swiss_knife/actions/common/raster_optimize.py
.py
08b4c60fe73b1fdc
7
0
"""Helpers for harrix.dev-style site article dual links.""" from __future__ import annotations import re from dataclasses import dataclass from pathlib import Path _LANG_RE = re.compile(r"^(en|ru)$", re.IGNORECASE) _YEAR_RE = re.compile(r"^\d{4}$") _H1_RE = re.compile(r"^#\s+(.+)$") _FRONTMATTER_RE = re.compile(r"\A...
Harrix/harrix-swiss-knife
src/harrix_swiss_knife/actions/common/site_article_links.py
.py
93ac0e83569397d0
7
0
"""Shared subprocess helpers with timeouts and argv lists.""" from __future__ import annotations import pathlib # noqa: TC003 import shutil import subprocess import sys from typing import Any DEFAULT_SUBPROCESS_TIMEOUT = 300.0 QT_OFFSCREEN_PLATFORM = "offscreen:size=1920x1080" def completed_process_output(process...
Harrix/harrix-swiss-knife
src/harrix_swiss_knife/actions/common/subprocess_run.py
.py
8ff5086ba058b489
7
0
import csv from datetime import date from env import CSV_PREFIX, CSV_PATH def load_history(years): """ Load participant data from multiple CSV files based on the specified history years. :param years: Number of years of history to load. :return: A list of all historical draw data. """ current_y...
jeanGaston/random-christmas-bot
src/file_io.py
.py
3ff703eb714efe0c
7
0
""" MIT License Copyright (c) 2024 Foxchip 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 to use, copy, modify, merge, publish, distr...
foxchip-fr/ebp-prestashop-connector
src/psebpconnector/dummy_handler.py
.py
2ce9d01bc78b1933
7
0
""" MIT License Copyright (c) 2024 Foxchip 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 to use, copy, modify, merge, publish, distr...
foxchip-fr/ebp-prestashop-connector
src/psebpconnector/models/model.py
.py
d5e3fe10f24778f2
7
0
#!/usr/bin/env python3 """Run graver's one-request live Find a Grave compatibility canary.""" from __future__ import annotations import argparse import json from graver._live_contract import LiveContractResult, run_live_contract def main() -> int: """Run the probe, print a safe report, and return its compatibi...
kinshipledger/graver
maintenance/live_canary.py
.py
83b268681ca57edd
7.24
2
"""Smoke-test an installed graver release artifact outside its source tree.""" from __future__ import annotations import subprocess import sys import tomllib from importlib.metadata import version from pathlib import Path from shutil import which from packaging.version import Version import graver import graver.app...
kinshipledger/graver
maintenance/release_smoke_test.py
.py
89c28bc7197f9f31
7.74
2
"""Internal SQLite connection lifecycle helpers.""" from __future__ import annotations import sqlite3 from os import PathLike from typing import Any class ClosingConnection(sqlite3.Connection): """Commit or roll back on context exit, then always close the connection.""" def __exit__(self, exc_type, exc_val...
kinshipledger/graver
src/graver/_sqlite.py
.py
5c32737a427cd072
7.24
2
"""Stable, presentation-neutral application error contracts.""" from __future__ import annotations from types import MappingProxyType from typing import Any, ClassVar, Mapping, Optional __all__ = ( "ApplicationError", "DatabaseBusy", "DatabaseOperationError", ) class ApplicationError(Exception): ""...
kinshipledger/graver
src/graver/errors.py
.py
743d1aa34890c9e9
7.24
2
"""Toolkit-neutral progress and cooperative cancellation contracts.""" from __future__ import annotations import threading from dataclasses import dataclass from typing import Optional, Protocol from graver.errors import ApplicationError __all__ = ( "CancellationRequested", "CancellationToken", "Progres...
kinshipledger/graver
src/graver/progress.py
.py
c5a2e0bd27d7efec
7.24
2
"""Internal synchronous HTTP transport for graver acquisition. Third-party client and response types stop at this module. The application and parser layers consume only the deliberately small graver-owned protocol below. """ from dataclasses import dataclass from importlib.metadata import PackageNotFoundError, versi...
kinshipledger/graver
src/graver/transport.py
.py
da14d5802110c266
7.24
2
"""Synchronous typed workspace composition for non-CLI application clients.""" from __future__ import annotations import sqlite3 from dataclasses import dataclass from os import PathLike from pathlib import Path from typing import Callable, Optional from graver.acquisition import ( AcquisitionReceipt, Memori...
kinshipledger/graver
src/graver/workspace.py
.py
63d127d204f4e1db
7.24
2
import os import shlex import shutil from types import SimpleNamespace import pytest from betamax import Betamax from click.testing import Result from faker import Faker from typer.testing import CliRunner from graver import config as graver_config from graver.api import Driver, Memorial from graver.cli import app fr...
kinshipledger/graver
tests/conftest.py
.py
6371e2a0c06a7e28
7.74
2
import json import os class Test: """Load deterministic domain fixtures for the test suite.""" ROOT = os.path.dirname(os.path.abspath(__file__)) @staticmethod def load_memorial_from_json(filename: str): json_path = f"{Test.ROOT}/fixtures/memorials/{filename}.json" with open(json_path...
kinshipledger/graver
tests/test.py
.py
312b44edb133b773
7.74
2
"""Documentation contract tests.""" import re import xml.etree.ElementTree as ET from pathlib import Path import pytest pytestmark = pytest.mark.unit REPOSITORY_ROOT = Path(__file__).parents[1] MARKDOWN_LINK = re.compile(r"\[[^\]]+\]\(([^)]+)\)") SVG_ASSET = re.compile(r"!\[[^\]]*\]\((assets/[^)]+\.svg)\)") def t...
kinshipledger/graver
tests/test_documentation.py
.py
12c38e272340e31f
7.74
2
import requests import datetime import pathlib import json import os import yaml import vulners from os.path import join from enum import Enum from discord import Webhook, RequestsWebhookAdapter CIRCL_LU_URL = "https://cve.circl.lu/api/query" CVES_JSON_PATH = join(pathlib.Path(__file__).parent.absolute...
roomme13/cveupdate
botpeas.py
.py
61e8209e8ee7186f
7
0
from datetime import datetime def clean_multiline_string(input_string: str) -> str: """ General text helper for universal use. Clean up newline-separated multi-line raw strings and put them back together without any blank lines. Edit the "formatted" variable to either concat lines wi...
roomme13/cveupdate
core/formatters.py
.py
429f60190a83464f
7
0
# import datetime import os from datetime import datetime import requests #from discord import Webhook, RequestsWebhookAdapter from discord import SyncWebhook from core.epss import EPSSGopher # Example URL: https://www.cvedetails.com/cve/CVE-2023-41892/ CVE_URL = "https://www.cvedetails.com/cve" def ...
roomme13/cveupdate
core/notifiers.py
.py
2902900add81de26
7
0
import datetime import os import json import requests import time from typing import List, Dict import asyncio import aiohttp def fetch_proxies() -> List[Dict[str, str]]: """ 从代理网站爬取代理IP列表 """ # proxies.extend( # from_kuaidaili(url="https://free.kuaidaili.com/free/fps/", region="GLOBAL") #...
genkin-he/news
news/scripts/callbacks/before_actions.py
.py
a8cec1e07867417a
7.15
1
from textual.app import App, ComposeResult from textual.widgets import Footer, Label, Tabs NAMES = [ "Paul Atreidies", "Duke Leto Atreides", "Lady Jessica", "Gurney Halleck", "Baron Vladimir Harkonnen", "Glossu Rabban", "Chani", "Silgar", ] class TabsApp(App): """Demonstrates the ...
bellanov/google
tui/prototypes/tabs.py
.py
47e6c758e859f8b3
7
0
"""Tests for custom error models.""" import pytest from tui.domain.models.errors import ( EnvironmentVariableError, OrganizationNotFoundError, TUIError, ValidationError, ) @pytest.mark.unit class TestTUIError: """Tests for TUIError base exception.""" def test_tui_error_creation(self): ...
bellanov/google
tui/tests/models/test_errors.py
.py
03f443ce3923d445
7.5
0