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 2024 Canonical Ltd.
# See LICENSE file for licensing details.
"""Background process for rotating logs."""
import logging
import os
import subprocess
from typing import TYPE_CHECKING
from ops.framework import Object
from ops.model import ActiveStatus
if TYPE_CHECKING:
from charm import PostgresqlOper... | canonical/postgresql-operator | src/rotate_logs.py | .py | 22f88b69f7a3b599 | 7.64 | 18 |
# Copyright 2023 Canonical Ltd.
# See LICENSE file for licensing details.
"""Upgrades implementation."""
import json
import logging
from typing import TYPE_CHECKING
from charms.data_platform_libs.v0.upgrade import (
ClusterNotReadyError,
DataUpgrade,
DependencyModel,
UpgradeGrantedEvent,
)
from charm... | canonical/postgresql-operator | src/upgrade.py | .py | 4efea4311fdebcbc | 7.64 | 18 |
# Copyright 2022 Canonical Ltd.
# See LICENSE file for licensing details.
"""A collection of utility functions that are used in the charm."""
import platform
import secrets
import string
from constants import POSTGRESQL_SNAP_NAME, SNAP_PACKAGES
def new_password() -> str:
"""Generate a random password string.
... | canonical/postgresql-operator | src/utils.py | .py | 3801336b71d4f73a | 7.64 | 18 |
#!/usr/bin/env python3
# Copyright 2022 Canonical Ltd.
# See LICENSE file for licensing details.
import contextlib
import logging
import subprocess
from asyncio import gather
import pytest as pytest
from juju.model import Model
from pytest_operator.plugin import OpsTest
from tenacity import Retrying, stop_after_delay,... | canonical/postgresql-operator | tests/integration/ha_tests/conftest.py | .py | 06d2305d2c095bde | 8.14 | 18 |
# Copyright 2022 Canonical Ltd.
# See LICENSE file for licensing details.
import contextlib
import json
import logging
import os
import random
import subprocess
from pathlib import Path
from tempfile import mkstemp
import psycopg2
import requests
import yaml
from juju.model import Model
from pytest_operator.plugin imp... | canonical/postgresql-operator | tests/integration/ha_tests/helpers.py | .py | aa3186c58c0101ea | 7.14 | 18 |
#!/usr/bin/env python3
# Copyright 2022 Canonical Ltd.
# See LICENSE file for licensing details.
import asyncio
import itertools
import json
import logging
import os
import subprocess
import tempfile
import zipfile
from datetime import datetime
from pathlib import Path
import botocore
import psycopg2
import requests
i... | canonical/postgresql-operator | tests/integration/helpers.py | .py | 2370cc9c58b32170 | 7.14 | 18 |
"""Support for recording details."""
import asyncio
import concurrent.futures
import logging
import queue
import threading
from collections.abc import Callable
from typing import Any
import homeassistant.helpers.config_validation as cv
import voluptuous as vol
from homeassistant.const import (
EVENT_HOMEASSISTANT... | CM000n/qss | custom_components/qss/__init__.py | .py | 5b04fefa7f572c40 | 7.52 | 10 |
"""Helper functions for event handling and data insertion."""
from collections.abc import Callable
from queue import Queue
from homeassistant.const import ATTR_ENTITY_ID, STATE_UNKNOWN
from homeassistant.core import Event
def put_event_to_queue(
event: Event, entity_filter: Callable[[str], bool], queue: Queue
)... | CM000n/qss | custom_components/qss/event_handling.py | .py | a353ffbd46c8922a | 7.52 | 10 |
"""Helper functions for IO operations on QuestDB."""
import logging
from json import dumps
from queue import Queue
from homeassistant.core import Event
from questdb.ingress import IngressError, Protocol, Sender
from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_fixed
from .const import RET... | CM000n/qss | custom_components/qss/io.py | .py | 9fccaf83f1fe7c62 | 7.52 | 10 |
# Creating the color palette for the App
NORD_PALETTE = {
# Polar Night
"nord0": "#2E3440",
"nord1": "#3B4252",
"nord2": "#434C5E",
"nord3": "#4C566A",
# Snow Storm
"nord4": "#D8DEE9",
"nord5": "#E5E9F0",
"nord6": "#ECEFF4",
# Frost
"nord7": "#8FBCBB",
"nord8": "#88C0D0",... | saccofrancesco/lock | colors/colors.py | .py | e9e5907528e68aea | 7.48 | 8 |
# Importing Libraries
import customtkinter as ctk
import tkinter as tk
from components.buttonframe import ButtonFrame
from components.header import Header
from colors.colors import color
from utils.paths import resource_path
# Craeting the App blueprint
class App(ctk.CTk):
"""
A custom application class that ... | saccofrancesco/lock | components/app.py | .py | 8c8d6b4f810654ae | 7.48 | 8 |
# Importing Libraries
import customtkinter as ctk
from colors.colors import color
from components.buttons import *
# Craeting the buttonframe blueprint
class ButtonFrame(ctk.CTkFrame):
"""
A custom frame class that creates a frame containing several buttons using customtkinter.
Attributes:
master... | saccofrancesco/lock | components/buttonframe.py | .py | 1a6c67fd14842e38 | 7.48 | 8 |
# Importing Libraries
import customtkinter as ctk
from colors.colors import color
# Creating the cancelbutton blueprint closing the toplevels
class CancellButton(ctk.CTkButton):
"""
A custom button class for canceling and closing a top-level window.
Attributes:
BGCOLOR (str): Background color for... | saccofrancesco/lock | components/cancelbutton.py | .py | c3fa1afebd5fec42 | 7.48 | 8 |
# Importing Libraries
import customtkinter as ctk
from colors.colors import color
# Creating the entry blueprint with custom color
class CustomEntry(ctk.CTkEntry):
"""
A custom entry field class with specified colors and placeholder text.
Args:
master (ctk.CTkFrame): The parent frame.
pla... | saccofrancesco/lock | components/customentry.py | .py | 16c317bac5a71dfe | 7.48 | 8 |
# Importing Libraries
import customtkinter as ctk
from PIL import Image
from utils.paths import resource_path
# Craeting the header blueprint
class Header(ctk.CTkFrame):
"""
A custom frame class for displaying a header with an image.
Attributes:
BASE_PATH (str): Base path for assets.
TITL... | saccofrancesco/lock | components/header.py | .py | 0276fff23dae8562 | 7.48 | 8 |
# Importing Libraries
import customtkinter as ctk
from colors.colors import color
from PIL import Image
from utils.paths import resource_path
# Creating the password entry widget with the option to show or not the password
class PasswordEntry(ctk.CTkFrame):
"""
A custom frame class for a password entry widget... | saccofrancesco/lock | components/passwordentry.py | .py | 49ed81a32761f4fb | 7.48 | 8 |
# Importing Libraries
import customtkinter as ctk
from colors.colors import color, darken_color
from components.cancelbutton import CancellButton
from components.customentry import CustomEntry
from components.passwordentry import PasswordEntry
from database.database import search_password
# Creating the blueprint for... | saccofrancesco/lock | components/searchform.py | .py | 2ce4bfc0deafe5a8 | 7.48 | 8 |
# Importing Libraries
from base64 import urlsafe_b64encode as b64e, urlsafe_b64decode as b64d
from cryptography.fernet import Fernet
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
from cryptograp... | saccofrancesco/lock | database/encryptor.py | .py | 35eb8e52549614c0 | 7.48 | 8 |
# Importing Libraries
import customtkinter as ctk
# Creaeting the custom App font
class CustomFont(ctk.CTkFont):
"""
Represents a custom font for the application.
This class inherits from ctk.CTkFont and allows creating custom fonts with specified size and weight.
Args:
size (int): The size ... | saccofrancesco/lock | font/font.py | .py | 3d013663dad644da | 7.48 | 8 |
from __future__ import annotations
import os
import shutil
import sys
from pathlib import Path
APP_NAME: str = "Lock"
DATABASE_FILENAME: str = ".database.db"
SEED_DATABASE_RELATIVE_PATH: tuple[str, str] = ("database", "seed.db")
def bundle_root() -> Path:
"""Return the runtime root for both source and PyInstall... | saccofrancesco/lock | utils/paths.py | .py | 0a69d7a801076874 | 7.48 | 8 |
from copy import deepcopy
from logging import Logger
from pathlib import Path
import time
import numpy as np
from numpy.typing import NDArray
from .calibration_utils import (
vis_extract_autocorr,
vis_cal_auto_init,
vis_calibration_flag,
vis_cal_bandpass,
vis_cal_polyfit,
vis_cal_auto_fit,
... | EoRImaging/pyfhd | src/pyfhd/calibration/calibrate.py | .py | a001280da69d26ee | 7.6 | 15 |
import numpy as np
from numpy.typing import NDArray
from pyfhd.io.pyfhd_io import save
from logging import Logger
from pathlib import Path
from astropy.io import fits
from datetime import datetime
from pyfhd.data_setup.obs import update_obs
from pyfhd.beam_setup.beam_utils import beam_image
from pyfhd.pyfhd_tools.unit_... | EoRImaging/pyfhd | src/pyfhd/io/pyfhd_quickview.py | .py | bb045b972edb6fa9 | 7.6 | 15 |
from pyfhd.io.pyfhd_io import recarray_to_dict
import numpy as np
from scipy.io import readsav
from pathlib import Path
import numpy.testing as npt
from colorama import Fore
from colorama import Style
from pyfhd.io.pyfhd_io import save
from numpy.typing import NDArray
def get_data(data_dir: Path, data_filename: str, ... | EoRImaging/pyfhd | src/pyfhd/pyfhd_tools/test_utils.py | .py | 2998e227236b18a7 | 8.1 | 15 |
"""Setup file"""
import io
import setuptools
with open("README.md", encoding="utf-8") as fp:
long_description = fp.read()
def read(*filenames, **kwargs):
"""function to read files like requirements.txt"""
encoding = kwargs.get("encoding", "utf-8")
# io.open defaults to \n as universal line ending no... | aws-cloudformation/resource-schema-guard-rail | setup.py | .py | 3c6315cc346971eb | 7.56 | 12 |
"""CLI entry to the package.
Execution of the rules can come via cli command. This module allows
one to execute resource json schema compliance assessment via cli
command with a prespecified set of arguments.
Typical usage example:
$ guard-rail --schema file://path1 --schema file://path2 --rule file://path1 --ru... | aws-cloudformation/resource-schema-guard-rail | src/cli.py | .py | 52908c6e1aedffc9 | 7.56 | 12 |
"""Module that holds custom data types.
Provides custom data types:
- Stateful
- Stateless
- GuardRuleSet
- GuardRuleSetResult
Typical usage example:
from guard_rail.core.data_types import GuardRuleResult, GuardRuleSetResult, Stateful, Stateless
payload: Stateless = Stateless(schemas=list_of_schemas, rules=... | aws-cloudformation/resource-schema-guard-rail | src/rpdk/guard_rail/core/data_types.py | .py | f1a2170b091c2fb7 | 7.56 | 12 |
"""Module to perform stateful schema diff.
The main idea is to run two json blobs (v1, v2) over deepdiff module;
This module will generate a metadiff, which will have three main categories:
1. iterable
2. values change
3. dictionary change
#1 covers most CFN invented constructs
#2 covers arbitrary changes in values
... | aws-cloudformation/resource-schema-guard-rail | src/rpdk/guard_rail/core/stateful.py | .py | 7d26e6b5b5767fcc | 7.56 | 12 |
"""Module to perform logging."""
import logging
from functools import wraps
logging.basicConfig(
level=logging.DEBUG,
format="%(asctime)s - %(levelname)-12s %(message)s",
datefmt="%m-%d %H:%M",
filename="guard-rail.log",
filemode="w",
)
console = logging.StreamHandler()
console.setLevel(logging.E... | aws-cloudformation/resource-schema-guard-rail | src/rpdk/guard_rail/utils/logger.py | .py | 2135af7cfde7224d | 7.56 | 12 |
"""Module to handle schema manipulations."""
from copy import deepcopy
from typing import Any, Dict, List, Sequence, Set, Tuple
from jsonschema import RefResolver
_PROPERTIES = "properties"
_DEFINITIONS = "definitions"
_REF = "$ref"
_ITEMS = "items"
_PATTERN_PROPERTIES = "patternProperties"
_ANY_OF = "anyOf"
_ONE_OF ... | aws-cloudformation/resource-schema-guard-rail | src/rpdk/guard_rail/utils/schema_utils.py | .py | be03b010c82064ac | 7.56 | 12 |
"""
Unit test for data_types.py
"""
from rpdk.guard_rail.core.data_types import GuardRuleResult, GuardRuleSetResult
def test_merge():
"""Test GuardRuleSetResult merge"""
try:
GuardRuleSetResult().merge("rule_result")
except TypeError as e:
assert "cannot merge with non GuardRuleSetResult ... | aws-cloudformation/resource-schema-guard-rail | tests/unit/core/test_data_types.py | .py | 5e11b130f1876c26 | 8.06 | 12 |
"""
Unit tests for data_types.py read functionality
"""
from rpdk.guard_rail.core.data_types import Stateless
def test_stateless_with_read_only_flag():
"""Test Stateless data type with is_read_only flag"""
payload = Stateless(schemas=[{"foo": "bar"}], rules=[], is_read_only=True)
assert payload.is_read_o... | aws-cloudformation/resource-schema-guard-rail | tests/unit/core/test_data_types_read_only.py | .py | 9600bacf6e709792 | 8.06 | 12 |
"""
Unit test for runner.py
"""
from unittest import mock
import pytest
from rpdk.guard_rail.core.data_types import Stateful, Stateless
from rpdk.guard_rail.core.runner import exec_compliance, prepare_ruleset
def test_prepare_ruleset():
"""Test rule set prepare"""
assert prepare_ruleset()
assert prepare... | aws-cloudformation/resource-schema-guard-rail | tests/unit/core/test_runner.py | .py | 6950410d5daa36d5 | 8.06 | 12 |
"""unittest module to test arg handler"""
import argparse
import os
from pathlib import Path
import pytest
from rpdk.guard_rail.utils.arg_handler import (
argument_validation,
collect_rules,
collect_schemas,
rule_input_path_validation,
schema_input_path_validation,
setup_args,
)
def test_arg... | aws-cloudformation/resource-schema-guard-rail | tests/unit/utils/test_arg_handler.py | .py | 01f4a4dfd4d2d57d | 8.06 | 12 |
"""
Unit tests for arg_handler.py read functionality
"""
from rpdk.guard_rail.utils.arg_handler import setup_args
def test_setup_args_includes_read_only_flag():
"""Test that setup_args includes the --is-read flag"""
parser = setup_args()
# Parse with the new flag
args = parser.parse_args(["--schema",... | aws-cloudformation/resource-schema-guard-rail | tests/unit/utils/test_arg_handler_read_only.py | .py | 089fcd04149e7cb2 | 8.06 | 12 |
"""
Unit test for cli.py
"""
import os
from pathlib import Path
import pytest
from rpdk.guard_rail.utils.common import is_guard_rule, read_file
@pytest.mark.parametrize(
"rule,result",
[("file:/data/sample.guard", True), ("file:/data/sample.json", False)],
)
def test_is_guard_rule(rule, result):
"""Unit... | aws-cloudformation/resource-schema-guard-rail | tests/unit/utils/test_common.py | .py | 51ac72421f806a13 | 8.06 | 12 |
/**
* Unit tests for DiagnosticProvider
*/
import * as assert from 'assert';
// Mock VS Code API
const mockDiagnosticCollection = {
set: () => {},
delete: () => {},
dispose: () => {}
};
const mockStatusBarItem = {
text: '',
tooltip: '',
backgroundColor: undefined as any,
show: () => {},
dispose: ()... | aws-cloudformation/resource-schema-guard-rail | vscode-extension/test/diagnosticProvider.test.ts | .ts | 0f01e844d2deb7f5 | 7.06 | 12 |
from hashlib import sha1
from pathlib import Path
from glob import glob
from zipfile import ZipFile
def ensureparent(filepath):
Path(filepath).parent.mkdir(parents=True, exist_ok=True)
def glob_posix(pattern, *args, **kwargs):
'''
An opinionated glob.glob():
* recursive=True by default
... | ftl-mv-translation/mvinstaller | mvinstaller/fstools.py | .py | 0e328d290fda03a7 | 7.6 | 15 |
from os.path import isdir, join
from typing import Optional
from ovos_config.locations import get_xdg_config_save_path
from ovos_bus_client.util import get_mycroft_bus
from ovos_utils.lang import standardize_lang_tag
from ovos_bus_client.apis.gui import GUIInterface
from ovos_bus_client.client.client import MessageBusC... | OpenVoiceOS/ovos-workshop | ovos_workshop/app.py | .py | 2807526e2393fa20 | 7.42 | 6 |
import threading
from functools import wraps
from inspect import signature
from typing import Optional, Type
from ovos_bus_client.session import SessionManager
from ovos_utils import create_killable_daemon
from ovos_bus_client.message import Message
from ovos_utils.log import LOG
class AbortEvent(StopIteration):
... | OpenVoiceOS/ovos-workshop | ovos_workshop/decorators/killable.py | .py | 1cb4a255dfbebace | 7.42 | 6 |
# Copyright 2017 Mycroft AI Inc.
#
# 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.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | OpenVoiceOS/ovos-workshop | ovos_workshop/filesystem.py | .py | f52dfb673bb6e01a | 7.42 | 6 |
# Copyright 2026 OpenVoiceOS
#
# 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.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | OpenVoiceOS/ovos-workshop | ovos_workshop/skills/util.py | .py | b79e40f0a6f829ad | 7.42 | 6 |
# Copyright 2026 OpenVoiceOS
#
# 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.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | OpenVoiceOS/ovos-workshop | test/end2end/intent4_test_skill/__init__.py | .py | d46d74eeb010ea42 | 7.92 | 6 |
# Copyright 2026 OpenVoiceOS
#
# 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.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | OpenVoiceOS/ovos-workshop | test/end2end/test_auto_entity_registration_e2e.py | .py | 2e87440d7579da8f | 7.92 | 6 |
# Copyright 2026 OpenVoiceOS
#
# 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.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | OpenVoiceOS/ovos-workshop | test/end2end/test_keyword_casing_e2e.py | .py | 2b86e07380c2c130 | 7.92 | 6 |
from ovos_workshop.decorators import killable_intent
from ovos_workshop.skills.converse import ConversationalSkill
from ovos_workshop.decorators import intent_handler
from time import sleep
class TestAbortSkill(ConversationalSkill):
"""
send "mycroft.skills.abort_question" and confirm only get_response is abo... | OpenVoiceOS/ovos-workshop | test/unittests/ovos_tskill_abort/__init__.py | .py | 291af4d0b89443b7 | 7.92 | 6 |
# Copyright 2026 OpenVoiceOS
#
# 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.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | OpenVoiceOS/ovos-workshop | test/unittests/skills/test_auto_translatable_extended.py | .py | c9312ecd713734df | 7.92 | 6 |
# Copyright 2026 OpenVoiceOS
#
# 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.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | OpenVoiceOS/ovos-workshop | test/unittests/skills/test_common_play_extended.py | .py | 9386dc13482991da | 7.92 | 6 |
# Copyright 2026 OpenVoiceOS
#
# 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.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, s... | OpenVoiceOS/ovos-workshop | test/unittests/skills/test_game_skill_extended.py | .py | c4bac4db8ae74102 | 7.92 | 6 |
"""
Parser for Qingping BLE advertisements.
This file is shamelessly copied from the following repository:
https://github.com/Ernst79/bleparser/blob/c42ae922e1abed2720c7fac993777e1bd59c0c93/package/bleparser/qingping.py
MIT License applies.
"""
from __future__ import annotations
import logging
from dataclasses impo... | Bluetooth-Devices/qingping-ble | src/qingping_ble/parser.py | .py | 7f1e7c2785a6100c | 7.52 | 10 |
from contextlib import nullcontext
from logging.config import fileConfig
from alembic import context
from sqlalchemy import engine_from_config, pool
from palace.manager.core.config import Configuration
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = co... | ThePalaceProject/circulation | alembic/env.py | .py | c8da7d47f7b408c1 | 7.45 | 7 |
"""Ability to suppress works per library
Revision ID: 9d2dccb0d6ff
Revises: 1c9f519415b5
Create Date: 2024-02-16 17:08:52.146860+00:00
Note: this migration was updated when older migrations were deleted from the repository history,
and this was made the first migration by changing the down_revision to None.
See: htt... | ThePalaceProject/circulation | alembic/versions/20240216_9d2dccb0d6ff_ability_to_suppress_works_per_library.py | .py | 017b977f3d74e3e6 | 7.45 | 7 |
"""Remove update-search-index work coverage records.
Revision ID: 50746a3bd243
Revises: f532186a3d48
Create Date: 2024-05-22 19:08:51.390547+00:00
"""
from alembic import op
# revision identifiers, used by Alembic.
revision = "50746a3bd243"
down_revision = "f532186a3d48"
branch_labels = None
depends_on = None
def... | ThePalaceProject/circulation | alembic/versions/20240522_50746a3bd243_remove_update_search_index_work_.py | .py | 4112cba9309555bf | 7.45 | 7 |
"""Remove Patron.last_loan_activity_sync
Revision ID: 7ba553f3f80d
Revises: 50746a3bd243
Create Date: 2024-06-12 00:53:37.497861+00:00
"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = "7ba553f3f80d"
down_revision = "507... | ThePalaceProject/circulation | alembic/versions/20240612_7ba553f3f80d_remove_patron_last_loan_activity_sync.py | .py | 3eca8ba0dc8c37d1 | 7.45 | 7 |
"""Update existing MarcExporter protocols
Revision ID: 350a29bf0ff0
Revises: 7a2fcaac8b63
Create Date: 2024-09-05 16:04:45.789665+00:00
"""
from alembic import op
# revision identifiers, used by Alembic.
revision = "350a29bf0ff0"
down_revision = "7a2fcaac8b63"
branch_labels = None
depends_on = None
def upgrade() ... | ThePalaceProject/circulation | alembic/versions/20240905_350a29bf0ff0_update_existing_marcexporter_protocols.py | .py | 01c8e27b6a0976f6 | 7.45 | 7 |
"""Remove unused Overdrive credentials
Revision ID: 87901a6323d6
Revises: 350a29bf0ff0
Create Date: 2024-09-16 19:54:56.986491+00:00
"""
from alembic import op
# revision identifiers, used by Alembic.
revision = "87901a6323d6"
down_revision = "350a29bf0ff0"
branch_labels = None
depends_on = None
def upgrade() -> ... | ThePalaceProject/circulation | alembic/versions/20240916_87901a6323d6_remove_unused_overdrive_credentials.py | .py | 0771373e878406de | 7.45 | 7 |
"""Remove Hold.external_identifier
Revision ID: 1938277e993f
Revises: 87901a6323d6
Create Date: 2024-10-15 19:47:55.697280+00:00
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "1938277e993f"
down_revision = "87901a6323d6"
branch_labels = None
depends_on = None... | ThePalaceProject/circulation | alembic/versions/20241015_1938277e993f_remove_hold_external_identifier.py | .py | 14d0f181f651bff3 | 7.45 | 7 |
"""Add index ix_licensepools_collection_id_work_id
Revision ID: 3faa5bba3ddf
Revises: 1938277e993f
Create Date: 2024-10-29 15:29:56.588830+00:00
"""
from alembic import op
# revision identifiers, used by Alembic.
revision = "3faa5bba3ddf"
down_revision = "1938277e993f"
branch_labels = None
depends_on = None
def u... | ThePalaceProject/circulation | alembic/versions/20241029_3faa5bba3ddf_add_index_ix_licensepools_collection_id_.py | .py | f4170726d468864d | 7.45 | 7 |
"""Add UUID to patron table
Revision ID: 272da5f400de
Revises: 3faa5bba3ddf
Create Date: 2024-10-30 17:41:28.151677+00:00
"""
import uuid
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects.postgresql import UUID
# revision identifiers, used by Alembic.
revision = "272da5f400de"
down_revision =... | ThePalaceProject/circulation | alembic/versions/20241030_272da5f400de_add_uuid_to_patron_table.py | .py | 5fc38902bcc2a259 | 7.45 | 7 |
"""Remove unsafe characters summary
Revision ID: c3458e1ef9aa
Revises: 272da5f400de
Create Date: 2024-11-27 20:32:41.431147+00:00
"""
from alembic import op
# revision identifiers, used by Alembic.
revision = "c3458e1ef9aa"
down_revision = "272da5f400de"
branch_labels = None
depends_on = None
def upgrade() -> Non... | ThePalaceProject/circulation | alembic/versions/20241127_c3458e1ef9aa_remove_unsafe_characters_summary.py | .py | f80067c092ca0d64 | 7.45 | 7 |
"""Remove collection facet settings
Revision ID: 603b8ebd6daf
Revises: 8dde64eab209
Create Date: 2024-12-02 19:42:23.775579+00:00
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "603b8ebd6daf"
down_revision = "8dde64eab209"
branch_labels = None
depends_on = Non... | ThePalaceProject/circulation | alembic/versions/20241202_603b8ebd6daf_remove_collection_facet_settings.py | .py | 16e6c42bcb22d7e5 | 7.45 | 7 |
"""Increase circulation event type field length
Revision ID: 579786fecbf4
Revises: 603b8ebd6daf
Create Date: 2024-12-20 06:30:30.148748+00:00
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "579786fecbf4"
down_revision = "603b8ebd6daf"
branch_labels = None
depe... | ThePalaceProject/circulation | alembic/versions/20241220_579786fecbf4_increase_circulation_event_type_field_.py | .py | f750c0e1131ccd16 | 7.45 | 7 |
"""Add task type to timestamp type enum
Revision ID: 704dd5322783
Revises: c800cc42184a
Create Date: 2025-02-24 18:24:45.709550+00:00
"""
from alembic import op
from palace.manager.sqlalchemy.model.coverage import Timestamp
from palace.manager.util.migration.helpers import pg_update_enum
# revision identifiers, us... | ThePalaceProject/circulation | alembic/versions/20250224_704dd5322783_add_task_type_to_timestamp_type_enum.py | .py | 8cef6b0e7766e609 | 7.45 | 7 |
"""Remove patron location
Revision ID: 16c016e599a0
Revises: 61df6012a5e6
Create Date: 2025-03-11 13:42:12.187155+00:00
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "16c016e599a0"
down_revision = "61df6012a5e6"
branch_labels = None
depends_on = None
def up... | ThePalaceProject/circulation | alembic/versions/20250311_16c016e599a0_remove_patron_location.py | .py | 7074c4ba20a10ab2 | 7.45 | 7 |
"""Add LicensePoolDeliveryMechanism.available
Revision ID: df27b4867e56
Revises: 16c016e599a0
Create Date: 2025-03-14 18:22:01.825315+00:00
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "df27b4867e56"
down_revision = "16c016e599a0"
branch_labels = None
depend... | ThePalaceProject/circulation | alembic/versions/20250314_df27b4867e56_add_licensepooldeliverymechanism_.py | .py | d623bb7d6101e55e | 7.45 | 7 |
"""Sort library languages
Revision ID: b96d67e65177
Revises: df27b4867e56
Create Date: 2025-04-09 14:24:59.558570+00:00
"""
import sqlalchemy as sa
from alembic import op
from palace.manager.util.json import json_serializer
# revision identifiers, used by Alembic.
revision = "b96d67e65177"
down_revision = "df27b48... | ThePalaceProject/circulation | alembic/versions/20250409_b96d67e65177_sort_library_languages.py | .py | 213bbd0009be3488 | 7.45 | 7 |
"""Make contributor.aliases not nullable
Revision ID: d671b95566fb
Revises: f36442df213d
Create Date: 2025-05-05 17:03:57.699199+00:00
"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = "d671b95566fb"
down_revision = "f36... | ThePalaceProject/circulation | alembic/versions/20250505_d671b95566fb_make_contributor_aliases_not_nullable.py | .py | ceacadd4922a631a | 7.45 | 7 |
"""Update axis datasource to boundless
Revision ID: 5e33dc35b5b9
Revises: bc471d8a83fb
Create Date: 2025-06-25 16:06:33.738280+00:00
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "5e33dc35b5b9"
down_revision = "bc471d8a83fb"
branch_labels = None
depends_on = ... | ThePalaceProject/circulation | alembic/versions/20250625_5e33dc35b5b9_update_axis_datasource_to_boundless.py | .py | 273db0a31d9657ba | 7.45 | 7 |
"""Remove superseded concept from license pools.
Revision ID: bc471d8a83fb
Revises: 87051f7b2905
Create Date: 2025-06-26 20:24:52.724565+00:00
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "bc471d8a83fb"
down_revision = "87051f7b2905"
branch_labels = None
dep... | ThePalaceProject/circulation | alembic/versions/20250626_bc471d8a83fb_remove_superseded_concept_from_license_pools.py | .py | 0d2fc72e087aa032 | 7.45 | 7 |
"""Add created and updated timestamps to editions
Revision ID: 1290ca457ee4
Revises: 5e33dc35b5b9
Create Date: 2025-07-21 18:29:35.463120+00:00
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "1290ca457ee4"
down_revision = "5e33dc35b5b9"
branch_labels = None
de... | ThePalaceProject/circulation | alembic/versions/20250721_1290ca457ee4_add_created_and_updated_timestamps_to_.py | .py | 9ea4989c12fca0ba | 7.45 | 7 |
"""Remove open_access_download_url column from licensepools
Revision ID: 4c2d754c04e9
Revises: dfc5e8f7ac03
Create Date: 2025-10-23 13:40:29.239298+00:00
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "4c2d754c04e9"
down_revision = "dfc5e8f7ac03"
branch_labels... | ThePalaceProject/circulation | alembic/versions/20251023_4c2d754c04e9_remove_open_access_download_url_column_.py | .py | e2c311c9ba3c03e6 | 7.45 | 7 |
"""Remove unused extra field from datasources
Revision ID: 6212e80c0fab
Revises: 4c2d754c04e9
Create Date: 2025-10-23 16:03:14.742447+00:00
"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = "6212e80c0fab"
down_revision =... | ThePalaceProject/circulation | alembic/versions/20251023_6212e80c0fab_remove_unused_extra_field_from_.py | .py | f8649d9fc75f81e3 | 7.45 | 7 |
"""Make sure that checkouts_available is not nullable
Revision ID: 8f84407cd52b
Revises: 6212e80c0fab
Create Date: 2025-10-23 18:02:34.605053+00:00
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "8f84407cd52b"
down_revision = "6212e80c0fab"
branch_labels = Non... | ThePalaceProject/circulation | alembic/versions/20251023_8f84407cd52b_make_sure_that_checkouts_available_is_.py | .py | 3a6b9993cab1df1d | 7.45 | 7 |
"""Add status and type enum to licensepool
Revision ID: 2ec8857ae150
Revises: 8f84407cd52b
Create Date: 2025-11-13 14:29:34.740641+00:00
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "2ec8857ae150"
down_revision = "8f84407cd52b"
branch_labels = None
depends_o... | ThePalaceProject/circulation | alembic/versions/20251113_2ec8857ae150_add_status_and_type_enum_to_licensepool.py | .py | ce07d9cb86953576 | 7.45 | 7 |
"""Update existing licensepools to use status and type enum
Revision ID: 7c8e14813018
Revises: 2ec8857ae150
Create Date: 2025-11-14 13:11:56.971127+00:00
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "7c8e14813018"
down_revision = "2ec8857ae150"
branch_labels... | ThePalaceProject/circulation | alembic/versions/20251114_7c8e14813018_update_existing_licensepools_to_use_.py | .py | e5f52bb5c45c5ef2 | 7.45 | 7 |
"""Add terms_checkouts to licenses table
Revision ID: adea054e2ea1
Revises: 7c8e14813018
Create Date: 2026-01-08 00:00:00.000000+00:00
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "adea054e2ea1"
down_revision = "7c8e14813018"
branch_labels = None
depends_on ... | ThePalaceProject/circulation | alembic/versions/20260108_add_terms_checkouts_to_licenses.py | .py | 085779575b40f478 | 7.45 | 7 |
"""Add last_updated to licensepools
Revision ID: 9c3f2b3fba1b
Revises: adea054e2ea1
Create Date: 2026-01-21 00:00:00.000000+00:00
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "9c3f2b3fba1b"
down_revision = "adea054e2ea1"
branch_labels = None
depends_on = Non... | ThePalaceProject/circulation | alembic/versions/20260121_9c3f2b3fba1b_add_last_updated_to_licensepools.py | .py | 0a3ef9a4264eb34b | 7.45 | 7 |
"""remove_deprioritize_lcp_non_epubs_setting
Revision ID: 08aba65e21e0
Revises: 9c3f2b3fba1b
Create Date: 2026-02-10 19:09:05.304837+00:00
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "08aba65e21e0"
down_revision = "9c3f2b3fba1b"
branch_labels = None
depends... | ThePalaceProject/circulation | alembic/versions/20260210_08aba65e21e0_remove_deprioritize_lcp_non_epubs_.py | .py | 2e31ba08c519007f | 7.45 | 7 |
"""Add startup_tasks table
Revision ID: a5ee359c2d31
Revises: 08aba65e21e0
Create Date: 2026-02-10 00:00:00.000000+00:00
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "a5ee359c2d31"
down_revision = "08aba65e21e0"
branch_labels = None
depends_on = None
def u... | ThePalaceProject/circulation | alembic/versions/20260210_a5ee359c2d31_add_startup_tasks_table.py | .py | 00b5d6e1bc3f7fe3 | 7.45 | 7 |
"""Remove sirsi library id
Revision ID: 23795e50c915
Revises: a5ee359c2d31
Create Date: 2026-03-19 23:55:41.909306+00:00
"""
import sqlalchemy as sa
from alembic import op
from palace.manager.util.migration.helpers import migration_logger
# revision identifiers, used by Alembic.
revision = "23795e50c915"
down_revi... | ThePalaceProject/circulation | alembic/versions/20260319_23795e50c915_remove_sirsi_library_id.py | .py | 811af2552e374e4e | 7.45 | 7 |
"""reset_checked_for_palace_marketplace_juvenile_nonfiction_subjects
Palace Marketplace sends Juvenile Fiction BISAC codes with an FB prefix and
N suffix (e.g. FBJUV000000N). The BISACClassifier.scrub_identifier() method
now strips the trailing N so these codes resolve to their canonical BISAC
entries (e.g. JUV000000 ... | ThePalaceProject/circulation | alembic/versions/20260423_45f74fdcec18_reset_checked_for_palace_marketplace_.py | .py | 7c143fee98a23447 | 7.45 | 7 |
"""reset_checked_for_all_fbjuv_subjects
Palace Marketplace sends BISAC codes with an "FBJUV" prefix (e.g. FBJUV000000,
FBJUV009000N). The previous migration only targeted a specific set of known
identifiers. This migration casts a wider net by resetting checked=False for
every BISAC subject whose identifier starts wit... | ThePalaceProject/circulation | alembic/versions/20260427_05a95c828149_reset_checked_for_all_fbjuv_subjects.py | .py | d732220b42a0638a | 7.45 | 7 |
"""Reset audience for works with mis-classified FB BISAC subjects
Works linked to BISAC subjects whose identifier begins with "FB" (e.g. FBJUV*, FBYA*)
were incorrectly assigned audience="Adult" before the scrubber fix landed. The
classify_unchecked_subjects repair task reclassified the subjects correctly, but a
struc... | ThePalaceProject/circulation | alembic/versions/20260512_d856ff4dbefb_reset_audience_for_works_with_mis_.py | .py | d72e32e27f8bc171 | 7.45 | 7 |
"""Add generate_playtime_report setting to Blackstone collections
Enable the generate_playtime_report flag for all OPDS 2.0 Import and
OPDS for Distributors collections whose data_source name begins with
"Blackstone" or "Unlimited". All other collections default to False
(the Pydantic field default), so no update is r... | ThePalaceProject/circulation | alembic/versions/20260528_a6c85605404c_add_generate_playtime_report_setting_to_.py | .py | bc7467038489740d | 7.45 | 7 |
"""Add server_default to lanes.size
Revision ID: dbeb42224c1b
Revises: a6c85605404c
Create Date: 2026-07-15 13:42:28.828886+00:00
"""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "dbeb42224c1b"
down_revision = "a6c85605404c"
branch_labels = None
depends_on = Non... | ThePalaceProject/circulation | alembic/versions/20260715_dbeb42224c1b_add_server_default_to_lanes_size.py | .py | 08e4ed49630c3766 | 7.45 | 7 |
"""Drop deprecated lanes.size columns
Revision ID: de6ae4bbf4a5
Revises: dbeb42224c1b
Create Date: 2026-07-15 14:08:25.692742+00:00
"""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision = "de6ae4bbf4a5"
down_revision = "dbeb42... | ThePalaceProject/circulation | alembic/versions/20260715_de6ae4bbf4a5_drop_deprecated_lanes_size_columns.py | .py | 6cb3c037a60757b8 | 7.45 | 7 |
'''
This script is used for generating developersIndia subreddit traffic stats
'''
import praw
import os
import json
from datetime import datetime, timedelta
from discord import get_discord_stats
from utils import *
client_id = os.environ["REDDIT_CLIENT_ID"]
client_secret = os.environ["REDDIT_CLIENT_SECRET"]
reddi... | developersIndia/metrics | main.py | .py | 0dd89f6c3e02671e | 7.5 | 9 |
import time
from datetime import datetime, timedelta
from sys import platform
def non_zero_padded_prefix():
"""Returns the platform specific prefix for the non-zero-padded numbers."""
prefix = "-"
if platform.startswith("win32"):
prefix = "#"
return prefix
def get_last_month():
now = da... | developersIndia/metrics | utils.py | .py | 8bcbd91a488b0a06 | 7.5 | 9 |
"""
need to download the files from endomondo
and store it in Workouts dir in running_page
"""
import json
import os
from collections import namedtuple
from datetime import datetime, timedelta
import polyline
from config import BASE_TIMEZONE, ENDOMONDO_FILE_DIR, JSON_FILE, SQL_FILE
from generator import Generator
fr... | yihong0618/run | run_page/endomondo_sync.py | .py | bcf25ef7f27976bc | 7.62 | 16 |
import traceback
from io import BytesIO
try:
from fit_tool.fit_file import FitFile
from fit_tool.fit_file_builder import FitFileBuilder
from fit_tool.profile.messages.device_info_message import DeviceInfoMessage
from fit_tool.profile.messages.record_message import RecordMessage
FIT_TOOL_AVAILABLE ... | yihong0618/run | run_page/garmin_device_adaptor.py | .py | 794cd4d3c1cea074 | 7.62 | 16 |
"""
Python 3 API wrapper for Garmin Connect to get your statistics.
Copy most code from https://github.com/cyberjunky/python-garminconnect
"""
import argparse
import asyncio
import datetime as dt
import logging
import os
import sys
import time
import traceback
import zipfile
from io import BytesIO
from lxml import etr... | yihong0618/run | run_page/garmin_sync.py | .py | 5cddefe1eab8e5d2 | 7.62 | 16 |
"""Draw a grid poster."""
# Copyright 2016-2019 Florian Pigorsch & Contributors. All rights reserved.
#
# Use of this source code is governed by a MIT-style
# license that can be found in the LICENSE file.
import svgwrite
from .exceptions import PosterError
from .poster import Poster
from .track import Track
from .t... | yihong0618/run | run_page/gpxtrackposter/grid_drawer.py | .py | 8197426e36167143 | 7.62 | 16 |
import math
import datetime
import svgwrite
from .exceptions import PosterError
from .tracks_drawer import TracksDrawer
from .utils import format_float
from .xy import XY
class MonthOfLifeDrawer(TracksDrawer):
"""Draw a Month of Life poster with 1000 months as circles"""
def __init__(self, the_poster):
... | yihong0618/run | run_page/gpxtrackposter/month_of_life_drawer.py | .py | 4f9b9750a6e52c5c | 7.62 | 16 |
"""Handle parsing of GPX files"""
# Copyright 2016-2019 Florian Pigorsch & Contributors. All rights reserved.
# 2019-now Yihong0618
#
# Use of this source code is governed by a MIT-style
# license that can be found in the LICENSE file.
import logging
import os
import sys
sys.path.append(os.path.join(os.path.dirname(... | yihong0618/run | run_page/gpxtrackposter/track_loader.py | .py | 485cc558755bdfc1 | 7.62 | 16 |
"""Contains the base class TracksDrawer, which other Drawers inherit from."""
# Copyright 2016-2019 Florian Pigorsch & Contributors. All rights reserved.
#
# Use of this source code is governed by a MIT-style
# license that can be found in the LICENSE file.
import argparse
import svgwrite
from .poster import Poster... | yihong0618/run | run_page/gpxtrackposter/tracks_drawer.py | .py | f0744aa1ebaf18d5 | 7.62 | 16 |
"""Assorted utility methods for use in creating posters."""
# Copyright 2016-2019 Florian Pigorsch & Contributors. All rights reserved.
#
# Use of this source code is governed by a MIT-style
# license that can be found in the LICENSE file.
import locale
import math
from datetime import datetime
from typing import Lis... | yihong0618/run | run_page/gpxtrackposter/utils.py | .py | 748583bbd1454198 | 7.62 | 16 |
"""Represent a range of numerical values"""
# Copyright 2016-2019 Florian Pigorsch & Contributors. All rights reserved.
#
# Use of this source code is governed by a MIT-style
# license that can be found in the LICENSE file.
class ValueRange:
"""Represent a range of numerical values.
Attributes:
_low... | yihong0618/run | run_page/gpxtrackposter/value_range.py | .py | c9e92e38b7914ae8 | 7.62 | 16 |
"""Represent x,y coords with properly overloaded operations."""
# Copyright 2016-2019 Florian Pigorsch & Contributors. All rights reserved.
#
# Use of this source code is governed by a MIT-style
# license that can be found in the LICENSE file.
from typing import Tuple, Union
class XY:
"""Represent x,y coords wi... | yihong0618/run | run_page/gpxtrackposter/xy.py | .py | 4c4125916401a828 | 7.62 | 16 |
"""Represent a range of years, with ability to update based on a track"""
# Copyright 2016-2019 Florian Pigorsch & Contributors. All rights reserved.
#
# Use of this source code is governed by a MIT-style
# license that can be found in the LICENSE file.
import datetime
import re
from typing import Optional
class Ye... | yihong0618/run | run_page/gpxtrackposter/year_range.py | .py | 8fdfb4c934c1f39a | 7.62 | 16 |
"""Draw a Year Summary poster similar to Cursor stats style."""
import datetime
from collections import defaultdict
import svgwrite
from .tracks_drawer import TracksDrawer
from .xy import XY
class YearSummaryDrawer(TracksDrawer):
"""Draw a Year Summary poster with monthly activity dots and statistics"""
d... | yihong0618/run | run_page/gpxtrackposter/year_summary_drawer.py | .py | cc184eb907de90d0 | 7.62 | 16 |
import argparse
import json
import logging
import os.path
import time
from collections import namedtuple
from datetime import datetime, timedelta, timezone
from xml.etree import ElementTree
import gpxpy.gpx
import httpx
from config import (
BASE_TIMEZONE,
GPX_FOLDER,
JSON_FILE,
OUTPUT_DIR,
SQL_FILE... | yihong0618/run | run_page/nike_sync.py | .py | a9c3e6a557f1403a | 7.62 | 16 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.