text stringlengths 185 73.3k | repo stringlengths 7 100 | path stringlengths 4 146 | language stringclasses 7
values | hash stringlengths 16 16 | score float64 7 8.5 | stars int64 0 237k |
|---|---|---|---|---|---|---|
"""Tests for dict_merge utility."""
from __future__ import annotations
from redreactor.helpers.utils import dict_merge
def test_flat_merge_overwrites_keys():
"""dict_merge overwrites top-level keys."""
dct = {"a": 1, "b": 2}
dict_merge(dct, {"b": 99, "c": 3})
assert dct == {"a": 1, "b": 99, "c": 3}
... | mreditor97/redreactor | tests/helpers/test_utils.py | .py | 6110c4475049c2f5 | 7.65 | 1 |
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.
"""# Juju Charm Library for the `ldap` Juju Interface.
This juju charm library contains the Provider and Requirer classes for handling
the `ldap` interface.
## Requirer Charm
The requirer charm is expected to:
- Provide information for the p... | canonical/ldap-integrator | lib/charms/glauth_k8s/v0/ldap.py | .py | f4f43ca528a92d63 | 7 | 0 |
#!/usr/bin/env python3
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
"""Charm the application."""
import logging
from typing import Optional
import ops
from charms.glauth_k8s.v0.ldap import LdapProvider, LdapProviderData
from constants import CONFIG_PASSWORD_SECRET_KEY, LDAP_INTEGRATION_... | canonical/ldap-integrator | src/charm.py | .py | 8a5d7126e5d2cbe2 | 7 | 0 |
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from charm import LdapIntegratorCharm
def missing_config(charm: "LdapIntegratorCharm") -> set[str]:
"""Check whether the required configuration has been provided."""
required_keys... | canonical/ldap-integrator | src/utils.py | .py | 3c2b9dd63f58c2d0 | 7 | 0 |
# Copyright 2025 Canonical Ltd.
# See LICENSE file for licensing details.
import subprocess
from collections.abc import Iterator
from contextlib import contextmanager
from pathlib import Path
from typing import Literal
import jubilant
import pytest
import yaml
from tenacity import Retrying, stop_after_attempt, wait_e... | canonical/ldap-integrator | tests/integration/helpers.py | .py | b3b36f7d6cda5a8b | 7.5 | 0 |
#!/usr/bin/env python3
# Copyright 2025 Canonical Ltd.
# See LICENSE file for licensing details.
"""Test `ldap-integrator` on machine clouds."""
from pathlib import Path
import jubilant
import pytest
from constants import (
APP_NAME,
BIND_PASSWORD_SECRET,
LDAP_SERVER_CLOUD_INIT,
OPENLDAP_APP,
SS... | canonical/ldap-integrator | tests/integration/test_charm_machine.py | .py | dd419e2e005d7409 | 7.5 | 0 |
# standard library imports
from datetime import datetime, timedelta, timezone
from functools import reduce
from json import loads
# third party imports
import pandas as pd
import requests
from fake_useragent import UserAgent
# local imports
from ..utils import BANDWIDTH_USE_DATA_PATH
class IngestionPipeline:
""... | ehan03/Steam-Time-Series | src/ingestion/ingestion_pipeline.py | .py | 1584b86d7922188c | 7.24 | 2 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
:Mod: dereferencer
:Synopsis:
:Author:
servilla
:Created:
1/26/23
"""
import copy
import daiquiri
from lxml import etree
from emlvp import exceptions
logger = daiquiri.getLogger(__name__)
class Dereferencer:
"""
Expands EML XML content by deref... | PASTAplus/EMLvp | src/emlvp/dereferencer.py | .py | 2b8977003d4848c5 | 7.35 | 4 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
:Mod: parser
:Synopsis:
:Author:
servilla
:Created:
1/22/23
"""
import daiquiri
from lxml import etree
from emlvp import exceptions
logger = daiquiri.getLogger(__name__)
class Parser:
"""
Parses an EML XML document instance inspecting for non-sc... | PASTAplus/EMLvp | src/emlvp/parser.py | .py | ca13b1dac5217940 | 7.35 | 4 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
:Mod: validator
:Synopsis:
:Author:
servilla
:Created:
1/21/23
"""
import os
from pathlib import Path
import daiquiri
from lxml import etree
from emlvp import exceptions
logger = daiquiri.getLogger(__name__)
def schema_path() -> str:
"""
Return... | PASTAplus/EMLvp | src/emlvp/validator.py | .py | 5842a8f83ce6091a | 7.35 | 4 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
:Mod:
conftest.py
:Synopsis:
:Author:
servilla
:Created:
11/23/25
"""
import os
import pytest
import tests
@pytest.fixture()
def test_data():
if "TEST_DATA" in os.environ:
test_data = os.environ["TEST_DATA"]
else:
test_data = ... | PASTAplus/EMLvp | tests/conftest.py | .py | 99444d15d683cd0c | 7.85 | 4 |
import logging
import sys
class ForceFilter(logging.Filter):
def __init__(self, threshold_level):
super().__init__()
self.threshold_level = threshold_level
def filter(self, record):
if getattr(record, 'force', False):
# 'force'フラグがあれば無条件で通す
return True
... | natukin1978/twitch-chat-trans-bot | logging_setup.py | .py | 1ab8a906af03dc5e | 7 | 0 |
import re
import unicodedata
from config_helper import read_config
def read_replace_words(name: str = "replace_words.json"):
return read_config(name)
def match_replace_word(replace_words: list[dict], target: str) -> str:
"""
指定された置換ルールのリストに基づき、文字列内の該当部分を置き換えます。
Args:
replace_words (list[di... | natukin1978/twitch-chat-trans-bot | replace_words_helper.py | .py | 806eccbd119a37cf | 7 | 0 |
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function
import json
from html import escape
import yaml
from flask import Flask, jsonify, render_template, request
from jinja2 import StrictUndefined, exceptions, select_autoescape
from jinja2.sandbox import ImmutableSandboxedEnvironment
app = Fl... | hatamiarash7/Jinja-Parser | app.py | .py | d222720fcad89d8e | 7.3 | 3 |
# type: ignore
from django.contrib import admin
from django.db.models import Count
from django.urls import reverse
from django.utils.html import format_html
from main.models import *
from django.apps import apps
# Register your models here.
admin.site.register(Cart)
admin.site.register(CartProduct)
class ProductIma... | PigsCanFlyLabs/pcfweb | main/admin.py | .py | 5d2b32edb869a71e | 7 | 0 |
"""A tiny self-hosted captcha, used to gate the Discord invite.
Deliberately not a third-party captcha: this guards one low-value page, and
every hosted option costs either a script tag from another origin (which the
cookie banner would then have to speak for) or an API key that has to be
plumbed through the cluster. ... | PigsCanFlyLabs/pcfweb | main/captcha.py | .py | 6eae5bdad511fbad | 7 | 0 |
"""Digital fulfilment: resolving book archives and signing download links.
The archives are baked into the image at /opt/app/book-assets (see build.sh
and the Dockerfile), which is deliberately outside both nginx aliases in
conf/nginx.default -- /static and /media are the only paths nginx serves off
disk, so nothing h... | PigsCanFlyLabs/pcfweb | main/digital.py | .py | 0348ad8e2057bb81 | 7 | 0 |
"""Forms for the mailing list and for post-checkout feedback."""
from typing import Optional
from django import forms
from newsletter.models import Newsletter
from main.mailing import parse_addresses
from main.models import PurchaseFeedback
from main.utils import normalize_email
class MailingListSignupForm(forms.... | PigsCanFlyLabs/pcfweb | main/forms.py | .py | 4036a2462bd4335e | 7 | 0 |
"""The launch-stock rule, defined once.
Two callers need this rule and must agree forever:
* ``main/migrations/0017_backfill_book_stock.py`` applies it to a database
that already has a catalogue -- production and every existing environment.
* ``seed_products`` applies it to rows it is *creating*, which is what a
... | PigsCanFlyLabs/pcfweb | main/launch_stock.py | .py | 94557a4bd2ed7768 | 7 | 0 |
"""Audit, on primary startup, that every sellable e-book has its archive.
The failure this exists to catch: a product is marked DIGITAL with
``sells_ebook`` set -- so the store will happily sell it and the Stripe
webhook will try to deliver it -- but ``<digital_asset_name>.zip`` is not
under ``settings.BOOK_ASSET_ROOT... | PigsCanFlyLabs/pcfweb | main/management/commands/check_book_assets.py | .py | 48ce025462709bb7 | 7 | 0 |
"""Attach every extra picture a product has on disk as a ProductImage row.
WHAT IT GRABS
-------------
The images on this site live in the sibling ``pcfweb-assets`` checkout and
arrive in the static tree as ``assets/images/...``; a product names its
primary one in ``image_name``. An extra picture of the same product i... | PigsCanFlyLabs/pcfweb | main/management/commands/grab_book_images.py | .py | f4196e8099fa9633 | 7 | 0 |
# Generated by Django 5.2.16 on 2026-07-24 22:41
from django.db import migrations, models
def merge_duplicate_cart_products(apps, schema_editor):
"""Collapse pre-existing duplicate (cart, product) rows.
Adding the constraint fails on any database that already raced its way
into duplicates, so fold them ... | PigsCanFlyLabs/pcfweb | main/migrations/0005_cartproduct_unique_cart_product.py | .py | f34a5f4926d86074 | 7 | 0 |
from django.db import migrations
def set_service_delivery_type(apps, schema_editor):
"""Existing products default to PHYSICAL; the services are not.
delivery_type replaces an inference that read "payment mode and not the
services category". Everything already in the database predates the field,
so th... | PigsCanFlyLabs/pcfweb | main/migrations/0010_backfill_service_delivery_type.py | .py | 61369e98e33d4664 | 7 | 0 |
"""The lists people can pick from when they subscribe.
An interest area is a django-newsletter Newsletter, so these are seeded there
rather than in a model of our own. Seeded rather than left to be typed in by
hand so a fresh database and production agree on the slugs -- an embedded
signup form on another site carries... | PigsCanFlyLabs/pcfweb | main/migrations/0014_seed_interest_areas.py | .py | 9d5cdf91d7fcb36f | 7 | 0 |
from django.db import migrations
from main.launch_stock import backfill_launch_stock
def backfill_book_stock(apps, schema_editor):
"""Give the print books a launch stock so they can be bought at all.
Every print SKU shipped with stock 0, which makes is_out_of_stock() true
and is_purchasable() false, so ... | PigsCanFlyLabs/pcfweb | main/migrations/0017_backfill_book_stock.py | .py | 9bf7a1ed6eabbbdc | 7 | 0 |
"""Point the sites-framework row at this site instead of example.com.
django-newsletter builds every activation and unsubscribe link off
``Site.objects.get_current()``, i.e. off the ``django.contrib.sites`` row
``SITE_ID`` names. On a database that predates migration 0014 -- production --
that row is the ``example.com... | PigsCanFlyLabs/pcfweb | main/migrations/0024_fix_default_site_domain.py | .py | 30efcbd8c51f4ba4 | 7 | 0 |
# Copyright © LFV
import gzip
import io
import os
import tarfile
import tempfile
from importlib.metadata import PackageNotFoundError, version
from pathlib import Path
from typing import Any, Dict, List, Optional
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
from hatchling.builders.plugin.in... | reqstool/reqstool-python-hatch-plugin | src/reqstool_python_hatch_plugin/build_hooks/reqstool.py | .py | df7ee539dee7662b | 7 | 0 |
# Copyright © LFV
import shutil
import subprocess
import tarfile
import tempfile
import venv
from pathlib import Path
import pytest
from reqstool_python_decorators.decorators.decorators import SVCs
FIXTURE_DIR = Path(__file__).parents[2] / "fixtures" / "test_project"
DIST_DIR = Path(__file__).parents[3] / "dist"
# T... | reqstool/reqstool-python-hatch-plugin | tests/e2e/reqstool_python_hatch_plugin/test_build_e2e.py | .py | b8adb85ae44d9691 | 7.5 | 0 |
import json
import re
import os
import sys
from typing import Any, Dict
from datetime import datetime
from .notification_level import NotificationLevel
CONFIG_FILE_NAME = "config.json"
LOCATION_FILE_NAME = "locations.json"
class Config:
"""
A class representing the configuration for the Trusted Traveler Sche... | ManagedKube/playground | nexus-global-entry/trusted-traveler-scheduler/trusted-traveler-scheduler/src/config.py | .py | 491bf70d8a6cd483 | 7 | 0 |
"""Primary script entrypoint where arguments are processed and locations are set up."""
import sqlite3
from .config import Config
from multiprocessing import Process
def create_database(filename: str) -> None:
"""
Creates a new SQLite database file with the given filename if it does not already exist,
and... | ManagedKube/playground | nexus-global-entry/trusted-traveler-scheduler/trusted-traveler-scheduler/src/main.py | .py | 554b74d08780e256 | 7 | 0 |
from __future__ import annotations
from datetime import datetime
import re
from typing import TYPE_CHECKING, List
import apprise
from .schedule import Schedule
from .notification_level import NotificationLevel
if TYPE_CHECKING: # pragma: no cover
from .schedule_retriever import ScheduleRetriever
class Notifi... | ManagedKube/playground | nexus-global-entry/trusted-traveler-scheduler/trusted-traveler-scheduler/src/notifcation_handler.py | .py | bb2fad1f7d870c71 | 7 | 0 |
class Schedule:
"""
A class representing a schedule of appointments for a Trusted Traveler program.
Attributes:
appointment_date (str): The date of the appointment in the format 'YYYY-MM-DD'.
appointment_times (list): A list of appointment times in the format 'HH:MM AM/PM'.
"""
def ... | ManagedKube/playground | nexus-global-entry/trusted-traveler-scheduler/trusted-traveler-scheduler/src/schedule.py | .py | 893c02cc8b8a7551 | 7 | 0 |
from __future__ import annotations
import os
import signal
import time
from datetime import datetime, timedelta
from multiprocessing import Lock, Process
from typing import TYPE_CHECKING
from .flight import Flight
from .log import get_logger
from .utils import RequestError, make_request
if TYPE_CHECKING:
from .c... | ManagedKube/playground | soutthwest.com/auto-southwest-check-in/auto-southwest-check-in/lib/checkin_handler.py | .py | 0e51e7879cbd556d | 7 | 0 |
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Dict, List
from .checkin_handler import CheckInHandler
from .flight import Flight
from .log import get_logger
from .utils import RequestError, make_request
from .webdriver import WebDriver
if TYPE_CHECKING:
from .reservation_monitor import... | ManagedKube/playground | soutthwest.com/auto-southwest-check-in/auto-southwest-check-in/lib/checkin_scheduler.py | .py | 2caa1df8df4e68e0 | 7 | 0 |
import json
import os
import sys
from pathlib import Path
from typing import Any, Dict, List
from .log import get_logger
from .utils import NotificationLevel, is_truthy
# Type alias for JSON
JSON = Dict[str, Any]
CONFIG_FILE_NAME = "config.json"
logger = get_logger(__name__)
# A custom exception for type or value ... | ManagedKube/playground | soutthwest.com/auto-southwest-check-in/auto-southwest-check-in/lib/config.py | .py | df85d9eb95f509e1 | 7 | 0 |
from __future__ import annotations
from typing import TYPE_CHECKING, Any, Dict, List, Tuple
from .checkin_scheduler import VIEW_RESERVATION_URL
from .flight import Flight
from .log import get_logger
from .utils import FlightChangeError, make_request
if TYPE_CHECKING:
from .reservation_monitor import ReservationM... | ManagedKube/playground | soutthwest.com/auto-southwest-check-in/auto-southwest-check-in/lib/fare_checker.py | .py | 78fc3ca347c9c450 | 7 | 0 |
from __future__ import annotations
import json
import os
from datetime import datetime
from pathlib import Path
from typing import Any, Dict
import pytz
JSON = Dict[str, Any]
TZ_FILE_PATH = "utils/airport_timezones.json"
class Flight:
"""
A helper class that parses flight information received from the Sou... | ManagedKube/playground | soutthwest.com/auto-southwest-check-in/auto-southwest-check-in/lib/flight.py | .py | 3cfe423a50670182 | 7 | 0 |
import logging
import logging.handlers
import multiprocessing
import os
import sys
from pathlib import Path
LOG_FILE = "logs/auto-southwest-check-in.log"
LOG_LEVEL = logging.INFO
def init_main_logging() -> None:
"""
Initialize the main logging setup for the script. This should only be
called in the main ... | ManagedKube/playground | soutthwest.com/auto-southwest-check-in/auto-southwest-check-in/lib/log.py | .py | 03c008a519b86f0f | 7 | 0 |
"""Primary script entrypoint where arguments are processed and flights are set up."""
from __future__ import annotations
import multiprocessing
import sys
from typing import List
from lib import log
from .config import GlobalConfig, ReservationConfig
from .reservation_monitor import AccountMonitor, ReservationMonit... | ManagedKube/playground | soutthwest.com/auto-southwest-check-in/auto-southwest-check-in/lib/main.py | .py | 818d3da79441dc0c | 7 | 0 |
import multiprocessing
import sys
import time
from datetime import datetime
from typing import Any, Dict, List, Tuple, Union
from .checkin_scheduler import CheckInScheduler
from .config import AccountConfig, ReservationConfig
from .fare_checker import FareChecker
from .log import get_logger
from .notification_handler ... | ManagedKube/playground | soutthwest.com/auto-southwest-check-in/auto-southwest-check-in/lib/reservation_monitor.py | .py | 92705e11b218700a | 7 | 0 |
import json
import time
from enum import IntEnum
from typing import Any, Dict, Union
import requests
from .log import get_logger
# Type alias for JSON
JSON = Dict[str, Any]
BASE_URL = "https://mobile.southwest.com/api/"
logger = get_logger(__name__)
def make_request(method: str, site: str, headers: JSON, info: JS... | ManagedKube/playground | soutthwest.com/auto-southwest-check-in/auto-southwest-check-in/lib/utils.py | .py | 90ebaad3b7568518 | 7 | 0 |
from __future__ import annotations
import json
import os
import re
import time
from typing import TYPE_CHECKING, Any, Dict, List
from seleniumbase import Driver
from seleniumbase.fixtures import page_actions as seleniumbase_actions
from .log import get_logger
from .utils import LoginError
if TYPE_CHECKING:
from... | ManagedKube/playground | soutthwest.com/auto-southwest-check-in/auto-southwest-check-in/lib/webdriver.py | .py | 81b543e461d99649 | 7 | 0 |
#!/usr/bin/env python3
"""Entrypoint into the script where the arguments are passed to lib.main"""
import sys
from typing import List
__version__ = "v7.3"
__doc__ = """
Schedule a check-in:
python3 southwest.py [options] CONFIRMATION_NUMBER FIRST_NAME LAST_NAME
Log into your account:
python3 southwest.py [o... | ManagedKube/playground | soutthwest.com/auto-southwest-check-in/auto-southwest-check-in/southwest.py | .py | 31e16df3158b24b6 | 7 | 0 |
"""
Tests the ReservationMonitor and CheckInScheduler to ensure flights are correctly scheduled, headers
are set, errors are handled, and integration with the webdriver works.
"""
import copy
import json
from multiprocessing import Lock
from unittest import mock
import pytest
from pytest_mock import MockerFixture
fro... | ManagedKube/playground | soutthwest.com/auto-southwest-check-in/auto-southwest-check-in/tests/integration/test_monitoring_and_scheduling.py | .py | 848471de950fe924 | 7.5 | 0 |
"""Safely turn an attachment into XML bytes.
DMARC reports arrive as plain XML, gzip, or zip attachments. We use magic bytes to determine the file type.
"""
from __future__ import annotations
import gzip
import zipfile
from io import BytesIO
from pathlib import PurePosixPath
from typing import TYPE_CHECKING, BinaryI... | stuartmaxwell/dmarc-report | src/dmarc_report/_attachments.py | .py | 11060fd1a8e23222 | 7.15 | 1 |
"""Render parsed DMARC aggregate reports with Rich."""
from enum import Enum
from rich import box
from rich.console import Console, Group
from rich.panel import Panel
from rich.table import Table
from rich.text import Text
from dmarc_report import schema
def display_console(
dmarc_report: schema.Report,
*,... | stuartmaxwell/dmarc-report | src/dmarc_report/display.py | .py | fa0f22cd36cccd47 | 7.15 | 1 |
"""Stable exceptions raised for malformed DMARC report content."""
from enum import Enum
class ParseErrorCode(str, Enum):
"""Machine-readable malformed-input reason codes."""
UNSUPPORTED_REPORT = "unsupported_report"
INPUT_LIMIT_EXCEEDED = "input_limit_exceeded"
DECOMPRESSION_LIMIT_EXCEEDED = "decom... | stuartmaxwell/dmarc-report | src/dmarc_report/exceptions.py | .py | 29bbd048bd48ae74 | 7.15 | 1 |
"""Public API for parsing legacy and RFC 9990 DMARC aggregate reports.
The parsing pipeline has three stages:
1. read the attachment file to bytes keeping within `ParserLimits`;
2. decode the attachment bytes to plain XML, extracting from gzip, or zip files if needed;
3. parse the XML tree into the public schema data... | stuartmaxwell/dmarc-report | src/dmarc_report/parser.py | .py | 7230346d4f35be96 | 7.15 | 1 |
"""Command line interface for parsing and displaying DMARC reports."""
import argparse
from pathlib import Path
from rich.console import Console
from rich.text import Text
from dmarc_report import __version__
from dmarc_report.display import display_console
from dmarc_report.exceptions import DMARCParseError
from dm... | stuartmaxwell/dmarc-report | src/dmarc_report/report.py | .py | b1951c75008bec89 | 7.15 | 1 |
"""Typed schema returned by the DMARC aggregate report parser."""
from dataclasses import dataclass, field
from datetime import datetime, timezone
from enum import Enum
class PublishedPolicy(str, Enum):
"""A policy published by a domain owner."""
NONE = "none"
QUARANTINE = "quarantine"
REJECT = "rej... | stuartmaxwell/dmarc-report | src/dmarc_report/schema.py | .py | 05dd8eb8c35ece77 | 7.15 | 1 |
"""Focused tests for the installed Rich command-line interface."""
import os
import subprocess
from io import StringIO
from pathlib import Path
import pytest
from rich.console import Console
import dmarc_report
from dmarc_report.display import display_console
from dmarc_report.parser import DMARCParser, ParserLimits... | stuartmaxwell/dmarc-report | tests/test_cli.py | .py | c90a2ac093da6a70 | 7.65 | 1 |
"""Tests for the reports module."""
import subprocess
from pathlib import Path
import pytest
from dmarc_report import exceptions, parser
valid_xml_reports = [
"reports/dmarc-sample-1.xml",
"reports/dmarc-sample-2.xml",
"reports/dmarc-sample-3.xml",
"reports/dmarc-empty-sp.xml",
"reports/dmarc-fe... | stuartmaxwell/dmarc-report | tests/test_reports.py | .py | e02ae3e2d54eb114 | 7.65 | 1 |
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.
"""Library for the certificate_transfer relation.
This library contains the Requires and Provides classes for handling the
ertificate-transfer interface.
## Getting Started
From a charm directory, fetch the library using `charmcraft`:
```shel... | canonical/identity-platform-login-ui-operator | lib/charms/certificate_transfer_interface/v0/certificate_transfer.py | .py | 8f110b3248a9c6d1 | 7.15 | 1 |
#!/usr/bin/env python3
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.
"""Interface library for sharing hydra endpoints.
This library provides a Python API for both requesting and providing public and admin endpoints.
## Getting Started
To get started using the library, you need to fetch the... | canonical/identity-platform-login-ui-operator | lib/charms/hydra/v0/hydra_endpoints.py | .py | ef85c398ec1d9900 | 7.15 | 1 |
#!/usr/bin/env python3
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.
"""Interface library for sharing Identity Platform Login UI application's endpoints with other charms.
This library provides a Python API for both requesting and providing a public endpoints.
## Getting Started
To get star... | canonical/identity-platform-login-ui-operator | lib/charms/identity_platform_login_ui_operator/v0/login_ui_endpoints.py | .py | df2ee9fd865d337d | 7.15 | 1 |
#!/usr/bin/env python3
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
"""Interface library for sharing kratos info.
This library provides a Python API for both requesting and providing kratos deployment info,
such as endpoints, namespace and ConfigMap details.
## Getting Started
To get star... | canonical/identity-platform-login-ui-operator | lib/charms/kratos/v0/kratos_info.py | .py | acab2236dbc0be72 | 7.15 | 1 |
# Copyright 2022 Canonical Ltd.
# See LICENSE file for licensing details.
"""## Overview.
This document explains how to use the `JujuTopology` class to
create and consume topology information from Juju in a consistent manner.
The goal of the Juju topology is to uniquely identify a piece
of software running across any... | canonical/identity-platform-login-ui-operator | lib/charms/observability_libs/v0/juju_topology.py | .py | 236a2f61b10997d9 | 7.15 | 1 |
# Copyright 2021 Canonical Ltd.
# See LICENSE file for licensing details.
"""# KubernetesServicePatch Library.
This library is designed to enable developers to more simply patch the Kubernetes Service created
by Juju during the deployment of a sidecar charm. When sidecar charms are deployed, Juju creates a
service na... | canonical/identity-platform-login-ui-operator | lib/charms/observability_libs/v0/kubernetes_service_patch.py | .py | 5a1fcb09975517a6 | 7.15 | 1 |
#!/usr/bin/env python3
# Copyright 2025 Canonical Ltd.
# See LICENSE file for licensing details.
"""Interface library for sharing tenant-service info.
This library provides a Python API for both providing and requesting tenant-service
deployment info, such as the HTTP service URL.
## Getting Started
To use the libr... | canonical/identity-platform-login-ui-operator | lib/charms/tenant_service/v0/tenant_service_info.py | .py | aceb56275fcaea38 | 7.15 | 1 |
#!/usr/bin/env python3
# Copyright 2022 Canonical Ltd.
# See LICENSE file for licensing details.
r"""# Interface Library for traefik_route.
This library wraps relation endpoints for traefik_route. The requirer of this
relation is the traefik-route-k8s charm, or any charm capable of providing
Traefik configuration fil... | canonical/identity-platform-login-ui-operator | lib/charms/traefik_k8s/v0/traefik_route.py | .py | fbdb495a5d23f7b5 | 7.15 | 1 |
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.
"""Helper class for trusting ca chains."""
import subprocess
from pathlib import Path
from typing import Callable, Union
from charms.certificate_transfer_interface.v0.certificate_transfer import (
CertificateAvailableEvent,
Certificate... | canonical/identity-platform-login-ui-operator | src/certificate_transfer_integration.py | .py | 5835cfbd55ff0f0f | 7.15 | 1 |
#!/usr/bin/env python3
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.
#
# Learn more at: https://juju.is/docs/sdk
"""A Juju charm for Identity Platform Login UI."""
import logging
import secrets
from typing import Optional
from charms.grafana_k8s.v0.grafana_dashboard import GrafanaDashboar... | canonical/identity-platform-login-ui-operator | src/charm.py | .py | 0871f689b0bb025b | 7.15 | 1 |
#!/usr/bin/env python3
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.
"""Utility functions for the login UI charm."""
from functools import wraps
from typing import Any, Callable, Optional, TypeVar
from urllib.parse import urlparse, urlunparse
from ops.charm import CharmBase
CharmEventHan... | canonical/identity-platform-login-ui-operator | src/utils.py | .py | 594564a4acaa3614 | 7.15 | 1 |
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
import os
import secrets
import subprocess
from contextlib import suppress
from pathlib import Path
from typing import Generator
import jubilant
import pytest
import requests
from integration.constants import (
APP_NAME,
PUBLIC_ROUTE_IN... | canonical/identity-platform-login-ui-operator | tests/integration/conftest.py | .py | f6609f4b8ff0fffe | 7.65 | 1 |
#!/usr/bin/env python3
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.
import logging
from pathlib import Path
from typing import Callable
import jubilant
import pytest
import requests
from integration.conftest import integrate_dependencies
from integration.constants import (
APP_NAME,
... | canonical/identity-platform-login-ui-operator | tests/integration/test_charm.py | .py | 797f743a92fc31a1 | 7.65 | 1 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
import platform
from contextlib import contextmanager
from typing import Callable, Iterator
import jubilant
import yaml
from integration.constants import APP_NAME
from tenacity import retry, stop_after_attempt, wait_exponential
StatusPredicate... | canonical/identity-platform-login-ui-operator | tests/integration/utils.py | .py | 1c411e22562e659a | 7.65 | 1 |
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.
"""Unit test configuration."""
import json
from unittest.mock import mock_open, patch
import ops.testing
import pytest
from pytest_mock import MockerFixture
from charm import IdentityPlatformLoginUiOperatorCharm
from constants import WORKLOAD... | canonical/identity-platform-login-ui-operator | tests/unit/conftest.py | .py | c41d925d1da723cb | 7.65 | 1 |
import logging
from typing import TYPE_CHECKING, Any, cast
if TYPE_CHECKING:
from jira import JIRA
from jira.client import ResultList
from jira.resources import Issue
from glitchtip_jira_bridge.backends.db import (
IssueCache,
Limits,
)
from glitchtip_jira_bridge.metrics import (
... | app-sre/glitchtip-jira-bridge | glitchtip_jira_bridge/backends/jira.py | .py | 23a349bcd15a073d | 7.35 | 4 |
# ruff: file-ignore[hardcoded-password-string]
from datetime import timedelta
from pathlib import Path
from pydantic_settings import BaseSettings
# OpenShift mounts the glitchtip-jira-bridge-secret Secret here as files (one
# per key) instead of injecting it via environment variables. Not present in
# local/dev envir... | app-sre/glitchtip-jira-bridge | glitchtip_jira_bridge/config.py | .py | a2fb3fe06f7a8a33 | 7.35 | 4 |
import logging
import re
from typing import override
_TOKEN_QUERY_PARAM_RE = re.compile(r"(?i)([?&]token=)[^&\s]*")
class RedactTokenQueryParamFilter(logging.Filter):
"""Redact the `token` query parameter from log records.
The `/api/v1/alert` endpoint accepts the API key as a `?token=` query
parameter (... | app-sre/glitchtip-jira-bridge | glitchtip_jira_bridge/logging_utils.py | .py | ef9962d4ceaf9cf4 | 7.35 | 4 |
import logging
import socket
from fastapi import (
APIRouter,
Depends,
FastAPI,
Request,
status,
)
from fastapi.exceptions import RequestValidationError
from fastapi.responses import JSONResponse
from prometheus_fastapi_instrumentator import Instrumentator
from glitchtip_jira_bridge.api import rou... | app-sre/glitchtip-jira-bridge | glitchtip_jira_bridge/main.py | .py | 704a1cb4ee486860 | 7.35 | 4 |
#!/usr/bin/env python3
"""
Caveman Compress CLI
Usage:
caveman <filepath>
"""
import sys
from pathlib import Path
from .compress import compress_file
from .detect import detect_file_type, should_compress
def print_usage():
print("Usage: caveman <filepath>")
def main():
if len(sys.argv) != 2:
... | noman3271/caveman | caveman-compress/scripts/cli.py | .py | 74c740a128afa5cb | 7.15 | 1 |
#!/usr/bin/env python3
"""
Caveman Memory Compression Orchestrator
Usage:
python scripts/compress.py <filepath>
"""
import os
import re
import subprocess
from pathlib import Path
from typing import List
OUTER_FENCE_REGEX = re.compile(
r"\A\s*(`{3,}|~{3,})[^\n]*\n(.*)\n\1\s*\Z", re.DOTALL
)
# Filenames and p... | noman3271/caveman | caveman-compress/scripts/compress.py | .py | 284c78340cd30d5a | 7.15 | 1 |
#!/usr/bin/env python3
"""Detect whether a file is natural language (compressible) or code/config (skip)."""
import json
import re
from pathlib import Path
# Extensions that are natural language and compressible
COMPRESSIBLE_EXTENSIONS = {".md", ".txt", ".markdown", ".rst"}
# Extensions that are code/config and shou... | noman3271/caveman | caveman-compress/scripts/detect.py | .py | c57e92a43e0ce6e7 | 7.15 | 1 |
#!/usr/bin/env python3
import re
from pathlib import Path
URL_REGEX = re.compile(r"https?://[^\s)]+")
FENCE_OPEN_REGEX = re.compile(r"^(\s{0,3})(`{3,}|~{3,})(.*)$")
HEADING_REGEX = re.compile(r"^(#{1,6})\s+(.*)", re.MULTILINE)
BULLET_REGEX = re.compile(r"^\s*[-*+]\s+", re.MULTILINE)
# crude but effective path detecti... | noman3271/caveman | caveman-compress/scripts/validate.py | .py | a42e60345ec4033b | 7.15 | 1 |
"""baseline app schema
Revision ID: 7200faf1d770
Revises:
Create Date: 2026-07-18 02:34:43.956229
"""
from alembic import op
import sqlalchemy as sa
revision = '7200faf1d770'
down_revision = None
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ##... | nidwe72/spectracsPy-model | alembic/app/versions/7200faf1d770_baseline_app_schema.py | .py | 1109994054c164d3 | 7 | 0 |
"""monitor record on the spectral workflow
SPEC_settled_measurement.md §15.2 — ONE nullable TEXT column holding the plugin's SELF-DESCRIBING
settling record (columns + rows + answer + policy + evaluator version). NULL for every plain-burst
capture, which is most of them, so no data is touched and the downgrade is a cl... | nidwe72/spectracsPy-model | alembic/app/versions/84fe759ba6d7_monitor_record_on_the_spectral_workflow.py | .py | 63a285f6c2660122 | 7.5 | 0 |
"""D4 sectionedPhases on spectral_workflow
SPEC_settled_measurement.md §27.14a — which phases are sectioned by step ("Reference" / "Sample" instead of
one "Acquisition"). The plugin declares it, the workflow carries it, and the chevron, a re-opened run, the
PDF and a LIMS addon all read it from the record instead of f... | nidwe72/spectracsPy-model | alembic/app/versions/cb8c2942a6bc_d4_sectionedphases_on_spectral_workflow.py | .py | 67fbe6bf692fe102 | 7.5 | 0 |
"""drop reportOnly - the settling views belong to the sample step
SPEC_settled_measurement.md §27.12 — reverts ed08faaf1864 one session later, on purpose.
`reportOnly` was invented to keep a settling step in PROCESSING out of the UI while the report still
collected it. ⛔ It solved a problem created by putting the vie... | nidwe72/spectracsPy-model | alembic/app/versions/dccf62fc4d10_drop_reportonly_the_settling_views_.py | .py | 4f2ecace35ffe9e1 | 7 | 0 |
"""report-only steps
Revision ID: ed08faaf1864
Revises: 84fe759ba6d7
Create Date: 2026-08-17 04:38:28.154044
"""
from alembic import op
import sqlalchemy as sa
revision = 'ed08faaf1864'
down_revision = '84fe759ba6d7'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic... | nidwe72/spectracsPy-model | alembic/app/versions/ed08faaf1864_report_only_steps.py | .py | f60df843d5b65565 | 7 | 0 |
"""add SpectralWorkflow.pluginVersion (A3 provenance)
Revision ID: f0ac79b33dde
Revises: 7200faf1d770
Create Date: 2026-07-19 18:14:05.654818
"""
from alembic import op
import sqlalchemy as sa
revision = 'f0ac79b33dde'
down_revision = '7200faf1d770'
branch_labels = None
depends_on = None
# A3 provenance (SPEC_plug... | nidwe72/spectracsPy-model | alembic/app/versions/f0ac79b33dde_add_spectralworkflow_pluginversion_a3_.py | .py | 78c126a1e3b9fb07 | 7.5 | 0 |
"""plugin identity (codeRef,version) + sealed columns (B0/B1)
Revision ID: 405d2ce2cec1
Revises: f641f17a1539
Create Date: 2026-07-18 02:43:31.658226
"""
from alembic import op
import sqlalchemy as sa
revision = '405d2ce2cec1'
down_revision = 'f641f17a1539'
branch_labels = None
depends_on = None
def upgrade():
... | nidwe72/spectracsPy-model | alembic/server/versions/405d2ce2cec1_plugin_identity_coderef_version_sealed_.py | .py | f31eca1f7bd61b76 | 7 | 0 |
import json
from sciens.spectracs.logic.model.util.SpectrometerUtil import SpectrometerUtil
from sciens.spectracs.logic.spectral.util.SpectralLineMasterDataUtil import SpectralLineMasterDataUtil
from sciens.spectracs.model.databaseEntity.DbServerBase import server_session_factory
from sciens.spectracs.model.databaseEn... | nidwe72/spectracsPy-model | sciens/spectracs/logic/instrument/InstrumentAuthoringLogicModule.py | .py | 21b96b40b115dd7e | 7.5 | 0 |
from abc import ABC, abstractmethod
from sciens.spectracs.logic.lims.dto.LimsHealth import LimsHealth
from sciens.spectracs.logic.lims.dto.LimsSampleRef import LimsSampleRef
from sciens.spectracs.logic.lims.dto.LimsSubmission import LimsSubmission
class LimsGateway(ABC):
"""The LIMS abstraction seam. One adapter... | nidwe72/spectracsPy-model | sciens/spectracs/logic/lims/LimsGateway.py | .py | c649bf3f7102e824 | 7.5 | 0 |
from sciens.spectracs.logic.lims.LimsGateway import LimsGateway
from sciens.spectracs.logic.lims.dto.LimsHealth import LimsHealth
from sciens.spectracs.logic.lims.dto.LimsSampleRef import LimsSampleRef
from sciens.spectracs.logic.lims.dto.LimsSubmission import LimsSubmission
class MockLimsGateway(LimsGateway):
""... | nidwe72/spectracsPy-model | sciens/spectracs/logic/lims/MockLimsGateway.py | .py | f955873827263e8c | 7.5 | 0 |
class LimsHealth:
"""Result of `LimsGateway.checkConnection()` — is the LIMS reachable and are the credentials
accepted. `detail` carries a backend-specific hint on failure. See SPEC_lims_integration.md §4/§9."""
def __init__(self, ok: bool, message: str = "", detail=None):
self.ok = ok
sel... | nidwe72/spectracsPy-model | sciens/spectracs/logic/lims/dto/LimsHealth.py | .py | e4c8a8843f166aed | 7.5 | 0 |
from typing import Optional
class LimsSampleRef:
"""What a successful `LimsGateway.submit()` returns: the created sample's id (e.g. "OIL-0001") and,
when the LIMS exposes one, a URL to view it. LIMS-agnostic. See SPEC_lims_integration.md §4."""
def __init__(self, sampleId: str, url: Optional[str] = None)... | nidwe72/spectracsPy-model | sciens/spectracs/logic/lims/dto/LimsSampleRef.py | .py | 20cce3cd5c212883 | 7.5 | 0 |
from typing import List, Optional
from sciens.spectracs.logic.lims.dto.LimsTarget import LimsTarget
class LimsCustomer:
"""The customer a sample belongs to. Server-filled from the authenticated AppUser
(SPEC_lims_integration.md §3/§4) — the client never supplies it. `code` is the stable
idempotency key (... | nidwe72/spectracsPy-model | sciens/spectracs/logic/lims/dto/LimsSubmission.py | .py | cd19746012441511 | 7.5 | 0 |
class LimsTarget:
"""Which LIMS backend a plugin wants, and under which config key its credentials live.
Declared by the plugin (`plugin.getLimsTarget()`); resolved by `LimsGatewayFactory` to a concrete
adapter. `configKey` selects the `.env` block `LIMS_<configKey>_BASE_URL/_USER/_PASSWORD`, so several
... | nidwe72/spectracsPy-model | sciens/spectracs/logic/lims/dto/LimsTarget.py | .py | eb38187bc8d24cb7 | 7.5 | 0 |
from typing import List, Optional
from sciens.spectracs.model.databaseEntity.DbServerBase import server_session_factory
from sciens.spectracs.model.databaseEntity.application.payment.Transaction import Transaction
# Ensure the FK target `app_user` is registered on the ServerDbBaseEntity metadata before
# create_all() ... | nidwe72/spectracsPy-model | sciens/spectracs/logic/persistence/database/payment/PersistTransactionLogicModule.py | .py | 7a1317e618a5e3a9 | 7.5 | 0 |
import logging
from typing import Any
# import os
# os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
# keep this line at the top of this file
__all__ = ["logger", "isinstance", "Decorator"]
logging.basicConfig(level=logging.WARNING)
logger = logging.getLogger('aequitas')
"""General logger to be used in all `aequitas*` modu... | aequitas-aod/core-lib | aequitas/__init__.py | .py | fabd3af07509ee02 | 7 | 0 |
from setuptools import setup, find_packages
import pathlib
import subprocess
import distutils.cmd
# current directory
here = pathlib.Path(__file__).parent.resolve()
version_file = here / 'VERSION'
# Get the long description from the README file
long_description = (here / 'README.md').read_text(encoding='utf-8')
# G... | aequitas-aod/core-lib | setup.py | .py | e5de9e2dcd5fb501 | 7 | 0 |
#!/usr/bin/env python
"""
Checks the status of essential Google Cloud services for the project.
This script verifies that "compute.googleapis.com", "datastore.googleapis.com",
and "gmail.googleapis.com" are enabled.
"""
import google.auth
from googleapiclient import discovery
def check_service_status(project_id, ser... | veltzer/gcp-machines | scripts/apis_check.py | .py | d1020bf03f9d404d | 7.15 | 1 |
#!/usr/bin/env python
"""
Manage firewall rules for a GCP project.
This script can be used to create firewall rules to open specific ports or all ports for all instances.
"""
import argparse
import sys
import google.auth
from googleapiclient import discovery
from googleapiclient.errors import HttpError
def require_... | veltzer/gcp-machines | scripts/firewall.py | .py | f6420ae49eb18eb3 | 7.15 | 1 |
#!/usr/bin/env python
"""
Manage Identity-Aware Proxy (IAP) access to the App Engine app.
Enabling IAP itself is a one-time manual step in the GCP console (see
doc/iap.md). Once it is on, this script manages which users may pass through
it by granting/revoking the "IAP-secured Web App User" role
(roles/iap.httpsResour... | veltzer/gcp-machines | scripts/iap.py | .py | 57cd53eb74af68af | 7.15 | 1 |
#!/usr/bin/env python
"""
List all service accounts associated with the current GCP project.
Run this under the default (personal) account, not under a service-account
key, since it is meant to give you an overview of every service account in
the project.
"""
import sys
import google.auth
from googleapiclient import... | veltzer/gcp-machines | scripts/list_service_accounts.py | .py | 97c15f6d35aa2984 | 7.15 | 1 |
#!/usr/bin/env python
"""
Manage the application's service account and its IAM permissions.
A single tool with subcommands to create the service account, (re-)grant its
roles, show whether it exists, and list the roles it currently holds.
Commands:
create Create the service account (replacing any existing one), ... | veltzer/gcp-machines | scripts/service_account.py | .py | 96e9e36e3433bcdf | 7.15 | 1 |
#!/usr/bin/env python
"""
main application
"""
import hmac
import os
import time
import flask
import google.auth
import markupsafe
from google.cloud import datastore
from googleapiclient import discovery
from googleapiclient.errors import HttpError
app = flask.Flask(__name__)
credentials, project_id = google.auth... | veltzer/gcp-machines | src/main.py | .py | 411f1cf5ae0e08e9 | 7.15 | 1 |
"""
AI Agent Trend Report v2 — Main Orchestrator
Pipeline:
1. Collect trending repos from GitHub Topics (stars>1000, active in 7d)
2. Compute velocity-based trend scores
3. Qualitative analysis (optional)
4. Generate trend report
5. Project-specific recommendations (optional)
Usage:
python run.py ... | juninfxp/git-trend-sync | run.py | .py | 65c3874a2bf709ec | 7 | 0 |
"""
Claude Code CLI를 사용하여 카테고리별 정성적 분석을 수행합니다.
"""
import json
import os
import shutil
import subprocess
import time
from datetime import datetime
from pathlib import Path
BASE_DIR = Path(__file__).resolve().parent.parent
def find_claude_cmd() -> str:
"""Find the claude CLI command."""
# Explicit Windows pa... | juninfxp/git-trend-sync | src/analyze.py | .py | 23f876efbf238d63 | 7 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.