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 |
|---|---|---|---|---|---|---|
"""
Tests the :mod:`~pyhelpers.dirs.navigation` submodule.
"""
import os
import shutil
import sys
from pathlib import Path
import pytest
from pyhelpers._cache import _normalize_path
from pyhelpers.dirs.navigation import cd, cd_data, cdd, find_executable, resolve_dir_path
from pyhelpers.dirs.validation import is_dir_... | mikeqfu/pyhelpers | tests/test_dirs/test_navigation.py | .py | 7bc935dc5728a37e | 8.1 | 15 |
"""
Tests the :mod:`~pyhelpers.dirs.validation` submodule.
"""
import os
import tempfile
from pathlib import Path
import pytest
from pyhelpers.dirs.validation import check_files_exist, is_dir_path, validate_filename
@pytest.fixture(scope='module')
def test_dirname():
return Path(__file__).resolve().parents[1] ... | mikeqfu/pyhelpers | tests/test_dirs/test_validation.py | .py | 922ffb21e824e31b | 8.1 | 15 |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2018 CERN.
# Copyright (c) 2017 Thomas P. Robitaille.
#
# Asclepias Broker is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
"""Core database models."""
import enum
import uuid
from invenio_db i... | asclepias/asclepias-broker | asclepias_broker/core/models.py | .py | bb795f22af508c0d | 7.59 | 14 |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2018 CERN.
#
# Asclepias Broker is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
"""Events API."""
import jsonschema
from flask import current_app
from invenio_db import db
from jsonresolver.con... | asclepias/asclepias-broker | asclepias_broker/events/api.py | .py | db90604737081ec5 | 7.59 | 14 |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2018 CERN.
#
# Asclepias Broker is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
"""Events CLI."""
from __future__ import absolute_import, print_function
import datetime
import json
import cl... | asclepias/asclepias-broker | asclepias_broker/events/cli.py | .py | 1722e72ff2d5178d | 7.59 | 14 |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2018 CERN.
# Copyright (c) 2017 Thomas P. Robitaille.
#
# Asclepias Broker is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
"""Event database models."""
import enum
import uuid
from typing impor... | asclepias/asclepias-broker | asclepias_broker/events/models.py | .py | ec6afc12c6c6e137 | 7.59 | 14 |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2018 CERN.
#
# Asclepias Broker is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
"""Event views."""
from flask import Blueprint, jsonify, request
from flask.views import MethodView
from flask_log... | asclepias/asclepias-broker | asclepias_broker/events/views.py | .py | 7aff958bae6d2905 | 7.59 | 14 |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2018 CERN.
#
# Asclepias Broker is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
"""Asynchronous tasks."""
from typing import Dict, List, Set, Tuple
from celery import shared_task
from flask i... | asclepias/asclepias-broker | asclepias_broker/graph/tasks.py | .py | 4bddac1d961e8fcf | 7.59 | 14 |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2018 CERN.
#
# Asclepias Broker is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
"""Harvesting CLI."""
from __future__ import absolute_import, print_function
import datetime
from typing import... | asclepias/asclepias-broker | asclepias_broker/harvester/cli.py | .py | 36b3ae8d6706305c | 7.59 | 14 |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2018 CERN.
#
# Asclepias Harvester is free software; you can redistribute it and/or modify
# it under the terms of the MIT License; see LICENSE file for more details.
"""Crossref client."""
from copy import deepcopy
from datetime import datetime, timezone
from typing import I... | asclepias/asclepias-broker | asclepias_broker/harvester/crossref.py | .py | 7b6f0fa66575a4bd | 7.59 | 14 |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2019 CERN.
#
# Asclepias Harvester is free software; you can redistribute it and/or modify
# it under the terms of the MIT License; see LICENSE file for more details.
"""Europe PMC harvester."""
from datetime import datetime, timezone
import requests
from flask import curren... | asclepias/asclepias-broker | asclepias_broker/harvester/europepmc.py | .py | 2222159be5d97d26 | 7.59 | 14 |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2018 CERN.
#
# Asclepias Harvester is free software; you can redistribute it and/or modify
# it under the terms of the MIT License; see LICENSE file for more details.
"""Harvester extension."""
from typing import List, Tuple
from flask import current_app
from invenio_queues.... | asclepias/asclepias-broker | asclepias_broker/harvester/ext.py | .py | b8a46708d9eba0ba | 7.59 | 14 |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2018 CERN.
#
# Asclepias Harvester is free software; you can redistribute it and/or modify
# it under the terms of the MIT License; see LICENSE file for more details.
"""Versioning metadata harvester."""
from datetime import datetime, timezone
from typing import List
from ..... | asclepias/asclepias-broker | asclepias_broker/harvester/github.py | .py | 7b42f833de9802df | 7.59 | 14 |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2018 CERN.
#
# Asclepias Harvester is free software; you can redistribute it and/or modify
# it under the terms of the MIT License; see LICENSE file for more details.
"""Harvester utilities."""
from datetime import datetime, timezone
from invenio_cache import current_cache
... | asclepias/asclepias-broker | asclepias_broker/harvester/utils.py | .py | e90d78b3e25b0cf6 | 7.59 | 14 |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2018 CERN.
#
# Asclepias Broker is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
"""Metadata functions."""
from datetime import datetime, timezone
from typing import List
import idutils
from f... | asclepias/asclepias-broker | asclepias_broker/metadata/api.py | .py | 3ba7f5c954602718 | 7.59 | 14 |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2018 CERN.
#
# Asclepias Broker is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
"""CLI for Asclepias broker."""
from __future__ import absolute_import, print_function
import json
import clic... | asclepias/asclepias-broker | asclepias_broker/metadata/cli.py | .py | e09377b7f33002b4 | 7.59 | 14 |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2018 CERN.
#
# Asclepias Broker is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
"""Metadata database models."""
from copy import deepcopy
import jsonschema
from invenio_db import db
from sqlal... | asclepias/asclepias-broker | asclepias_broker/metadata/models.py | .py | 5e8dbb9975ada3e6 | 7.59 | 14 |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2018 CERN.
#
# Asclepias Broker is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
"""Monitoring CLI."""
from __future__ import absolute_import, print_function
from typing import List
import cl... | asclepias/asclepias-broker | asclepias_broker/monitoring/cli.py | .py | e625bd03c72fa015 | 7.59 | 14 |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2018 CERN.
#
# Asclepias Broker is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
"""Monitoring database models."""
import uuid
import enum
import datetime
from sqlalchemy.sql.sqltypes import B... | asclepias/asclepias-broker | asclepias_broker/monitoring/models.py | .py | 3e3c0f48dea83dfd | 7.59 | 14 |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2018 CERN.
#
# Asclepias Broker is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
"""PIDStore fetchers and minters."""
from invenio_pidstore.fetchers import FetchedPID
def relid_fetcher(dummy_... | asclepias/asclepias-broker | asclepias_broker/pidstore.py | .py | e5e409380d8b288b | 7.59 | 14 |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2018 CERN.
#
# Asclepias Broker is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
"""Marshmallow loaders."""
from copy import deepcopy
from typing import Tuple
import idutils
from flask import ... | asclepias/asclepias-broker | asclepias_broker/schemas/loaders.py | .py | 0d2129ba64ec7b40 | 7.59 | 14 |
# -*- coding: utf-8 -*-
#
# Copyright (C) 2018-2019 CERN.
#
# Asclepias Broker is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
"""CLI for Asclepias broker search module."""
from __future__ import absolute_import, print_function
impor... | asclepias/asclepias-broker | asclepias_broker/search/cli.py | .py | b276c5502f2c340b | 7.59 | 14 |
# -*- coding: utf-8 -*-
import gc
import numpy as np
from numba import set_num_threads
from collections import namedtuple
from itertools import cycle
from quartical.gains.general.generics import combine_gains, combine_flags
from quartical.weights.robust import robust_reweighting
from quartical.statistics.stat_kernels i... | ratt-ru/QuartiCal | quartical/calibration/solver.py | .py | 3d6dfca3c2fd5f4f | 7.5 | 9 |
from dataclasses import make_dataclass, field
from omegaconf import OmegaConf as oc
from typing import Dict, Any
from scabha.cargo import Parameter
from quartical.config import Gain, BaseConfig, gain_schema
def finalize_structure(additional_config):
terms = None
# Get last specified version of solver.terms.... | ratt-ru/QuartiCal | quartical/config/external.py | .py | 4d1a0e4e7013ff29 | 7.5 | 9 |
import sys
import os
import textwrap
import re
from colorama import Fore, Style
from omegaconf import OmegaConf as oc
from dataclasses import fields
from quartical.config.external import finalize_structure
GAIN_MSG = (
"Gains make use of a special configuration mechanism. Use 'solver.terms' "
"to specify the n... | ratt-ru/QuartiCal | quartical/config/helper.py | .py | 444a9e4afe693310 | 7.5 | 9 |
# -*- coding: utf-8 -*-
import sys
import os
from loguru import logger
from ruamel.yaml import YAML
from omegaconf import OmegaConf as oc
from quartical.config.external import finalize_structure
from quartical.config.internal import additional_validation
from omegaconf.errors import ConfigKeyError, ValidationError
de... | ratt-ru/QuartiCal | quartical/config/parser.py | .py | 24e4c6fa8a493c74 | 7.5 | 9 |
# -*- coding: utf-8 -*-
from loguru import logger
import re
import dask.array as da
from collections import namedtuple
import os.path
from dataclasses import dataclass
from typing import List, Dict, Set, Any
sky_model_nt = namedtuple("sky_model_nt", ("name", "tags"))
@dataclass
class Ingredients:
model_columns:... | ratt-ru/QuartiCal | quartical/config/preprocess.py | .py | f61b5c4a38adfd71 | 7.5 | 9 |
import numpy as np
from quartical.gains.conversion import no_op
from quartical.gains.parameterized_gain import ParameterizedGain
from quartical.gains.amplitude.kernel import (
amplitude_solver,
amplitude_params_to_gains
)
from quartical.gains.general.flagging import (
apply_gain_flags_to_gains,
apply_pa... | ratt-ru/QuartiCal | quartical/gains/amplitude/__init__.py | .py | 671c46066a5bd248 | 7.5 | 9 |
import numpy as np
from quartical.gains.conversion import trig_to_angle
from quartical.gains.parameterized_gain import ParameterizedGain
from quartical.gains.crosshand_phase.kernel import (
crosshand_phase_solver,
crosshand_params_to_gains
)
from quartical.gains.crosshand_phase.null_v_kernel import (
null_v... | ratt-ru/QuartiCal | quartical/gains/crosshand_phase/__init__.py | .py | 05004f7ac7203e27 | 7.5 | 9 |
# -*- coding: utf-8 -*-
from quartical.config.external import Gain
from loguru import logger # noqa
import numpy as np
import dask.array as da
import xarray
from uuid import uuid4
from daskms.experimental.zarr import xds_to_zarr
from quartical.gains.gain import gain_spec_tup, param_spec_tup
from quartical.gains import... | ratt-ru/QuartiCal | quartical/gains/datasets.py | .py | 50b31691945e935d | 7.5 | 9 |
import numpy as np
from collections import namedtuple
from quartical.gains.conversion import no_op
from quartical.gains.parameterized_gain import ParameterizedGain
from quartical.gains.delay_and_tec.kernel import (
delay_and_tec_solver,
delay_and_tec_params_to_gains
)
from quartical.gains.general.flagging impor... | ratt-ru/QuartiCal | quartical/gains/delay_and_tec/__init__.py | .py | a79c6644c4d4454f | 7.5 | 9 |
import os
''' GENERATE SECRET KEY '''
if not os.getenv('SECRET_KEY'):
# Attempt to read the secret from the secret file
# This will fail if the secret has not been written
try:
with open('.ctfd_secret_key', 'rb') as secret:
key = secret.read()
except (OSError, IOError):
key... | Hong5489/Custom-CTFd-Engine | CTFd/config.py | .py | 4ddd82b23e5b9d74 | 7.42 | 6 |
from CTFd.plugins import register_plugin_assets_directory
from CTFd.plugins.flags import get_flag_class
from CTFd.models import db, Solves, Fails, Flags, Challenges, ChallengeFiles, Tags, Hints, ShareFlags
from CTFd.utils.user import get_ip
from CTFd.utils.uploads import upload_file, delete_file
from flask import Bluep... | Hong5489/Custom-CTFd-Engine | CTFd/plugins/challenges/__init__.py | .py | 220db44b6c9c6552 | 7.42 | 6 |
from __future__ import division # Use floating point for math calculations
from CTFd.plugins.challenges import BaseChallenge, CHALLENGE_CLASSES
from CTFd.plugins import register_plugin_assets_directory
from CTFd.plugins.flags import get_flag_class
from CTFd.models import db, Solves, Fails, Flags, Challenges, Challenge... | Hong5489/Custom-CTFd-Engine | CTFd/plugins/dynamic_challenges/__init__.py | .py | 64df32c2b4d38990 | 7.42 | 6 |
import io
import tarfile
import zipfile
import fiona
import requests
from geojson import Feature, FeatureCollection
def get_all():
"""
Get all watch, warning and advisory data.
Returns a GeoJSON object.
"""
return _parse_shapefile("current_all.tar.gz")
def get_hazards():
"""
Get all ha... | datadesk/nws-wwa | nws_wwa/__init__.py | .py | bb2a939238f9f043 | 7.56 | 12 |
import click
from nws_wwa import get_all, get_hazards, get_warnings
@click.group()
def cmd():
"""
A command-line interface for downloading watch, warning and advisory data from the National Weather Service.
Returns GeoJSON.
"""
pass
@cmd.command(help="All watch, warning and advisory data")
def... | datadesk/nws-wwa | nws_wwa/cli.py | .py | 7256d1ded47c8550 | 7.56 | 12 |
import os
from setuptools import setup
def read(fname):
with open(os.path.join(os.path.dirname(__file__), fname)) as f:
return f.read()
def version_scheme(version):
"""
Version scheme hack for setuptools_scm.
Appears to be necessary to due to the bug documented here: https://github.com/pypa... | datadesk/nws-wwa | setup.py | .py | 28dfa0f17a11b336 | 7.56 | 12 |
"""Download-time annotation of an AP-mode world's seed text.
The conversion pass runs at generation, before Archipelago has filled
anything, so a freshly generated seed can only say "AP Item #n" and can only
guess where an exported item went. Once the room has been connected each
world scouts its own reserved location... | sparkle-preference/ori_rando_server | archipelago/annotate.py | .py | e4ebf220e4c37652 | 7.5 | 9 |
"""Packages the oride world as oride.apworld for an Archipelago install.
Run from repo root: python -m archipelago.build_apworld
Output: archipelago/dist/oride.apworld -- drop it in Archipelago's
custom_worlds/ (or worlds/ for a source install).
zip_bytes() is the same build without the file: main.py's /generator/ap... | sparkle-preference/ori_rando_server | archipelago/build_apworld.py | .py | 2b49bbbc68da160a | 7.5 | 9 |
"""Follow-up probes isolating the divergence classes compare.py surfaces.
Run right after compare.py -- reads the sphere-walk round inventories from
ap_in.json before replacing the exchange files with its own queries:
.venv312\\Scripts\\python.exe archipelago\\difftest\\probes.py <randomizer0.dat>
Writes probes.txt... | sparkle-preference/ori_rando_server | archipelago/difftest/probes.py | .py | b0b00e1992f76a10 | 7 | 9 |
"""Server-side reach oracle for the differential test.
Run from the repo root with the server venv (PYTHONPATH=repo root):
.venv312\\Scripts\\python.exe archipelago\\difftest\\reach_server.py in.json out.json
in.json: {"spawn": "Glades", "modes": [...], "inventories": [{"CODE|ID": count}, ...]}
out.json: {"results... | sparkle-preference/ori_rando_server | archipelago/difftest/reach_server.py | .py | 3151b8bda980ec9a | 7 | 9 |
from dataclasses import dataclass
from Options import DeathLink, OptionDict, PerGameCommonOptions
class OrirandoData(OptionDict):
"""The seed pairing blob emitted by orirando.com -- not meant to be
hand-written. Roll a seed with the Archipelago game mode and download
the paired yaml from the seed page.""... | sparkle-preference/ori_rando_server | archipelago/oride_apworld/oride/options.py | .py | 07699baf1adeebb4 | 7.5 | 9 |
"""Compiles areas.ori requirement paths into AP access rules.
A connection's paths are OR'd alternatives; each path is a list of tokens
that AND together. Compilation resolves every path to an item-count
requirement dict (or drops it: disabled pathset tag, dead variation flag),
so rules evaluate as state.has_all_count... | sparkle-preference/ori_rando_server | archipelago/oride_apworld/oride/rules.py | .py | dacaaaf1d02bcf61 | 7.5 | 9 |
"""Emits the paired Archipelago yaml for a rolled Ori seed (prototype).
The K placed SK/TP/EV items move to the AP pool and their locations become
AP slots; every other progression placement (KS/MS/HC/EC/AC, shards, frags,
keysanity keys) is pinned local so AP reachability mirrors the seed exactly.
EX and bonus RBs ne... | sparkle-preference/ori_rando_server | archipelago/yaml_emit.py | .py | 4a2fc11a760dad5c | 7.5 | 9 |
"""Transport-neutral session layer for the client netcode.
Each handler is a function of (game_id, player_id, ...path args, payload) ->
(status, body). `payload` is any Mapping with .get()/`in` (the HTTP adapters in
main.py pass request.args or request.form verbatim; a websocket adapter passes
a plain dict). Bodies ar... | sparkle-preference/ori_rando_server | netcode.py | .py | 33365f6811aa6508 | 7.5 | 9 |
"""Decoupling hub between game-state code and the websocket push layer.
models/cache call notify(gpid) at the moments a player's next tick output
is known to have changed (in practice: every tick-cache checksum bust).
If the websocket layer has push enabled it registers a handler that sends
that player a fresh tick fr... | sparkle-preference/ori_rando_server | push.py | .py | aafb7132faf8a22f | 7.5 | 9 |
#
# Copyright (c) 2021 by Delphix. All rights reserved.
#
"""
Utility functions to convert between unicode and bytes.
"""
import six
def to_bytes(string, encoding="utf-8"):
"""
Converts the given object to binary object, bytes (Py3) or str (Py2).
:param string: The string like object to convert to byt... | delphix/virtualization-sdk | common/src/main/python/dlpx/virtualization/common/util.py | .py | b41d79b5f1b067b7 | 7.45 | 7 |
#
# Copyright (c) 2019, 2021 by Delphix. All rights reserved.
#
import sys
from dlpx.virtualization.common.exceptions import PluginRuntimeError
class LibraryError(Exception):
"""Plugin-catchable exception
Some library errors (timeouts, host unreachable, etc.) are potentially
actionable by plugin code. F... | delphix/virtualization-sdk | libs/src/main/python/dlpx/virtualization/libs/exceptions.py | .py | cc463e6233620070 | 7.45 | 7 |
#
# Copyright (c) 2020 by Delphix. All rights reserved.
#
import inspect
from dlpx.virtualization.platform import exceptions
_IMPORT_CHECKS = {}
_POST_IMPORT_CHECKS = {}
class PluginModule:
"""
Import helper class for the plugin. An instance of this class helps to pass
state of imported module and relev... | delphix/virtualization-sdk | platform/src/main/python/dlpx/virtualization/platform/import_util.py | .py | 5edc22c21edbd6e5 | 7.45 | 7 |
#!/usr/bin/env python3
"""
Working BIOS demo - Shows that subsystems DO run correctly
"""
import queue
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent))
from test_phone_tree import AudioPlayer, setup_bios_phone_tree, navigate_bios_menu
def demo():
"""Demonstrate working BIOS navi... | rchatham/pay-phone | demo_bios_working.py | .py | 3a20533b6dde00bb | 7.48 | 8 |
#!/usr/bin/env python3
"""
Generate audio files for BIOS menu using text-to-speech.
Creates:
- bios/main_menu.mp3
- bios/system_information_booth.mp3
- bios/system_tdtm.mp3 (if TDTM discovered)
- prompts/invalid_extension.mp3
- prompts/no_systems.mp3
"""
import os
import sys
from pathlib import Path
# Try importing ... | rchatham/pay-phone | generate_bios_audio.py | .py | ed4db9359cb40650 | 7.48 | 8 |
#!/usr/bin/env python3
"""
Generate DTMF (Dual-Tone Multi-Frequency) tones for each keypad button.
DTMF tones are composed of two simultaneous frequencies:
- Row frequency (low)
- Column frequency (high)
"""
import numpy as np
import wave
import os
from pathlib import Path
# DTMF frequency table
DTMF_FREQUENCIES = {
... | rchatham/pay-phone | generate_dtmf_tones.py | .py | 6b41764fb38e2c11 | 7.48 | 8 |
"""
Configuration manager for BIOS/Bootloader system.
Handles persistent storage of system selection and BIOS settings.
"""
import json
import os
import logging
from typing import Dict, List, Optional, Any
from pathlib import Path
logger = logging.getLogger(__name__)
class ConfigManager:
"""Manages BIOS config... | rchatham/pay-phone | payphone/bios/config_manager.py | .py | 68a49a0f0d6f258e | 7.48 | 8 |
#!/usr/bin/env python3
"""
Base class for payphone systems.
This provides the core functionality for running a payphone system,
while allowing subclasses to define their own phone tree structure.
"""
import logging
import queue
import signal
import threading
import time
from abc import ABC, abstractmethod
from typing ... | rchatham/pay-phone | payphone/core/system.py | .py | 37a77b0f574adf56 | 7.48 | 8 |
import queue
import logging
from typing import Callable, Optional, List
logger = logging.getLogger(__name__)
# Conditional import for RPi.GPIO (only available on Raspberry Pi)
try:
import RPi.GPIO as GPIO
_GPIO_AVAILABLE = True
except (ImportError, RuntimeError):
# RuntimeError can occur if GPIO is instal... | rchatham/pay-phone | payphone/hardware/gpio_handler.py | .py | 0dfa746a7cdd812d | 7.48 | 8 |
import RPi.GPIO as GPIO
import time
import threading
import logging
from typing import Callable, Optional, Union, List
logger = logging.getLogger(__name__)
class GPIOHookSwitch:
"""
Handle hook switch using Raspberry Pi GPIO pins.
Supports two configurations:
1. Single pin mode: One GPIO pin with oth... | rchatham/pay-phone | payphone/hardware/gpio_hook.py | .py | 23da35713995020d | 7.48 | 8 |
import RPi.GPIO as GPIO
import time
import queue
import threading
import logging
from typing import List, Tuple, Optional
logger = logging.getLogger(__name__)
class GPIOKeypad:
"""Handle matrix keypad (3x3 or 4x3) using Raspberry Pi GPIO pins"""
def __init__(self, row_pins: List[int], col_pins: List[int], in... | rchatham/pay-phone | payphone/hardware/gpio_keypad.py | .py | dde6f74a598400ab | 7.48 | 8 |
import threading
import queue
import logging
from typing import Callable, Optional
logger = logging.getLogger(__name__)
# Conditional import for pyserial (only available when installed)
try:
import serial
_SERIAL_AVAILABLE = True
except ImportError:
_SERIAL_AVAILABLE = False
serial = None
logger.d... | rchatham/pay-phone | payphone/hardware/serial_handler.py | .py | 5a0fa502da5f6bbc | 7.48 | 8 |
#!/usr/bin/env python3
import logging
import signal
import sys
import os
import subprocess
import time
# Configure logging
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
)
logger = logging.getLogger(__name__)
def _kill_existing_instances():
"""Kill ... | rchatham/pay-phone | payphone/main.py | .py | 338a66ba0f8d638e | 7.48 | 8 |
"""Compatibility wrapper for the core PhoneTree implementation."""
from typing import Optional
from payphone.audio.handler import AudioHandler
from payphone.core.phone_tree import PhoneTree as CorePhoneTree
class PhoneTree(CorePhoneTree):
"""Deprecated import path for :class:`payphone.core.phone_tree.PhoneTree`... | rchatham/pay-phone | payphone/phone_system/phone_tree.py | .py | abdeeab1951ea1db | 7.48 | 8 |
#!/usr/bin/env python3
"""
Information Booth Phone System
A simple information phone system with weather, time, jokes, and music options.
"""
from payphone.core import PhoneSystemBase, PhoneTree
class InformationBoothSystem(PhoneSystemBase):
"""
Information booth phone system with multiple menu options.
... | rchatham/pay-phone | phone_systems/information_booth/system.py | .py | f56dd90f1a2ad6d1 | 7.48 | 8 |
"""Message storage helpers for the Leave a Message plugin."""
from __future__ import annotations
import os
import random
from pathlib import Path
from typing import Optional
class MessageManager:
"""Manage sequential caller message files."""
def __init__(self, audio_dir: str = "audio_files", messages_subdi... | rchatham/pay-phone | plugins/LAM/message_manager.py | .py | 3f9c36e517e561f5 | 7.48 | 8 |
#!/usr/bin/env python3
"""
GPIO Pin Calibration Tool for Payphone
This tool automatically detects which GPIO pins are connected to:
- Hook switch (1 or 2 pins)
- Keypad matrix (4 rows + 3 columns)
Usage:
sudo python3 calibrate_pins.py
The tool will guide you through the calibration process and save
the configura... | rchatham/pay-phone | scripts/calibrate_pins.py | .py | 4a5e6ab53e493a73 | 7.48 | 8 |
#!/usr/bin/env python3
"""
Exhaustive GPIO Pin Scanner
Tests ALL possible pin combinations without any assumptions:
- Hook switch: Test each individual pin
- Keypad: Test all possible combinations of 4 rows + 3 columns
This is thorough but may take a few minutes.
"""
import RPi.GPIO as GPIO
import time
import sys
fr... | rchatham/pay-phone | scripts/exhaustive_pin_scanner.py | .py | 2c23e0a97163c23c | 7.48 | 8 |
#!/usr/bin/env python3
"""
Pin Connectivity Tester
Tests connectivity between pins by:
1. Driving one pin HIGH (output)
2. Reading all other pins (inputs with pull-down)
3. Any pin that reads HIGH is connected to the driven pin
This shows which pins are physically connected through switches/buttons.
"""
import RPi.G... | rchatham/pay-phone | scripts/pin_connectivity_test.py | .py | e8e345bb40d1b6fc | 7.98 | 8 |
#!/usr/bin/env python3
"""
GPIO Pin Diagnostic Tool
Shows the raw state of all GPIO pins before and after an action.
This helps identify which pins are actually connected to your hardware.
"""
import RPi.GPIO as GPIO
import time
import sys
# Safe GPIO pins to test
SAFE_GPIO_PINS = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12... | rchatham/pay-phone | scripts/pin_diagnostic.py | .py | fe2b518a993aff8b | 7.48 | 8 |
#!/usr/bin/env python3
"""
Active GPIO Pin Scanner
This tool actively drives GPIO pins to detect keypad matrix connections.
For keypad detection, it tries different combinations of:
- Some pins as outputs (rows) driving LOW
- Other pins as inputs (columns) with pull-ups
When you press a button, it creates a connectio... | rchatham/pay-phone | scripts/pin_scanner.py | .py | 4ac9c07da91a9d74 | 7.48 | 8 |
#!/usr/bin/env python3
"""
Raw Pin State Monitor
Simply reads and displays the state of all pins.
No fancy logic - just shows you what's happening.
"""
import RPi.GPIO as GPIO
import time
import sys
# Your pins
PINS = [17, 18, 27, 22, 23, 24, 25, 5, 6, 12, 13, 16, 19, 20, 21]
class Colors:
GREEN = '\033[92m'
... | rchatham/pay-phone | scripts/raw_pin_monitor.py | .py | 85c77b861ca433b7 | 7.48 | 8 |
#!/usr/bin/env python3
"""
Simple Pin State Viewer
Shows the raw state of all your pins in real-time.
This helps diagnose wiring issues.
"""
import RPi.GPIO as GPIO
import time
import sys
# Your connected pins
PINS = [17, 18, 27, 22, 23, 24, 25, 5, 6, 12, 13, 16, 19, 20, 21]
class Colors:
GREEN = '\033[92m'
... | rchatham/pay-phone | scripts/simple_pin_viewer.py | .py | 58a538a0acfccf54 | 7.48 | 8 |
#!/usr/bin/env python3
"""
Targeted GPIO Pin Scanner
User knows which pins are connected, but not which is which.
Tests only the specified pins to identify:
- Hook switch (1-2 pins)
- Keypad rows (4 pins)
- Keypad columns (3 pins)
"""
import RPi.GPIO as GPIO
import time
import sys
from itertools import combinations
... | rchatham/pay-phone | scripts/targeted_pin_scanner.py | .py | a22630446982662e | 7.48 | 8 |
#!/usr/bin/env python3
"""
Hardware testing script for payphone components
"""
import sys
import time
import serial
import pygame
import os
def test_serial_connection():
"""Test Arduino serial communication"""
print("\n=== Testing Serial Connection ===")
try:
ser = serial.Serial('/dev/ttyUSB0', 960... | rchatham/pay-phone | scripts/test_hardware.py | .py | 31dfda323373d3cb | 7.98 | 8 |
#!/usr/bin/env python3
"""
Hardware testing script for GPIO-connected payphone components
"""
import sys
import time
import pygame
import os
# Check if running on Raspberry Pi
try:
import RPi.GPIO as GPIO
ON_PI = True
except ImportError:
print("Warning: RPi.GPIO not available. Some tests will be skipped.")... | rchatham/pay-phone | scripts/test_hardware_gpio.py | .py | a8778408db2490c9 | 7.98 | 8 |
#!/usr/bin/env python3
"""
Test Keypad Integration
Tests the actual keypad with the configured pins to verify buttons work.
"""
import sys
import os
import time
import queue
# Add project to path
sys.path.insert(0, '/home/pi/payphone')
from dotenv import load_dotenv
load_dotenv()
import RPi.GPIO as GPIO
from payph... | rchatham/pay-phone | scripts/test_keypad_integration.py | .py | 3444a533fef52de2 | 7.98 | 8 |
#!/usr/bin/env python3
"""
Test Single Button - Non-Interactive
Tests which pins are connected when you're holding a button.
Run this while holding a button down.
Usage: python3 test_single_button.py [button_name]
Example: python3 test_single_button.py 2
"""
import RPi.GPIO as GPIO
import time
import sys
# Your con... | rchatham/pay-phone | scripts/test_single_button.py | .py | 46c9afa4712eacf1 | 7.98 | 8 |
#!/usr/bin/env python3
"""
Quick test script for BIOS/Bootloader system.
Tests:
1. ConfigManager - Load/save configuration
2. SystemManager - Discover and load systems
3. BIOSBootloader - Basic initialization
Run: python test_bios.py
"""
import logging
import sys
import os
from pathlib import Path
# Setup logging
l... | rchatham/pay-phone | test_bios.py | .py | d5096714516fde78 | 7.98 | 8 |
import os
import httpx
def get_github_commit_diff(owner, repo, commit_hash, token):
"""Fetches the commit diff from GitHub."""
url = f"https://api.github.com/repos/{owner}/{repo}/commits/{commit_hash}"
headers = {
"Authorization": f"token {token}",
"Accept": "application/vnd.github.v3.dif... | coursetable/ferry | .github/scripts/get_course_names.py | .py | e09b4d4b2fcf9d3d | 7.62 | 16 |
"""
Generic LLM client for any OpenAI-compatible chat API.
Supports OpenAI, Anthropic, Gemini, Groq, OpenRouter, and
other providers that expose an OpenAI-style API.
"""
import asyncio
import logging
import re
from typing import Any
# Default model when none is specified (OpenAI).
DEFAULT_MODEL = "gpt-5.6-luna"
# R... | coursetable/ferry | ferry/ai/client.py | .py | 00cdc6f7f3102b29 | 7.62 | 16 |
from pathlib import Path
from typing import Any
def load_cache_json(path: Path):
"""
Load JSON from cache file
Parameters
----------
path: str
Path to cache file
Returns
-------
data: Any | None
JSON data
"""
import ujson
if not path.is_file():
re... | coursetable/ferry | ferry/crawler/cache.py | .py | a7fe7f754f82c1a4 | 7.62 | 16 |
"""
This script fetches course evaluation data from the Yale
Online Course Evaluation (OCE), in JSON format through the
following steps:
1. Selection of seasons to fetch ratings
2. Construction of a cached check for Yale College courses
3. Aggregation of all season courses into a queue
4. Fetch and sav... | coursetable/ferry | ferry/crawler/evals/fetch.py | .py | 457b47fbc6dccc05 | 7.62 | 16 |
import logging
import re
from pathlib import Path
from typing import TypedDict, cast
import numpy as np
import pandas as pd
import ujson
from tqdm import tqdm
from ferry import database
from ferry.crawler.cache import load_cache_json
def match_evaluations_to_courses(
evals: pd.DataFrame, listings: pd.DataFrame
... | coursetable/ferry | ferry/transform/import_evaluations.py | .py | 11dab0b299fec757 | 7.62 | 16 |
"""
Find historical offerings of a course.
"""
import itertools
from typing import cast
import edlib
import pandas as pd
from scipy.cluster.hierarchy import DisjointSet
from tqdm import tqdm
# TODO: I don't quite like these hard-coded constants. Is there a better way
# to measure similarity that's more context-aware... | coursetable/ferry | ferry/transform/same_courses.py | .py | b03c22749694f7e8 | 7.62 | 16 |
import logging
import math
import re
from typing import cast
import numpy as np
import pandas as pd
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer
from ferry import database
from ferry.transform.same_courses import (
resolve_historical_courses,
split_same_professors,
)
def questions_co... | coursetable/ferry | ferry/transform/transform_compute.py | .py | f029ad30fefee482 | 7.62 | 16 |
import logging
import threading
from datetime import datetime, timezone
from recorder.bililive.models import RoomState, SessionState
WORKER_JOIN_TIMEOUT_SECONDS = 30
WORKER_WAIT_SECONDS = 60
_WORKER_PAUSE_STATUSES = frozenset({
'ambiguous',
'fatal',
'resettle_pending',
'retry_scheduled',
'retryab... | hldh214/recorder | recorder/bililive/service.py | .py | 1b684d9b48e4e2dd | 7.45 | 7 |
import datetime
import pathlib
import arrow
from recorder import video_name_sep, TZ_INFO, ARROW_DATETIME_FORMAT, config
from recorder.danmaku.caption import Caption
def parse_datetime(obj):
return arrow.get(obj if isinstance(obj, datetime.datetime) else arrow.get(obj, ARROW_DATETIME_FORMAT),
... | hldh214/recorder | recorder/danmaku/__init__.py | .py | bc74d31a098fce55 | 7.45 | 7 |
import arrow
import cachetools
VTT_CAPTION_MINIMAL_INTERVAL = 0.1 # 两条字幕之间间隔不小于 0.1 秒, 为了字幕播放性能
VTT_CONTENT_TTL = 4 # 弹幕展示时间 (秒)
VTT_CONTENT_MAXSIZE = 7 # 最多一次显示多少条弹幕
VTT_TIME_FORMAT = 'HH:mm:ss.SSS'
VTT_HEADERS = '''\
WEBVTT
Kind: captions
Language: zh-Hans
'''
ASS_STYLE_MEDIUM_FONT_WIDTH = 26 # 26 * 2 == 52
AS... | hldh214/recorder | recorder/danmaku/caption.py | .py | 4b725dd82cfe11bb | 7.45 | 7 |
import re
import random
import json
from typing import Optional, Dict, Any
import httpx
from recorder import logger
from recorder.ffmpeg import USER_AGENTS
REQUEST_TIMEOUT = 5
ROOM_ID_REGEX = re.compile(r'"room_id"\s*:\s*(\d+)')
def _http_get(url: str, params: Dict[str, Any] = None, headers: Dict[str, str] = None)... | hldh214/recorder | recorder/source/bilibili.py | .py | 5965feb8ec5f18d5 | 7.45 | 7 |
from __future__ import annotations
import argparse
import copy
import json
import logging
import sys
from collections import defaultdict
from dataclasses import dataclass
from pathlib import Path
from typing import Any
import annofabapi
import pandas
from annofabapi.models import ProjectMemberRole
from annofabapi.pyd... | kurusugawa-computer/annofab-cli | annofabcli/annotation/change_annotation_data_per_annotation.py | .py | 0479842766196b84 | 7.48 | 8 |
from __future__ import annotations
import argparse
import copy
import json
import logging
import sys
from collections import defaultdict
from dataclasses import dataclass
from pathlib import Path
from typing import Any
import annofabapi
import pandas
from annofabapi.models import ProjectMemberRole
from annofabapi.pyd... | kurusugawa-computer/annofab-cli | annofabcli/annotation/create_annotation.py | .py | 73a7023d2408a377 | 7.48 | 8 |
from __future__ import annotations
import copy
import uuid
from collections.abc import Mapping, Sequence
from dataclasses import dataclass
from typing import Any, assert_never
import ulid
from annofabapi.models import AdditionalDataDefinitionType, DefaultAnnotationType
from annofabapi.plugin import EditorPluginId
fro... | kurusugawa-computer/annofab-cli | annofabcli/annotation/create_annotation_converter.py | .py | 6198068572c12728 | 7.48 | 8 |
from __future__ import annotations
import argparse
import logging
import multiprocessing
import sys
from typing import Any
import annofabapi
from annofabapi.models import DefaultAnnotationType, ProjectMemberRole, TaskStatus
from annofabapi.util.annotation_specs import AnnotationSpecsAccessor
import annofabcli.common... | kurusugawa-computer/annofab-cli | annofabcli/annotation/create_classification_annotation.py | .py | a485b0c80355d865 | 7.48 | 8 |
from __future__ import annotations
import argparse
import copy
import logging
import sys
from dataclasses import dataclass
from pathlib import Path
from typing import Any
import annofabapi
from annofabapi.dataclass.task import Task
from annofabapi.models import ProjectMemberRole, TaskStatus
import annofabcli.common.... | kurusugawa-computer/annofab-cli | annofabcli/annotation/delete_invalid_attribute_value.py | .py | 23c262d62a6961f8 | 7.48 | 8 |
from __future__ import annotations
import argparse
import logging
import sys
from dataclasses import dataclass
from pathlib import Path
from typing import Any
import annofabapi
from annofabapi.dataclass.task import Task
from annofabapi.models import ProjectMemberRole, TaskStatus
import annofabcli.common.cli
from ann... | kurusugawa-computer/annofab-cli | annofabcli/annotation/delete_invalid_label_annotation.py | .py | 138cf8744af98e27 | 7.48 | 8 |
from __future__ import annotations
from typing import Any
from pydantic import BaseModel, ConfigDict, StrictBool
class EditorPropsForCli(BaseModel):
"""
`--editor_props` で指定できるエディタ用プロパティ。
"""
can_delete: StrictBool | None = None
"""アノテーションがエディタ上で削除できるかどうか。"""
can_edit_data: StrictBool | No... | kurusugawa-computer/annofab-cli | annofabcli/annotation/editor_props.py | .py | a9a10b17ce1dc398 | 7.48 | 8 |
from __future__ import annotations
import argparse
import logging
import sys
from typing import Any
import annofabapi
import pandas
from annofabapi.models import SingleAnnotation
from annofabapi.util.annotation_specs import AnnotationSpecsAccessor, get_label_name_en
import annofabcli.common.cli
from annofabcli.annot... | kurusugawa-computer/annofab-cli | annofabcli/annotation/list_annotation.py | .py | d1276eec7234aa7e | 7.48 | 8 |
from __future__ import annotations
import argparse
import copy
import enum
import logging
import uuid
from collections.abc import Mapping, Sequence
from dataclasses import dataclass
from typing import Any
import annofabapi
from annofabapi.util.annotation_specs import AnnotationSpecsAccessor, get_label_name_en
import... | kurusugawa-computer/annofab-cli | annofabcli/annotation_specs/add_attribute.py | .py | 9bd5529a111aed7b | 7.98 | 8 |
from __future__ import annotations
import argparse
import copy
import json
import logging
import sys
from dataclasses import dataclass
from typing import Any
import annofabapi
import annofabcli.common.cli
from annofabcli.annotation_specs.attribute_restriction import AttributeRestrictionMessage
from annofabcli.common... | kurusugawa-computer/annofab-cli | annofabcli/annotation_specs/add_attribute_restriction.py | .py | 32439eb896b32944 | 7.98 | 8 |
from __future__ import annotations
import argparse
import copy
import json
import logging
from collections.abc import Mapping, Sequence
from typing import Any
import annofabapi
from annofabapi.pydantic_models.additional_data_definition_type import AdditionalDataDefinitionType
from annofabapi.util.annotation_specs imp... | kurusugawa-computer/annofab-cli | annofabcli/annotation_specs/add_attributes.py | .py | 7c2ecc214debf7ea | 7.98 | 8 |
from __future__ import annotations
import argparse
import copy
import json
import logging
from collections.abc import Mapping, Sequence
from dataclasses import dataclass, replace
from pathlib import Path
from typing import Any
import annofabapi
import pandas
from annofabapi.util.annotation_specs import AnnotationSpec... | kurusugawa-computer/annofab-cli | annofabcli/annotation_specs/add_choices_to_attribute.py | .py | 30d4e28a9bf34105 | 7.98 | 8 |
from __future__ import annotations
import argparse
import copy
import json
import logging
from collections.abc import Sequence
from dataclasses import dataclass
from typing import Any
import annofabapi
from annofabapi.util.annotation_specs import get_attribute_name_en, get_english_message
import annofabcli.common.cl... | kurusugawa-computer/annofab-cli | annofabcli/annotation_specs/add_choices_to_attributes.py | .py | ad093d2eb95547e0 | 7.98 | 8 |
from __future__ import annotations
import argparse
import copy
import logging
from collections.abc import Mapping, Sequence
from dataclasses import dataclass
from typing import Any
import annofabapi
from annofabapi.util.annotation_specs import AnnotationSpecsAccessor, get_attribute_name_en, get_label_name_en
import ... | kurusugawa-computer/annofab-cli | annofabcli/annotation_specs/add_existing_attribute_to_labels.py | .py | 52385b70b8473eb2 | 7.98 | 8 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.