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
""" Adds touch-style scrolling functionality to widgets that support scan_mark/scan_dragto. This module defines the `TouchScroller` class, which enables touch-style scrolling for widgets like Canvas or Text. The functionality includes axis locking and drag thresholds, making it suitable for handling intuitive touch ge...
HelloMorrisMoss/mahlo_popup
help_window/utils/touch_scroller.py
.py
3f67de8668848817
7
0
from tkinter import ttk from PIL import Image, ImageTk from ..utils.scaling import calculate_dimensions class HelpImage(ttk.Label): """ A self-scaling image widget for the ArticleViewer. Handles its own PhotoImage reference to prevent garbage collection. """ def __init__(self, parent, image_pat...
HelloMorrisMoss/mahlo_popup
help_window/widgets/image_viewer.py
.py
0bbc274a3acf3dba
7
0
import tkinter as tk from tkinter import ttk from typing import Dict, Any class HelpVideoPlayer(ttk.Frame): """ A standalone video player widget for the Help Window. Encapsulates tkVideoPlayer and its controls. """ def __init__(self, parent, video_path: str, metadata: dict = None, **kwargs): ...
HelloMorrisMoss/mahlo_popup
help_window/widgets/video_player.py
.py
fdc1587b75615b1e
7
0
import collections from dataclasses import dataclass from operator import attrgetter from typing import TYPE_CHECKING from exiftool import ExifToolHelper from rich.progress import track from reloci.file_info import FileInfo if TYPE_CHECKING: from pathlib import Path from reloci.renamer import BaseRenamer ...
153957/reloci
reloci/planner.py
.py
9f6e5f946851b61f
7.15
1
# cpf_disk_resolver.py import re def _build_mapper_map(sp_dict): """Parse 'dev mapper N' entries → {mapper_name: dm_device}.""" mapper_map = {} for key, value in sp_dict.items(): if not key.startswith("dev mapper "): continue # e.g. "lrwxrwxrwx 1 root root 7 May 8 vgdb-lvdb -...
murrayo/yaspe
cpf_disk_resolver.py
.py
75678c34215d4f89
7.3
3
import os import sys import tempfile sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from extract_sections import parse_toc_section_order, get_last_needed_section RHEL_TOC = """\ <html> <head><title>Test</title></head> <a id="Topofpage"></a> <table> <tr> <td><a href=#IRISALL>IRIS ...
murrayo/yaspe
tests/test_early_stop.py
.py
14613e6af30c6480
7.8
3
# tests/test_performance_analysis.py import sys, os sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import sqlite3 import tempfile import pandas as pd from datetime import datetime from performance_analysis import IRIS_PERIODS, METRIC_THRESHOLDS, Finding from performance_analysis impor...
murrayo/yaspe
tests/test_performance_analysis.py
.py
04d348fc41e792ae
7.8
3
import os import sys sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from extract_sections import build_section_ranges, read_ranges, extract_sections # Synthetic pButtons file, same shape as tests/test_early_stop.py, with an # iostat section and a tail that must never be parsed. SYNTH...
murrayo/yaspe
tests/test_section_seek.py
.py
fcb12879cfaaa8da
7.8
3
#!/usr/bin/env python3 """ Simplified VMStat Comparison - No Complex Time Alignment This version skips the complex time alignment and just compares the datasets as-is. """ import pandas as pd import matplotlib matplotlib.use("Agg") # Set non-interactive backend import matplotlib.pyplot as plt import seaborn as sns ...
murrayo/yaspe
vmstat_example.py
.py
2440b629041d0273
7.3
3
# yaspe_combined_overlay.py """ Combined vmstat+mgstat overlay chart: one Plotly HTML with CPU stacked areas and mgstat IO/routing lines. IO metrics share one right y-axis; each routing metric gets its own independent right y-axis. """ import os import sqlite3 import pandas as pd import plotly.graph_objects as go _...
murrayo/yaspe
yaspe_combined_overlay.py
.py
209704f028884bd2
7.3
3
""" Compare overlay charts: process all HTML files in a directory and produce one Plotly HTML overlay chart per vmstat/mgstat column. """ import os import re import sqlite3 from pathlib import Path import pandas as pd import plotly.graph_objects as go from plotly.subplots import make_subplots import sp_check _COLO...
murrayo/yaspe
yaspe_compare_overlay.py
.py
c49b7375467c98c1
7.3
3
import locale from datetime import datetime, timedelta import itertools import dateutil import dateutil.parser def check_keyword_exists(data, keyword): if isinstance(data, dict): if keyword in data: return True return any(check_keyword_exists(value, keyword) for value in data.values())...
murrayo/yaspe
yaspe_utilities.py
.py
c1f37af282e403bb
7.3
3
""" utils.py """ import logging import os import subprocess from pyocutil.static import APP_NAME def ensure_dir(f): folder = os.path.dirname(f) if folder != "" and not os.path.isdir(folder): os.makedirs(folder) def touch(f): if os.path.isfile(f): os.utime(f, None) else: wit...
veltzer/pyocutil
src/pyocutil/utils.py
.py
9868adec219b0a9e
7
0
""" All configurations for pygitpub """ from pytconf import Config, ParamCreator # The values github accepts in the "affiliation" parameter of its # "list repositories" api. They are sent over the wire verbatim. AFFILIATIONS = [ "owner", "collaborator", "organization_member", ] class ConfigGithub(Config)...
veltzer/pygitpub
src/pygitpub/configs.py
.py
d254936ab8b62c4b
7
0
""" misc.py """ import glob import logging import os import os.path from pygitpub import LOGGER_NAME def get_logger(): return logging.getLogger(LOGGER_NAME) def get_number_of_files(folder: str) -> int: count = 0 for _root, _directories, files in os.walk(folder): count += len(files) return ...
veltzer/pygitpub
src/pygitpub/utils/misc.py
.py
f8f2680cf0d8b501
7
0
""" This code checks goodreads ids of books """ import shelve import bs4 # type: ignore import requests import yaml CHEKC_ID_FOR_EVERY_BOOK = True def get_goodreads_data(f_goodreads_id, session): # print(f"retrieving {f_goodreads_id}...") url = f"https://www.goodreads.com/book/show/{f_goodreads_id}" ...
veltzer/pydatacheck
src/pydatacheck/data_check_books.py
.py
4ddbe4920cff7f91
7
0
""" Check that .yaml files have correct names of movies """ import importlib.util import pkgutil import shelve import yaml def _get_cinemagoer_class(): """ import Cinemagoer lazily, shimming pkgutil.find_loader for Python 3.14+ """ # cinemagoer (imdb) still uses pkgutil.find_loader, removed in Python 3.14 ...
veltzer/pydatacheck
src/pydatacheck/data_check_videos.py
.py
08406d0324f5a992
7
0
""" main entry point to the program """ import browsercookie import pylogconf.core from pytconf import config_arg_parse_and_launch, register_endpoint, register_main from pycookie.static import APP_NAME, DESCRIPTION, VERSION_STR @register_endpoint( description="dump cookies", configs=[ ], ) def dump_cook...
veltzer/pycookie
src/pycookie/main.py
.py
146cdc4f7662d4a4
7
0
""" utilities for C-like languages """ import typing from . import core, utils def escape_special_char(in_atom: core.Atom) -> str: """ if in_char is a special_character function returns its escape sequences otherwise it returns in_char """ special_chars = { r'"': r"\"", r"'": r"\...
vil02/string_to_code_proj
string_to_code/c_like_utils.py
.py
816ddfd8dca35be6
7.24
2
""" core functions of the string_to_code module """ import functools import random import typing Strings: typing.TypeAlias = list[str] class Atom(typing.NamedTuple): """represents a single character to be printed""" atom_char: str CalledListEntry: typing.TypeAlias = int | Atom InitialCall: typing.TypeAli...
vil02/string_to_code_proj
string_to_code/core.py
.py
7e25b9316dba0d69
7.24
2
""" Provides utilities related to: - querying available target languages, - calling proc-like functions, where target language is specified programmatically """ import importlib import pathlib def _remove_prefix(in_str: str, in_prefix: str) -> str: assert in_str.startswith(in_prefix) # nosec B101 return in_...
vil02/string_to_code_proj
string_to_code/string_to_code.py
.py
187bad3ec4dc5165
7.24
2
""" provides string_to_ada utilities """ from . import core, utils _get_function_name = utils.get_function_name_fun("Proc_") _NULL_CALL = "null;" def atom_to_code(in_atom: core.Atom) -> str: """ returns a string/piece of Ada code resulting in printing the in_atom.atom_char to the standard output ""...
vil02/string_to_code_proj
string_to_code/to_ada.py
.py
cad785638faac707
7.24
2
""" provides string_to_algol68 utilities """ from . import core, utils _get_function_name = utils.get_function_name_fun("p") def atom_to_code(in_atom: core.Atom) -> str: """ returns a string/piece of ALGOL 68 code resulting in printing the in_atom.atom_char to the standard output """ special_cha...
vil02/string_to_code_proj
string_to_code/to_algol68.py
.py
a14e373eaa826410
7.24
2
""" provides string_to_ballereina utilities """ from . import c_like_utils, core, utils _get_function_name = utils.get_function_name_fun("fun_") def atom_to_code(in_atom: core.Atom) -> str: """ returns a string/piece of ballerina code resulting in printing the in_atom.atom_char to the standard output ...
vil02/string_to_code_proj
string_to_code/to_ballerina.py
.py
b61ae1dca20dd4ef
7.24
2
""" provides string_to_bash utilities """ from . import core, utils _get_function_name = utils.get_function_name_fun() def atom_to_code(in_atom: core.Atom) -> str: """ returns a string/piece of bash code resulting in printing the in_atom.atom_char to the standard output """ special_chars = { ...
vil02/string_to_code_proj
string_to_code/to_bash.py
.py
8d89e30ab27b5f51
7.24
2
""" provides string_to_fortran90 utilities """ from . import core, utils _get_function_name = utils.get_function_name_fun("fun_") def _atom_to_code(in_atom: core.Atom) -> str: if in_atom.atom_char == "\n": return "write (*, *)" special_chars = { '"': "'\"'", "\t": "char(9)", } ...
vil02/string_to_code_proj
string_to_code/to_fortran90.py
.py
2acdc78fc12a5017
7.24
2
""" provides string_to_haskell utilities """ from . import core, utils _get_function_name = utils.get_function_name_fun() def atom_to_code(in_atom: core.Atom) -> str: """ returns a string/piece of bash code resulting in printing the in_atom.atom_char to the standard output """ special_chars = {r...
vil02/string_to_code_proj
string_to_code/to_haskell.py
.py
f67320f352b1a986
7.24
2
""" provides string_to_lisp utilities """ from . import core, utils _get_function_name = utils.get_function_name_fun() def atom_to_code(in_atom: core.Atom) -> str: """ returns a string/piece of lisp code resulting in printing the in_atom.atom_char to the standard output """ def proc_char(in_cha...
vil02/string_to_code_proj
string_to_code/to_lisp.py
.py
7eec55d03a380eab
7.24
2
""" provides string_to_lua utilities """ from . import core, utils def _get_table_name(**kwargs) -> str: return kwargs.get("table_name", "main") def _get_function_name(in_function_id: int, **kwargs) -> str: prefix = _get_table_name(**kwargs) + "." return prefix + kwargs.get("function_id_to_name", core....
vil02/string_to_code_proj
string_to_code/to_lua.py
.py
3e5845e8dba7c484
7.24
2
""" provides string_to_pascal utilities """ from . import c_like_utils, core, utils _get_function_name = utils.get_function_name_fun("p_") def atom_to_code(in_atom: core.Atom) -> str: """ returns a string/piece of Pascal code resulting in printing the in_atom.atom_char to the standard output """ ...
vil02/string_to_code_proj
string_to_code/to_pascal.py
.py
5635418651d8efd9
7.24
2
""" provides string_to_python utilities """ from . import core, utils _get_function_name = utils.get_function_name_fun() def atom_to_code(in_atom: core.Atom) -> str: """ returns a string/piece of python code resulting in printing the in_atom.atom_char to the standard output """ print_arg = "" ...
vil02/string_to_code_proj
string_to_code/to_python3.py
.py
09103e7590a9943e
7.24
2
""" provides string_to_rust utilities """ from . import c_like_utils, core, utils _get_function_name = utils.get_function_name_fun() def atom_to_code(in_atom: core.Atom) -> str: """ returns a string/piece of Rust code resulting in printing the in_atom.atom_char to the standard output """ if in_a...
vil02/string_to_code_proj
string_to_code/to_rust.py
.py
1467413a2877728b
7.24
2
""" utilities for to_some_language modules """ import typing from . import core def get_function_name_fun(in_prefix: str = "fun_"): """returns a function returning a function name based on id""" def _get_function_name(in_function_id: int, **kwargs) -> str: return kwargs.get("function_id_to_name", c...
vil02/string_to_code_proj
string_to_code/utils.py
.py
3fb5e18935c58338
7.24
2
""" imports all of the setup_*.py modules """ import importlib import pathlib _ALL_SETUP = [ importlib.import_module(_.stem) for _ in pathlib.Path(__file__).parent.glob("setup_*.py") ] def get_all_test_data(): """returns test-specific-description of each available language""" return [_.get_test_data...
vil02/string_to_code_proj
tests/all_language_data.py
.py
3fa0f2ca3bbe7119
7.74
2
"""pytest config file""" import collections import itertools import all_language_data import pytest import source_code_examples _ALL_TEST_DATA = all_language_data.get_all_test_data() def pytest_addoption(parser): """specifies command line options""" parser.addoption( "--iteration_size", act...
vil02/string_to_code_proj
tests/conftest.py
.py
03e0a658a5046697
7.74
2
""" general utilities for tests """ import collections import pathlib import subprocess # nosec B404 import typing Language = collections.namedtuple( "Language", [ "tool_names", "string_to_code", "printer_program_to_code", "run_code", "id", "source_code_file_ex...
vil02/string_to_code_proj
tests/general_utilities.py
.py
6196fdf22b0727dd
7.74
2
""" setup for the tests of the module string_to_ada """ import general_utilities as gu from string_to_code import to_ada def get_compiler(): """returns the name of the Ada compiler""" return "gnatmake" def _get_source_code_file_extension(): return "adb" def compile_code(in_code, tmp_folder): """...
vil02/string_to_code_proj
tests/setup_ada.py
.py
0789a397e1fbd57d
7.74
2
""" setup for the tests of the module string_to_ALGOL 68 """ import general_utilities as gu from string_to_code import to_algol68 def get_algol68_interpreter(): """returns the name of the ALGOL 68 interpreter""" return "a68g" def _get_source_code_file_extension(): return "alg" def run_algol68_code(i...
vil02/string_to_code_proj
tests/setup_algol68.py
.py
20e9d9dc9387a1e2
7.74
2
""" setup for the tests of the module string_to_ballerina """ import general_utilities as gu from string_to_code import to_ballerina def get_bal(): """returns the name of the ballerina interpreter""" return "bal" def _get_source_code_file_extension(): return "bal" def run_code(in_code, tmp_folder): ...
vil02/string_to_code_proj
tests/setup_ballerina.py
.py
eebaeccafe899963
7.74
2
from typing import Optional from ovos_config import Configuration from ovos_plugin_manager.dialog_transformers import find_dialog_transformer_plugins from ovos_plugin_manager.transformer_services import ( DialogTransformersService as _DialogTransformersService, TTSTransformersService as _TTSTransformersService...
OpenVoiceOS/ovos-audio
ovos_audio/transformers.py
.py
4a2abc2e3ef6562d
7.35
4
# Copyright 2017 Mycroft AI Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
OpenVoiceOS/ovos-audio
ovos_audio/utils.py
.py
91420680b69b425a
7.35
4
# Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the...
OpenVoiceOS/ovos-audio
test/end2end/test_audio_service_e2e.py
.py
ba7eb672604f431c
7.85
4
# Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the...
OpenVoiceOS/ovos-audio
test/end2end/test_playback_service_e2e.py
.py
acdb31f4414d6510
7.85
4
# Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the...
OpenVoiceOS/ovos-audio
test/unittests/test_utils.py
.py
6a46ca7aafae0610
7.85
4
"""Tests for ovos_audio.version and ovos_audio.tts.""" import unittest from unittest.mock import MagicMock, patch class TestVersion(unittest.TestCase): """Ensure version module exports correct fields.""" def test_version_constants_exist(self): from ovos_audio.version import VERSION_MAJOR, VERSION_MIN...
OpenVoiceOS/ovos-audio
test/unittests/test_version_and_tts.py
.py
1eea1ca2bf877832
7.85
4
#!/usr/bin/env python3 """ Validate Merewether simulation against ARR benchmark observation points. Reads the SWW output from outputs_1_1_1/ and compares peak stage at each of the 5 field observation points against the recorded field data. Usage: python examples/merewether/validation/validate.py Exit codes: ...
Hydrata/run_anuga
examples/merewether/validation/validate.py
.py
77383001f019f7b5
7
0
"""HTTP helper for control-server callbacks. Used by: * ``_handoff.py::report_resource_summary`` and ``_handoff.py::emit_early_resource_partial`` — they build the ``X-Internal-Token`` Session this module owns and hand it to ``gn_anuga.batch_common.emit`` for POST /api/v2/anuga/jobs/resource-report/. The resou...
Hydrata/run_anuga
run_anuga/_http.py
.py
7d9c4da71d88721c
7
0
"""Shared logging helper for run_anuga (TASK-1276). anuga_core (``anuga/utilities/log.py``) installs a *root* logger formatter that references ``%(mname)s`` / ``%(lnum)s`` (its own non-standard LogRecord fields). run_anuga's module loggers propagate their records up to that root handler, but run_anuga records don't ca...
Hydrata/run_anuga
run_anuga/_logging.py
.py
54d8b549afa85692
7
0
"""CLI entry point for run-anuga.""" import argparse import os import sys def resolve_package_dir(path): """Accept either a directory or a path to scenario.json, return the directory.""" path = os.path.abspath(path) if os.path.isfile(path): if os.path.basename(path) == "scenario.json": ...
Hydrata/run_anuga
run_anuga/cli.py
.py
026f26030d677ae5
7
0
""" Pydantic configuration model for scenario.json. Usage:: from run_anuga.config import ScenarioConfig config = ScenarioConfig.from_package("/path/to/package") print(config.run_label) # "run_42_1_7" print(config.model_dump()) # dict, suitable for JSON serialisation """ from __future__ im...
Hydrata/run_anuga
run_anuga/config.py
.py
c4733946990397ad
7
0
"""Thread-safe build-phase tracker for sub-phase memory attribution (TASK-1910). The cgroup ``memory.peak`` the resource sampler reads is a MONOTONIC whole-run high-water mark — a per-phase peak cannot be read from it directly. Instead the sampler thread TAGS each periodic RSS sample with the build phase that is activ...
Hydrata/run_anuga
run_anuga/phase_tracker.py
.py
91254c6eec9446f2
7
0
"""Array-level validator for a playback store (TASK-2622, W1.1, epic 2618). Checks a local Zarr v3 store directory against the signed schema (``docs/reports/2026-08-04-task-2619-playback-store-schema.html``, v1): required arrays, dtypes, shapes, codecs, chunk-key encoding, fill_value, and the per-array quantization at...
Hydrata/run_anuga
run_anuga/validate_playback_store.py
.py
9a0160207c2ce474
7
0
"""Component tests for create_boundary_polygon_from_boundaries(). Requires shapely (marked requires_geo). """ import json import os import pytest from run_anuga.run_utils import create_boundary_polygon_from_boundaries FIXTURE_DIR = os.path.join(os.path.dirname(__file__), "data", "minimal_package") def _make_boun...
Hydrata/run_anuga
tests/test_boundaries.py
.py
6ef213a71efd6063
7.5
0
"""Tests for run_anuga.callbacks — callback protocol and implementations. TASK-2681 (epic 2662 W4.1) DELETED HydrataCallback outright — its routes are 410 tombstones and TelemetryCallback is the one web reporter (covered in test_events_dialect.py). HISTORY — TASK-1049 (W1 of TASK-1048): HydrataCallback was rewritten t...
Hydrata/run_anuga
tests/test_callbacks.py
.py
2bcbf6552d3027d7
7.5
0
"""Tests for the catchment + rainfall combo branch of ``run_anuga.run_utils.apply_inflows_to_domain`` (TASK-882 / W3.0 followup). Covers two pre-existing bugs: * (a) The "multiple rainfall + catchment" guard must fail-fast BEFORE any ``Polygonal_rate_operator`` side effects are registered on the catchment. * (b) If...
Hydrata/run_anuga
tests/test_catchment_guard.py
.py
39d471294dfdc93d
7.5
0
"""Checkpoint tests — two complementary layers. 1. ``TestCheckpoint`` (requires ANUGA + dill): integration tests that run a real simulation and assert checkpoint pickle files are created. 2. ``TestCheckpointGate`` (pure-Python, TASK-1919): unit tests for the checkpoint write gate on the Batch / no-resume path. ...
Hydrata/run_anuga
tests/test_checkpoint.py
.py
027adbc64a55f226
7.5
0
"""Component tests for check_coordinates_are_in_polygon(). Requires shapely (marked requires_geo). """ import pytest from hypothesis import given from hypothesis import strategies as st from run_anuga.run_utils import check_coordinates_are_in_polygon @pytest.mark.requires_geo class TestCheckCoordinatesAreInPolygon...
Hydrata/run_anuga
tests/test_coordinate_checks.py
.py
7a2d8515266b5ea1
7.5
0
"""Tests for run_anuga.defaults — verify constant types and physically-justified ranges.""" import math from run_anuga import defaults def test_building_burn_height(): assert isinstance(defaults.BUILDING_BURN_HEIGHT_M, (int, float)) # Typical building height 2–15 m; 5 m is standard for flood modelling a...
Hydrata/run_anuga
tests/test_defaults.py
.py
8bacd15e006f1473
7.5
0
"""Contract test for the /process-result/ wire field name. TASK-1158 (Phase F0): the entrypoint previously POSTed the JSON field ``key``, but the V2 ``/process-result/`` endpoint reads ``result_package_key``. A Batch run that SUCCEEDED at simulation therefore lost its result key, and the run wedged in COMPUTING until ...
Hydrata/run_anuga
tests/test_entrypoint_contract.py
.py
79b1340cc4cfb32f
7.5
0
"""Tests for the TASK-1846 ANUGA resource-report retrofit (epic 1830 W4). Updated for TASK-1879: ``report_resource_summary`` now delegates to the shared ``gn_anuga.batch_common.emit.emit_resource_summary`` helper. The helper is imported via a guarded try/except inside the function (mirrors the existing ``_make_resour...
Hydrata/run_anuga
tests/test_handoff_resource_report.py
.py
577f26e593c4e489
7.5
0
"""Tests for run_anuga._http.post_to_control_server. Covers happy path (201), 4xx, 5xx, connection error, and the dispatch between POST and PATCH. Uses unittest.mock to match the existing test-suite style (responses lib is available but not used elsewhere). TASK-2692 (epic 2662 W5): the sample URL was ``/api/v2/anug...
Hydrata/run_anuga
tests/test_http_helper.py
.py
91a4299f3cefd3f4
7.5
0
"""Tests for run_anuga._imports — lazy import helper.""" import pytest from run_anuga._imports import import_optional def test_import_stdlib_module(): """Importing a stdlib module should succeed.""" mod = import_optional("json") assert hasattr(mod, "loads") def test_import_pydantic(): """Pydantic ...
Hydrata/run_anuga
tests/test_imports.py
.py
27ddd0fc32451a59
7.5
0
# Copyright 2026 UW-IT, University of Washington # SPDX-License-Identifier: Apache-2.0 import random import string from urllib.parse import urlparse, urlunparse from django.conf import settings from django.core.cache import cache from django.core.exceptions import ObjectDoesNotExist from uw_pws import PWS class Pho...
uw-it-aca/compass
compass/dao/photo.py
.py
a4fe84b57fe73c46
7
0
# Copyright 2026 UW-IT, University of Washington # SPDX-License-Identifier: Apache-2.0 import datetime from logging import getLogger from django.core.files.storage import default_storage from compass.dao.rad_csv import get_pred_csv_from_json from compass.models.rad_data import RADWeek logger = getLogger(__name__) ...
uw-it-aca/compass
compass/dao/storage.py
.py
46c42ae8e48ff26b
7
0
# Copyright 2026 UW-IT, University of Washington # SPDX-License-Identifier: Apache-2.0 import datetime from uw_sws.term import get_term_after, get_term_by_date from compass.dao import current_datetime TERMS = {1: "Winter", 2: "Spring", 3: "Summer", 4: "Autumn"} def current_term(): return get_term_by_date(cur...
uw-it-aca/compass
compass/dao/term.py
.py
6e0f813a81f1eefc
7
0
# Copyright 2026 UW-IT, University of Washington # SPDX-License-Identifier: Apache-2.0 from logging import Filter from asgiref.local import Local _local = Local() class UserFilter(Filter): """ Add user information to each log entry. """ def filter(self, record): record.user = getattr(_local, "user...
uw-it-aca/compass
compass/logging.py
.py
27ad1a987ab94e1a
7
0
""" This script updates the topic of a Slack channel with the current sprint information. """ import json import os from datetime import date, timedelta import requests def get_sprint_dates(year): """ Returns a dictionary with the start and end dates for each sprint in the year. Sprints: - are a...
managedkaos/100-days-of-code-bot
src/main.py
.py
75bc1709d6ed6012
7
0
""" Test functions for the main.py script """ import os from datetime import date, timedelta from main import get_topic def test_full_year_simulation(): """ This test function simulates a full year of running the main.py script by calling the prepare_and_update_topic function """ year = int(os.g...
managedkaos/100-days-of-code-bot
src/tests/test_full_year_simulation.py
.py
0766b5e455d26b60
7.5
0
""" Test the lambda_handler function locally. """ import json import os from unittest import TestCase from main import lambda_handler class TestLambdaFunction(TestCase): """ Test the lambda_handler function. """ def setUp(self): # Store the original SLACK_AUTH_TOKEN to restore it later ...
managedkaos/100-days-of-code-bot
src/tests/test_lambda_handler.py
.py
60decfa3e6589eee
7.5
0
""" Updates a customer managed VPC prefix list with the valid Google service CIDR ranges. These are determined by retrieving Google"s service CIDR range and subtracting the Google Cloud Platform CIDR ranges. Adapted from Google"s CIDR tool: https://github.com/GoogleCloudPlatform/networking-tools-python/tree/main/tool...
cds-snc/notification-lambdas
google-cidr/cidr.py
.py
1b15109f276aa5cd
7.15
1
import os import json import base64 import uuid import boto3 import pytest from moto import mock_sqs from ses_to_sqs_email_callbacks import lambda_handler # Import your Lambda function def sqs_event(num_records=10): """Generate a mock SQS event message with the specified number of records.""" record = { ...
cds-snc/notification-lambdas
sesemailcallbacks/test_ses_to_sqs_email_callbacks.py
.py
502222f95ce5e11e
7.65
1
""" Listens on receiving emails on SES in the us-east-1 region. Upon receiving an email, it will create a Celery send-notify-no-reply task to be put onto the notify-internal-tasks SQS queue. This will automatically get picked up by the Celery worker which will send a no-reply email to the recipients. The lambda wil...
cds-snc/notification-lambdas
sesreceivingemails/ses_receiving_emails.py
.py
ce8232c0f1018758
7.15
1
import polars as pl class BalanceBase: def __init__(self, data: pl.DataFrame = pl.DataFrame()): self._data = data @property def balance(self) -> list[dict]: """ Return [{'date': datetime.datetime, 'title': float}] """ return [] if self.is_empty(self._data) else sel...
nezinomas/keeping
project/bookkeeping/lib/balance_base.py
.py
56cbbeab4a8d34f0
7.15
1
import calendar from datetime import date import polars as pl class DateRangeProvider: @staticmethod def get_dates(year: int, month: int | None = None) -> pl.DataFrame: if month: days = calendar.monthrange(year, month)[1] dates = [date(year, month, d) for d in range(1, days + ...
nezinomas/keeping
project/bookkeeping/lib/make_dataframe.py
.py
dafb1abd83ba4099
7.15
1
"""``analyse_text`` (plan T-P2.4, ``DESIGN.md`` section 6.8). Two failure modes matter, and they pull in opposite directions: claiming too little means `guess_lexer` never finds PSS, and claiming too much means PSS steals files from SystemVerilog and C. The second is worse -- someone who writes ```` ```pss ```` was ne...
PSSTools/pygments-pss
tests/test_analyse_text.py
.py
515ba1740153fd7e
7.5
0
"""Packaging tests (plan section 3.5). These are the only tests that exercise the installed distribution rather than the module: the ``pygments.lexers`` entry point, the aliases, and the console path. Nothing in the unit suite would notice if the metadata broke. """ import subprocess import sys import textwrap impor...
PSSTools/pygments-pss
tests/test_entry_point.py
.py
946e075f4914374f
7.5
0
"""Rule assertions swept over the whole corpus (plan section 3.3). The highest value-per-line tests available. R2 in particular is the one that catches a runaway state, which produces perfectly *valid* tokens and so slips straight past an error check. """ from __future__ import annotations import time from pathlib i...
PSSTools/pygments-pss
tests/test_no_error_tokens.py
.py
687c695cd34241e1
7.5
0
"""Lexer options (plan section 3.6). Targeted assertions per option; the full cross-product is swept for R1-R3 in ``test_no_error_tokens.py::test_r5_...``. Options land phase by phase, so this file grows: ``dialect`` (T6.1/T6.2) with P3.1 and ``builtins`` (T6.3) with P2.5. """ from __future__ import annotations impo...
PSSTools/pygments-pss
tests/test_options.py
.py
9ea2f9797079a4ad
7.5
0
"""Golden token dumps (plan section 3.4, ``DESIGN.md`` section 8.2). One snippet per ordering constraint in ``DESIGN.md`` section 6.3, one per keyword bucket in section 6.2, one per construct in section 7. These are what make a taxonomy change *reviewable*: the diff of a ``.tokens`` file says exactly what the reader w...
PSSTools/pygments-pss
tests/test_snippets.py
.py
73544d3e1edfc63b
7.5
0
"""Drift guards between ``pssparser``'s grammar and ``_keywords.py``. Marked ``upstream``: a ``pssparser`` keyword addition must **fail** CI, not skip it. The whole point of generating the vocabulary (``DESIGN.md`` section 5) is that a new 3.x keyword can never quietly lex as an ordinary identifier, and a guard that s...
PSSTools/pygments-pss
tests/test_vocabulary_sync.py
.py
8f5a19652cff61e6
7.5
0
from typing import List, Tuple import yaml from server.ats.trees.app import AppTree from server.ats.trees.blueprint import BlueprintTree from server.ats.trees.blueprint_v2 import BlueprintV2Tree from server.ats.trees.common import ( BaseTree, MapNode, MappingNode, NodeError, ObjectNode, Propert...
QualiTorque/torque-vs-code-extensions
server/ats/parser.py
.py
efb99faa2133dac3
7.15
1
#!/usr/bin/env python3 """ yml → tsv conversion for x-cmd install data. Output TSV columns: name, category, lang, source, desc_cn, desc_en, binlist, rule, other Usage: python3 yml2tsv.py # use defaults (./src → ./all.tsv) python3 yml2tsv.py /path/to/src # custom src dir py...
x-cmd/install
.x-cmd/v1.yml2tsv.py
.py
8579146a3d47ec54
7.35
4
import machine, time from machine import Pin __version__ = '0.2.0' __author__ = 'Roberto Sánchez' __license__ = "Apache License 2.0. https://www.apache.org/licenses/LICENSE-2.0" class HCSR04: """ Driver to use the untrasonic sensor HC-SR04. The sensor range is between 2cm and 4m. The timeouts receive...
DaTiC0/Sprinkler
hcsr04.py
.py
a31a90ce17047b46
7
0
import json from typing import Optional from config import CONTENT_DIR from utils.helpers import normalize_text # Load JSON content datasets with open(CONTENT_DIR / "talents.json", "r", encoding="utf-8") as jf: TALENTS_DATA: dict[str, dict] = json.load(jf) with open(CONTENT_DIR / "abilities.json", "r", encoding=...
anthonybartczak/discord-elvenden-bot
core/data.py
.py
1bd6e27c433ce56d
7
0
import unicodedata from typing import Optional import discord from config import FOOTER_TEXT, MAIN_COLOR import content.pictures as pic POLISH_CHAR_MAP = str.maketrans({ "ł": "l", "Ł": "l", "ą": "a", "ć": "c", "ę": "e", "ń": "n", "ó": "o", "ś": "s", "ź": "z", "ż": "z", "Ą": "a", "Ć": "c", "Ę": "e", "Ń": ...
anthonybartczak/discord-elvenden-bot
utils/helpers.py
.py
c99d99ff5ff809a0
7
0
"""SystemLink TestMonitor store and forward health monitor beacon.""" import asyncio import atexit import logging import os import sys from typing import Any, Dict, List, Tuple, Union from urllib.parse import quote import winreg import psutil from systemlink.clientconfig import get_configuration_by_id, HTTP_MASTER_CON...
ni/systemlink-storeandforward-beacon
src/systemlink_storeandforward_beacon/systemlink_storeandforward_monitor.py
.py
7d54bffa90e82f37
7
0
"""This script fetches data from a google sheet used by the ONE team to track positions on the recommendations. It then reshapes the data into a format suitable for plotting a Flourish heatmap.""" import pandas as pd from scripts import config # mapping of the recommendations used by the tracking sheet and the user-...
ONEcampaign/data_dive_MDBs
scripts/intel_tracker/heatmap_tracker.py
.py
330f46a30450b93a
7.3
3
"""This script contains functions to generate the data for the World Bank scrollytelling story.""" from scripts import config from scripts.multilateral_spending.spending_data import full_mdb_data import pandas as pd def _filter_years(data: pd.DataFrame, years: list[int] | int) -> pd.DataFrame: """Return a DataFra...
ONEcampaign/data_dive_MDBs
scripts/multilateral_spending/wb_scolly.py
.py
2e689d7f0c377123
7.3
3
import pandas as pd from bblocks.dataframe_tools.add import add_population_column, add_income_level_column from bblocks.cleaning_tools.clean import convert_id from scripts import config, common from scripts.logger import logger from bblocks import set_bblocks_data_path set_bblocks_data_path(config.PATHS.raw_data) fro...
ONEcampaign/data_dive_MDBs
scripts/world_bank_votes/download_shares.py
.py
811b8b5facec19b4
7.3
3
# coding: utf-8 """Generate github-actions dashboard.""" import argparse import os from urllib.parse import urlparse from github import Auth, Github import jinja2 class GithubUrlParsing: """Extract information from Github url.""" def __init__(self, repo_full_name, github_base_url="https://github.com"): ...
diodonfrost/github-actions-dashboard
generate.py
.py
ba35191a681099a1
7.15
1
"""Daily egress (download volume) report for PDS web analytics.""" import argparse import json import logging import os import smtplib from datetime import datetime from datetime import timezone from email.mime.text import MIMEText from typing import Any from typing import Dict from typing import List from typing impor...
NASA-PDS/o11y-cloudfront-batch
src/pds/web_analytics/egress_report.py
.py
f53e3ccaac5d0b0b
7
0
"""Unittest helper functions and utilities for testing.""" import os import shutil import tempfile from unittest.mock import patch import yaml # Constants for test patterns LOG_PATTERN = "*.log" TXT_PATTERN = "*.txt" def create_test_data_dir(): """Create a test data directory for testing.""" temp_dir = temp...
NASA-PDS/o11y-cloudfront-batch
tests/conftest.py
.py
359f62847a5befe8
7.5
0
"""Unit tests for the EgressReporter class.""" import os import tempfile import unittest from unittest.mock import MagicMock from unittest.mock import patch from pds.web_analytics.egress_report import EgressReporter SAMPLE_RESPONSE = { "aggregations": { "total_gb": {"value": 123.456}, "top_domain...
NASA-PDS/o11y-cloudfront-batch
tests/test_egress_report.py
.py
27c4b54662e4922a
7.5
0
#!/usr/bin/env python3 # Copyright 2021 Canonical Ltd. # See LICENSE file for licensing details. """Charm responsible for distributing certificates through relationship. Certificates are provided by the operator through Juju configs. """ import base64 import json import logging from typing import Any, List, Optional...
canonical/manual-tls-certificates-operator
src/charm.py
.py
d498498ef5253535
7.24
2
#!/usr/bin/env python3 # Copyright 2023 Canonical Ltd. # See LICENSE file for licensing details. """Methods used to generate self-signed certificates.""" import logging from typing import List from cryptography import x509 from cryptography.exceptions import InvalidSignature logger = logging.getLogger(__name__) d...
canonical/manual-tls-certificates-operator
src/helpers.py
.py
0a6905cb51e9c433
7.24
2
#!/usr/bin/env python3 # Copyright 2024 Canonical Ltd. # See LICENSE file for licensing details. import os from pathlib import Path import pytest def pytest_addoption(parser: pytest.Parser) -> None: """Add options to the pytest command line.""" parser.addoption( "--charm_path", action="store", defau...
canonical/manual-tls-certificates-operator
tests/integration/conftest.py
.py
65e9bf5e4e7aee73
7.74
2
#!/usr/bin/env python3 """Check that a freshly fetched derived dataset hasn't regressed. `fetch.py` rebuilds `build/derived.json` from live sources, which can degrade: an API hiccup, a soft block, a deleted Zotero item, or a recount can drop publications, rewrite bibliographic data, or report lower counts than what wa...
jhrmnn/jhrmnn.github.io
check_derived.py
.py
f39268798312f9d4
7
0
#!/usr/bin/env python3 """Cross-check that the publication sources agree. The site's reference list comes from the Zotero "My Publications" library; ORCID, Google Scholar, Web of Science and Crossref are independent records of the same publications. This reads a freshly fetched `build/derived.json` and verifies that t...
jhrmnn/jhrmnn.github.io
check_sources.py
.py
3a706ceb4262f06d
7
0
#!/usr/bin/env python3 """Helpers shared by the fetch and render stages. These live here so `fetch.py` and `render.py` stay independent of each other (neither imports the other) without duplicating the small pieces they both need. """ import re import unicodedata import yaml SMALL_CAPS = dict(zip('ᴍʏɴɢɪɴᴇ', 'myngine...
jhrmnn/jhrmnn.github.io
common.py
.py
2454e63d841a483d
7
0
#!/usr/bin/env python3 """Render the blog: each `posts/YYYY-MM-DD-slug.md` into an h-entry permalink page at `notes/YYYY-MM-DD-slug/index.html`, plus an h-feed index at `notes/index.html`. Emits IndieWeb microformats2 markup (h-card on the home page, h-entry here) so the notes are machine-readable to feed readers and ...
jhrmnn/jhrmnn.github.io
posts.py
.py
0e097115baaf0034
7
0