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
# Copyright©2021, Regents of the University of California # http://creativecommons.org/licenses/BSD """List existing shoulders """ import argparse import logging import django.core.management import impl.nog_sql.shoulder import impl.nog_sql.util log = logging.getLogger(__name__) class Command(django.core.manag...
CDLUC3/ezid
ezidapp/management/commands/shoulder-list.py
.py
15afef2926b6a555
7.56
12
# Copyright©2021, Regents of the University of California # http://creativecommons.org/licenses/BSD """Mint one or more new identifiers on an existing shoulder """ import argparse import logging import django.core.management import ezidapp.models.shoulder import impl.nog_sql.ezid_minter import impl.nog_sql.util ...
CDLUC3/ezid
ezidapp/management/commands/shoulder-mint.py
.py
1475e7af8116672f
7.56
12
# Copyright©2021, Regents of the University of California # http://creativecommons.org/licenses/BSD """Update the Datacenter for an existing DOI shoulder """ import argparse import logging import django.core.management import ezidapp.models.datacenter import ezidapp.models.shoulder import impl.nog_sql.shoulder im...
CDLUC3/ezid
ezidapp/management/commands/shoulder-update-datacenter.py
.py
2af2286a4c5bec09
7.56
12
#!/usr/bin/env -S uv run --script # /// script # requires-python = ">=3.11" # dependencies = ["youtube-transcript-api==1.2.4"] # /// """ Extract transcript from a YouTube video. Usage: get-transcript.py <video_id_or_url> [--timestamps] [--language LANGUAGE] """ import argparse import re import sys from youtube_t...
ipruning/dotfiles
modules/bin/get-transcript.py
.py
94c6fb5c09fba818
7.57
13
#!/usr/bin/env -S uv run --script # /// script # requires-python = ">=3.11" # dependencies = [ # "loguru==0.7.3", # "rich==15.0.0", # ] # /// import os import re import subprocess import sys from loguru import logger from rich.console import Console from rich.text import Text logger.remove() logger.add( ...
ipruning/dotfiles
modules/bin/link.py
.py
b903ae043c12a94c
7.57
13
#!/usr/bin/env -S uv run --script # /// script # requires-python = ">=3.11" # /// import logging import os import sys def _setup_logger(): logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s") return logging.getLogger(__name__) def _read_text_file(path: str) -> str: expanded = os...
ipruning/dotfiles
modules/bin/pmt.py
.py
fa98a135f3bfcbbe
7.57
13
"""Host-owned policy that can make this repository audit-only.""" from __future__ import annotations import tomllib from dataclasses import dataclass from pathlib import Path POLICY_RELATIVE_PATH = Path(".config/dotfiles/policy.toml") MANAGED_MODE = "managed" AUDIT_ONLY_MODE = "audit-only" class HostPolicyError(Ru...
ipruning/dotfiles
scripts/host_policy.py
.py
87833a2c4fb189cb
7.57
13
"""Shared ownership policy for the mise executable.""" from __future__ import annotations import os from pathlib import Path from .host_policy import configured_mise_path MISE_RELATIVE_PATH = Path(".local/bin/mise") def canonical_mise_path(home: Path) -> Path: return configured_mise_path(home) or home / MISE_...
ipruning/dotfiles
scripts/mise.py
.py
f34ed0e94e124138
7.57
13
"""Host profiles shared by inspection and explicit setup commands.""" from __future__ import annotations import platform from enum import StrEnum class HostProfile(StrEnum): AUTO = "auto" LINUX_LITE = "linux-lite" MACOS = "macos" FULL = "full" LINUX_LITE_APPLICATIONS = frozenset( {"atuin", "bt...
ipruning/dotfiles
scripts/profiles.py
.py
7acec3c92d6380ad
7.57
13
"""Shared fixtures for repository behavior tests.""" from __future__ import annotations import os import subprocess import sys from functools import cache from pathlib import Path REPO_ROOT = Path(__file__).resolve().parents[1] def mackup_cfg(applications: str = "") -> str: """Return a minimal Mackup storage c...
ipruning/dotfiles
tests/conftest.py
.py
b02fae44ea522bed
8.07
13
import os from itertools import cycle from runez.system import flattened class AsciiAnimation: """Progress spinner animations""" env_var = "SPINNER" # Env var overriding which predefined spinner to use default = "dots" # Default spinner to use @classmethod def available_names(cls, include_vir...
codrsquad/runez
src/runez/ascii.py
.py
1657e5be4c991213
7.5
9
""" Convenience commonly used click options: @runez.click.version() @runez.click.debug() @runez.click.dryrun("-n") # If you wanted an extra `-n` flag to mean `--dryrun` as well @runez.click.log() def main(debug, dryrun, log, ...): ... """ import argparse import errno import logging import...
codrsquad/runez
src/runez/click.py
.py
a72395493b760d94
7.5
9
import os from runez.colors import NamedColors, NamedStyles, PlainBackend, Renderable from runez.convert import to_int VALID_FLAVORS = {"dark", "light", "neutral"} class AnsiCode: """Compute ANSI escape codes to use for a given RGB color""" bg_offset = 40 fg_offset = 30 @classmethod def enhanc...
codrsquad/runez
src/runez/colors/terminal.py
.py
2625bc566484d300
7.5
9
""" Import this only from your test cases Example: from runez.conftest import cli, temp_folder """ from __future__ import annotations import logging import os import re import sys import traceback from pathlib import Path from typing import TYPE_CHECKING import _pytest.logging import pytest if TYPE_CHECKING: ...
codrsquad/runez
src/runez/conftest.py
.py
659f118c4c1d4be9
8
9
""" Daemon thread that can be used to run periodical background tasks. Assumptions: - Tasks should be reasonably short running (do not use this for long operations) - Execution frequency should be >= 1 second (this is not designed for very quick frequency) - Frequency does not dynamically change (stated once at task c...
codrsquad/runez
src/runez/heartbeat.py
.py
696c5397c1d82e88
7.5
9
""" This module holds less often used conveniences, it is not available via `import runez` Functions from this module must be explicitly imported, for example: >>> from runez.inspector import auto_import_siblings """ import importlib from runez.system import find_caller def auto_import_siblings(skip=None, caller=...
codrsquad/runez
src/runez/inspector.py
.py
62356516536835d7
8
9
from __future__ import annotations import inspect import os from runez.colors import ColorManager from runez.convert import to_int from runez.system import _R, flattened, joined, OptionalColor, short, Slotted, stringified, SYS_INFO, UNSET, wcswidth NAMED_BORDERS = { "ascii": "rstgrid,t:+++=,m:+++-", "compact...
codrsquad/runez
src/runez/render.py
.py
72b8483b4e6a40a3
7.5
9
import threading THREAD_LOCAL = threading.local() class thread_local_property: """ A property that is computed once per thread Use this in rare cases where you need just a property (or 2) to be thread local in a given object If you need an entire object to be thread-local, then use class `ThreadLoca...
codrsquad/runez
src/runez/thread.py
.py
9e32785fa17f79ad
7.5
9
import os import pytest import runez from runez.__main__ import main from runez.conftest import cli, ClickRunner, IsolatedLogSetup, logged, temp_folder from runez.http import GlobalHttpCalls from runez.logsetup import LogManager from runez.system import CaptureOutput, short # Re-export fixtures so pytest discovers t...
codrsquad/runez
tests/conftest.py
.py
14f93fc5bf6a141e
8
9
""" Test click related methods """ import errno import logging import os import sys import click import pytest import runez import runez.config from .conftest import exception_raiser def my_formatter(text): return text.format(placeholder="epilog") @runez.click.group() @runez.click.version(message="%(prog)s,...
codrsquad/runez
tests/test_click.py
.py
fa58608d760bed9d
8
9
import os import sys import pytest import runez from runez.inspector import auto_import_siblings def importable_test_py_files(folder): """Finds all .py files in tests/ folder, used for auto-import validation""" for fname in os.listdir(folder): fpath = os.path.join(folder, fname) if os.path.i...
codrsquad/runez
tests/test_inspector.py
.py
667479ab1b85a416
8
9
import os from unittest.mock import patch import pytest import runez from runez.prompt import ask_once def custom_serializer(value): if value == "invalid": return None return {"value": value} def mocked_input(x): return x def test_no_tty(logged): assert ask_once("test", "Please enter va...
codrsquad/runez
tests/test_prompt.py
.py
c165aa17fd4b06b8
7
9
import logging import os import re import sys import pytest import runez import runez.conftest def sample_main(): args = sys.argv[1:] runez.log.trace("Running main() with: %s" % args) if args: args = runez.flattened(args, shellify=True) if args[0] == "TypeError": # Raise a Ty...
codrsquad/runez
tests/test_testing.py
.py
3abc9d74e11ece3d
7
9
"""Interface for ``python -m scanspec``.""" import logging import string import click # Need this so we can eval() below from .specs import * # noqa @click.group(invoke_without_command=True) @click.option( "--log-level", default="INFO", type=click.Choice( ["CRITICAL", "ERROR", "WARNING", "INFO...
bluesky/scanspec
src/scanspec/cli.py
.py
315cbbf46ae7fcb1
8.04
11
"""Core classes like `Dimension` and `Path`.""" from __future__ import annotations import itertools import sys import warnings from collections.abc import Callable, Iterable, Iterator, Sequence from dataclasses import dataclass from functools import lru_cache from inspect import isclass from typing import ( Any, ...
bluesky/scanspec
src/scanspec/core.py
.py
8f791ed99184702a
7.04
11
"""`plot_spec` to visualize a scan.""" from collections.abc import Generator, Iterable from itertools import cycle from typing import Any import numpy as np import numpy.typing as npt from matplotlib import colors, patches from matplotlib import pyplot as plt from matplotlib.axes import Axes from mpl_toolkits.mplot3d...
bluesky/scanspec
src/scanspec/plot.py
.py
63610b0abf182812
8.04
11
"""FastAPI service to query information about Specs.""" import base64 import json from collections.abc import Mapping from enum import StrEnum from typing import Any import numpy as np import numpy.typing as npt from fastapi import Body, FastAPI from fastapi.middleware.cors import CORSMiddleware from fastapi.openapi....
bluesky/scanspec
src/scanspec/service.py
.py
c9ab38759eab0568
7.04
11
"""An example_spec directive.""" from contextlib import contextmanager from typing import Any, cast from docutils.statemachine import StringList from matplotlib.sphinxext import plot_directive from sphinx.application import Sphinx from . import __version__ @contextmanager def always_create_figures(): """Force ...
bluesky/scanspec
src/scanspec/sphinxext.py
.py
dcfc281321a3edc2
8.04
11
from typing import Any import pytest def approx( expected: Any, rel: float | None = None, abs: float | None = None, nan_ok: bool = False, ) -> Any: """ Temporary loosely typed wrapper around approx. To be removed pending: https://github.com/pytest-dev/pytest/issues/7469 Args: ...
bluesky/scanspec
tests/__init__.py
.py
4460fe069307a2cf
7.04
11
import json import pathlib import subprocess import sys from typing import cast from unittest.mock import patch import matplotlib.pyplot as plt import numpy as np import numpy.typing as npt from click.testing import CliRunner from matplotlib.lines import Line2D from matplotlib.text import Annotation from mpl_toolkits....
bluesky/scanspec
tests/test_cli.py
.py
25b99a61152f218b
7.04
11
import json import logging import os import sys import uuid from dataclasses import dataclass from datetime import datetime, timedelta from http.client import HTTPConnection, HTTPSConnection from logging import LogRecord from logging.handlers import QueueHandler, QueueListener from queue import Queue from typing import...
Jellyfish-AI/jf_agent
jf_agent/agent_logging.py
.py
ad773e1a3cb4a31f
7.63
17
import logging import string import traceback from typing import Optional from jf_ingest import diagnostics, logging_helper from jf_ingest.config import IngestionConfig from jf_ingest.jf_jira import load_and_push_jira_to_s3 from jf_ingest.jf_jira.auth import get_jira_connection as get_jira_connection_from_jf_ingest fr...
Jellyfish-AI/jf_agent
jf_agent/jf_jira/jira_download.py
.py
7b5c80d6393a9953
7.63
17
import logging import time from typing import Any, Callable, Optional from jf_ingest import logging_helper logger = logging.getLogger(__name__) def get_wait_time(e: Optional[Exception], retries: int) -> int: """ This function attempts to standardize determination of a wait time on a retryable failure. I...
Jellyfish-AI/jf_agent
jf_agent/jf_jira/utils.py
.py
ca643a13e088d178
7.63
17
import bisect import logging import threading import time from collections import defaultdict, namedtuple from contextlib import contextmanager from datetime import datetime, timedelta import requests from jf_ingest import logging_helper logger = logging.getLogger(__name__) RateLimitRealmConfig = namedtuple('RateLim...
Jellyfish-AI/jf_agent
jf_agent/ratelimit.py
.py
2e92dccbffb63f9d
7.63
17
import requests from requests.adapters import HTTPAdapter from requests.packages.urllib3.util.retry import Retry class ReauthSession(requests.Session): def __init__(self, **kwargs): super().__init__(**kwargs) def request(self, method, url, **kwargs): # If we get HTTP 401, re-authenticate and ...
Jellyfish-AI/jf_agent
jf_agent/session.py
.py
ab7dbc1a053e0aec
7.63
17
import logging from collections import namedtuple from itertools import islice from time import sleep from typing import Any, List import requests from jf_ingest import logging_helper from jf_agent.exception import BadConfigException from jf_agent.session import retry_session logger = logging.getLogger(__name__) U...
Jellyfish-AI/jf_agent
jf_agent/util.py
.py
3029a3f78309cc88
7.63
17
import logging import os import shutil import traceback from typing import Optional import psutil import requests from jf_ingest.validation import ( GitConnectionHealthCheckResult, IngestionHealthCheckResult, IngestionType, JiraConnectionHealthCheckResult, validate_git, validate_jira, ) from j...
Jellyfish-AI/jf_agent
jf_agent/validation.py
.py
98a9cecc844371fc
7.63
17
""" Audit how many cross-references make_chebi_relations() takes out of ChEBI's database_accession.tsv. The file identifies each xref's database only by a numeric source_id, and a row's `type` decides whether `accession_number` is that database's own identifier at all. Both columns therefore have to be matched, and th...
NCATSTranslator/Babel
docs/sources/CHEBI/scripts/audit_database_accession.py
.py
ac1532a8977acc0a
7.63
17
""" Audit the ChEBI SDF's data-item tags against the keys make_chebi_relations() asks for. ChEBI renames SDF tags between releases without notice. Because chebi_sdf_entry_to_dict() matches tags by exact (normalized) string and simply omits anything it doesn't recognize, a rename is silent: the ingest keeps running and...
NCATSTranslator/Babel
docs/sources/CHEBI/sdf_tags/audit_sdf_tags.py
.py
71116e9bb5a4d7a4
7.63
17
"""Measure what DOID's ICD xrefs do to disease clique sizes. Prints the four-scenario table quoted in ``docs/sources/DOID/mappings.md``: * **ICD kept** -- every DOID ICD xref fed to glom(), the merge problem in the raw. * **overuse-filtered** -- ``remove_overused_xrefs`` over the whole DOID concord, unscoped. * **ICD...
NCATSTranslator/Babel
docs/sources/DOID/mappings/scripts/measure_icd_xrefs.py
.py
cdb19d7efb2ab87e
7.63
17
#!/usr/bin/env python """Regenerate the two DrugBank food-and-extract audit CSVs in this directory (issue #828). This is the committed generator for the sibling files: - ``food-and-extracts.csv`` (File A) — every structureless DrugBank food/material this PR retypes, with the type it ships now (``biolink:Food`` ...
NCATSTranslator/Babel
docs/sources/DRUGBANK/food-and-extracts/scripts/generate_csvs.py
.py
e3c0e73f57d22335
7.63
17
#!/usr/bin/env python """Replay create_typed_sets() over a completed build's Food.txt to check the #935 type vote. Issue #918 typed a chemical clique as ``biolink:Food`` whenever *any* member carried DrugBank food evidence, overriding the per-identifier type vote entirely. That was asserted to be safe because "every c...
NCATSTranslator/Babel
docs/sources/DRUGBANK/food-and-extracts/scripts/replay_type_vote.py
.py
e4f4ce5876ac9a88
7.63
17
""" List every UBERON term that cross-references more than one EMAPA term. These are the cliques that decided whether `EMAPA` belongs in `anatomy_unique_prefixes` (config.yaml). Restricting a prefix makes `glom()` refuse any merge whose union would hold two identifiers sharing it, so each UBERON term below would have ...
NCATSTranslator/Babel
docs/sources/EMAPA/scripts/multi_emapa_uberon_xrefs.py
.py
ae4abf8adbb8ddb3
7.63
17
"""Characterize the quoting/punctuation used in the two NCBIGene free-text synonym columns. NCBI's ``gene_info.gz`` packs multiple values into two pipe-delimited free-text columns: - ``Synonyms`` (column index 4) -- the NCBI "otheraliases" field - ``Other_designations`` (column index 13) -- the NCBI "other...
NCATSTranslator/Babel
docs/sources/NCBIGene/quoting/analyze_quoting.py
.py
a75d044ece56b803
7.63
17
"""Report on '' occurrences in NCBIGene gene_info.gz that could be *genuine* name components (e.g. double-prime nomenclature) rather than issue-#744 pipe-split artifacts. Classification of a '' occurrence: - **open-marker artifact**: a pipe-fragment that STARTS with '' (e.g. ``''cytochrome P450``) -- the opening of...
NCATSTranslator/Babel
docs/sources/NCBIGene/quoting/double_prime_report.py
.py
587adc3f92fbfbb4
7.63
17
"""Report every synonym that the issue-#932 fix removes from NCBIGene's shredded alias fields. NCBI wraps a comma-containing alias in ''...'' and then turns that value's internal commas into '|' -- the ``Synonyms`` column's own delimiter -- so the value arrives shredded into pipe-fragments. The #744 fix drops the two ...
NCATSTranslator/Babel
docs/sources/NCBIGene/quoting/shredded_pieces_report.py
.py
264bf8b9998d3f93
7.63
17
#!/usr/bin/env python3 """Archive a build's summary reports into ``releases/<build>/``. A finished build directory is hundreds of gigabytes and lives on a cluster that will eventually be cleaned. A small part of it -- the summary tables, the per-compendium content reports, and the provenance metadata -- is what people...
NCATSTranslator/Babel
releases/scripts/archive_build.py
.py
fafb60aaae70be55
7.63
17
# standard modules from typing import NamedTuple # logger = LoggingUtil.init_logging(__name__, logging.ERROR) class LabeledID(NamedTuple): """ Labeled Thing Object --- schema: id: LabeledID required: - identifier properties: identifer: t...
NCATSTranslator/Babel
src/LabeledID.py
.py
ac0d54dbfa641e8e
7.63
17
import logging from collections import defaultdict import jsonlines from src.babel_utils import glom from src.categories import GENE from src.metadata.provenance import write_concord_metadata from src.prefixes import NCBIGENE, UNIPROTKB from src.util import LoggingUtil logger = LoggingUtil.init_logging(__name__, lev...
NCATSTranslator/Babel
src/createcompendia/geneprotein.py
.py
5113e7d119e98081
7.63
17
from collections import defaultdict import src.datahandlers.ec as ec import src.datahandlers.obo as obo import src.datahandlers.reactome as reactome import src.datahandlers.rhea as rhea import src.datahandlers.umls as umls from src.babel_utils import get_prefixes, glom, read_identifier_file, remove_overused_xrefs, wri...
NCATSTranslator/Babel
src/createcompendia/processactivitypathway.py
.py
a9d5d9e9c7c6bb21
7.63
17
import logging import src.datahandlers.mesh as mesh import src.datahandlers.umls as umls from src.babel_utils import glom, read_identifier_file, write_compendium from src.categories import ORGANISM_TAXON from src.metadata.provenance import write_concord_metadata from src.prefixes import MESH, NCBITAXON, UMLS from src....
NCATSTranslator/Babel
src/createcompendia/taxon.py
.py
0d3de85b3c0796a1
7.63
17
import ftplib import pyoxigraph from src.babel_utils import parse_rdf_literal, pull_via_ftp from src.prefixes import CHEMBLCOMPOUND def pull_chembl(moleculefilename): fname = get_latest_chembl_name() if fname is not None: # fname should be like chembl_28.0_molecule.ttl.gz # Pull via ftp is g...
NCATSTranslator/Babel
src/datahandlers/chembl.py
.py
b605b560031c6bd8
7.63
17
import logging import pyoxigraph from src.babel_utils import parse_rdf_literal, pull_via_urllib from src.categories import CELL_LINE from src.metadata.provenance import write_download_metadata from src.prefixes import CLO, ORPHANET from src.util import LoggingUtil, Text logger = LoggingUtil.init_logging(__name__, le...
NCATSTranslator/Babel
src/datahandlers/clo.py
.py
1190143a5113597d
7.63
17
import json from src.babel_utils import norm, pull_via_urllib from src.prefixes import DOID, OIO def pull_doid(): pull_via_urllib( "https://raw.githubusercontent.com/DiseaseOntology/HumanDiseaseOntology/main/src/ontology/", "doid.json", subpath="DOID", decompress=False, ) de...
NCATSTranslator/Babel
src/datahandlers/doid.py
.py
3b186f096721af29
7.63
17
# Download CC-0 licensed data from DrugBank (https://go.drugbank.com/releases/latest) import csv import os.path import shutil from zipfile import ZipFile import requests from src.categories import COMPLEX_MOLECULAR_MIXTURE, FOOD from src.datahandlers.ncit import read_ncit_code_set from src.datahandlers.unii import re...
NCATSTranslator/Babel
src/datahandlers/drugbank.py
.py
485d2127a82e3dd0
7.63
17
import pyoxigraph from src.babel_utils import parse_rdf_literal, pull_via_urllib from src.categories import MOLECULAR_ACTIVITY from src.prefixes import EC def pull_ec(): pull_via_urllib("https://ftp.expasy.org/databases/enzyme/", "enzyme.rdf", subpath="EC", decompress=False) class ECgraph: """Load the mesh...
NCATSTranslator/Babel
src/datahandlers/ec.py
.py
3bfbffee384ebe42
7.63
17
import logging import pyoxigraph from src.babel_utils import parse_rdf_literal, pull_via_urllib from src.metadata.provenance import write_concord_metadata from src.prefixes import EFO, ORPHANET from src.util import LoggingUtil, Text logger = LoggingUtil.init_logging(__name__, level=logging.WARNING) def pull_efo():...
NCATSTranslator/Babel
src/datahandlers/efo.py
.py
3ddc5a48a574b29c
7.63
17
from bs4 import BeautifulSoup from src.babel_utils import pull_via_urllib from src.prefixes import GTOPDB def pull_gtopdb_ligands(): pull_via_urllib("https://www.guidetopharmacology.org/DATA/", "ligands.tsv", decompress=False, subpath="GTOPDB") def strip_html_tags(name): """ GtoPDB contains HTML tags, ...
NCATSTranslator/Babel
src/datahandlers/gtopdb.py
.py
e53e1afb78c4820b
7.63
17
import warnings from collections import defaultdict import pyoxigraph from src.babel_utils import make_local_name, pull_via_ftp from src.categories import ANATOMICAL_ENTITY, CELL, CELLULAR_COMPONENT from src.prefixes import MESH MESH_IRI_PREFIX = "http://id.nlm.nih.gov/mesh/" def get_mesh_id_from_iri(iri) -> str: ...
NCATSTranslator/Babel
src/datahandlers/mesh.py
.py
735274ec69f2ba05
7.63
17
from __future__ import with_statement import os from logging.config import fileConfig from pathlib import Path # Python 3.6+ only from alembic import context from dotenv import load_dotenv from sqlalchemy import create_engine if not load_dotenv(): env_path = Path('.') / '..' / '..' / '.env' load_dotenv(dote...
dbvis-ukon/coronavis
Backend/migrations/alembic/env.py
.py
a766c3db65950882
7.63
17
"""create germany materialized view Revision ID: 00a7bf4dae6c Revises: 8175af65a5b9 Create Date: 2020-11-26 14:37:50.902921 """ from alembic import op # revision identifiers, used by Alembic. revision = '00a7bf4dae6c' down_revision = '8175af65a5b9' branch_labels = None depends_on = None def upgrade(): op.get_b...
dbvis-ukon/coronavis
Backend/migrations/alembic/versions/00a7bf4dae6c_create_germany_materialized_view.py
.py
cf38ffbbee80bf75
7.63
17
"""create cases_lk_risklayer table Revision ID: 2ea7edb628ac Revises: 3610493d8979 Create Date: 2020-11-25 20:43:50.998184 """ from alembic import op # revision identifiers, used by Alembic. revision = '2ea7edb628ac' down_revision = '3610493d8979' branch_labels = None depends_on = None def upgrade(): op.get_bi...
dbvis-ukon/coronavis
Backend/migrations/alembic/versions/2ea7edb628ac_create_cases_lk_risklayer_table.py
.py
6abdffe1eedd90f8
7.63
17
"""create cases table Revision ID: 3610493d8979 Revises: Create Date: 2020-11-25 20:42:26.698495 """ from alembic import op # revision identifiers, used by Alembic. revision = '3610493d8979' down_revision = None branch_labels = None depends_on = None def upgrade(): op.get_bind().execute(""" create table c...
dbvis-ukon/coronavis
Backend/migrations/alembic/versions/3610493d8979_create_cases_table.py
.py
f333effb34085005
7.63
17
"""add columns to divi_meldungen Revision ID: a3a5ae77b6b9 Revises: bbaf5488b4fe Create Date: 2021-03-23 11:42:48.229731 """ from alembic import op # revision identifiers, used by Alembic. revision = 'a3a5ae77b6b9' down_revision = 'bbaf5488b4fe' branch_labels = None depends_on = None def upgrade(): op.get_bind...
dbvis-ukon/coronavis
Backend/migrations/alembic/versions/a3a5ae77b6b9_add_columns_to_divi_meldungen.py
.py
a8e10683f8e91789
7.63
17
"""create cases_current view Revision ID: b84312f6532e Revises: 00a7bf4dae6c Create Date: 2020-11-26 14:43:32.346113 """ from alembic import op # revision identifiers, used by Alembic. revision = 'b84312f6532e' down_revision = '00a7bf4dae6c' branch_labels = None depends_on = None def upgrade(): op.get_bind().e...
dbvis-ukon/coronavis
Backend/migrations/alembic/versions/b84312f6532e_create_cases_current_view.py
.py
06117aa51b71c766
7.63
17
"""create risklayer_prognosis table Revision ID: c34d4cef2dad Revises: 91aca0bccf3f Create Date: 2020-11-25 21:28:24.950572 """ from alembic import op # revision identifiers, used by Alembic. revision = 'c34d4cef2dad' down_revision = '91aca0bccf3f' branch_labels = None depends_on = None def upgrade(): op.get_b...
dbvis-ukon/coronavis
Backend/migrations/alembic/versions/c34d4cef2dad_create_risklayer_prognosis_table.py
.py
f98b6791c88f2b08
7.63
17
from sqlalchemy.dialects.postgresql import JSONB from sqlalchemy.orm import deferred from db import db class Crawl(db.Model): """ Hospital data class """ __tablename__ = 'crawl' id = db.Column(db.Integer, primary_key=True, autoincrement=True) url = db.Column(db.String, nullable=False) te...
dbvis-ukon/coronavis
Backend/models/crawl.py
.py
813bc3ab5fa28255
7.63
17
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import json import os # noinspection PyUnresolvedReferences from datetime import datetime from flasgger import Swagger from flask import Flask, jsonify, redirect from flask_compress import Compress from flask_cors import CORS, cross_origin from flask_mail import Mail from...
dbvis-ukon/coronavis
Backend/server.py
.py
a3423eb109eafe75
7.63
17
""" Govspeak markdown rendering module. Provides markdown rendering with GOV.UK-specific extensions including: - Call-to-action blocks ($CTA...$CTA) - Information callouts (^...^) - Warning callouts (%...%) - Numbered steps (s1., s2., etc.) - Email address links (<email@example.com>) """ import re import markdown fro...
digital-land/specification
bin/govspeak.py
.py
bb792a858ca7094f
7.45
7
#!/usr/bin/env python3 import sys import csv from pathlib import Path import frontmatter def output_to_file(file_path, output_string): with open(file_path, "a") as file: file.write(output_string) def generate(specification_path, output_path=None): svg_content = [] tables = { "dataset":...
digital-land/specification
bin/specification-svg.py
.py
70b7fa5282c921d5
7.95
7
"""Builds the memory-mapped domain index the workers read. Runs in the librarian, after the lists have been downloaded and cleaned. Writes beside the live path and renames, so a worker holding an mmap keeps reading a consistent file until it chooses to reopen. """ import os import struct import time from libtb.index...
MelonSmasher/TurkeyBite
src/libtb/index/builder.py
.py
1e736341a55bf2ac
7.5
9
"""Moves the domain index from the librarian to the workers. Only one node runs the librarian, and ./vols/lists is a per-node bind mount, so a worker on another host cannot see the file the librarian wrote. This module ships it through Valkey, which both nodes already reach and authenticate to, so distribution needs n...
MelonSmasher/TurkeyBite
src/libtb/index/transport.py
.py
463dd6ca5673c482
7.5
9
import json import sys from rq import Queue from redis import Redis from libtb.util import dig def describe(data, verdict): """Builds the log line for an observed packet. Every field is read through dig() or checked for its type first. This code used to reach straight into nested keys, and since the call...
MelonSmasher/TurkeyBite
src/libtb/inlet/__init__.py
.py
436e66b707d5af46
7.5
9
"""Registrable domains, using the Public Suffix List. The question is where the name somebody registered ends and the subdomains that registrant controls begin. Taking the last two labels is the obvious answer and it is wrong whenever the public part of the name is itself more than one label: news.bbc.co.uk ...
MelonSmasher/TurkeyBite
src/libtb/psl/__init__.py
.py
c40daffcb064e40a
7.5
9
import socket class Facility: """Syslog facilities""" KERN, USER, MAIL, DAEMON, AUTH, SYSLOG, \ LPR, NEWS, UUCP, CRON, AUTHPRIV, FTP = range(12) LOCAL0, LOCAL1, LOCAL2, LOCAL3, \ LOCAL4, LOCAL5, LOCAL6, LOCAL7 = range(16, 24) class Level: """Syslog levels""" EMERG, ALERT, CRIT, ERR, \ ...
MelonSmasher/TurkeyBite
src/libtb/tbsyslog/__init__.py
.py
4efa7d69e2d447c0
7.5
9
"""Tests for retiring the Valkey host list keyspace. Two things can go wrong here and both are quiet. Sweeping too widely takes the domain index manifest and chunks with it, because they share the turkey-bite: prefix. Gating too widely stops populating the keyspace that `compare` mode reads as authoritative, which tur...
MelonSmasher/TurkeyBite
tests/test_host_list_keyspace.py
.py
5a8da3dc070bc32e
8
9
""" Benchmark: get()'s simple-path fast path vs the walk() machinery (issue #58). Simple paths (literal Key/Attr/Slot chains) resolve via engine.simple_get(); everything else goes through walk(). This times both on the same paths by driving the walk machinery directly, so the comparison stays valid as long as both cod...
freywaid/dotted
benchmarks/bench_simple_get.py
.py
ca193341ff84afaf
7.57
13
""" Root conftest. Adds the `--all` flag and the skip logic for integration tests. Tests under `tests/integration/` auto-mark themselves via that directory's conftest; by default they're skipped. They run when either `--all` is passed or the caller explicitly targets the directory. """ import pytest def pytest_addopt...
freywaid/dotted
conftest.py
.py
b40230478d0ed077
8.07
13
""" Base classes, sentinels, and infrastructure for the dotted element system. """ import collections import pyparsing as pp from .utypes import marker, ANY, CUT_SENTINEL, BRANCH_CUT, BRANCH_SOFTCUT, resolve_types # noqa: F401 # Generator safety (data): keep lazy things lazy as long as possible. Avoid needlessly co...
freywaid/dotted
dotted/base.py
.py
dd5b4ad23855809c
7.57
13
""" CLI entry point for dq — dotted notation query tool. """ import json import signal import sys import dotted from dotted.api import ParseError from .formats import READERS, WRITERS, validate_reader, validate_writer OPERATIONS = {'get', 'update', 'remove'} def parse_value(s): """ Parse a string as JSON,...
freywaid/dotted
dotted/cli/main.py
.py
840f9aedf371874e
7.57
13
""" Traversal engine for dotted path operations. Core traversal functions (walk, gets, updates, removes, expands). """ import copy from . import base from . import matchers from . import wrappers from .access import Attr, Slot from .results import Dotted def _needs_parents(ops): """ True if any op in the ch...
freywaid/dotted
dotted/engine.py
.py
250c3400dcc645cf
7.57
13
""" Dotted result model and transform registry. """ import itertools from . import predicates from . import utils from .access import Attr, Invert, Key, Slot from .matchers import Const from .utils import lazyprop class rdoc(str): def expandtabs(*args, **kwargs): title = 'Supported transforms\n\n' ...
freywaid/dotted
dotted/results.py
.py
2cc97ce44a8706bc
7.57
13
""" Shared type-checking helpers (duck-typing). """ class lazyprop: """ Non-data descriptor: compute once on first access, cache the result in the instance __dict__ (which then shadows the descriptor). Like functools.cached_property but lock-free and available on 3.6+. """ def __init__(self, fn...
freywaid/dotted
dotted/utils.py
.py
81a35111c637ad49
7.57
13
""" Type specification, sentinels, and registry for the dotted element system. """ # Sentinel used as a "missing" marker and as the ANY constant for remove. marker = object() class _ANYMeta(type): """Metaclass for ANY: isinstance(x, ANY) is always True.""" def __instancecheck__(cls, instance): return...
freywaid/dotted
dotted/utypes.py
.py
9fd3c56e906ccfb9
7.57
13
""" Fixtures and collection rules for integration tests. Every test collected under `tests/integration/` is auto-marked as `integration`. Root `conftest.py` handles the default skip + `--all` override. A session-scoped fixture creates a dedicated `dotted_test` schema and seeds a sample table; per-test transaction rol...
freywaid/dotted
tests/integration/conftest.py
.py
705adc1b57c8bc3c
8.07
13
""" Smoke tests: minimum infrastructure check. Confirms the DSN is reachable, the schema was created, and the seed data is present. """ def test_conn_reachable(query): rows = query('SELECT 1 AS one') assert rows == [{'one': 1}] def test_seed_row_count(query): rows = query('SELECT count(*) AS c FROM dott...
freywaid/dotted
tests/integration/test_smoke.py
.py
1c13cffb6b555551
7.57
13
""" End-to-end integration tests: run dotted.sql output against the seeded Postgres schema and verify row-level semantics. The seeded table `dotted_test.items` has columns: id, status, age, deleted_at, data (JSONB) Seed (from tests/integration/conftest.py): id=1: status=active age=25 user.age=...
freywaid/dotted
tests/integration/test_sqlize_e2e.py
.py
3e12a7e3dc8e1bf2
8.07
13
""" Tests for API functions """ import pytest import dotted # quote def test_quote_string(): assert dotted.quote('hello') == 'hello' # spaces and reserved chars require quoting assert dotted.quote('has space') == "'has space'" assert dotted.quote('has.dot') == "'has.dot'" assert dotted.quote('a[0...
freywaid/dotted
tests/test_api.py
.py
2216338967aaeaef
7.07
13
""" Tests for template bindings and resolution in parse() and traversal APIs. """ import pytest import dotted def test_parse_template_partial_true_default(): """ parse() with default partial=True allows templates through. """ ops = dotted.parse('a.$0.b') assert dotted.is_template(ops) def test_p...
freywaid/dotted
tests/test_bindings.py
.py
8c3061bfb88d688d
7.07
13
""" Tests for the + concatenation operator in key construction. """ import pytest import dotted from dotted.api import parse, get, update, remove, replace, is_template from dotted.matchers import Concat, ConcatPart, Word, Numeric, Subst, Reference from dotted.results import assemble # ---- parsing: key context ---- ...
freywaid/dotted
tests/test_concat.py
.py
328d5757c4d8178d
7.07
13
""" Tests for empty path operations (root access). """ import dotted def test_get_empty_returns_root(): data = {'a': 1, 'b': 2} assert dotted.get(data, '') == data def test_get_empty_list(): data = [1, 2, 3] assert dotted.get(data, '') == data def test_get_empty_primitive(): assert dotted.get(...
freywaid/dotted
tests/test_empty.py
.py
ce64dcde6186d21e
7.07
13
import pytest import dotted def test_parse_lookahead_keyvalue(): dotted.parse('hello&id=1') dotted.parse('*&id=1') dotted.parse('a[id=1]') dotted.parse('a[*]') dotted.parse('a[*&id=1]') def test_parse_not_equal(): """!= parses as its own filter (same semantics as !(key=val), repr stays id!=1...
freywaid/dotted
tests/test_filter_keyvalue.py
.py
95bb31f22da9e7da
7.07
13
import pytest import dotted def test_get_key(): d = {'hello': {'there': [1, '2', 3]}} r = dotted.get(d, 'hello.there') assert r == [1, '2', 3] def test_get_dot_index(): """Test dot notation for list index access (items.0 instead of items[0])""" # Basic list index data = {'items': [1, 2, 3]}...
freywaid/dotted
tests/test_get.py
.py
d60503dec13047dc
8.07
13
""" Tests for guard transforms: field|transform=value, [slot]|transform=value, **|transform=value, filter transforms [*&field|transform=value], and template-level guards. Guard transforms are matching-only: yielded values are originals (untransformed). """ import dotted # --- Parse / Assemble round-trips --- def t...
freywaid/dotted
tests/test_guard_transforms.py
.py
ee26b4ba02a16c83
7.07
13
""" """ import dotted def test_invert_get(): r = dotted.get({'hello': 'there'}, '-hello') assert r == 'there' r = dotted.get([], '-[0]') assert r is None def test_invert_remove_via_update(): r = dotted.update({'hello': {'there': 'me', 'not': 'this'}}, '-hello.there', dotted.ANY) assert r ==...
freywaid/dotted
tests/test_invert.py
.py
4ae4a0300984236f
7.07
13
""" Tests for dotted.keys, dotted.values, and dotted.items. """ import dotted def test_keys_flat(): d = {'a': 1, 'b': 2} assert list(dotted.keys(d)) == ['a', 'b'] def test_keys_nested(): d = {'a': {'b': 1}, 'x': 2} assert list(dotted.keys(d)) == ['a.b', 'x'] def test_keys_deep(): d = {'a': {'b...
freywaid/dotted
tests/test_keys_values.py
.py
ac3748854913757f
7.07
13
""" Direct tests for _match_from declarations and the generic matchable method. """ from dotted.matchers import ( Const, Word, Numeric, String, Wildcard, WildcardFirst, Regex, RegexFirst, Special, Appender, Subst, Reference, Concat, ConcatPart, ) from dotted.utypes import ANY, resolve_types # -- ANY t...
freywaid/dotted
tests/test_matchable.py
.py
225427c359b9edb2
8.07
13
# SPDX-FileCopyrightText: 2026 Open Source Robotics Foundation, Inc. # SPDX-License-Identifier: Apache-2.0 """Build-time helpers for the JSON-domain schema reference rendered by schema.md.""" import re from pathlib import Path import yaml _HERE = Path(__file__).parent SCHEMA_SRC = _HERE / '..' / '..' / 'nodl_schema'...
ros-tooling/nodl
nodl/doc/schema_reference.py
.py
fb9e82bbcec4baf0
7.63
17
# SPDX-FileCopyrightText: 2026 Open Source Robotics Foundation, Inc. # SPDX-License-Identifier: Apache-2.0 """Static type checking with pyright.""" import subprocess import sys from pathlib import Path # The importable package source lives one level up from this test directory. _SOURCE_DIR = Path(__file__).resolve()....
ros-tooling/nodl
nodl_docgen/test/test_pyright.py
.py
21c637d40fef251e
7.13
17
# SPDX-FileCopyrightText: 2026 Open Source Robotics Foundation, Inc. # SPDX-License-Identifier: Apache-2.0 import argparse import sys from pathlib import Path from nodl_generator_cpp.generate import cmake_deps, generate_cpp from nodl_generator_cpp.params import generate_parameter_header def main(argv: list[str] | No...
ros-tooling/nodl
nodl_generator_cpp/nodl_generator_cpp/cli.py
.py
c22c5595e915c157
7.63
17