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 |
|---|---|---|---|---|---|---|
"""Helpers for sentry instrumentation."""
from __future__ import annotations
from collections.abc import Generator
from contextlib import contextmanager
from typing import Any, Literal
import sentry_sdk
from safir.sentry import before_send_handler
from sentry_sdk.tracing import Span, Transaction
from sentry_sdk.type... | lsst-sqre/mobu | src/mobu/sentry.py | .py | 581a35b3d7e1587d | 7.3 | 3 |
"""Base class for business logic for mobu."""
import asyncio
from abc import ABCMeta, abstractmethod
from asyncio import Queue, QueueEmpty
from collections.abc import AsyncGenerator
from contextlib import aclosing
from datetime import UTC, datetime, timedelta
from enum import Enum
from typing import TypedDict
from ru... | lsst-sqre/mobu | src/mobu/services/business/base.py | .py | c12c27ba974470b2 | 7.3 | 3 |
"""EmptyLoop business logic for mobu."""
from __future__ import annotations
from typing import override
from mobu.events import EmptyLoopExecution
from .base import Business
__all__ = ["EmptyLoop"]
class EmptyLoop(Business):
"""Business class that does nothing, successfully.
This is a minimal business c... | lsst-sqre/mobu | src/mobu/services/business/empty.py | .py | 51d38742198d05a0 | 7.3 | 3 |
"""Class for executing Git-LFS tests."""
import importlib
import shutil
import tempfile
import uuid
from pathlib import Path
from typing import override
from urllib.parse import urlparse
from rubin.repertoire import DiscoveryClient
from safir.sentry import duration
from structlog.stdlib import BoundLogger
from ...ev... | lsst-sqre/mobu | src/mobu/services/business/gitlfs.py | .py | 5da919a08300be38 | 7.3 | 3 |
"""Run checks of ingresses and authentication against the Muster server."""
from typing import override
from httpx import AsyncClient, HTTPError, Response
from rubin.repertoire import DiscoveryClient
from safir.sentry import duration
from structlog.stdlib import BoundLogger
from ...events import Events, MusterExecut... | lsst-sqre/mobu | src/mobu/services/business/muster.py | .py | 6757e9bb048e11c3 | 7.3 | 3 |
import pathlib
import pytest
from pre_commit_hook.formatter import Formatter
_CONTENT = {"1.0.0.yaml": {"Added": ["a feature"]}}
def _spy_steps(mocker):
"""Replace every side-effecting step so a test observes dispatch, not file IO."""
return {
name: mocker.patch.object(Formatter, name, autospec=Tru... | chrysa/pre-commit-hooks-changelog | tests/formatter_test.py | .py | 2a23fe44811b3415 | 7.5 | 0 |
"""Unit Tests for Basic Validation of All DAGs."""
import unittest
from airflow.models import DagBag
class TestDagIntegrity(unittest.TestCase):
"""Primary Class for Testing all DAGs' validation."""
LOAD_SECOND_THRESHOLD = 2
def setUp(self):
"""Method to set up the DAG Validation Class instance fo... | tulibraries/funcake_dags | tests/dag_validation_test.py | .py | 152b9d33423775a0 | 7.85 | 4 |
import asyncio
import inspect
import json
import logging
import typing
from itertools import count
import msgspec
import websockets.asyncio.client
import websockets.asyncio.connection
import websockets.exceptions
from .exceptions import ChromeClosedException, ResponseErrorException
from .protocol import resolve_domai... | pilate/cdipy | cdipy/cdipy.py | .py | 9cdb6a654c8290e1 | 7.15 | 1 |
import asyncio
import logging
import os
import signal
import time
from asyncio import subprocess
from pathlib import Path
from tempfile import TemporaryDirectory
from .exceptions import ChromeClosedException
LOGGER = logging.getLogger("cdipy.chrome")
CHROME_PATH = os.environ.get("CDIPY_CHROME_PATH", "/usr/bin/googl... | pilate/cdipy | cdipy/chrome.py | .py | 5166955c195a4aef | 7.15 | 1 |
import os
import types
import msgspec.json
from .utils import get_cache_path, update_protocol_data
SKIP_VALIDATION = os.environ.get("CDIPY_SKIP_VALIDATION", False)
class DomainBase: # pylint: disable=too-few-public-methods
"""
Template class used for domains (ex: obj.Page)
"""
__slots__ = ("devt... | pilate/cdipy | cdipy/protocol.py | .py | 0c6de354138e6b81 | 7.15 | 1 |
import logging
import os
import urllib.request
from pathlib import Path
LOGGER = logging.getLogger("cdipy.utils")
ROOT = "https://raw.githubusercontent.com/ChromeDevTools/devtools-protocol/master/json"
SOURCE_FILES = [f"{ROOT}/browser_protocol.json", f"{ROOT}/js_protocol.json"]
OS_VAR = "CDIPY_CACHE"
def get_cache... | pilate/cdipy | cdipy/utils.py | .py | 240155b15a5c0740 | 7.15 | 1 |
# pyright: reportPrivateUsage=false
# pylint: disable=protected-access,super-init-not-called
# ruff: noqa: ANN401, SLF001
"""Tests for Model Target Web API detail helpers."""
import re
from typing import Any
import pytest
import requests
from selenium.webdriver.remote.webdriver import WebDriver
import vws_web_tools
... | VWS-Python/vws-web-tools | tests/test_model_target_web_api_details.py | .py | a4e33823e9fcee41 | 7.5 | 0 |
#!/usr/bin/env python3
import os
from collections import defaultdict
from dataclasses import dataclass
from itertools import count
from typing import (
Any,
Dict,
FrozenSet,
Iterator,
List,
Optional,
Set,
TextIO,
Tuple,
Type,
)
import requests
ITEMS_PER_PAGE = 100 # 100 is the... | rucio/documentation | tools/generate_wishlist.py | .py | cfbd16540cca251c | 7.35 | 4 |
"""
Models the game state and exposes functions for manipulating it.
"""
from enum import Enum
from random import randint, choice
class CellState(Enum):
UNKNOWN = "?"
SAFE = "-"
WARN1 = "1"
WARN2 = "2"
WARN3 = "3"
WARN4 = "4"
WARN5 = "5"
WARN6 = "6"
WARN7 = "7"
WARN8 = "8"
... | JoelEager/terminal-mines | terminal_mines/game_logic/game_model.py | .py | acbc9f54b95bd705 | 7.35 | 4 |
"""Pydantic models for the metadata API responses."""
from pydantic import BaseModel, ConfigDict, Field
class Resource(BaseModel):
"""Metadata resource; keep permissive."""
model_config = ConfigDict(extra="allow")
id: str = Field(..., description="Unique identifier for the resource", examples=["attasido... | spraakbanken/metadata-api | metadata_api/models.py | .py | c672f011d7669d3f | 7.15 | 1 |
"""Util functions used by the metadata API."""
from __future__ import annotations
import datetime
import json
import logging
import tomllib
from enum import Enum
from pathlib import Path
from typing import TYPE_CHECKING, Any
import jsonschema_rs
import requests
from metadata_api.settings import settings
if TYPE_CH... | spraakbanken/metadata-api | metadata_api/utils.py | .py | 0c5de541850b2398 | 7.15 | 1 |
"""Tests for parse_yaml module."""
import logging
from collections import defaultdict
from pathlib import Path
import pytest
from metadata_api.parse_yaml import _process_yaml_file # ruff: ignore[import-private-name]
from metadata_api.settings import settings
from metadata_api.utils import get_schema_validator
YAML... | spraakbanken/metadata-api | tests/test_parse_yaml.py | .py | 377f9eba41580c83 | 7.65 | 1 |
#!/usr/bin/env python3
"""
Erzeugt den Referenzblock in docs/admin/console-commands.md aus `php artisan list`.
Die Befehle leben in ../anton.test (app/Console/Commands/); ihre Beschreibungen
laufen der handgeschriebenen Doku sonst davon (zuletzt 87 Befehle im Code, 21
dokumentiert). Dieser Generator hält die *vollstän... | kraenzle-ritter/anton-documentation | scripts/gen-command-reference.py | .py | e73439a780b60b13 | 7 | 0 |
"""Marimo notebook: VarianceGamma EM diverges to NaN on heavy-tailed data.
Run with:
uv run marimo edit dev-notes/investigations/variance_gamma_em_nan.py
or, headless:
uv run marimo run dev-notes/investigations/variance_gamma_em_nan.py
Summary of the finding is in ``variance_gamma_em_nan.md``.
"""
import ... | xshi19/normix | dev-notes/investigations/variance_gamma_em_nan.py | .py | 38658b07991632d4 | 7 | 0 |
r"""
Diversification analytics: effective number of bets under a torsion.
Variance ENB diagonalizes the return covariance
:math:`\mathrm{Cov}[X] = E[Y]\Sigma + \mathrm{Var}[Y]\,\gamma\gamma^\top`
(:doc:`/theory/enb`); generalized ENB diagonalizes the Hessian of the squared
coherent risk :math:`H_{r^2} = 2\nabla r\,\na... | xshi19/normix | normix/finance/diversification.py | .py | 7665fa97081724f9 | 7 | 0 |
r"""
Risk measures as JIT-able functions of portfolio weights.
:class:`WeightFunctional` bundles a :class:`~normix.finance.risk.RiskMeasure`,
a multivariate normal-mixture model, and a fixed subordinator sample ``Y`` into
a callable ``w -> ℝ`` with gradient and Hessian companions for optimisation.
"""
from __future__ ... | xshi19/normix | normix/finance/functional.py | .py | 655d06661dcb3cdd | 7 | 0 |
"""
Generic RVS utilities for univariate distributions.
:func:`build_pinv_table` builds a quantile table from any univariate
log-kernel in pure JAX (trapezoidal CDF on a :math:`w`-grid). Distributions
supply ``log_kernel(w)`` from their own ``log_prob`` (plus a Jacobian when
working in :math:`w = \\log x`). :class:`... | xshi19/normix | normix/utils/rvs.py | .py | 8357749f8d0bde0f | 7 | 0 |
"""Moment validation and parameter printing utilities for normix notebooks."""
from __future__ import annotations
from typing import Any, Dict
import numpy as np
def validate_moments(
dist,
n_samples: int = 20000,
seed: int = 42,
is_joint: bool = True,
) -> Dict[str, Any]:
"""
Validate E[X] ... | xshi19/normix | normix/utils/validation.py | .py | 8d193522a1553475 | 7 | 0 |
import contextlib
import json
import logging
import os
import shutil
from datetime import date, datetime
from io import BytesIO
import requests
import torch
from PIL import Image
from requests.auth import HTTPDigestAuth
LOCAL_FALLBACK = "/data/local"
# Module-level session for connection reuse
_session = None
def ... | brianegge/garbage_bin | garbage_bin/detect.py | .py | 72209743f9e33b75 | 7.39 | 5 |
#!/usr/bin/env python3
"""monitor garage camera in loop"""
import configparser
import faulthandler
import gc
import json
import logging
import signal
import sys
import time
from pathlib import Path
import paho.mqtt.client as paho
import psutil
import requests.exceptions
import sdnotify
from detect import detectframe,... | brianegge/garbage_bin | garbage_bin/main.py | .py | f23a4ea31e9a593c | 7.39 | 5 |
import configparser
import pytest
from garbage_bin.main import (
connect_mqtt,
get_device_info,
get_health_status,
get_section,
get_version,
graceful_shutdown,
load_config,
main,
on_connect,
on_disconnect,
on_message,
publish_discovery,
)
def test_get_section_exists()... | brianegge/garbage_bin | tests/main_test.py | .py | aeaaafa4cfad258b | 7.89 | 5 |
#!/usr/bin/env python3
"""Check that the build backend constraint actually bound the build.
`build-system.requires` names hatchling with no version, and build requirements
resolve outside `uv.lock`, so the only thing holding the backend still is the
`[tool.uv] build-constraint-dependencies` pin in pyproject.toml. A co... | 20c/ctl | ci/check_build_constraint.py | .py | 2a3983f2c1e0b0a9 | 7 | 0 |
#!/usr/bin/env python3
"""Check ./dist with the publish action's own twine, at the pinned action ref.
#44 died because the pre-tag gate and the publisher disagreed about which
`Metadata-Version` values are acceptable: the backend emitted 2.5, the pinned
publish action's twine understood 2.4, and nothing compared them ... | 20c/ctl | ci/publisher_metadata_gate.py | .py | 6abf324d80aec251 | 7 | 0 |
import copy
import os
from importlib.metadata import version
import confu.config
import confu.exceptions
import grainy.core
import munge
import pluginmgr.config
from grainy.core import PermissionSet, int_flags
# import to namespace
from ctl.config import BaseSchema
from ctl.exceptions import ConfigError, PermissionDe... | 20c/ctl | src/ctl/__init__.py | .py | 016e2f08057c5cc5 | 7 | 0 |
import collections
import re
from functools import wraps
from grainy.core import int_flags
from ctl.exceptions import PermissionDenied
class expose:
"""
Decorator to expose a ctl plugin's method - permissions will be checked before
method is executed
"""
def __init__(self, namespace, level=None... | 20c/ctl | src/ctl/auth.py | .py | c6e4c1aa2e8ab8fd | 7 | 0 |
import argparse
import sys
import traceback
import ctl
import ctl.plugins.all
from ctl import Context, Ctl, plugin
from ctl.events import common_events
from ctl.exceptions import ConfigError, PluginOperationStopped
# <release env> moving after deploy
def add_options(parser, options):
for opt in options:
... | 20c/ctl | src/ctl/cli.py | .py | 50756b6c9bc41367 | 7 | 0 |
import confu.schema
class pymdgen_confu_types:
"""
Decorates a confu schema class to show pretty
class attribute types when generating docs with
pymdgen
TODO: should this maybe live in confu?
"""
def __init__(self):
pass
def __call__(self, cls):
for name in dir(cls):... | 20c/ctl | src/ctl/docs.py | .py | 2e81f1b2bd505b8e | 7 | 0 |
class Events:
"""
Events handler that works similarly to jquery events
"""
def __init__(self):
self.events = {}
def trigger(self, event_name, *args, **kwargs):
"""
Trigger an event by name, calling all callbacks
attached to the event
All arguments and keywo... | 20c/ctl | src/ctl/events.py | .py | ec14f4cc85597396 | 7 | 0 |
# TODO py3 implements PermissionError, probably extend that?
class PermissionDenied(Exception):
def __init__(self, grainy_namespace, level):
super().__init__(
f"You do not have '{level}' permission to this namespace: {grainy_namespace}"
)
class OperationNotExposed(Exception):
def _... | 20c/ctl | src/ctl/exceptions.py | .py | 2b0433b7ffe6e364 | 7 | 0 |
import logging
import logging.config
from ctl.events import common_events
def default_pylogger_config(name="ctl"):
"""
The defauly python logging setup to use when no `log` config
is provided via the ctl config file
"""
return {
"version": 1,
"formatters": {"default": {"format": "... | 20c/ctl | src/ctl/log.py | .py | bbee3d8b9419773d | 7 | 0 |
"""
Base classes for ctl plugins
"""
import collections
import confu.schema
import pluginmgr.config
from confu.cli import argparse_options
import ctl
from ctl.events import common_events
from ctl.exceptions import ConfigError, OperationNotExposed, UsageError
from ctl.log import Log
__all__ = ["command", "config"]
... | 20c/ctl | src/ctl/plugins/__init__.py | .py | 9e783dc586cacf7d | 7 | 0 |
"""
A plugin that allows you to execute other plugins in a chain
"""
import collections
import confu.schema
import ctl
import ctl.config
from ctl.docs import pymdgen_confu_types
@pymdgen_confu_types()
class ChainActionConfig(confu.schema.Schema):
"""
Confu schema describes a plugin action
"""
name... | 20c/ctl | src/ctl/plugins/chain.py | .py | b7832490abb13487 | 7 | 0 |
"""
A plugin that allows you to run one or several shell commands
"""
import os
import subprocess
import sys
import confu.schema
import ctl
import ctl.config
from ctl.auth import expose
from ctl.docs import pymdgen_confu_types
class CwdContext:
"""
A context manager that allows you to temporarily
execu... | 20c/ctl | src/ctl/plugins/command.py | .py | 694437d9bdb1d2a6 | 7 | 0 |
import confu
import munge
import ctl
class ConfigPluginConfig(confu.schema.Schema):
"""
configuration schema for command plugin
"""
format = confu.schema.Str("format", default="yaml", help="output format")
def option_name(path, delimiter="--"):
"""returns a cli option name from attribute path"... | 20c/ctl | src/ctl/plugins/config.py | .py | a42503e07642bc01 | 7 | 0 |
"""
A plugin that allows you to copy files
"""
import os
import shutil
import confu.schema
import ctl
from ctl.docs import pymdgen_confu_types
from ctl.plugins.walk_dir import WalkDirPlugin, WalkDirPluginConfig
@pymdgen_confu_types()
class CopyPluginConfig(WalkDirPluginConfig):
copy_metadata = confu.schema.Boo... | 20c/ctl | src/ctl/plugins/copy.py | .py | e9defbab79f79e1f | 7 | 0 |
"""
A plugin for sending emails
"""
import smtplib
from email.mime.text import MIMEText
import confu.schema
import ctl
from ctl.config import SMTPConfigSchema
from ctl.docs import pymdgen_confu_types
from ctl.plugins import PluginBase
@pymdgen_confu_types()
class EmailPluginConfig(confu.schema.Schema):
"""
... | 20c/ctl | src/ctl/plugins/email.py | .py | 1973863e9b9eccd5 | 7 | 0 |
"""
Plugin that allows you to manage a git repository
"""
import argparse
import os
import re
import subprocess
import ctl
from ctl.auth import expose
from ctl.exceptions import OperationNotExposed
from ctl.plugins.repository import RepositoryPlugin
from ctl.util.git import GitManager, RepositoryConfig, TemporaryGitC... | 20c/ctl | src/ctl/plugins/git.py | .py | 3f7649201d46df5c | 7 | 0 |
"""
Plugin that allows you send notification for log events
"""
import ctl
from ctl.plugins.log import LogPlugin
@ctl.plugin.register("log_alert")
class LogAlertPlugin(LogPlugin):
"""
send notifications on log events
# Instanced Attributes
- messages (`list`): list of messages that triggered a noti... | 20c/ctl | src/ctl/plugins/log_alert.py | .py | d49a601a12f82607 | 7 | 0 |
"""
Plugin that appends git reposity commit hash and tag version to log messages
"""
import os
import confu.schema
import ctl
from ctl import plugin
from ctl.docs import pymdgen_confu_types
from ctl.plugins.log_user import LogUserPlugin
@pymdgen_confu_types()
class LogGitConfig(LogUserPlugin.ConfigSchema.config.__... | 20c/ctl | src/ctl/plugins/log_git.py | .py | 7c30f349a99421f4 | 7 | 0 |
"""
Plugin that allows you to append user information to log messages
"""
import os
import pwd
import ctl
from ctl.plugins.log import LogPlugin
@ctl.plugin.register("log_user")
class LogUserPlugin(LogPlugin):
"""
append user information to log messages
# Instanced Attributes
- username (`str`): us... | 20c/ctl | src/ctl/plugins/log_user.py | .py | db0e4d6514f53632 | 7 | 0 |
"""
Plugin that allows you to release a python package to pypi
## Requirements
`pip install twine`
"""
import os.path
import confu.schema
import ctl
import ctl.config
from ctl.docs import pymdgen_confu_types
from ctl.plugins import release
PYPI_TEST_REPO = "https://test.pypi.org/legacy/"
PYPY_LIVE_REPO = ""
try:... | 20c/ctl | src/ctl/plugins/pypi.py | .py | 9f9c8a8013ee406a | 7 | 0 |
"""
Plugin interface for plugins that handle software releases
"""
import argparse
import os
import confu.schema
import ctl
import ctl.config
import ctl.plugins.git
import ctl.plugins.repository
from ctl.auth import expose
from ctl.docs import pymdgen_confu_types
from ctl.plugins import command
@pymdgen_confu_type... | 20c/ctl | src/ctl/plugins/release.py | .py | f4b7430c7e13e2b3 | 7 | 0 |
"""
Plugin interface for plugins that manage software repositories
"""
import os
import confu.schema
from ogr.parsing import parse_git_repo
from ctl.docs import pymdgen_confu_types
from ctl.plugins import ExecutablePlugin
@pymdgen_confu_types()
class PluginConfig(confu.schema.Schema):
"""
Configuration sch... | 20c/ctl | src/ctl/plugins/repository.py | .py | 5952462e81b734f6 | 7 | 0 |
"""
Plugin that allows you to handle repository versioning
"""
import semver
import ctl
from ctl.auth import expose
from ctl.exceptions import OperationNotExposed, UsageError
from ctl.plugins.version_base import VersionBasePlugin, VersionBasePluginConfig
@ctl.plugin.register("semver2")
class Semver2Plugin(VersionBa... | 20c/ctl | src/ctl/plugins/semver2.py | .py | c7e2caa53d0c15e6 | 7 | 0 |
"""
Plugin that allows you to render templates
## Requirements
`pip install tmpl jinja`
"""
import collections
import os
import confu.schema
import munge
import ctl
try:
import tmpl
except ImportError:
tmpl = None
from ctl.docs import pymdgen_confu_types
from ctl.plugins.copy import CopyPlugin, CopyPlugi... | 20c/ctl | src/ctl/plugins/template.py | .py | 9105c441ee548eaf | 7 | 0 |
"""
Plugin that allows you to manage a python virtual env
## Requirements
- `pipenv`
- `pipenv-setup` if you want to run the `sync_setup` operation
"""
import argparse
import os
import confu.schema
import ctl
import ctl.config
from ctl.auth import expose
from ctl.docs import pymdgen_confu_types
from ctl.exception... | 20c/ctl | src/ctl/plugins/venv.py | .py | e75bac6ce77ffbe5 | 7 | 0 |
"""
Plugin that allows you to handle repository versioning
"""
import confu.schema
import ctl
from ctl.auth import expose
from ctl.docs import pymdgen_confu_types
from ctl.exceptions import OperationNotExposed, UsageError
from ctl.plugins.version_base import VersionBasePlugin, VersionBasePluginConfig
from ctl.util.ve... | 20c/ctl | src/ctl/plugins/version.py | .py | ee6047544ece30d1 | 7 | 0 |
"""
Plugin that allows you to handle repository versioning
"""
import argparse
import os
import confu.schema
import munge
import ctl
import ctl.plugins.git
from ctl.docs import pymdgen_confu_types
from ctl.exceptions import PluginOperationStopped, UsageError
from ctl.plugins import ExecutablePlugin
from ctl.plugins.... | 20c/ctl | src/ctl/plugins/version_base.py | .py | 2a4398301f1ab8b9 | 7 | 0 |
import re
try:
import jinja2
class VariableString(dict):
"""
Will render the variable string back to the template
so other renderers can render it later if needed
"""
def __init__(self, name, *args, **kwargs):
self.name = name
super().__init__(*... | 20c/ctl | src/ctl/util/template.py | .py | fe4acb85f766e765 | 7 | 0 |
import re
def version_tuple(version):
"""Returns a tuple from version string"""
if isinstance(version, tuple):
return version
return tuple(version.split("."))
def version_string(version):
"""Returns a string from version tuple or list"""
if isinstance(version, str):
return versio... | 20c/ctl | src/ctl/util/versioning.py | .py | 4308b0b85a8114af | 7 | 0 |
"""
Utility module for creating and populating in-memory test databases.
This module uses the existing updater logic to transform game states into skill database content.
"""
import contextlib
import datetime
import json
import pathlib
import sqlite3
from typing import Dict, List, Tuple
import pytest
from truescrub i... | trevorc/truescrub | tests/db_test_utils.py | .py | 2d0d535de7095da4 | 7.8 | 3 |
import pytest
from proto import common_pb2
from proto import highlights_service_pb2
from truescrub.accolades import (
parse_high_low, parse_accolade, parse_condition, parse_accolades,
compute_expected_rating, evaluate_conditions, compute_accolades,
format_accolades, get_accolades
)
def test_parse_high_low():
... | trevorc/truescrub | tests/test_accolades.py | .py | 3cf9a672404ce8a4 | 7.8 | 3 |
import datetime
from truescrub.proto.game_state_pb2 import GameStateEntry
import pytest
from truescrub.statewriter import GameStateLog
from truescrub.statewriter.segmented_log import (
Segment, segment_name)
def make_test_entry(game_state_id: int) -> GameStateEntry:
# Using a simple empty payload with just the ... | trevorc/truescrub | tests/test_segmented_log_dir.py | .py | 10fe6fa9261a5847 | 7.8 | 3 |
import collections
import configparser
import numbers
from importlib.resources import files
from typing import Dict, List, Tuple, Iterator, OrderedDict, Sequence
from proto import highlights_service_pb2
from truescrub.db import KILL_COEFF, DEATH_COEFF, DAMAGE_COEFF, INTERCEPT
def parse_high_low(high_low: str) -> boo... | trevorc/truescrub | truescrub/accolades.py | .py | 76b9ed40b210741a | 7.3 | 3 |
#!/usr/bin/env python3
"""Build pip using pinned build requirements."""
import subprocess
import tempfile
import venv
from os import PathLike
from pathlib import Path
from types import SimpleNamespace
from typing import Union
class EnvBuilder(venv.EnvBuilder):
"""A subclass of venv.EnvBuilder that exposes the py... | sailfishos-mirror/pip | build-project/build-project.py | .py | 1d36d8b0a5bdcbc8 | 7 | 0 |
"""Execute exactly this copy of pip, within a different environment.
This file is named as it is, to ensure that this module can't be imported via
an import statement.
"""
# /!\ This version compatibility check section must be Python 2 compatible. /!\
import sys
# Copied from pyproject.toml
PYTHON_REQUIRES = (3, 10... | sailfishos-mirror/pip | src/pip/__pip-runner__.py | .py | ef6d0cb7a874ed47 | 7 | 0 |
from __future__ import annotations
import abc
from collections.abc import Iterable
from contextlib import AbstractContextManager as ContextManager
from typing import TYPE_CHECKING, Literal, Protocol
from pip._vendor.packaging.version import Version
from pip._internal.locations import get_scheme
from pip._internal.me... | sailfishos-mirror/pip | src/pip/_internal/build_env/base.py | .py | ed11d6e57f904955 | 7 | 0 |
from __future__ import annotations
import os
import sys
import sysconfig
from collections.abc import Iterable
from types import TracebackType
from typing import TYPE_CHECKING
from pip._internal.build_env.base import (
BuildEnvironment,
BuildEnvironmentInstaller,
Prefix,
)
from pip._internal.exceptions imp... | sailfishos-mirror/pip | src/pip/_internal/build_env/venv.py | .py | 3ec0e5d0fa6607d8 | 7 | 0 |
from __future__ import annotations
import os
import site
import sys
import textwrap
from collections import OrderedDict
from collections.abc import Iterable
from types import TracebackType
from typing import TYPE_CHECKING
from pip._internal.build_env.base import (
BuildEnvironment,
BuildEnvironmentInstaller,
... | sailfishos-mirror/pip | src/pip/_internal/build_env/virtual.py | .py | 1ec551cf3860046c | 7 | 0 |
"""Cache Management"""
from __future__ import annotations
import hashlib
import json
import logging
import os
from pathlib import Path
from typing import Any
from pip._vendor.packaging.tags import Tag, interpreter_name, interpreter_version
from pip._vendor.packaging.utils import canonicalize_name
from pip._internal... | sailfishos-mirror/pip | src/pip/_internal/cache.py | .py | 7aa31055fa43f31e | 7 | 0 |
"""Logic that powers autocompletion installed by ``pip completion``."""
from __future__ import annotations
import optparse
import os
import sys
from collections.abc import Iterable
from itertools import chain
from typing import Any
from pip._internal.cli.main_parser import create_main_parser
from pip._internal.comma... | sailfishos-mirror/pip | src/pip/_internal/cli/autocompletion.py | .py | 805b6688584771c8 | 7 | 0 |
"""Base Command class, and related routines"""
from __future__ import annotations
import contextlib
import logging
import logging.config
import optparse
import os
import sys
import traceback
from collections.abc import Callable, Iterator
from optparse import Values
from pip._vendor.rich import reconfigure
from pip._... | sailfishos-mirror/pip | src/pip/_internal/cli/base_command.py | .py | c85e7f990108acb1 | 7 | 0 |
"""
Contains command classes which may interact with an index / the network.
Unlike its sister module, req_command, this module still uses lazy imports
so commands which don't always hit the network (e.g. list w/o --outdated or
--uptodate) don't need waste time importing PipSession and friends.
"""
from __future__ im... | sailfishos-mirror/pip | src/pip/_internal/cli/index_command.py | .py | fd0cdcf681e706eb | 7 | 0 |
"""A single place for constructing and exposing the main parser"""
from __future__ import annotations
import os
import subprocess
import sys
from pip._vendor.rich.markup import escape
from pip._internal.cli import cmdoptions
from pip._internal.cli.parser import ConfigOptionParser, UpdatingDefaultsHelpFormatter
from... | sailfishos-mirror/pip | src/pip/_internal/cli/main_parser.py | .py | 794f719324e0c6a8 | 7 | 0 |
from __future__ import annotations
import functools
import sys
from collections.abc import Callable, Generator, Iterable, Iterator
from typing import TYPE_CHECKING, Literal, TypeVar
from pip._vendor.rich.progress import (
BarColumn,
DownloadColumn,
FileSizeColumn,
MofNCompleteColumn,
Progress,
... | sailfishos-mirror/pip | src/pip/_internal/cli/progress_bars.py | .py | d77537018dc36307 | 7 | 0 |
from __future__ import annotations
import contextlib
import itertools
import logging
import sys
import time
from collections.abc import Generator
from typing import IO, Final
from pip._vendor.rich.console import (
Console,
ConsoleOptions,
RenderableType,
RenderResult,
)
from pip._vendor.rich.live impo... | sailfishos-mirror/pip | src/pip/_internal/cli/spinners.py | .py | 109cd921937252d2 | 7 | 0 |
"""
Package containing all pip commands
"""
from __future__ import annotations
import importlib
from collections import namedtuple
from typing import Any
from pip._internal.cli.base_command import Command
CommandInfo = namedtuple("CommandInfo", "module_path, class_name, summary")
# This dictionary does a bunch of ... | sailfishos-mirror/pip | src/pip/_internal/commands/__init__.py | .py | 68d7826d0bab1968 | 7 | 0 |
import os
import textwrap
from collections.abc import Callable
from optparse import Values
from pip._internal.cli.base_command import Command
from pip._internal.cli.status_codes import ERROR, SUCCESS
from pip._internal.exceptions import CommandError, PipError
from pip._internal.utils import filesystem
from pip._intern... | sailfishos-mirror/pip | src/pip/_internal/commands/cache.py | .py | 60b66b2d636f0a19 | 7 | 0 |
import sys
import textwrap
from optparse import Values
from pip._internal.cli.base_command import Command
from pip._internal.cli.status_codes import SUCCESS
from pip._internal.utils.misc import get_prog
BASE_COMPLETION = """
# pip {shell} completion start{script}# pip {shell} completion end
"""
COMPLETION_SCRIPTS = ... | sailfishos-mirror/pip | src/pip/_internal/commands/completion.py | .py | 2e3bd1219e905220 | 7 | 0 |
from __future__ import annotations
import logging
import os
import subprocess
from collections.abc import Callable
from optparse import Values
from typing import Any
from pip._internal.cli.base_command import Command
from pip._internal.cli.status_codes import ERROR, SUCCESS
from pip._internal.configuration import (
... | sailfishos-mirror/pip | src/pip/_internal/commands/configuration.py | .py | e4ce8a337d06de2e | 7 | 0 |
from __future__ import annotations
import logging
import os
import sys
from optparse import Values
from types import ModuleType
from typing import Any
import pip._vendor
from pip._vendor.certifi import where
from pip._vendor.packaging.version import parse as parse_version
from pip._internal.cli import cmdoptions
fro... | sailfishos-mirror/pip | src/pip/_internal/commands/debug.py | .py | b42594384cb3d877 | 7 | 0 |
import hashlib
import logging
import sys
from optparse import Values
from pip._internal.cli.base_command import Command
from pip._internal.cli.status_codes import ERROR, SUCCESS
from pip._internal.utils.hashes import FAVORITE_HASH, STRONG_HASHES
from pip._internal.utils.misc import read_chunks, write_output
logger = ... | sailfishos-mirror/pip | src/pip/_internal/commands/hash.py | .py | 18ef6944ddf05c2d | 7 | 0 |
from optparse import Values
from pip._internal.cli.base_command import Command
from pip._internal.cli.status_codes import SUCCESS
from pip._internal.exceptions import CommandError
class HelpCommand(Command):
"""Show help for commands"""
usage = """
%prog <command>"""
ignore_require_venv = True
... | sailfishos-mirror/pip | src/pip/_internal/commands/help.py | .py | 073dcb7233505e4c | 7 | 0 |
import logging
from optparse import Values
from typing import Any
from pip._vendor.packaging.markers import default_environment
from pip._vendor.rich import print_json
from pip import __version__
from pip._internal.cli import cmdoptions
from pip._internal.cli.base_command import Command
from pip._internal.cli.status_... | sailfishos-mirror/pip | src/pip/_internal/commands/inspect.py | .py | 8a200cf89b8bfd9d | 7.5 | 0 |
from __future__ import annotations
import contextlib
import json
import logging
from collections.abc import Generator, Iterator, Sequence
from email.parser import Parser
from optparse import Values
from typing import TYPE_CHECKING, cast
from pip._vendor.packaging.utils import canonicalize_name
from pip._vendor.packag... | sailfishos-mirror/pip | src/pip/_internal/commands/list.py | .py | 5be172c574eb1c98 | 7 | 0 |
"""Configuration management setup
Some terminology:
- name
As written in config files.
- value
Value associated with a name
- key
Name combined with it's section (section.name)
- variant
A single word describing where the configuration key-value pair came from
"""
from __future__ import annotations
import co... | sailfishos-mirror/pip | src/pip/_internal/configuration.py | .py | d1e11d875c5394e1 | 7 | 0 |
from __future__ import annotations
import abc
from typing import TYPE_CHECKING
from pip._internal.metadata.base import BaseDistribution
from pip._internal.req import InstallRequirement
if TYPE_CHECKING:
from pip._internal.build_env import BuildEnvironmentInstaller, BuildIsolationMode
class AbstractDistribution... | sailfishos-mirror/pip | src/pip/_internal/distributions/base.py | .py | 06361ace0d8485b1 | 7 | 0 |
# This file was meant to be used with the Leapp actor framework
import os
import re
from datetime import datetime
from shutil import copyfileobj
from requests import Session
from six.moves import configparser
# from leapp.libraries.common.mounting import BindBount, LoopMount, OverlayMount, NullMount
from leapp.excep... | oamg/snippets | attic/download_rhn_boot_iso.py | .py | 7f669b83ffb95f66 | 7 | 0 |
# -*- coding:utf-8 -*-
__author__ = 'Dragon Sun'
__date__ = '2026-08-19 11:53:05'
import datetime
from typing import Optional
from zoneinfo import ZoneInfo
from pydantic import BaseModel, Field, AwareDatetime, field_validator, ValidationError
class Payload2(BaseModel):
name: str = Field(alias='name', default=''... | dragonsun7/dsPyLib | demo/demo_pydantic.py | .py | f7be72d40f2c7de4 | 7 | 0 |
# -*- coding:utf-8 -*-
__author__ = 'Dragon Sun'
__date__ = '2019-12-30 12:49:13'
import os
import tempfile
import threading
import uuid
from pathlib import Path
from typing import Literal, TypeAlias
from dsPyLib.ali.ali_access_token import AccessToken
from dsPyLib.sound.sound import play_wav, play_wav_async
from dsP... | dragonsun7/dsPyLib | dsPyLib/ali/ali_tts.py | .py | 6bdc104e33157f2a | 7 | 0 |
# -*- coding:utf-8 -*-
__author__ = 'Dragon Sun'
__date__ = '2020-06-08 09:56:26'
import warnings
import pandas
import peewee
from dsPyLib.类型.ds_rust_style_result import Result, Ok, Err
# 从Peewee的Query中生成DataFrame
def query_to_df(query: peewee.ModelSelect) -> Result[pandas.DataFrame, Exception]:
"""
wa... | dragonsun7/dsPyLib | dsPyLib/db/convert.py | .py | 241c10c3e65d0e5c | 7 | 0 |
# -*- coding:utf-8 -*-
__author__ = 'Dragon Sun'
__date__ = '2020-05-18 01:15:37'
from peewee import Model, SQL, DateTimeField, CharField
from dsPyLib.db.db import database_proxy
class DBBaseModel(Model):
""" 所有模型的基类 """
@classmethod
def 属性名转属性列表(cls, 属性名列表: list[str]) -> list:
return [getattr(... | dragonsun7/dsPyLib | dsPyLib/db/model.py | .py | cff3543afbc1ff6d | 7 | 0 |
# -*-coding:utf-8-*-
__author__ = 'Dragon Sun'
import psycopg2.extras
"""
psycopg2 官方文档:
http://initd.org/psycopg/docs/index.html
PostgreSQL 中的占位符与参数
有两种占位符:位置占位 和 名称占位
位置占位(使用 tuple 或者 list 传递参数):
sql = 'INSERT INTO drug (org_id, is_local, approval, approval_number) VALUES (%s, %s, %s, %s)'
param... | dragonsun7/dsPyLib | dsPyLib/db/pgsql.py | .py | db8678db248c0286 | 7 | 0 |
# -*- coding:utf-8 -*-
__author__ = 'Dragon Sun'
__date__ = '2020-01-23 15:02:45'
import datetime
from dsPyLib.utils.timez import str_to_date, date_to_str, is_weekend
from dsPyLib.pandas.pandas_config import *
"""
中国法定节假日数据 (chinese_holiday_data)
整个数据是一个数组,数组中的每一个元素包含了一年的法定节假日数据(按照年份升序排列),为字典类型,下面简称年数据
... | dragonsun7/dsPyLib | dsPyLib/holiday/holiday.py | .py | 0128a8d68586a8a5 | 7 | 0 |
# -*- coding:utf-8 -*-
__author__ = 'Dragon Sun'
__date__ = '2020-06-05 15:11:57'
import json
import pika
# RabbitMQ 保留的队列名(RPC Server),用于直接回复(Direct reply-to)
# https://pika.readthedocs.io/en/stable/examples/direct_reply_to.html
RESERVED_REPLY_TO_QUEUE = 'amq.rabbitmq.reply-to'
g_username = str() # RabbitMQ 服务器的用... | dragonsun7/dsPyLib | dsPyLib/mqueue/message_queue.py | .py | eef43fd302d54770 | 7 | 0 |
# -*- coding:utf-8 -*-
__author__ = 'Dragon Sun'
__date__ = '2020-07-28 18:58:32'
import datetime
import math
"""
进度信息管理器
"""
class ProgressInfoManager(object):
def __init__(self, on_changed):
"""
@param on_changed: def (percent: float, whole: str, elapsed: str, remain: str)
"""
... | dragonsun7/dsPyLib | dsPyLib/progress/progress_info_mgr.py | .py | e90731695177bfa1 | 7 | 0 |
# -*- coding:utf-8 -*-
__author__ = 'Dragon Sun'
__date__ = '2025-07-14 13:14:24'
import threading
import time
from typing import Optional
import rpyc
from rpyc.core.protocol import Connection
from rpyc.core.protocol import PingError
from dsPyLib.utils.logging import init_console_logger_with_level
class DSRPCClien... | dragonsun7/dsPyLib | dsPyLib/rpc/ds_rpc_client.py | .py | 6c6ae0551553c222 | 7 | 0 |
# -*- coding: utf-8 -*-
__author__ = 'Dragon Sun'
# 使用云之讯接口发送短信
# http://www.ucpaas.com/
import requests
import uuid
import json
g_sid = '填写你的 sid'
g_token = '填写你的 token'
g_app_id = '填写你的 app_id'
# 设置全局Keys(在使用前必须调用该函数传入相关信息)
def set_sms_keys(sid: str, token: str, app_id: str):
global g_sid
global g_token... | dragonsun7/dsPyLib | dsPyLib/sms/sms.py | .py | c163abc74ce43d8d | 7 | 0 |
# -*- coding:utf-8 -*-
__author__ = 'Dragon Sun'
__date__ = '2019-08-23 14:26:29'
import threading
import wave
from typing import Callable, Optional
import pyaudio
from dsPyLib.类型.ds_rust_style_result import Result, Ok, Err
def play_wav(file: str) -> Result[str, Exception]:
"""
同步播放WAV文件 (需要引用pyaudio)
... | dragonsun7/dsPyLib | dsPyLib/sound/sound.py | .py | 5715477a94271a98 | 7 | 0 |
# -*-coding:utf-8-*-
__author__ = 'Dragon Sun'
import calendar
import datetime
import math
import time
from enum import Enum
from typing import Union
from dateutil.parser import parse, ParserError
"""
"%Y-%m-%d %H:%M:%S.%f"
"""
时间类型 = Union[datetime.datetime, datetime.time, str]
日期类型 = Union[datetime.datetime, date... | dragonsun7/dsPyLib | dsPyLib/utils/datetimes.py | .py | f7d646cd0b038261 | 7 | 0 |
#! python3
# -*- coding: utf-8 -*-
"""Helpers to make class-only APIs usable from instances without boilerplate."""
from __future__ import annotations
from typing import Any, Callable, Type, cast
def add_instance_shortcuts(*classes: Type[Any]) -> None:
"""Attach a generic __getattr__ that forwards to class attri... | egigoka/commands | commands/_instance.py | .py | 68e69174ae03544c | 7.15 | 1 |
#! python3
# -*- coding: utf-8 -*-
"""Internal module to work with zip and tar.lzma archives."""
from __future__ import annotations
from .module import LazyModule, LazyProperty
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from typing import Any, Literal, Optional, cast
else:
def cast(_type, value):
... | egigoka/commands | commands/archive.py | .py | 7bb4d297f952adf5 | 7.15 | 1 |
#! python3
# -*- coding: utf-8 -*-
"""Internal module to work with audio."""
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from typing import Any
from .module import LazyModule
__version__ = "0.0.1"
mutagen = LazyModule("mutagen")
class Audio:
"""Class to work with ... | egigoka/commands | commands/audio.py | .py | 5257a9c7c2fed260 | 7.15 | 1 |
#! python3
# -*- coding: utf-8 -*-
"""Internal module to work with base64."""
from __future__ import annotations
from .module import LazyModule, LazyProperty
from typing import TYPE_CHECKING
if TYPE_CHECKING:
import base64
from typing import Optional, Union
__version__ = "2.0.1"
if not TYPE_CHECKING:
base... | egigoka/commands | commands/base64.py | .py | 4699b22e756c81f6 | 7.15 | 1 |
#! python3
# -*- coding: utf-8 -*-
"""Internal module to help with bash."""
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
import shlex
from typing import List, Optional
from .module import LazyModule, LazyProperty
__version__ = "0.1.0"
Console = LazyProperty(".console"... | egigoka/commands | commands/bash.py | .py | a22ea77a6daaa30b | 7.15 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.