text stringlengths 185 73.3k | repo stringlengths 7 100 | path stringlengths 4 146 | language stringclasses 7
values | hash stringlengths 16 16 | score float64 7 8.5 | stars int64 0 237k |
|---|---|---|---|---|---|---|
from typing import Any, Dict
class ClientException(Exception):
"""
Base Exceptions for sending notifications that fail
"""
pass
class Client(object):
"""
Base client for sending notifications.
"""
pass
class Clients(object):
def __init__(self) -> None:
self.sms_client... | cds-snc/notification-api | app/clients/__init__.py | .py | f3e197c9cf1d6d0e | 7.89 | 59 |
from typing import Optional
from pyairtable import Api
class AirtableClient:
"""
A barebones Airtable client that provides quick access to the pyairtable API.
Follows the Flask extension init_app() pattern.
"""
def __init__(self):
self.api_key: Optional[str] = None
self.api: Opti... | cds-snc/notification-api | app/clients/airtable/airtable_client.py | .py | 88f2a30fd0a4e093 | 7.89 | 59 |
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from time import monotonic
import boto3
import botocore
from flask import current_app
from notifications_utils.recipients import InvalidEmailError
from notifications_utils.statsd_decor... | cds-snc/notification-api | app/clients/email/aws_ses.py | .py | 8294e4fd73fa4568 | 7.89 | 59 |
import base64
import json
import requests
from flask import current_app
from notifications_utils.timezones import convert_utc_to_local_timezone
class PerformancePlatformClient:
@property
def active(self):
return self._active
def init_app(self, app):
self._active = app.config.get("PERFORM... | cds-snc/notification-api | app/clients/performance_platform/performance_platform_client.py | .py | a1bd7c6f287c2196 | 7.89 | 59 |
r"""
We treat an s-expression as a binary tree, where leaf nodes are atoms and pairs
are nodes with two children. We then number the paths as follows:
1
/ \
/ \
/ \
/ \
/ \
/ \
2 3
/ \ ... | Chia-Network/clvm_tools | clvm_tools/NodePath.py | .py | ba2e02838897f34a | 7.86 | 51 |
from clvm_tools.binutils import assemble
from stages.stage_0 import run_program
from .pattern_match import match
# CURRY_OBJ_CODE contains compiled code from the output of the following:
# run -i clvm_runtime '(mod (F . args) (include curry.clvm) (curry_args F args))'
# the text below has been hand-optimized to re... | Chia-Network/clvm_tools | clvm_tools/curry.py | .py | 5f55f3df1f34488f | 7.86 | 51 |
ATOM_MATCH = b"$"
SEXP_MATCH = b":"
def unify_bindings(bindings, new_key, new_value):
"""
Try to add a new binding to the list, rejecting it if it conflicts
with an existing binding.
"""
new_key = bytes(new_key).decode()
if new_key in bindings:
if bindings[new_key] != new_value:
... | Chia-Network/clvm_tools | clvm_tools/pattern_match.py | .py | 7f1d49bc03c922c8 | 7.86 | 51 |
from clvm import KEYWORD_TO_ATOM
from clvm_tools.NodePath import TOP
QUOTE_ATOM = KEYWORD_TO_ATOM["q"]
APPLY_ATOM = KEYWORD_TO_ATOM["a"]
def quote(sexp):
"""quoted list as a python list, not as an sexp"""
return (QUOTE_ATOM, sexp)
def eval(prog, args):
return prog.to([APPLY_ATOM, prog, args])
def ru... | Chia-Network/clvm_tools | stages/stage_2/helpers.py | .py | 289e049c10112afb | 7.86 | 51 |
from clvm import KEYWORD_TO_ATOM
from clvm_tools import binutils
from clvm_tools.debug import build_symbol_dump
from clvm_tools.NodePath import LEFT, RIGHT, TOP
from .helpers import eval, quote
from .optimize import optimize_sexp
QUOTE_ATOM = KEYWORD_TO_ATOM["q"]
CONS_ATOM = KEYWORD_TO_ATOM["c"]
MAIN_NAME = b""
... | Chia-Network/clvm_tools | stages/stage_2/mod.py | .py | 4dfb07a4a0cb64d9 | 7.86 | 51 |
from clvm import KEYWORD_TO_ATOM
from clvm_tools.pattern_match import match
from clvm_tools.binutils import assemble
from clvm_tools.NodePath import NodePath, LEFT, RIGHT
from .helpers import quote
QUOTE_ATOM = KEYWORD_TO_ATOM["q"]
APPLY_ATOM = KEYWORD_TO_ATOM["a"]
FIRST_ATOM = KEYWORD_TO_ATOM["f"]
REST_ATOM = KEYWO... | Chia-Network/clvm_tools | stages/stage_2/optimize.py | .py | b4ab146ea1cde274 | 7.86 | 51 |
"""
These tests check that the `clvmc` utility methods
continue to work with the `include` keyword, and produce
the expected output. It's not intended to be a complete
test of the compiler, just the `clvmc` api.
"""
from tempfile import TemporaryDirectory
from clvm_tools import clvmc
INCLUDE_CODE = "((defconstant F... | Chia-Network/clvm_tools | tests/clvmc_test.py | .py | e2a8c755e8481870 | 8.36 | 51 |
import io
import os
import shlex
import sys
import unittest
import importlib_metadata
# If the REPAIR environment variable is set, any tests failing due to
# wrong output will be corrected. Be sure to do a "git diff" to validate that
# you're getting changes you expect.
REPAIR = os.getenv("REPAIR", 0)
def get_test... | Chia-Network/clvm_tools | tests/cmds_test.py | .py | 23edf1c8e19f1d63 | 7.36 | 51 |
# -*- coding: utf-8 -*-
"""
Created on 2020.03.02
@author: MiniUFO
Copyright 2018. All rights reserved. Use is subject to license terms.
"""
import numpy as np
import xarray as xr
from xgrads import open_CtlDataset, open_mfdataset
def test_template1():
dset1 = open_CtlDataset('./ctls/test8.ctl')
... | miniufo/xgrads | tests/test_openDataset.py | .py | 0e89bae7f5dfffb2 | 8.45 | 79 |
# -*- coding: utf-8 -*-
"""
Created on 2022.05.06
@author: MiniUFO
Copyright 2018. All rights reserved. Use is subject to license terms.
"""
#%%
import numpy as np
from pyproj import CRS
from xgrads import open_CtlDataset, get_data_projection,\
get_coordinates_from_PDEF
def test_llc_proj_wrf... | miniufo/xgrads | tests/test_proj.py | .py | d995b4ea298e3d84 | 7.45 | 79 |
# -*- coding: utf-8 -*-
"""
Created on 2023.06.11
@author: MiniUFO
Copyright 2018. All rights reserved. Use is subject to license terms.
"""
#%% test objective analysis method
import numpy as np
import xarray as xr
from xgrads import oacressman
def test_oacressman():
ds = xr.open_dataset('./ctls/st... | miniufo/xgrads | tests/test_utils.py | .py | 5a06f1bf94250730 | 7.45 | 79 |
# pyright: reportIncompatibleVariableOverride=false
# Disable this check because of multiple non-dangerous violations (SCHEMA variables,
# BaseSchema.Meta class)
from dataclasses import dataclass
from enum import Enum
from typing import (
TYPE_CHECKING,
Any,
ClassVar,
Dict,
Generic,
List,
Op... | GitGuardian/py-gitguardian | pygitguardian/models_utils.py | .py | a4370d062e1990c6 | 7.97 | 88 |
import tarfile
from io import BytesIO
from unittest import mock
import pytest
from pygitguardian.client import ContentTooLarge, _create_tar
def test_create_tar(tmp_path):
"""
GIVEN a list of filenames, representing paths relative to the tmp directory
WHEN the _create_tar method is called
THEN a byte... | GitGuardian/py-gitguardian | tests/test_utils.py | .py | 42e883db36e881f2 | 8.47 | 88 |
from pygitguardian.models import Invitation, Source, Team, TeamsParameters
from pygitguardian.models_utils import CursorPaginatedResponse
from .conftest import create_client
def get_source() -> Source:
"""
Return the first source available in the account,
not all accounts have a source so testing from sc... | GitGuardian/py-gitguardian | tests/utils.py | .py | 59dc970f1ac601ae | 7.47 | 88 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Drive the upgrade-path CI job for one scenario: install each version in
the given order (from PyPI, or from the checked-out working tree for
"main"), running upgrade_path_fetch.py after each install. All steps share
the same interpreter/site-packages and the same curren... | SciQLop/speasy | .github/scripts/upgrade_path_driver.py | .py | 5035ab524b471326 | 7.79 | 37 |
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Fetch a few small, known-good products through whatever Speasy version is
currently installed. Run once per version step (see upgrade_path_driver.py)
within one persistent environment: AMDA's requested window grows with --step,
so a later step necessarily reuses at leas... | SciQLop/speasy | .github/scripts/upgrade_path_fetch.py | .py | bd7709645d67b152 | 7.79 | 37 |
"""Generates the UiowaEphTool body/coordinate-systems table at build time.
Unlike CDPP 3DView, UiowaEphTool has no server endpoint listing its bodies or coordinate
systems -- that structure is entirely hardcoded in speasy.data_providers.uiowa_eph_tool's
dictionaries. Introspecting the built inventory here (rather than... | SciQLop/speasy | docs/_generate_uiowaephtool_table.py | .py | 27e6ac8303235f2e | 7.79 | 37 |
"""Shared helpers for the build-time generated-table Sphinx extensions."""
from datetime import datetime, timezone
def utc_now_str():
return datetime.now(tz=timezone.utc).strftime("%Y-%m-%d %H:%M UTC")
def escape_rst(text):
return str(text).replace("`", "'").replace("*", "").strip()
def render_list_table(... | SciQLop/speasy | docs/_rst_gen_utils.py | .py | 3dbb3366ee71be3e | 7.79 | 37 |
# -*- coding: utf-8 -*-
"""
.. testsetup:: *
import speasy as spz
"""
import logging
from importlib import metadata as _metadata
log = logging.getLogger(__name__)
__author__ = """Alexis Jeandet"""
__email__ = 'alexis.jeandet@member.fsf.org'
try:
__version__ = _metadata.version("speasy")
except _metadata.Pac... | SciQLop/speasy | speasy/__init__.py | .py | f4326818c97a1649 | 7.79 | 37 |
"""
.. testsetup:: *
from speasy.core import *
import numpy as np
"""
import os
import warnings
from tqdm.auto import tqdm
from .time import make_utc_datetime, make_utc_datetime64, datetime64_to_epoch, epoch_to_datetime64, EnsureUTCDateTime
from .typing import AnyDateTimeType, all_of_type, is_collection, listi... | SciQLop/speasy | speasy/core/__init__.py | .py | 11bac9e403c6b339 | 7.79 | 37 |
"""
.. testsetup:: *
from speasy.core.algorithms import *
import numpy as np
"""
import random
from typing import Any, Dict, Callable
from functools import wraps
"""
The rationale behind the following function is to randomize the order of execution so we minimize the requests collisions and maximize the throug... | SciQLop/speasy | speasy/core/algorithms.py | .py | 4a99e757441f39fa | 7.79 | 37 |
from typing import Union, Optional
import re
from .cache import Cache, CacheItem, migration_backups, delete_migration_backups
from ._function_cache import CacheCall
from ._providers_caches import CACHE_ALLOWED_KWARGS, Cacheable, UnversionedProviderCache
from ._instance import _cache
from ._request_locker import request... | SciQLop/speasy | speasy/core/cache/__init__.py | .py | 32b921178fdcb772 | 7.79 | 37 |
from contextlib import contextmanager
from datetime import datetime, timezone
from time import sleep
from typing import Optional
from ._instance import _cache
from ..platform import is_running_on_wasm
if is_running_on_wasm():
get_native_id = lambda: 0
else:
from threading import get_native_id
PENDING_REQUES... | SciQLop/speasy | speasy/core/cache/_request_locker.py | .py | 96569b8fcba15f43 | 7.79 | 37 |
import os
import re
import shutil
import logging
from contextlib import contextmanager
from datetime import datetime, timedelta, timezone
from pathlib import Path
from typing import List, Optional, Union
try:
import pysciqlop_cache as sc
except ImportError: # pragma: no cover - platform-specific (WASM has no whee... | SciQLop/speasy | speasy/core/cache/cache.py | .py | f2fc47ef347c40e6 | 7.79 | 37 |
from speasy.core.codecs.codecs_registry import register_codec
from ..codec import HapiBaseCodec
from .writer import save_hapi_binary
from .reader import load_hapi_binary
@register_codec
class HapiBinary(HapiBaseCodec):
"""Codec for HAPI Binary files"""
def __init__(self):
super().__init__(load_hapi_b... | SciQLop/speasy | speasy/core/codecs/bundled_codecs/hapi/binary/codec.py | .py | 48bb6a40705f2eda | 7.29 | 37 |
import io
import json
from typing import IO, Optional, Union
import numpy as np
from speasy.core.codecs.bundled_codecs.hapi.hapi_file import HapiFile
from speasy.core.codecs.bundled_codecs.hapi.writer import save_hapi
from speasy.core.codecs.codec_interface import Buffer
def _base_np_type(p):
"""
Returns the... | SciQLop/speasy | speasy/core/codecs/bundled_codecs/hapi/binary/writer.py | .py | f102be1df3a34f26 | 7.79 | 37 |
from typing import Optional
from .codec_interface import CodecInterface
from speasy.config import core as cfg
import logging
import os
import appdirs
log = logging.getLogger(__name__)
__USER_CODECS_DIR__ = f'{appdirs.user_data_dir("speasy", "LPP")}/codecs'
__CODECS__ = {}
"""Speasy codecs registry
This module prov... | SciQLop/speasy | speasy/core/codecs/codecs_registry.py | .py | 7e7b9a5305bfc010 | 7.79 | 37 |
# -*- coding: utf-8
"""
This module is designed to hold the definition of the central ThermalNetwork
object and its components.
This file is part of project dhnx (). It's copyrighted
by the contributors recorded in the version control history of the file,
available from its original location:
SPDX-License-Identifier... | oemof/DHNx | src/dhnx/network.py | .py | 7182d522732e32a6 | 7.84 | 46 |
# -*- coding: utf-8
"""
This module is designed to hold functions for visualization.
This file is part of project dhnx (). It's copyrighted
by the contributors recorded in the version control history of the file,
available from its original location:
SPDX-License-Identifier: MIT
"""
import logging
from collections ... | oemof/DHNx | src/dhnx/plotting.py | .py | e47b665c85e27815 | 7.84 | 46 |
# -*- coding: utf-8 -*-
"""
This is a collection of helper functions that can be used within the tests.
This file is part of project DHNx (). It's copyrighted
by the contributors recorded in the version control history of the file,
available from its original location.
SPDX-License-Identifier: MIT
"""
import os
im... | oemof/DHNx | tests/helpers.py | .py | ee90eb68307d87f6 | 8.34 | 46 |
# -*- coding: utf-8 -*-
"""
These tests test if proper errors are raised when the data is not consistent,
of the wrong type or not all required data are given.
This file is part of project oemof (). It's copyrighted
by the contributors recorded in the version control history of the file,
available from its original lo... | oemof/DHNx | tests/test_errors.py | .py | 8d63134b79c6a842 | 8.34 | 46 |
# -*- coding: utf-8 -*-
"""
These tests test little examples for the use of the library.
This file is part of project oemof (). It's copyrighted
by the contributors recorded in the version control history of the file,
available from its original location oemof/oemof/tools/helpers.py
SPDX-License-Identifier: MIT
"""
... | oemof/DHNx | tests/test_integration.py | .py | 2d61f98f3ff40678 | 7.34 | 46 |
# -*- coding: utf-8 -*-
"""
Test the complete investment optimization workflow of DHNx.
This file is part of project oemof (). It's copyrighted
by the contributors recorded in the version control history of the file,
available from its original location oemof/oemof/tools/helpers.py
SPDX-License-Identifier: MIT
"""
i... | oemof/DHNx | tests/test_optimization.py | .py | f2bb76a7390b946a | 7.34 | 46 |
# -*- coding: utf-8 -*-
"""
These tests test little examples for the use of the library.
This file is part of project oemof (). It's copyrighted
by the contributors recorded in the version control history of the file,
available from its original location oemof/oemof/tools/helpers.py
SPDX-License-Identifier: MIT
"""
... | oemof/DHNx | tests/test_units.py | .py | 172f6af6af75b6f1 | 8.34 | 46 |
# Copyright 2014: Mirantis Inc.
# All Rights Reserved.
#
# 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 b... | openstack/rally-openstack | rally-jobs/plugins/fake_plugin.py | .py | 4f7ad0c735dfeaf1 | 7.8 | 39 |
# Copyright 2016: Mirantis Inc.
# All Rights Reserved.
#
# 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 b... | openstack/rally-openstack | rally-jobs/plugins/rally_profile.py | .py | eec144c9bbc01b4e | 7.8 | 39 |
# All Rights Reserved.
#
# 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... | openstack/rally-openstack | rally_openstack/_compat.py | .py | 52b765c35b2c7dbc | 7.8 | 39 |
# All Rights Reserved.
#
# 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... | openstack/rally-openstack | rally_openstack/common/clients/base.py | .py | 52675a1c188d997a | 7.8 | 39 |
# Copyright 2013: Mirantis Inc.
# All Rights Reserved.
#
# 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 b... | openstack/rally-openstack | rally_openstack/common/consts.py | .py | 93d93e9f3753ee7b | 7.8 | 39 |
# Copyright 2017: Mirantis Inc.
# All Rights Reserved.
#
# 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 b... | openstack/rally-openstack | rally_openstack/common/credential.py | .py | e0874bd909b8a658 | 7.8 | 39 |
#
# 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, software
# ... | openstack/rally-openstack | rally_openstack/common/service.py | .py | 585a75c592720575 | 7.8 | 39 |
#
# 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, software
# ... | openstack/rally-openstack | rally_openstack/common/services/heat/main.py | .py | 63afe97782cd643c | 7.8 | 39 |
# SPDX-FileCopyrightText: 2023 TU Wien.
# SPDX-License-Identifier: MIT
"""Access request UI views."""
from flask import abort, current_app, g, redirect, render_template, request
from invenio_access.permissions import system_identity
from invenio_i18n import lazy_gettext as _
from invenio_mail.tasks import send_email
... | inveniosoftware/invenio-rdm-records | invenio_rdm_records/access_requests_ui/views.py | .py | 12c5fd2f74d9b85b | 7.69 | 23 |
# SPDX-FileCopyrightText: 2021 TU Wien.
# SPDX-License-Identifier: MIT
"""Create table for secret links."""
import sqlalchemy as sa
import sqlalchemy_utils
from alembic import op
# revision identifiers, used by Alembic.
revision = "0cf260eb8e97"
down_revision = "4a15e8671f4d"
branch_labels = ()
depends_on = None
d... | inveniosoftware/invenio-rdm-records | invenio_rdm_records/alembic/0cf260eb8e97_create_table_for_secret_links.py | .py | e92485dd36f4eed3 | 7.69 | 23 |
# SPDX-FileCopyrightText: 2025 TU Wien.
# SPDX-License-Identifier: MIT
"""Drop ``RDMRecordQuota.user_id`` unique constraint."""
from alembic import op
# revision identifiers, used by Alembic.
revision = "1746626978"
down_revision = "ff9bec971d30"
branch_labels = ()
depends_on = [
# invenio_collections/alembic/42... | inveniosoftware/invenio-rdm-records | invenio_rdm_records/alembic/1746626978_drop_rdmrecordquota_user_id_unique_.py | .py | 9c73745d25e2d113 | 7.69 | 23 |
# SPDX-FileCopyrightText: 2016-2018 CERN.
# SPDX-FileCopyrightText: 2026 CESNET z.s.p.o.
# SPDX-License-Identifier: MIT
"""Merge PIDRelations tables removal to single head."""
# revision identifiers, used by Alembic.
revision = "1777274324"
down_revision = ("912251a56a49", "a3957490361d")
branch_labels = ()
depends_o... | inveniosoftware/invenio-rdm-records | invenio_rdm_records/alembic/1777274324_merge_pidrelations_tables_removal.py | .py | d0f41b8ab33975a1 | 7.19 | 23 |
# SPDX-FileCopyrightText: 2026 CERN.
# SPDX-License-Identifier: MIT
"""Create record_id index in rdm_parents_community."""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "1780576627"
down_revision = "1777278349"
branch_labels = ()
depends_on = None
def upgrade():... | inveniosoftware/invenio-rdm-records | invenio_rdm_records/alembic/1780576627_create_record_id_index_in_rdm_parents_community.py | .py | 4366717e575b3cfc | 7.69 | 23 |
# SPDX-FileCopyrightText: 2023 TU Wien.
# SPDX-License-Identifier: MIT
"""Add deletion status to RDMRecords."""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "2186256e8d9b"
down_revision = "ff860d48fb4b"
branch_labels = ()
depends_on = None
def _get_default_dele... | inveniosoftware/invenio-rdm-records | invenio_rdm_records/alembic/2186256e8d9b_add_deletion_status_to_rdmrecords.py | .py | d7dd633e936e844d | 7.69 | 23 |
# SPDX-FileCopyrightText: 2021 CERN.
# SPDX-License-Identifier: MIT
"""Create parent record table."""
import sqlalchemy as sa
from alembic import op
from sqlalchemy.dialects import mysql, postgresql
from sqlalchemy_utils import JSONType, UUIDType
# revision identifiers, used by Alembic.
revision = "88d1463de5c0"
dow... | inveniosoftware/invenio-rdm-records | invenio_rdm_records/alembic/88d1463de5c0_create_parent_record_table.py | .py | e3d396cb63a2dd5d | 7.69 | 23 |
# SPDX-FileCopyrightText: 2021 CERN.
# SPDX-License-Identifier: MIT
"""Migrate secret links permission levels."""
from alembic import op
# revision identifiers, used by Alembic.
revision = "8ed1a438601c"
down_revision = "0cf260eb8e97"
branch_labels = ()
depends_on = None
def upgrade():
"""Upgrade database."""
... | inveniosoftware/invenio-rdm-records | invenio_rdm_records/alembic/8ed1a438601c_migrate_secret_links.py | .py | 4986e871b1f7fc05 | 7.69 | 23 |
# SPDX-FileCopyrightText: 2021 CERN.
# SPDX-License-Identifier: MIT
"""Create records/communities M2M table."""
import sqlalchemy as sa
from alembic import op
from sqlalchemy_utils import UUIDType
# revision identifiers, used by Alembic.
revision = "9e0ac518b9df"
down_revision = ("8ed1a438601c", "88d1463de5c0")
bran... | inveniosoftware/invenio-rdm-records | invenio_rdm_records/alembic/9e0ac518b9df_create_records_communities_m2m_table.py | .py | cc6c593e260d6229 | 7.69 | 23 |
# SPDX-FileCopyrightText: 2021 TU Wien.
# SPDX-License-Identifier: MIT
"""Remove PIDRelations tables."""
from alembic import op
from sqlalchemy.engine.reflection import Inspector
# revision identifiers, used by Alembic.
revision = "a3957490361d"
down_revision = "88d1463de5c0"
branch_labels = ()
depends_on = None
d... | inveniosoftware/invenio-rdm-records | invenio_rdm_records/alembic/a3957490361d_remove_pidrelations_tables.py | .py | c1f7db3b6c473961 | 7.69 | 23 |
# SPDX-FileCopyrightText: 2023 TU Wien.
# SPDX-License-Identifier: MIT
"""Add origin and description to secret links."""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "a6bfa06b1a6d"
down_revision = "9e0ac518b9df"
branch_labels = ()
depends_on = None
def upgrade(... | inveniosoftware/invenio-rdm-records | invenio_rdm_records/alembic/a6bfa06b1a6d_add_origin_and_description_to_secret_links.py | .py | 0914e0e7b2137c1c | 7.69 | 23 |
# SPDX-FileCopyrightText: 2021 TU Wien.
# SPDX-License-Identifier: MIT
"""Create RDM-Records branch."""
# revision identifiers, used by Alembic.
revision = "b822ba22c688"
down_revision = None
branch_labels = ("invenio_rdm_records",)
depends_on = "dbdbc1b19cf2"
def upgrade():
"""Upgrade database."""
pass
d... | inveniosoftware/invenio-rdm-records | invenio_rdm_records/alembic/b822ba22c688_create_rdm_records_branch.py | .py | 54a85beb13441ab5 | 7.19 | 23 |
# SPDX-FileCopyrightText: 2023 TU Wien.
# SPDX-License-Identifier: MIT
"""Create access request tokens table."""
import sqlalchemy as sa
import sqlalchemy_utils as utils
from alembic import op
# revision identifiers, used by Alembic.
revision = "cfcb8cb78708"
down_revision = "a6bfa06b1a6d"
branch_labels = ()
depends... | inveniosoftware/invenio-rdm-records | invenio_rdm_records/alembic/cfcb8cb78708_create_access_request_tokens_table.py | .py | 66d3222aaf2b7e1d | 7.69 | 23 |
# SPDX-FileCopyrightText: 2016-2018 CERN.
# SPDX-License-Identifier: MIT
"""Create record and user quota tables."""
import sqlalchemy as sa
from alembic import op
from sqlalchemy_utils.types import UUIDType
# revision identifiers, used by Alembic.
revision = "faf0cefa79a0"
down_revision = "ffd725001655"
branch_label... | inveniosoftware/invenio-rdm-records | invenio_rdm_records/alembic/faf0cefa79a0_create_record_quota_tables.py | .py | d8878896553dd58b | 7.69 | 23 |
# SPDX-FileCopyrightText: 2016-2018 CERN.
# SPDX-License-Identifier: MIT
"""Add field to record consent to share personal data for access request."""
import sqlalchemy as sa
from alembic import op
# revision identifiers, used by Alembic.
revision = "ffd725001655"
down_revision = "a2a6819f14f1"
branch_labels = ()
dep... | inveniosoftware/invenio-rdm-records | invenio_rdm_records/alembic/ffd725001655_add_field_to_record_consent_to_share_.py | .py | ec381565e18bd271 | 7.69 | 23 |
# Copyright 2024 Google LLC
#
# 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
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, ... | datacommonsorg/schema | test/url_checker.py | .py | 58c075380966a179 | 8.17 | 21 |
from django.apps import AppConfig
class DjangoLogicConfig(AppConfig):
"""The one installed app: ``INSTALLED_APPS = ['django_logic']``.
The label stays ``django_logic_background``: the label is the address
of the live ``TransitionMessage`` table, of its rows in
``django_migrations`` and of its content... | Borderless360/django-logic | django_logic/apps.py | .py | 66509bbdfd77ce4c | 7.92 | 67 |
from django.apps import AppConfig
from django.core.exceptions import ImproperlyConfigured
def validate_on_ready() -> None:
"""The app's boot gate — fail fast on a misconfigured settings block."""
from django_logic import conf
mode = conf.background_execution()
# Surface value errors now rather than o... | Borderless360/django-logic | django_logic/background/apps.py | .py | 1efa6519e793d1b7 | 7.92 | 67 |
from django_logic.exceptions import TransitionTemporarilyUnavailable
class PermanentFailure(Exception):
"""Raise from a background side-effect to say: another attempt gets the
same answer, so do not retry.
The worker then takes the terminal path on this first attempt — it
writes ``failed_state`` (whe... | Borderless360/django-logic | django_logic/background/exceptions.py | .py | 98998065f4703b48 | 7.92 | 67 |
"""The safety nets: the stuck finalizer and the cleanup sweep.
Plain functions. The pull worker loop runs them on a fixed cadence
(``pull.run_worker``), so no scheduler has to be configured for them.
Sync-mode tests call them directly, or through ``retry_pending()`` for
the retry pass.
What each one owns:
* :func:`r... | Borderless360/django-logic | django_logic/background/safety_nets.py | .py | ececd56b8194f599 | 7.92 | 67 |
"""kwargs serialization for persisting transition arguments.
``TransitionMessage.kwargs`` is a JSONField, so everything we write must
be JSON-serializable. Values that JSON cannot represent natively are
stored with a self-describing type tag and restored to their original
Python type in the worker, so a side-effect re... | Borderless360/django-logic | django_logic/background/serializers.py | .py | be6110eccaa14a99 | 7.92 | 67 |
"""BackgroundTransition — durable, queue-routed background work.
``change_state`` enqueues the work (same steps in Pull and Sync mode):
* validate conditions + permissions,
* acquire the state lock for the critical section and revalidate the
persisted state under it,
* atomically write ``in_progress_state`` (when d... | Borderless360/django-logic | django_logic/background/transitions.py | .py | a3b968a392f73da1 | 7.92 | 67 |
"""Django system checks for django-logic.
Hook-signature validation raises at bind time since 1.0.0, so the old
re-report check is retired: a machine with a bad hook never binds.
"""
from django.core import checks
from django_logic.process import ProcessManager
def _process_tree_has_background_transition(process_cl... | Borderless360/django-logic | django_logic/checks.py | .py | 95e6ef233d3fa5d5 | 7.92 | 67 |
"""Command objects wrapped around transition hook lists.
Every hook slot on a ``Transition`` — conditions, permissions,
side-effects, callbacks, failure callbacks — is represented by a
``BaseCommand`` subclass that owns a list of callables and knows how to
run them.
"""
import logging
from django.db import DEFAULT_DB... | Borderless360/django-logic | django_logic/commands.py | .py | a3d4f55decb5f359 | 7.92 | 67 |
"""Every ``DJANGO_LOGIC`` settings reader, and boot-time validation.
One module owns every key: one reader per key, one number validator,
and one place where each default is written down.
Validation runs from one boot gate: ``DjangoLogicConfig.ready`` calls
``validate_on_ready``, which validates every key in every mo... | Borderless360/django-logic | django_logic/conf.py | .py | b9904c81e9072a45 | 7.92 | 67 |
class TransitionNotAllowed(Exception):
"""When the process resolver raises this, it sets ``current_state``
and ``available_actions`` on the instance so an API layer does not
have to reconstruct them. Both stay ``None`` on other raise sites.
"""
current_state = None
available_actions = None
cl... | Borderless360/django-logic | django_logic/exceptions.py | .py | d893cfd2508859eb | 7.92 | 67 |
from django.db import migrations, models
def normalize_uncompleted_proxy_rows(apps_registry, schema_editor):
"""Rewrite uncompleted rows keyed on a proxy's name to the concrete key.
The key columns now name the concrete model, and the recording proxy
class moves to ``proxy_model_label``. Rows written bef... | Borderless360/django-logic | django_logic/migrations/0010_proxy_model_label.py | .py | ea67b1278dc01d35 | 7.92 | 67 |
from hashlib import blake2b
from uuid import uuid4
from django.core.cache import cache
from django.db import DEFAULT_DB_ALIAS
from django_logic.conf import lock_timeout as _get_lock_timeout
class State:
def __init__(self, instance, field_name: str, process_name=None):
self.instance = instance
se... | Borderless360/django-logic | django_logic/state.py | .py | 3faf891c6d75682e | 7.92 | 67 |
"""Idempotency assertion for background side-effects.
Background side-effects re-run FROM SCRATCH on every retry (a crashed
worker's released row, a failed row claimed again after the retry wait),
so every side-effect
must be idempotent: a second application must change nothing observable.
Consumers hand-rolled "call ... | Borderless360/django-logic | django_logic/testing/idempotency.py | .py | 903b5e8e44703e2f | 8.42 | 67 |
"""Stand up an uncompleted ``TransitionMessage`` row for a test.
Tests that pin behaviour around the one-uncompleted-row gate need a row
whose fields agree with the engine's keying. Hand-rolled rows get one of
the eight fields wrong and pin nothing, so this helper writes them all
from the instance itself.
"""
from __f... | Borderless360/django-logic | django_logic/testing/rows.py | .py | 737107713fd1c1a1 | 7.42 | 67 |
"""Synchronous execution helpers — run background transitions and their
retries inline, without Celery.
Built on the library's own ``sync_execution()`` context manager (which forces
the worker to run in-process) so tests exercise the *real* enqueue + worker code,
not a reimplementation.
"""
from __future__ import anno... | Borderless360/django-logic | django_logic/testing/runner.py | .py | db43be9539540411 | 8.42 | 67 |
"""State capture & restore — close the loop between production bugs and tests.
``snapshot(instance)`` serialises an instance (its concrete fields, current
state, and the related ``TransitionMessage`` if any) to a plain
JSON-able dict. ``from_snapshot(data)`` rebuilds that instance — and restores
the ``TransitionMessag... | Borderless360/django-logic | django_logic/testing/snapshot.py | .py | 7836e85d555d2dc9 | 8.42 | 67 |
"""Side-effect / callback execution tracking and failure injection.
We do not mock. During a tracked transition we temporarily replace the
callables on the transition's hook bundles (``side_effects``, ``callbacks``,
``failure_callbacks``) with thin wrappers that:
* record the hook's ``__name__`` *after* it runs succe... | Borderless360/django-logic | django_logic/testing/tracking.py | .py | ef8429d064db810f | 8.42 | 67 |
"""Transition — a single state-machine edge.
A ``Transition`` moves an instance from one of its source states to its
target state, running side-effects on success and either callbacks or
failure callbacks on completion. Everything happens synchronously, in
the caller's call frame — validate, lock, run, write the targe... | Borderless360/django-logic | django_logic/transition.py | .py | fa3c167f3659a11d | 7.92 | 67 |
"""Test-suite helpers.
``dl_settings`` exists because ~26 test modules used to hand-copy the whole
six-key ``DJANGO_LOGIC`` dict just to change one key, so adding a setting meant
editing all of them.
"""
def dl_settings(**overrides):
"""The active ``DJANGO_LOGIC`` settings with ``overrides`` applied.
Use wi... | Borderless360/django-logic | tests/__init__.py | .py | 5d8670d81a66bf76 | 7.42 | 67 |
from django.apps import AppConfig
from django_logic import ProcessManager
class BackgroundTestsConfig(AppConfig):
name = 'tests.background'
label = 'bg_tests'
default_auto_field = 'django.db.models.BigAutoField'
def ready(self):
# The single binding site for this app. ready() runs after ever... | Borderless360/django-logic | tests/background/apps.py | .py | d76966b05c3ba11f | 7.42 | 67 |
"""Support for first generation Bosch smart home thermostats: Nefit Easy, Junkers CT100 etc."""
from __future__ import annotations
import asyncio
from datetime import timedelta
import logging
import re
from typing import Any
from aionefit import NefitCore
from homeassistant.config_entries import ConfigEntry
from hom... | ksya/ha-nefiteasy | custom_components/nefiteasy/__init__.py | .py | 1940211738c1b2df | 7.98 | 92 |
"""Support for Bosch home thermostats."""
from __future__ import annotations
import asyncio
import logging
from types import MappingProxyType
from typing import Any
from homeassistant.components.climate import ClimateEntity
from homeassistant.components.climate.const import (
ClimateEntityFeature,
HVACAction... | ksya/ha-nefiteasy | custom_components/nefiteasy/climate.py | .py | c182a9dd94c8118f | 7.98 | 92 |
"""Config flow for Nefit Easy Bosch Thermostat integration."""
from __future__ import annotations
import asyncio
import logging
from typing import Any
from aionefit import NefitCore
from homeassistant import config_entries, core, exceptions
from homeassistant.data_entry_flow import FlowResult
from homeassistant.help... | ksya/ha-nefiteasy | custom_components/nefiteasy/config_flow.py | .py | afda6c739cfa7f0b | 7.98 | 92 |
"""Support for Bosch home thermostats."""
from __future__ import annotations
import logging
from types import MappingProxyType
from typing import Any
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from . import NefitEasy
from .const import CONF_NAME, CONF_SERIAL, DOMAIN
from .models import N... | ksya/ha-nefiteasy | custom_components/nefiteasy/nefit_entity.py | .py | edf1491fd43bc3de | 7.98 | 92 |
"""Support for Bosch home thermostats."""
from __future__ import annotations
import logging
from types import MappingProxyType
from typing import Any
from homeassistant.components.number import NumberEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeass... | ksya/ha-nefiteasy | custom_components/nefiteasy/number.py | .py | b0500ad4c5d865da | 7.98 | 92 |
"""Support for Bosch home thermostats."""
from __future__ import annotations
import logging
from types import MappingProxyType
from typing import Any
from homeassistant.components.select import SelectEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeass... | ksya/ha-nefiteasy | custom_components/nefiteasy/select.py | .py | 79ef571a27f370a5 | 7.98 | 92 |
"""Support for Bosch home thermostats."""
from __future__ import annotations
from contextlib import suppress
import logging
from homeassistant.components.sensor import SensorDeviceClass, SensorEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.... | ksya/ha-nefiteasy | custom_components/nefiteasy/sensor.py | .py | dca593aaadc78e15 | 7.98 | 92 |
"""Support for Bosch home thermostats."""
from __future__ import annotations
import logging
from types import MappingProxyType
from typing import Any
from homeassistant.components.switch import SwitchEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeass... | ksya/ha-nefiteasy | custom_components/nefiteasy/switch.py | .py | 95c772f8e585b06c | 7.98 | 92 |
"""Test configuration of the nefiteasy integration."""
import asyncio
import json
from unittest.mock import MagicMock, patch
from homeassistant.helpers import entity_registry as er
import pytest
from pytest_homeassistant_custom_component.common import MockConfigEntry, load_fixture
from custom_components.nefiteasy.co... | ksya/ha-nefiteasy | tests/conftest.py | .py | ea3a06ea084dcea7 | 7.48 | 92 |
from errbot import botcmd
from errbot import BotPlugin
class ExampleCards(BotPlugin):
@botcmd
def example_card(self, msg, _):
# Add your card definition into the message.card attribute
#
# Use https://adaptivecards.io/designer/ to build your card
#
# Ensure to include a... | marksull/err-backend-cisco-webex-teams | plugins/err-example-cards/examplecards.py | .py | eef141160e40a7cb | 7.7 | 24 |
from pathlib import Path
from errbot import botcmd
from errbot import BotPlugin
class ExampleLarge(BotPlugin):
@staticmethod
def fenced_code_block(message):
"""
Wrap a message in a Fenced Code Block
"""
return f"```\n{message}\n```\n"
@botcmd
def example_large_respons... | marksull/err-backend-cisco-webex-teams | plugins/err-example-large/examplelarge.py | .py | e779923a946a2611 | 7.7 | 24 |
from errbot import BotPlugin
from errbot import cmdfilter
class ExampleNotFound(BotPlugin):
@cmdfilter(catch_unprocessed=True)
def cnf_filter(self, msg, cmd, args, dry_run, emptycmd=False):
"""
To avoid the core plugin CommandNotFoundFilter from generating a response
when a command is... | marksull/err-backend-cisco-webex-teams | plugins/err-example-not-found/examplenotfound.py | .py | 7e99059b2abb86a9 | 7.7 | 24 |
from errbot import BotPlugin, botcmd
from pathlib import Path
class ExampleSendCallback(BotPlugin):
@botcmd
def simple_message_with_callback(self, msg, _):
yield "This is a Simple Teams Message which will trigger a callback"
def callback_send_message(self, message):
"""
Inspect a... | marksull/err-backend-cisco-webex-teams | plugins/err-example-send-callback/examplesendcallback.py | .py | 20b9f7d2006adfaf | 7.7 | 24 |
from errbot import botcmd
from errbot import BotPlugin
class ExampleTemplate(BotPlugin):
@botcmd(template="my_template")
def template(self, msg, message=None):
"""
This is an example of using a template to reply to a message
The template is defined in the templates/my_example.md file
... | marksull/err-backend-cisco-webex-teams | plugins/err-example-templates/exampletemplate.py | .py | 86f93baa014fffde | 7.2 | 24 |
from . import core, mixin
class AuxiliaryCoordinate(
mixin.NetCDFVariable,
mixin.NetCDFNodeCoordinateVariable,
mixin.Coordinate,
mixin.Files,
core.AuxiliaryCoordinate,
):
"""An auxiliary coordinate construct of the CF data model.
An auxiliary coordinate construct provides information whic... | NCAS-CMS/cfdm | cfdm/auxiliarycoordinate.py | .py | 059bc3f13b7dc86a | 7.75 | 31 |
from . import core, mixin
class Bounds(
mixin.BoundsMixin,
mixin.NetCDFVariable,
mixin.NetCDFDimension,
mixin.PropertiesData,
mixin.Files,
core.Bounds,
):
"""A cell bounds component.
Specifically, a cell bounds component of a coordinate or domain
ancillary construct of the CF data... | NCAS-CMS/cfdm | cfdm/bounds.py | .py | 7ebc2dc0e4f16da0 | 7.75 | 31 |
from . import core, mixin
from .decorators import _inplace_enabled, _inplace_enabled_define_and_cleanup
class CellConnectivity(
mixin.NetCDFVariable,
mixin.NetCDFConnectivityDimension,
mixin.Topology,
mixin.PropertiesData,
mixin.Files,
core.CellConnectivity,
):
"""A cell connectivity const... | NCAS-CMS/cfdm | cfdm/cellconnectivity.py | .py | ad46b5697f18408b | 7.75 | 31 |
import logging
from . import core, mixin
from .decorators import _manage_log_level_via_verbosity
logger = logging.getLogger(__name__)
class CellMeasure(
mixin.NetCDFVariable,
mixin.NetCDFExternal,
mixin.PropertiesData,
mixin.Files,
core.CellMeasure,
):
"""A cell measure construct of the CF d... | NCAS-CMS/cfdm | cfdm/cellmeasure.py | .py | 7ad74c3f4930dedb | 7.75 | 31 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.