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 |
|---|---|---|---|---|---|---|
from django import template
from masterdata.models import MasterData
register = template.Library()
@register.filter(name="range")
def _range(number):
return range(1, number + 1)
@register.filter(name="split")
def _split(string):
return string.split()
@register.filter(name="getattr")
def _getattr(obj, att... | karilint/cradle_of_mankind | app/masterdata/templatetags/my_filters.py | .py | 0c9f489e64a9c3be | 7 | 0 |
"""Provider boundary for local and future remote account acquisition."""
from __future__ import annotations
from typing import Protocol
from accounts.models import AccountLease, AccountRegion, InvalidAccountReason
class AccountProviderError(RuntimeError):
"""Credential-safe provider failure with stable machine... | Sekai-World/sekai-client | accounts/provider.py | .py | ad7342ee8c35cb0c | 7 | 0 |
"""Minimal game-account registration independent of client lifecycle code."""
from __future__ import annotations
from typing import Any, Protocol
import jwt
from accounts.models import AccountCredential, AccountRegion, JpEnCredential
from game_auth import GameAuthenticationService
REGISTRATION_PAYLOAD = {
"pla... | Sekai-World/sekai-client | accounts/registration.py | .py | 55e51f18b22dc764 | 7 | 0 |
"""
Public Flask API server for sekai-client JSON-RPC functionality.
Provides HTTP REST endpoints that proxy requests to region-specific
JSON-RPC servers running on localhost. Includes health check,
user profile fetching, and event ranking endpoints.
Authentication:
- All endpoints (except /health) require 'x-api-tok... | Sekai-World/sekai-client | api_public_server.py | .py | 17f200e61ababf66 | 7 | 0 |
"""
Centralized logging configuration for sekai-client.
Provides standardized logging setup with consistent formatting across
all modules. Use configure_logging() to initialize at application startup.
"""
import logging
import sys
from utils.redaction import enable_log_redaction
# Standard log format with structure... | Sekai-World/sekai-client | logging_config.py | .py | c0048d0122dfaa99 | 7 | 0 |
import json
import re
import subprocess
import time
from dataclasses import dataclass
from pathlib import Path
from typing import Any
from config import Config
from utils.jsonrpc_client import JSONRPCClient
from utils.redaction import redact_structure, redact_text
SERVICE_TYPES = ("shared_client", "check_update", "ev... | Sekai-World/sekai-client | service_dashboard.py | .py | 39028fcc01791521 | 7 | 0 |
"""
Pytest configuration and fixtures.
Provides common fixtures for testing sekai-client components.
"""
import logging
import os
import queue as queue_module
from unittest.mock import Mock
import pytest
# ``shared_client`` intentionally fails closed when a production process does
# not declare its region. Pytest ... | Sekai-World/sekai-client | tests/conftest.py | .py | 60bebd5f0934410d | 7.5 | 0 |
"""
Unit tests for configuration management.
Tests config parsing, validation, and defaults.
"""
from unittest.mock import patch
import pytest
from config import (
Config,
_parse_float_env,
_parse_int_env,
_parse_port_env,
_parse_str_env,
)
class TestConfigParsing:
"""Tests for environment... | Sekai-World/sekai-client | tests/test_config.py | .py | 1fddad31024eae10 | 7.5 | 0 |
#!/usr/bin/env python3
"""How much does eager task start actually save at the accept site?
``connection_made`` used to schedule the serve coroutine with
``asyncio.create_task``, which queues its first step for a later loop
iteration. ``asyncio.Task(coro, eager_start=True)`` runs that first step
inline instead. This ... | TOKUJI/BlackBull | bench/accept_hop_ab.py | .py | 66b86bdc8d1b4e14 | 7.35 | 4 |
"""Plaintext WebSocket echo server for Autobahn|Testsuite conformance runs.
Autobahn|Testsuite (``wstest --mode=fuzzingserver``) drives a peer over
``ws://`` to exercise RFC 6455 framing, control-frame handling, UTF-8
validation, close codes, fragmentation, and (optionally) permessage-deflate.
The expected behaviour ... | TOKUJI/BlackBull | bench/conformance/autobahn_app.py | .py | fe71d8aa117a6346 | 7.35 | 4 |
#!/usr/bin/env python3
"""Targeted repro for the Autobahn close-handshake hang.
Mimics the Autobahn fuzzingclient's pattern that leaves a *client* stalled
for the suite's whole duration:
1. TCP connect, HTTP upgrade handshake.
2. Send a frame the server must fail the connection over (reserved
non-control opc... | TOKUJI/BlackBull | bench/conformance/repro_autobahn_close.py | .py | c83260e26fee313b | 7.35 | 4 |
"""Slowloris body-phase attack.
Completes the request headers (with Content-Length) fast enough to
get past ``BB_HEADER_TIMEOUT``, then dribbles request-body bytes
one at a time to test ``BB_BODY_TIMEOUT`` (default 30 s).
Exercises the body-phase slowloris defence path in
[recipient.py](../../../blackbull/server/reci... | TOKUJI/BlackBull | bench/hostile_repro/attacks/slowloris_body.py | .py | 7aa39227881c7466 | 7.35 | 4 |
"""Slowloris quantitative characterisation.
Turns the qualitative "the three deadline timeouts work" claim in
`KNOWN_LIMITATIONS.md` into a defendable curve:
with N concurrent Slowloris-header connections held open, what is the
acceptance+service latency for a fresh *legitimate* HTTP/1.1 request?
A correctly... | TOKUJI/BlackBull | bench/hostile_repro/characterize_slowloris.py | .py | b67a5c6d11bfa36a | 7.35 | 4 |
#!/usr/bin/env python3
"""Capture the header lines a *real* browser sends, per connection.
`line_cache_realistic.py` encodes an assumption about what Chrome sends and how
it varies. An assumption about the input is exactly the thing a measurement
should not rest on, and the classic web-workload literature (SURGE and
... | TOKUJI/BlackBull | bench/hotpath/capture_browser_headers.py | .py | 13308b042ff6b8bd | 7.35 | 4 |
#!/usr/bin/env python3
"""Summarise a py-spy raw (folded) profile: self time and inclusive time.
A folded line is `<frame>;<frame>;...;<leaf> <count>`, one per distinct
stack. Self time is the leaf's share; inclusive time is every stack the
frame appears anywhere in. Import-time stacks are dropped — they are
startup... | TOKUJI/BlackBull | bench/hotpath/folded.py | .py | 1420e995790017eb | 7.35 | 4 |
#!/usr/bin/env python3
"""Where does the header-line cache break even, in requests per connection?
The cache is per connection, so the first request on every connection pays for
it and gets nothing back: every lookup misses and every line is admitted into a
dict that is discarded when the connection closes. Only from... | TOKUJI/BlackBull | bench/hotpath/line_cache_churn.py | .py | 27ff9260dc1e1a23 | 7.35 | 4 |
#!/usr/bin/env python3
"""Score the header-line cache against *captured* browser traffic.
Takes the JSON `capture_browser_headers.py` writes — real header lines from a
real Chromium, grouped by the TCP connection they arrived on — and reports both
the achieved hit rate and the parse cost, so the win is measured on obs... | TOKUJI/BlackBull | bench/hotpath/line_cache_hitrate.py | .py | 362e416ef54aa46b | 7.35 | 4 |
#!/usr/bin/env python3
"""What the validated header-line cache costs when it never hits.
`parser_micro.py` reuses one actor and one byte-identical request, which is the
keep-alive case the cache is designed for and therefore its best case. This is
the other end: every request carries header *values* this connection h... | TOKUJI/BlackBull | bench/hotpath/line_cache_miss.py | .py | 8cdaf5b3df2529a2 | 7.35 | 4 |
#!/usr/bin/env python3
"""Does the header-line cache pay on *real* traffic, or only on benchmarks?
`parser_micro.py` replays one byte-identical request and `wrk` sends the same
bytes every time — both are 100 % hit rate, which is the cache's best case and
not what a browser does. A real client keeps the connection al... | TOKUJI/BlackBull | bench/hotpath/line_cache_realistic.py | .py | d49fa07933ce71dc | 7.35 | 4 |
#!/usr/bin/env python3
"""The header-line cache's worst case, stated in numbers rather than adjectives.
Every other harness here measures where the cache is *meant* to help. This one
measures where it cannot help and can only cost, because a bound that has only
been exercised on friendly input is not a bound that has... | TOKUJI/BlackBull | bench/hotpath/line_cache_worst_case.py | .py | 6630f87d4b726b17 | 7.35 | 4 |
#!/usr/bin/env python3
"""Head-to-head on the one thing the two stacks do not share: the parser.
BlackBull owns every byte of HTTP/1.1 in Python (an architectural rule, not
an oversight); uvicorn delegates to httptools, a C wrapper around the
Node.js parser. Everything else in a request — routing, the handler, the
re... | TOKUJI/BlackBull | bench/hotpath/parser_micro.py | .py | 532291bd3d365346 | 7.35 | 4 |
"""aiohttp entrypoint for HttpArena — BlackBull-equivalent baseline app.
HttpArena's baseline profile (conns 512/4096) drives three request shapes
against /baseline11 (see scripts/lib/tools/gcannon.sh --raw rotation):
GET /baseline11?a=13&b=42 → "55" (query-param sum)
POST /baseline11?a=13&b=42 bod... | TOKUJI/BlackBull | bench/httparena/aiohttp/app.py | .py | 966a447eb8a28744 | 7.35 | 4 |
#!/usr/bin/env python3
"""Generate a 3-way HttpArena comparison table: two BlackBull result dirs plus
an optional peer (FastAPI) — every subscribed profile/conns cell, missing arms
left blank.
Usage:
python3 bench/httparena/compare_3way.py <dir-v067-peer> <dir-pr223> [--out FILE]
Both dirs come from the SAME EC2 in... | TOKUJI/BlackBull | bench/httparena/compare_3way.py | .py | 63771fdc7651500b | 7.35 | 4 |
#!/usr/bin/env python3
"""Emit a simple per-profile framework comparison table for an HttpArena run.
Reads the result JSONs an ``httparena_compare.sh`` run pulled back to
``<result_dir>/httparena-tree/results/<profile>/<conns>/<framework>.json`` and
writes a markdown table (``COMPARISON.md``) into the result dir, also... | TOKUJI/BlackBull | bench/httparena/compare_table.py | .py | 1ba89621baa7f75d | 7.35 | 4 |
"""HttpArena gRPC profiles — ``benchmark.BenchmarkService`` (``GetSum`` +
``StreamSum``).
The proto is tiny::
service BenchmarkService {
rpc GetSum (SumRequest) returns (SumReply);
rpc StreamSum (StreamRequest) returns (stream SumReply);
}
message SumRequest { int32 a = 1; int32 b... | TOKUJI/BlackBull | bench/httparena/grpc_bench.py | .py | 2a08420497cacde3 | 7.35 | 4 |
"""Sanic launcher for HttpArena — spawns Sanic on required ports.
HttpArena expects:
:8080 HTTP/1.1 cleartext
:8081 HTTPS HTTP/1.1 (json-tls profile)
:8082 h2c — Sanic does NOT support; left unbound
:8443 HTTPS H2 — Sanic does NOT support; serves HTTP/1.1
Sanic workers are set via WEB_... | TOKUJI/BlackBull | bench/httparena/sanic/launcher.py | .py | edb8804ac29330a9 | 7.35 | 4 |
"""Event loop lag monitor for BlackBull benchmarking.
Usage in a BlackBull app::
from bench.lag_monitor import LoopLagMonitor
monitor = LoopLagMonitor()
@app.on_startup
async def _start():
monitor.start()
@app.on_shutdown
async def _stop():
monitor.stop()
@app.route('/m... | TOKUJI/BlackBull | bench/lag_monitor.py | .py | fa28a00448c15b50 | 7.35 | 4 |
#!/usr/bin/env python3
import os
import re
from dataclasses import dataclass
from itertools import count
from typing import Any, Iterator, Type
import requests
ITEMS_PER_PAGE = 100 # 100 is the max
RELEASE_NOTES_FOLDER = (
f"{os.path.dirname(os.path.realpath(__file__))}/../docs/release-notes/"
)
@dataclass(fro... | rucio/documentation | tools/generate_release_notes.py | .py | abd43c59cea6502a | 7.35 | 4 |
#!/usr/bin/env python3
import os
import re
from collections import defaultdict
from functools import cmp_to_key, partial
from pathlib import Path
from typing import Union
import jinja2
ONEMINOR = re.compile(r"\d+\.\d+\.(\d+)")
SEMANTICMINOR = re.compile(r"\d+\.(\d+).+")
SEMANTICPATCH = re.compile(r"\d+\.\d+\.(\d+).*"... | rucio/documentation | tools/generate_release_notes_index.py | .py | cf22a941a3a553e2 | 7.35 | 4 |
#!/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, Set, TextIO, Tuple, Type
import requests
ITEMS_PER_PAGE = 100 # 100 is the max
OWNER = "rucio"
CORE_REPO = "rucio"
SECONDARY_REPO... | rucio/documentation | tools/generate_wishlist.py | .py | 19b0cb43c3e43502 | 7.35 | 4 |
"""Generate the code reference pages and navigation."""
import os
from pathlib import Path
import mkdocs_gen_files
def clean_dir(doc_path):
try:
files = os.listdir(doc_path)
for file in files:
try:
os.remove(f"{doc_path}/{file}")
except IsADirectoryError:
... | rucio/documentation | tools/run_in_docker/generate_policy_pages.py | .py | cee4d7d8adcd732e | 7.35 | 4 |
"""
A helper Python script to create a dict that contains the mappings between the various assays
that the proteomics pipeline can run, and the unique parameter files that each of the assays
requires.
"""
from pathlib import Path
from typing import Any
from pydantic import (
BaseModel, ConfigDict, AliasGenerator,... | MoTrPAC/motrpac-proteomics-pipeline | scripts/parameter_mapping_generator.py | .py | a5384a95405902d7 | 7.15 | 1 |
#! /usr/bin/env python
from django.conf import settings
from django.contrib.auth.models import User, Group
from django.core.paginator import Paginator
from drf_queryfields import QueryFieldsMixin
from face_manager.models import Person, Face
from filepopulator.models import ImageFile, Directory
from rest_framework impo... | benjaminlewis-1000/django_picasa | api/serializers.py | .py | b530a2941af140db | 7 | 0 |
#! /usr/bin/env python
import os
import PIL
from PIL import Image, ExifTags
import numpy as np
import django
def apply_exif_orientation(image, orientation):
"""Apply the EXIF Orientation transform to a PIL Image, returning the
corrected image. Handles all 8 standard values (1-8) via transpose(),
which i... | benjaminlewis-1000/django_picasa | common/open_img_oriented.py | .py | 189abb9ee73f9f2b | 7 | 0 |
import os
import numpy as np
from django.conf import settings
from django.test import TestCase
from PIL import Image
from common.open_img_oriented import open_img_oriented, apply_exif_orientation
class OpenImgOrientedTests(TestCase):
def test_missing_file_raises(self):
with self.assertRaises(FileNotFoun... | benjaminlewis-1000/django_picasa | common/tests.py | .py | 107361e88d4db36e | 7.5 | 0 |
#! /usr/bin/env python
import getpass
import os
import readline
import pathlib
import random
import shutil
import string
import xmltodict
import subprocess
import string
import sys
import glob
def randomString(stringLength=10):
"""Generate a random string of fixed length """
letters = string.ascii_letters + s... | benjaminlewis-1000/django_picasa | dockerize_dev/setup.py | .py | 52b2134d41b095fb | 7 | 0 |
#! /usr/bin/env python
from face_manager.models import Person, Face
from face_manager.face_extract_encode import FaceExtractor
from filepopulator.models import ImageFile
from django.core.management.base import BaseCommand
import editdistance
from time import sleep
import numpy as np
import insightface
from insightfac... | benjaminlewis-1000/django_picasa | face_manager/management/commands/encode_library_to_insightface.py | .py | b8d48902cf69d077 | 7 | 0 |
#! /usr/bin/env python
from django.conf import settings
from django.core.management.base import BaseCommand
from django.db.models import Count
from django.db.models import Q
from face_manager import face_classifier
from face_manager.models import Person, Face
from filepopulator.models import ImageFile
from scipy impor... | benjaminlewis-1000/django_picasa | face_manager/management/commands/feature_vecs_for_snn.py | .py | d461931e39ec4258 | 7 | 0 |
"""Sphinx ReadTheDocs theme.
From https://github.com/ryan-roemer/sphinx-bootstrap-theme.
"""
from os import path
__version__ = '0.4.3'
__version_full__ = __version__
def get_html_theme_path():
"""Return list of HTML theme paths."""
cur_dir = path.abspath(path.dirname(path.dirname(__file__)))
return cur... | Dennis-van-Gils/python-dvg-devices | docs/_themes/sphinx_rtd_theme/__init__.py | .py | 66a48b25f8fb70e5 | 7.35 | 4 |
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Cyclic Redundancy Check (CRC) tools
"""
__author__ = "Dennis van Gils"
__authoremail__ = "vangils.dennis@gmail.com"
__url__ = "https://github.com/Dennis-van-Gils/python-dvg-devices"
__date__ = "23-05-2024"
__version__ = "1.5.0"
from typing import Tuple
# fmt:off
auchC... | Dennis-van-Gils/python-dvg-devices | src/dvg_devices/XylemHydrovarHVL_CRC_tools.py | .py | c771879f8d2de4f7 | 7.35 | 4 |
""" joint.py
Define the Joint class and subclasses
A Joint object stores the degrees of freedom that the joint constrains,
and a draw() method for creating the image on the canvas
See support.py
"""
import support as sup
class Joint:
""" Parent class for joints
Each Joint instance should inherit also from a Supp... | jonkb/phys.mtrl | src/joint.py | .py | 01b7d94db0595e7c | 7 | 0 |
""" load.py
Define the Load class & subclasses
Load types (ltype):
0: Point load (Load)
1: Distributed load (Distr_Load)
2: Applied Moment (Moment)
"""
import math
import numpy as np
import sympy as sym
class Load:
""" Standard point load
Also serves as a parent class for other kinds of loads
"""
# Constants
a... | jonkb/phys.mtrl | src/load.py | .py | 9b7edfd932e6925a | 7 | 0 |
""" math_util.py
Math utilities
"""
import math
import numpy as np
import sympy as sym
#from sympy.sets import Interval
# Constants
eps = 1e-14
default_sigfig = 6
grav = 9.81 # m/s^2
def sigfig(x, n=default_sigfig):
""" Significant Figures
Round x to n significant figures
"""
if isinstance(x, np.ndarray):
# Th... | jonkb/phys.mtrl | src/math_util.py | .py | e65b9bd417f9ed69 | 7 | 0 |
""" pmfs.py
phys.mtrl file system
Define functions for saving and loading the Lab
"""
import tkinter as tk
from datetime import datetime
import xml.etree.ElementTree as ET
import os
#My files
from member import *
from region import *
from support import *
from load import *
# Constants
ftypes = [('All Files', '*.*'... | jonkb/phys.mtrl | src/pmfs.py | .py | e873a81f89e3e9a2 | 7 | 0 |
""" support.py
Define the Support class and subclasses
A Support object stores the degrees of freedom that the support constrains,
and a draw() method for creating the image on the canvas
"""
import math
import math_util as m_u
class Support:
""" Parent class for supports
"""
sup_types = {
0: "Fixed",
1: "Pi... | jonkb/phys.mtrl | src/support.py | .py | fea71cd57a310ac8 | 7 | 0 |
""" tk_wig.py
Custom Tkinter Widgets
Tk_rt: Wrapper for tk.Tk
PM_Menu: Phys.Mtrl Menu bar
Txt_wig: Text widget used for displaying copyable text without receiving input
"""
import math
import tkinter as tk
from tkinter import font
import os
from member import Member
# Constants
default_font_size = 11
font_list = ["... | jonkb/phys.mtrl | src/tk_wig.py | .py | efbb99e5fe275419 | 7 | 0 |
""" toolbars.py
Define the toolbars for adding Members, Supports/Joints, and Loads
"""
import tkinter as tk
import math
from member import *
from region import *
from support import Support
# Width of numerical entry fields
num_e_wid = 8
class Add_mem:
""" Add member toolbar
"""
def __init__(self, main_frm):
s... | jonkb/phys.mtrl | src/toolbars.py | .py | ff9fd0b2c6140039 | 7 | 0 |
#!/usr/bin/env python
# coding=utf-8
"""
A framework for command-line Python "applications", with features that I was
in need of at the time.
Modernized version:
- AppFrameworkError is a normal, catchable exception (it no longer calls
sys.exit() itself and no longer swallows the original traceback).
- run() is... | mindthump/python_app_framework | app_utils/app_framework.py | .py | 63f18da5906687b2 | 7 | 0 |
"""
Optional, opt-in local-storage support for AppFramework apps.
This is NOT wired into AppFramework or every app -- it's a mixin. Only
apps that actually need a small local database between runs inherit from
it; apps that don't (like greet.py) carry no trace of this feature at all.
Usage:
from app_utils import... | mindthump/python_app_framework | app_utils/db_support.py | .py | d5a11e4e91fc92ab | 7 | 0 |
import os
import sys
# We should be able to import toolbox stuff here b/c this module is
# imported after the sys.path setup
from pathlib import Path
import contextlib
import logging
import logging.handlers
logging.getLogger("requests").setLevel(logging.WARNING)
logging.getLogger("urllib3").setLevel(logging.WARNING)
... | mindthump/python_app_framework | app_utils/utils.py | .py | d08edab7cf914e4a | 7 | 0 |
import json
import os
import random
import falcon
from app_utils import utils
logger = utils.initialize_logging()
_FRUIT_FILE = os.path.join(os.path.dirname(__file__), "fruit.json")
# Load once at import time instead of re-reading/re-parsing the file on
# every single request -- the list is static for the life of ... | mindthump/python_app_framework | fruit_server_app/fruit_server.py | .py | 95b87bfd5a60f856 | 7 | 0 |
import random
import sys
import json
from app_utils import app_framework
class Greeter(app_framework.AppFramework):
# Return codes for a single user's greeting attempt.
FRUIT_SERVICE_UNREACHABLE = 66
FRUIT_SERVICE_UNEXPECTED_ERROR = 99
def __init__(self):
# This call to super().__init__ is t... | mindthump/python_app_framework | greet_app/greet.py | .py | 00b75a1b581f621d | 7 | 0 |
"""
Minimal test-only stand-in for the real `configargparse` package.
This is NOT a full reimplementation of configargparse -- it supports just
enough of the real library's API surface (as actually used by
app_framework.py / greet.py: env_var=, is_config_file=,
default_config_files=, format_values(),
get_command_line_... | mindthump/python_app_framework | greet_app/tests/fakes/configargparse.py | .py | aaab6416dfa7ce23 | 7.5 | 0 |
import sqlite3
import tempfile
import unittest
from pathlib import Path
from tests import _bootstrap # noqa: F401 (sets up sys.path for the fake configargparse)
from app_utils import app_framework
from app_utils.db_support import SqliteStorageMixin
class _DbApp(SqliteStorageMixin, app_framework.AppFramework):
... | mindthump/python_app_framework | greet_app/tests/test_db_support.py | .py | b589b860318ff628 | 7.5 | 0 |
"""
Boilerplate script frame, so a tiny command-line script has
basic organization, arguments, etc.
"""
# import os
import sys
import argparse
import logging
from pathlib import Path
class App:
def __init__(self, app_args):
self.args = app_args
logging.basicConfig(
level=logging.DEBUG,... | mindthump/python_app_framework | instant_app.py | .py | d2b596c6d3645897 | 7 | 0 |
#!/usr/bin/env python3
"""Make hard links where possible."""
import argparse
import collections
import csv
import hashlib
import stat
import subprocess
import typing as t
from pathlib import Path
if t.TYPE_CHECKING:
import os
__TODO__ = """
- Proper, rsync/tar-like exclude
"""
DEFAULT_MIN_SIZE = 1024 * 1024
de... | ErezVolk/evstuff | attic/dedupe.py | .py | a37a49c6d9db4c1d | 7.3 | 3 |
#!/usr/bin/env -S uv run --script
"""Unpair bluetooth devices."""
import argparse
import json
import shutil
import subprocess
import sys
import typing as t
import beaupy # ty: ignore[unresolved-import]
BLUETOOTH_PAGE = "x-apple.systempreferences:com.apple.preferences.Bluetooth"
class Demagic:
"""Unpair bluetoo... | ErezVolk/evstuff | attic/demagic.py | .py | bddef5d4c96c8676 | 7.3 | 3 |
#!/usr/bin/env python3
"""Remove password from PDF."""
import getpass
import sys
from pathlib import Path
import pymupdf
def depass() -> None:
"""Remove password from one or more PDFs."""
for name in sys.argv[1:]:
depass_file(Path(name))
def depass_file(path: Path) -> None:
"""Remove password f... | ErezVolk/evstuff | attic/depass.py | .py | f24bbd3bb18b7cea | 7.3 | 3 |
#!/usr/bin/env python3
"""Download a bunch of lessons"""
import argparse
from dataclasses import dataclass
import datetime
from pathlib import Path
import subprocess
import time
import random
import re
import shutil
import tempfile
import tomllib
import typing as t
import pandas as pd
HERE = Path.cwd()
THIS = Path(__... | ErezVolk/evstuff | attic/dlessons.py | .py | d616ada295fc5b00 | 7.3 | 3 |
"""DocxWorker: Base class for scripts that do stuff to .docx files."""
# pyright: reportAttributeAccessIssue=false
import abc
import typing as t
import zipfile as zf
from collections import Counter
from collections.abc import Callable
from collections.abc import Iterable
from pathlib import Path
from pathlib import Pur... | ErezVolk/evstuff | attic/docx_worker.py | .py | 1aa3ae2ccf1244ba | 7.3 | 3 |
#!/usr/bin/env -S uv run --script
"""Shuffle paragraphs in a Word document."""
import argparse
import pickle
import random
import re
from collections import defaultdict
from pathlib import Path
import numpy as np
from lxml import etree
from docx_worker import DocxWorker
from evutils import write_runner
class DocxSh... | ErezVolk/evstuff | attic/docxshuffle.py | .py | 06b346f3c46c1eb5 | 7.3 | 3 |
#!/usr/bin/env python3
"""Download LibreOffice language packs."""
import argparse
import random
import subprocess
from pathlib import Path
def download_libreoffice_language_packs() -> None:
"""Download LibreOffice language packs."""
parser = argparse.ArgumentParser()
parser.add_argument("-v", "--version",... | ErezVolk/evstuff | attic/download_libreoffice_language_packs.py | .py | 3c576aeba6449c65 | 7.3 | 3 |
#!/usr/bin/env -S uv run --script
"""Based on code from https://github.com/fab-jul/parse_dictionaries."""
import itertools
import json
import zlib
from pathlib import Path
import regex as re # ty: ignore[unresolved-import]
from lxml import etree # ty: ignore[unresolved-import]
ROOT = Path(
"/System/Library/Ass... | ErezVolk/evstuff | attic/get_hebrew_words.py | .py | b75b082e562ce661 | 7.3 | 3 |
#!/usr/bin/env python
"""A simple metronome.
Metronome sounds recorded by Ludwig Peter Müller (muellerwig@gmail.com)
and distributed under the Creative Commons CC0 1.0 Universal license.
https://www.reddit.com/r/audioengineering/comments/kg8gth/free_click_track_sound_archive/?rdt=48837
Zip file: https://stash.reaper.f... | ErezVolk/evstuff | attic/metronome.py | .py | 2bc59a0fe63fea41 | 7.3 | 3 |
#!/usr/bin/env -S uv run --script
"""Help extracting some semblance of index from PDF files."""
# pyright: reportMissingImports=false
# pylint: disable=import-error
import argparse
import re
import subprocess
import tempfile
from pathlib import Path
import pymupdf # ty: ignore[unresolved-import]
THIS = Path(__file__... | ErezVolk/evstuff | attic/mkidx.py | .py | e2d3a69642ad915f | 7.3 | 3 |
#!/usr/bin/env python3
"""Simple 2-up for PDFs."""
# pyright: reportMissingImports=false
# pylint: disable=import-error
import argparse
from pathlib import Path
import pymupdf
class Pdf2Up:
"""Simple 2-up for PDFs."""
def parse_args(self) -> None:
"""Parse command line arguments."""
parser ... | ErezVolk/evstuff | attic/pdf2up.py | .py | 8888f8b045157360 | 7.3 | 3 |
#!/usr/bin/env -S uv run --script
"""PDF to UTF-8 and audiobook (WIP)."""
__TODO__ = """
- U+2011 NON-BREAKING-HYPHEN should consume all preceding whitespace (Jorge)
- repeating header/footer (Jorge)
"""
import argparse
import html
import re
import subprocess
import typing as t
from pathlib import Path
import numpy ... | ErezVolk/evstuff | attic/pdf2utf.py | .py | 9cd702aee59d9407 | 7.3 | 3 |
#!/usr/bin/env python3
"""Pack InDesign published folder."""
import argparse # noqa: I001
import datetime
from pathlib import Path
import shutil
import string
import tempfile
import typing as t
import zipfile
class PackInDesignPublishedFolder:
"""Pack InDesign published folder."""
args: argparse.Namespace
... | ErezVolk/evstuff | attic/pidpf.py | .py | 0992cde636c6dfbe | 7.3 | 3 |
#!/usr/bin/env -S uv run --script
"""Checks things in .docx files."""
__TODO__ = """
- Hebrew Maqaf
"""
import argparse
import datetime
import re
import shutil
import subprocess
import typing as t
from collections import Counter
from collections import defaultdict
from copy import deepcopy
from pathlib import Path
fr... | ErezVolk/evstuff | attic/proof.py | .py | 7f2185673be2cc38 | 7.3 | 3 |
#!/usr/bin/env -S uv run --script
"""Collect professional ratings for albums linked from a musician's Wikipedia page.
Given the URL of a Wikipedia article about a musician, find every album
*linked* in the article's Discography section (album/work titles are wiki-links
wrapped in italics), open each album's page, read... | ErezVolk/evstuff | attic/ratings.py | .py | 58eccdbcdd334f2c | 7.3 | 3 |
#!/usr/bin/env python3
"""Act as tee (stripping ANSI codes)."""
import re
import sys
from pathlib import Path
_HELP = {"-?", "-h", "--help"}
# ECMA-48: 2-byte Fe escapes and CSI sequences (covers SGR color codes)
_ANSI = re.compile(rb"\x1B(?:[@-Z\\-_]|\x5B[0-9;?]*[ -/]*[@-~])")
def _usage(progname: str) -> None:
... | ErezVolk/evstuff | attic/striptee.py | .py | f928eea93c70c507 | 7.3 | 3 |
#!/usr/bin/env -S uv run --script
"""UTF-8 to audiobook."""
import argparse
import html
import re
import subprocess
import sys
from pathlib import Path
import pandas as pd
from google.cloud import texttospeech as gg_tts # ty: ignore[unresolved-import]
PAUSE_TO_GAP_MS = {3: 4000, 2: 3000, 1: 1000}
class Utf2Tts:
... | ErezVolk/evstuff | attic/utf2tts.py | .py | afffab806d3d4919 | 7.3 | 3 |
#!/usr/bin/env -S uv run --script
"""Create translation CVs."""
# pyright: reportMissingImports=false
# mypy: disable-error-code="import-untyped,import-not-found"
import argparse
import re
import sys
import typing as t
from pathlib import Path
import pandas as pd # ty: ignore[unresolved-import]
from docxtpl import D... | ErezVolk/evstuff | cv/convert.py | .py | a87f22ff32d572e3 | 7.3 | 3 |
"""
.. See the NOTICE file distributed with this work for additional information
regarding copyright ownership.
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.or... | Ensembl/thr | info/serializers.py | .py | f6acf4709db9b4ca | 7.15 | 1 |
"""
.. See the NOTICE file distributed with this work for additional information
regarding copyright ownership.
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.or... | Ensembl/thr | info/tests.py | .py | f73351b5c77ba094 | 7.65 | 1 |
"""
.. See the NOTICE file distributed with this work for additional information
regarding copyright ownership.
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.or... | Ensembl/thr | info/views.py | .py | d169fee92c10c67e | 7.15 | 1 |
"""
.. See the NOTICE file distributed with this work for additional information
regarding copyright ownership.
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.or... | Ensembl/thr | search/serializers.py | .py | 96a2080c27b8755e | 7.15 | 1 |
"""
.. See the NOTICE file distributed with this work for additional information
regarding copyright ownership.
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.or... | Ensembl/thr | search/views.py | .py | 7f21a1b9ae62f96e | 7.15 | 1 |
"""
.. See the NOTICE file distributed with this work for additional information
regarding copyright ownership.
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.or... | Ensembl/thr | stats/serializers.py | .py | fbfec5a8cddd6bba | 7.15 | 1 |
"""
.. See the NOTICE file distributed with this work for additional information
regarding copyright ownership.
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.or... | Ensembl/thr | stats/views.py | .py | 40cb374b665d8274 | 7.15 | 1 |
"""
.. See the NOTICE file distributed with this work for additional information
regarding copyright ownership.
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.or... | Ensembl/thr | trackdbs/serializers.py | .py | 30abb2b8589774de | 7.15 | 1 |
"""
.. See the NOTICE file distributed with this work for additional information
regarding copyright ownership.
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.or... | Ensembl/thr | trackdbs/tests.py | .py | 225973994ec3fd12 | 7.65 | 1 |
"""
.. See the NOTICE file distributed with this work for additional information
regarding copyright ownership.
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.or... | Ensembl/thr | trackdbs/update_trackdb.py | .py | 64216b426f07d8dc | 7.15 | 1 |
"""
.. See the NOTICE file distributed with this work for additional information
regarding copyright ownership.
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.or... | Ensembl/thr | trackdbs/views.py | .py | 7f368027b4fc0eda | 7.15 | 1 |
"""
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 | ac25a01c00dc97a5 | 7.35 | 4 |
"""
An input loop based around click.getchar(). Supports arrow key escape sequences on both Unix-like platforms and Windows.
When run directly this this script will enter a test loop.
"""
from enum import Enum
import click
class ArrowKeyMapping(Enum):
UP = "w"
DOWN = "s"
LEFT = "a"
RIGHT = "d"
de... | JoelEager/terminal-mines | terminal_mines/game_logic/keyboard_listener.py | .py | a9b68ffc8a7f3060 | 7.35 | 4 |
"""
A minesweeper board solver. Includes logic to display moves as they are made.
"""
from random import randint, shuffle
from time import sleep
from click import echo
from .game_model import GameState, CellState
from .renderer import render
class Move:
"""
Models a move for the AI.
"""
... | JoelEager/terminal-mines | terminal_mines/game_logic/solver.py | .py | 22e3775ea816a799 | 7.35 | 4 |
"""
Entry point and CLI implementation for terminal-mines.
"""
import click
from .game_logic import random_minefield, Minefield, GameState, input_loop, render, solve_game
DIFFICULTY_PRESETS = {
"balanced": (35, 20, 15),
"challenging": (70, 25, 20),
"easy": (10, 8, 8),
"intermediate": (40, 16, 16),
... | JoelEager/terminal-mines | terminal_mines/mines.py | .py | 5ba09332c8ec541b | 7.35 | 4 |
# Give us access to the urllib2 functions.
from urllib2 import build_opener, install_opener, urlopen, HTTPError
# Give us access to the OS module functions.
from os import makedirs, path
# Give us access to our basic SimpleRequests functions.
from .SimpleRequest import error
# Give us access to the JSON module funct... | rodriada000/SessionCustomMapReleases | Discord-Scraper/SimpleRequests/SimpleRequestsPy2.py | .py | e92844062a9cadcf | 7.15 | 1 |
# Give us access to http.client functions for network requests.
from http.client import HTTPConnection, HTTPSConnection, HTTPException
# Give us access to the OS module functions.
from os import makedirs, path
# Give us access to our basic SimpleRequests functions.
from .SimpleRequest import error
# Give us access t... | rodriada000/SessionCustomMapReleases | Discord-Scraper/SimpleRequests/SimpleRequestsPy3.py | .py | 76ee26a46146df43 | 7.15 | 1 |
# -*- coding: utf-8 -*-
__author__ = "Paul Schifferer <dm@sweetrpg.com>"
"""Library routes.
"""
from flask import Blueprint, current_app, request, jsonify, flash, redirect, url_for
from sweetrpg_game_room_web.application import constants
from sweetrpg_web_core.helpers.context import get_context
from sweetrpg_game_room... | sweetrpg/game-room-web | src/sweetrpg_game_room_web/application/blueprints/library/__init__.py | .py | 64f9c1e45429edc2 | 7 | 0 |
# -*- coding: utf-8 -*-
__author__ = "Paul Schifferer <dm@sweetrpg.com>"
"""License routes.
"""
import functools
from flask import Blueprint, current_app, render_template, request, g, flash
from sweetrpg_game_room_web.application import constants
from sweetrpg_web_core.helpers.context import get_context
from sweetrpg_... | sweetrpg/game-room-web | src/sweetrpg_game_room_web/application/blueprints/licenses/__init__.py | .py | 355940212e834f7e | 7 | 0 |
# -*- coding: utf-8 -*-
__author__ = "Paul Schifferer <dm@sweetrpg.com>"
"""Table routes.
"""
from flask import Blueprint, current_app, request, flash, redirect, url_for
from sweetrpg_game_room_web.application import constants
from sweetrpg_web_core.helpers.context import get_context
from sweetrpg_game_room_web.applic... | sweetrpg/game-room-web | src/sweetrpg_game_room_web/application/blueprints/tables/__init__.py | .py | a0536a5a1948a5a6 | 7 | 0 |
# -*- coding: utf-8 -*-
__author__ = "Paul Schifferer <dm@sweetrpg.com>"
"""Volume routes.
"""
import functools
from flask import Blueprint, current_app, render_template, request, g, flash
from sweetrpg_game_room_web.application import constants
from sweetrpg_web_core.helpers.context import get_context
from sweetrpg_c... | sweetrpg/game-room-web | src/sweetrpg_game_room_web/application/blueprints/volumes/__init__.py | .py | 66857681d326020b | 7 | 0 |
# -*- coding: utf-8 -*-
__author__ = "Paul Schifferer <dm@sweetrpg.com>"
"""Wishlist routes.
"""
from flask import Blueprint, current_app, request, flash, redirect, url_for
from sweetrpg_game_room_web.application import constants
from sweetrpg_web_core.helpers.context import get_context
from sweetrpg_game_room_web.app... | sweetrpg/game-room-web | src/sweetrpg_game_room_web/application/blueprints/wishlist/__init__.py | .py | 0fee05abc31d82f3 | 7 | 0 |
# -*- coding: utf-8 -*-
__author__ = "Paul Schifferer <dm@sweetrpg.com>"
"""
"""
def normalize_query_param(value):
"""
Given a non-flattened query parameter value,
and if the value is a list only containing 1 item,
then the value is flattened.
:param value: a value from a query parameter
:ret... | sweetrpg/game-room-web | src/sweetrpg_game_room_web/application/utils/__init__.py | .py | e53e166ce4b3eba0 | 7 | 0 |
# -*- coding: utf-8 -*-
__author__ = "Paul Schifferer <dm@sweetrpg.com>"
"""test_maintenance_mode.py
Covers the maintenance-mode before_request hook added to the main "web"
blueprint: it should short-circuit with a maintenance page when admin-api
reports an active maintenance-mode record for this app's scopes, stay
co... | sweetrpg/game-room-web | tests/test_maintenance_mode.py | .py | 071ca69bf0a8e0a4 | 7.5 | 0 |
#!/usr/bin/env python
"""
Asmodeus, script 2: observe
Computes apparent positions and magnitudes for all observers as defined in the configuration file,
using generated meteors saved in specified dataset's `meteors` subdirectory
Requires: meteors
Outputs: sightings
"""
from core impo... | sesquideus/asmodeus | apps/observe.py | .py | 9c93effbe41f9a45 | 7.35 | 4 |
"""Deprecated import shim for the old ``TheHawkesPackage`` import name.
Importing this package emits a :class:`DeprecationWarning`. Every attribute and
submodule is forwarded to :mod:`hawkes_package`; the objects are *identical*
(same module objects, same classes), so ``isinstance`` checks are unaffected.
This shim i... | jeMATHfischer/TheHawkesPackage | src/TheHawkesPackage/__init__.py | .py | 542836a7f9fe1bbd | 7.15 | 1 |
"""Helpers for emitting :class:`DeprecationWarning` from renamed public APIs.
Everything the package deprecates routes through here so the wording, the
removal version and the ``stacklevel`` stay consistent across call sites.
"""
from __future__ import annotations
import functools
import warnings
from collections.ab... | jeMATHfischer/TheHawkesPackage | src/hawkes_package/_deprecation.py | .py | 5d04822791be227f | 7.15 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.