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
"""A single frame of a TV episode at a given point in time.""" from pydantic import Field from compuglobal.models.base import BaseCompuGlobalModel from compuglobal.models.timestamp import Timestamp class Frame(BaseCompuGlobalModel): """A single frame of an episode at a point in time of a TV Show. Attribute...
MitchellAW/CompuGlobal
compuglobal/models/frame.py
.py
3249ef306eb889b7
7.57
13
"""Helper class for formatting of StreamOverlays and ComicOverlays.""" from pydantic import Field from compuglobal.models.base import BaseCompuGlobalModel from compuglobal.models.font import FontAlignment, FontColor, FontFamily class OverlayFormat(BaseCompuGlobalModel): """The formatting style to use in an over...
MitchellAW/CompuGlobal
compuglobal/models/overlay.py
.py
dc6fb418ca3d90d9
7.57
13
"""Streams are posted to the CGHMC APIs for generating gifs/mp4s.""" import json from base64 import b64encode from typing import Any from pydantic import Field from compuglobal.models.base import BaseCompuGlobalModel from compuglobal.models.font import FontAlignment, FontFamily from compuglobal.models.overlay import...
MitchellAW/CompuGlobal
compuglobal/models/stream.py
.py
476d220b0cf4d791
7.57
13
"""Subtitles are used in Screencaps and Comic/Stream overlays.""" from pydantic import Field from compuglobal.models.base import BaseCompuGlobalModel from compuglobal.models.timestamp import Timestamp class Subtitle(BaseCompuGlobalModel): """A Subtitle for a given period of time in a TV show. Attributes ...
MitchellAW/CompuGlobal
compuglobal/models/subtitle.py
.py
4d6e8d5dafc0b9e5
7.57
13
"""Test all exceptions in errors module.""" import re import pytest from compuglobal.errors import APIPageStatusError, NoSearchResultsFoundError def test_no_search_results_found_error() -> None: with pytest.raises(NoSearchResultsFoundError, match="No search results found"): raise NoSearchResultsFoundEr...
MitchellAW/CompuGlobal
tests/test_errors.py
.py
c0a9837d563ec87b
8.07
13
"""Helper functions for describing and building a CLI with command groups, which contain many subcommands.""" import inspect from argparse import ArgumentDefaultsHelpFormatter, ArgumentParser, Namespace, _SubParsersAction from collections.abc import Callable from typing import Any from aec.util.display import OutputF...
seek-oss/aec
src/aec/util/cli.py
.py
7cd872fffe9d555a
7.52
10
import os.path from argparse import Namespace from collections.abc import Callable from typing import Any, TypedDict import pytoml as toml class SsmConfig(TypedDict, total=False): s3bucket: str s3prefix: str class VpcConfig(TypedDict, total=False): name: str subnet: str security_group: str | li...
seek-oss/aec
src/aec/util/config.py
.py
006fe9e729da1c08
7.52
10
import os import shutil # use importlib_resources backport for compatibility with python < 3.11 # which don't have Traversable import importlib_resources as resources from importlib_resources.abc import Traversable def example() -> None: """create example config files in ~/.aec/.""" config_dir = os.path.exp...
seek-oss/aec
src/aec/util/configure.py
.py
2a566dd839b2455e
7.52
10
from collections.abc import Sequence from typing import TypedDict import boto3 import aec.util.tags as util_tags from aec.util.config import Config from aec.util.ec2_types import DescribeArgs class InstanceNameState(TypedDict): InstanceId: str State: str Name: str | None def describe_running_instances...
seek-oss/aec
src/aec/util/ec2_util.py
.py
cf5e1285fda833ef
7.52
10
import os import pytest from moto import mock_aws from moto.core.models import DEFAULT_ACCOUNT_ID from moto.ec2.models import ec2_backends from moto.ssm.models import ssm_backends @pytest.fixture(scope="session", autouse=True) def aws_credentials(): """Mocked AWS Credentials for moto.""" # avoid stale creds...
seek-oss/aec
tests/conftest.py
.py
43041317c9742de9
8.02
10
import io import boto3 import pytest from moto.ec2.models.amis import AMIS from mypy_boto3_ec2 import EC2Client from pytest import MonkeyPatch from aec.command.ssm import commands, fetch_instance_ids, run from aec.util.config import Config # NB: moto provides limited coverage of the SSM API so there's not many tests...
seek-oss/aec
tests/test_ssm.py
.py
7454bd356edd6ecb
7.02
10
import socket import libnacl import libnacl.utils import struct import base64 import time from dnsdist_console import util class Console: def __init__(self, key, host="127.0.0.1", port=5199): """authenticator class""" self.console_host = host self.console_port = port self.console_ke...
dmachard/python-dnsdist-console
dnsdist_console/console.py
.py
86aff335f55f9dc8
7.57
13
from dnsdist_console import Statistics import time import sys class Dashboard: def __init__(self, console): """statistics class""" self.console = console self.show() def show(self): """show dashboard updated every seconds""" prev_queries = 0 prev...
dmachard/python-dnsdist-console
dnsdist_console/dashboard.py
.py
857b88f02c738c2a
7.57
13
import re class Statistics: def __init__(self, console, top_num=10): """statistics class""" self.c = console self.top_num = top_num self.__stats__ = {"global": {}, "backends": [] } self.fetch() def __repr__(self): """print stats""" retu...
dmachard/python-dnsdist-console
dnsdist_console/statistics.py
.py
b1236f5540effd16
7.57
13
from dnsdist_console import HashPassword import unittest class TestHashPassword(unittest.TestCase): def test_generate_hashpassword(self): """generate hash password""" h = HashPassword().generate(password="superpassword") self.assertRegex(h, "^\$scrypt\$.*")
dmachard/python-dnsdist-console
tests/test_hashpwd.py
.py
f0d4f254c5a324e5
7.07
13
from dnsdist_console import Key import unittest class TestConnect(unittest.TestCase): def test_generate_key(self): """generate key in base64""" k = Key().generate() self.assertRegex(k, "[a-zA-Z0-9+\/]+={0,2}")
dmachard/python-dnsdist-console
tests/test_key.py
.py
872e881e5acf0975
7.07
13
class Base(object): """ This file contains the base class for the Mailwizz Python-SDK. Base is the base class for all the other classes used in the sdk. """ __config = {} @property def config(self): """ Config the configuration object injected into the application at runtim...
twisted1919/mailwizz-python-sdk
mailwizz/base.py
.py
f89dcd1b4a69cc26
7.54
11
from urllib.parse import urlparse from mailwizz.base import Base class Config(Base): """ Config contains the configuration class that is injected at runtime into the main application. It's only purpose is to set the needed data so that the API calls will run without problems. """ def __init__(se...
twisted1919/mailwizz-python-sdk
mailwizz/config.py
.py
d097a08c69fe25f3
7.54
11
from mailwizz.base import Base from mailwizz.client import Client class CampaignBounces(Base): """ CampaignBounces handles all the API calls for campaigns bounces. """ def get_bounces(self, campaign_uid: str, page=1, per_page=10): """ Get bounces from a certain campaign :para...
twisted1919/mailwizz-python-sdk
mailwizz/endpoint/campaign_bounces.py
.py
87164849f80bd2b8
7.54
11
from mailwizz.base import Base from mailwizz.client import Client class Customers(Base): """ Customers handles all the API calls for customers. """ def create(self, data: dict): """ Create a new customer :param data: :return: """ client = Client({ ...
twisted1919/mailwizz-python-sdk
mailwizz/endpoint/customers.py
.py
a913f4dbd926e181
7.54
11
from mailwizz.base import Base from mailwizz.client import Client class ListFields(Base): """ ListFields handles all the API calls for handling the list custom fields. """ def get_fields(self, list_uid: str): """ Get fields from a certain mail list :param list_uid: :re...
twisted1919/mailwizz-python-sdk
mailwizz/endpoint/list_fields.py
.py
8e1dada061280b76
7.54
11
import html import hashlib import hmac import os import time import requests import urllib.parse from collections import OrderedDict from multidimensional_urlencode import urlencode from mailwizz.base import Base class Request(Base): """ Request is the request class used to send the requests to the API endpo...
twisted1919/mailwizz-python-sdk
mailwizz/request.py
.py
bf6f983bdc8cdb8c
7.54
11
"""Pytest configuration and fixtures.""" import pytest from mailwizz.base import Base from mailwizz.config import Config @pytest.fixture def config(): """Provide a test configuration.""" return Config({ 'api_url': 'https://api.example.com/api', 'public_key': 'TEST_PUBLIC_KEY', 'private...
twisted1919/mailwizz-python-sdk
tests/conftest.py
.py
9ee7e1d6ec7c16ee
8.04
11
"""Tests for Base class.""" import pytest from mailwizz.base import Base from mailwizz.config import Config class TestBase: """Test suite for Base class.""" def test_set_and_get_config(self): """Test setting and retrieving config.""" config = Config({ 'api_url': 'https://api.examp...
twisted1919/mailwizz-python-sdk
tests/test_base.py
.py
51a461b3413d4ad1
8.04
11
"""Tests for Client class.""" import pytest from mailwizz.client import Client class TestClient: """Test suite for Client class.""" def test_client_initialization_requires_url(self): """Test that Client requires a URL.""" with pytest.raises(ValueError, match="Please set the url"): ...
twisted1919/mailwizz-python-sdk
tests/test_client.py
.py
2b6ccdf8c74c19c1
8.04
11
"""Tests for Config class.""" import pytest from mailwizz.config import Config class TestConfig: """Test suite for Config class.""" def test_config_initialization_with_dict(self): """Test config can be initialized with a dict.""" config = Config({ 'api_url': 'https://api.example.c...
twisted1919/mailwizz-python-sdk
tests/test_config.py
.py
8b0d58b0b9271fa1
8.04
11
"""Integration tests verifying full request flow.""" from unittest.mock import Mock, patch import pytest from mailwizz.base import Base from mailwizz.config import Config from mailwizz.endpoint.list_subscribers import ListSubscribers from mailwizz.endpoint.lists import Lists class TestIntegration: """Integration...
twisted1919/mailwizz-python-sdk
tests/test_integration.py
.py
5ccabf19406861a0
8.04
11
"""Tests for ListSubscribers endpoint.""" from unittest.mock import Mock, patch import pytest from mailwizz.base import Base from mailwizz.config import Config from mailwizz.endpoint.list_subscribers import ListSubscribers class TestListSubscribers: """Test suite for ListSubscribers endpoint.""" @pytest.fix...
twisted1919/mailwizz-python-sdk
tests/test_list_subscribers.py
.py
8a7833b25e741ff3
7.04
11
"""Tests for Request class and signing logic.""" import hashlib import hmac import urllib.parse from collections import OrderedDict from unittest.mock import Mock, patch import pytest from mailwizz.base import Base from mailwizz.client import Client from mailwizz.config import Config from mailwizz.request import Reque...
twisted1919/mailwizz-python-sdk
tests/test_request.py
.py
2c5ddba6f5bfb108
7.04
11
from django.contrib.auth.models import AbstractUser, BaseUserManager from django.db import models from django.utils import timezone try: # < Django 4.0 from django.utils.translation import ugettext_lazy as _ except ImportError: # Django 4.0+ from django.utils.translation import gettext_lazy as _ class...
rework-union/django-rework
rework/contrib/users/models.py
.py
9ea951a2182f1de3
7.42
6
""" Deploy hosts hosts is a ordered dict, key is the `c.host` value is ``` { 'host': '123.123.123.123', 'user': 'root', 'port': '22', 'password': 'your password', 'envs': ['test', 'prod'], 'exclude_components': ['redis'], } ``` """ import inspect import os from collections import OrderedDict ...
rework-union/django-rework
rework/core/devops/hosts.py
.py
d2e354abe0835800
7.42
6
""" Deploy to server """ import os from ..hosts import get_host_value, connect from ... import devops from ...utils import say class Deploy: def __init__(self, c): self.c = connect(c) self.host_value = get_host_value(c)[1] self.project = devops.PROJECT self.env = devops.ENV ...
rework-union/django-rework
rework/core/devops/tasks/deploy.py
.py
bb5313a777b820a8
7.42
6
""" Setup server configurations from a new server Support CentOS 7 """ # from patchwork import files from ..hosts import get_host_value, connect from ...utils import say, patch_connection_with_say class SetupServer: def __init__(self, c): self.c = connect(c) self.host_value = get_host_value(c)[1]...
rework-union/django-rework
rework/core/devops/tasks/setup_server.py
.py
32d9c2e60066002d
7.42
6
""" Django Rework App managements """ import os import re import subprocess from .handlers.urls import UrlsHandle from .. import utils from ..utils import say def _initialize_basics_model(): # Initialize `basics/models.py` file base_dir = os.getcwd() model_file = os.path.join(base_dir, 'basics', 'models...
rework-union/django-rework
rework/core/management/app.py
.py
a710e03ab21b5248
7.42
6
import os import re class SettingsHandle: """ Handle django settings files """ def __init__(self, project, path): self.base_dir = os.getcwd() self.project = project self.path = path # settings root path, generally is project name self.base_settings_file = os.path.join(...
rework-union/django-rework
rework/core/management/handlers/settings.py
.py
407cf5940673b637
7.42
6
import re from rework.core.utils import get_root_urls_path class UrlsHandle: """ Handle django app's urls """ def __init__(self, app=None): self.app = app # When app is None, target to root urls @staticmethod def _save(f, content): f.seek(0) f.truncate() f.wr...
rework-union/django-rework
rework/core/management/handlers/urls.py
.py
0eb99ab7ba6d1eba
7.42
6
import os from string import Template from .say import * def get_project_name(): """Determined the project path project settings folder contains `wsgi.py` """ for path in os.listdir('.'): if os.path.exists(os.path.join(path, 'wsgi.py')): say(f'Determined the project path is: {path...
rework-union/django-rework
rework/core/utils/__init__.py
.py
442827d3f4b087e4
7.42
6
def say(content, icon=None, wrap=""): """convenient way to output message `wrap` choices is 'A' - append wrap after content, 'B' - before content, 'C' - both """ leading = f"{icon:3}" if icon else " - " wrap = wrap.upper() if wrap in ["B", "C"]: print() pri...
rework-union/django-rework
rework/core/utils/say.py
.py
d22bd70a643e2f22
7.42
6
#!/usr/bin/env python3 """ Example publisher for `util/pubsub.py`. @Author jonnykong@cs.ucla.edu @Date 2020-05-10 """ import asyncio as aio import datetime import logging from ndn.app import NDNApp from ndn.encoding import Name, NonStrictName from ndn_python_repo.utils import PubSub async def run_publ...
UCLA-IRL/ndn-python-repo
examples/publisher.py
.py
53704f5539bafa0e
7.63
17
#!/usr/bin/env python3 """ Example subscriber for `util/pubsub.py`. @Author jonnykong@cs.ucla.edu @Date 2020-05-10 """ import logging from ndn.app import NDNApp from ndn.encoding import Name, NonStrictName from ndn_python_repo.utils import PubSub async def run_subscriber(app: NDNApp, subscriber_prefix...
UCLA-IRL/ndn-python-repo
examples/subscriber.py
.py
e19b1a0d018a9eda
7.63
17
# noinspection GrazieInspection """ This script ports sqlite db file from repo-ng to ndn-python-repo. It takes as input a repo-ng sqlite database file, traverses the database, and inserts data into an ndn-python-repo using TCP bulk insertion. @Author jonnykong@cs.ucla.edu @Date 2019-12-26 """ im...
UCLA-IRL/ndn-python-repo
ndn_python_repo/cmd/port.py
.py
97157ae88e694e77
7.63
17
""" Repo command encoding. @Author jonnykong@cs.ucla.edu @Date 2019-11-01 """ from typing import TypeVar import ndn.encoding as enc __all__ = [ "RepoTypeNumber", "EmbName", "ObjParam", "SyncParam", "SyncStatus", "RepoCommandParam", "ObjStatus", "RepoCommandRes", "Rep...
UCLA-IRL/ndn-python-repo
ndn_python_repo/command/repo_commands.py
.py
c20ea5ee9a9b356f
7.63
17
import asyncio as aio import logging import json from ndn.app import NDNApp from ndn.encoding import Name, NonStrictName, FormalName, Component from ndn.encoding.tlv_model import DecodeError from ..command import RepoStatQuery, RepoCommandRes, RepoStatCode, RepeatedNames, RepoCommandParam from ..storage import Storage...
UCLA-IRL/ndn-python-repo
ndn_python_repo/handle/command_handle_base.py
.py
0926e92ef886ac63
7.63
17
import asyncio as aio import logging from ndn.app import NDNApp from ndn.encoding import Name, NonStrictName, Component from typing import Optional from . import ReadHandle, CommandHandle from ..command import RepoCommandRes, RepoCommandParam, ObjParam, ObjStatus, RepoStatCode from ..storage import Storage from ..utils...
UCLA-IRL/ndn-python-repo
ndn_python_repo/handle/delete_command_handle.py
.py
559e27e2682b6cf8
7.63
17
import asyncio as aio import logging from ndn.app import NDNApp from ndn.encoding import Name from ..storage import Storage class ReadHandle(object): """ ReadCommandHandle processes ordinary interests, and return corresponding data if exists. """ def __init__(self, app: NDNApp, storage: Storage, confi...
UCLA-IRL/ndn-python-repo
ndn_python_repo/handle/read_handle.py
.py
74bf9821476e9471
7.63
17
import asyncio as aio import logging from hashlib import sha256 from ndn.app import NDNApp from ndn.encoding import Component, DecodeError, Name, NonStrictName, parse_data from ..command import ( RepoCommandParam, RepoCommandRes, RepoStatCode, SyncParam, SyncStatus, ) from ..storage import Storage...
UCLA-IRL/ndn-python-repo
ndn_python_repo/handle/sync_command_handle.py
.py
c4f6efb9893f2358
7.63
17
import asyncio as aio import io import logging import sys from . import ReadHandle, CommandHandle from ..storage import * from ndn.encoding import Name, read_tl_num_from_stream, parse_data from ndn.encoding import TypeNumber, FormalName class TcpBulkInsertHandle(object): class TcpBulkInsertClient(object): ...
UCLA-IRL/ndn-python-repo
ndn_python_repo/handle/tcp_bulk_insert_handle.py
.py
d8bc1f90911ceadc
7.63
17
import logging from ndn.app import NDNApp from ndn.encoding import Name from .storage import * from .handle import * class Repo(object): def __init__(self, app: NDNApp, storage: Storage, read_handle: ReadHandle, write_handle: WriteCommandHandle, delete_handle: DeleteCommandHandle, ...
UCLA-IRL/ndn-python-repo
ndn_python_repo/repo.py
.py
32b360a6dca8b98e
7.63
17
import os import pickle import plyvel # fixme: my ide tells me this doesn't exist from .storage_base import Storage from typing import Optional class LevelDBStorage(Storage): def __init__(self, level_dir: str): """ Creates a LevelDB storage instance at disk location ``str``. :param level...
UCLA-IRL/ndn-python-repo
ndn_python_repo/storage/leveldb.py
.py
aa098ed015adda0f
7.63
17
import base64 from pymongo import MongoClient, ReplaceOne from .storage_base import Storage from typing import Optional class MongoDBStorage(Storage): def __init__(self, db: str, collection: str, uri: str = 'mongodb://127.0.0.1:27017/'): """ Init a MongoDB storage with unique index on key. ...
UCLA-IRL/ndn-python-repo
ndn_python_repo/storage/mongodb.py
.py
6d1512e790bdfa01
7.63
17
import os import sqlite3 from typing import Optional from .storage_base import Storage class SqliteStorage(Storage): def __init__(self, db_path: str): """ Init table "data" with the attribute ``key`` being the primary key. :param db_path: str. Path to database file. """ s...
UCLA-IRL/ndn-python-repo
ndn_python_repo/storage/sqlite.py
.py
4506706b94761b38
7.63
17
import asyncio as aio from hashlib import sha256 import logging from contextlib import suppress from ndn.encoding.tlv_var import parse_tl_num from ndn.encoding import Name, Component, parse_data, NonStrictName from ndn.name_tree import NameTrie import time from typing import Optional class Storage: cache = NameTr...
UCLA-IRL/ndn-python-repo
ndn_python_repo/storage/storage_base.py
.py
687656afcb2522f6
7.63
17
import asyncio as aio import filecmp import multiprocessing from ndn.app import NDNApp from ndn.encoding import Name from ndn.security import KeychainDigest from ndn.types import InterestNack, InterestTimeout from ndn_python_repo.clients import GetfileClient, PutfileClient, DeleteClient, CommandChecker from ndn_python_...
UCLA-IRL/ndn-python-repo
tests/integration/integration_test.py
.py
b299bb315dd0102d
7.13
17
import os from flask import Flask import logging def create_app(test_config=None): app = Flask(__name__, instance_relative_config=True) app.config.from_mapping( SECRET_KEY='dev', IP_WHITE_LIST='' ) app.config.from_prefixed_env() if test_config is None: app.config.fro...
ComPlat/chem-spectra-app
chem_spectra/__init__.py
.py
67ad1945b2e3e2c1
7.12
16
"""LCMS-specific request helpers. Keeps LCMS request parsing/normalisation out of the generic ``share.py`` helpers so the original (pre-LCMS) request pipeline stays untouched. """ import os.path as os_path def _param_to_text(value): """Normalise an arbitrary form/file param into a UTF-8 string (or None).""" ...
ComPlat/chem-spectra-app
chem_spectra/controller/helper/lcms.py
.py
07690e14cf3145f8
8.12
16
# https://github.com/rdkit/rdkit/tree/master/Contrib/IFG # Richard hall 2017 # IFG main code # Guillaume Godin 2017 # refine output function # astex_ifg: identify functional groups a la Ertl, J. Cheminform (2017) 9:36 from rdkit import Chem from collections import namedtuple def merge(mol, marked, aset): bset = s...
ComPlat/chem-spectra-app
chem_spectra/lib/chem/ifg.py
.py
b1e35f80046c1a25
7.12
16
import numpy as np from scipy.interpolate import interp1d def __num_pts(base, x_max, x_min): if base.typ in ['NMR']: return 32000 elif base.typ in ['INFRARED', 'RAMAN']: return int(x_max - x_min + 1) * 2 else: return 32000 def __parse_xy_points(base): pts = [] if 'XYPOINT...
ComPlat/chem-spectra-app
chem_spectra/lib/converter/jcamp/data_parse.py
.py
c542f66d65b5e586
7.12
16
import hashlib import subprocess as sbp import time import shutil import numpy as np import pymzml import pyopenms from pathlib import Path from datetime import datetime from chem_spectra.lib.shared.buffer import store_byte_in_tmp from chem_spectra.lib.converter.share import reduce_pts MARGIN = 1 tmp_dir = Path('./...
ComPlat/chem-spectra-app
chem_spectra/lib/converter/ms.py
.py
260d8878ddb4e388
7.12
16
"""Configuration display and deployment CLI commands. Provides commands to inspect, deploy, and generate example configuration. Contents: * :func:`cli_config` - Display merged configuration. * :func:`cli_config_deploy` - Deploy configuration to target locations. * :func:`cli_config_generate_examples` - Ge...
bitranox/fake_winreg
src/fake_winreg/adapters/cli/commands/config.py
.py
abaecc64ede123dd
7.45
7
"""CLI command to export demo registry files to the current directory.""" from __future__ import annotations import logging from pathlib import Path from typing import TYPE_CHECKING import lib_log_rich.runtime import rich_click as click from fake_winreg.adapters.persistence.reg_io import export_reg from fake_winreg...
bitranox/fake_winreg
src/fake_winreg/adapters/cli/commands/demo_registries.py
.py
0df27304feeb18b5
7.45
7
"""Click context helpers for CLI state management.""" from __future__ import annotations from dataclasses import dataclass from typing import TYPE_CHECKING import lib_cli_exit_tools if TYPE_CHECKING: import rich_click as click from lib_layered_config import Config from fake_winreg.composition import Ap...
bitranox/fake_winreg
src/fake_winreg/adapters/cli/context.py
.py
330b2e96a27143c8
7.45
7
"""CLI entry point and execution wrapper. Provides the main entry point used by console scripts and ``python -m`` execution, ensuring consistent error handling and traceback restoration. Contents: * :func:`main` - Primary entry point for CLI execution. """ from __future__ import annotations import sys import th...
bitranox/fake_winreg
src/fake_winreg/adapters/cli/main.py
.py
6a7bb0e60b9d5bb1
7.45
7
"""Root CLI command group and global option handling. Defines the top-level Click command group that serves as the entry point for all subcommands. Handles global flags like --traceback, --profile, and --set. Contents: * :func:`cli` - Root command group with global options. """ from __future__ import annotations...
bitranox/fake_winreg
src/fake_winreg/adapters/cli/root.py
.py
711152cc0494d27e
7.45
7
"""Encode-safe console output. Purpose ------- Wraps :func:`click.echo` so a console whose codepage cannot represent a glyph degrades that glyph instead of aborting the command. Why --- Console output is a sink with an encoding the program does not choose. Python hands stdout to a Windows console at codepage 1252 wit...
bitranox/fake_winreg
src/fake_winreg/adapters/cli/safe_console.py
.py
4f46121528cd775f
7.45
7
"""Strictly-typed wrappers for rich_click's partially-typed decorators. rich_click ships ``py.typed``, but its ``option````, ``argument`` and ``version_option`` decorators are typed with a partially-unknown return, so the strict type checker reports ``reportUnknownMemberType`` at every call site. click's own decorator...
bitranox/fake_winreg
src/fake_winreg/adapters/cli/typed_click.py
.py
00b7289a6ff98dfb
7.45
7
"""Configuration loader with caching and profile/override support.""" from __future__ import annotations from functools import lru_cache from pathlib import Path from typing import Protocol, cast from lib_layered_config import ( DEFAULT_MAX_PROFILE_LENGTH, Config, read_config, validate_profile_name, ...
bitranox/fake_winreg
src/fake_winreg/adapters/config/loader.py
.py
3b318f862c8ff696
7.45
7
"""Parse and apply ``--set SECTION.KEY=VALUE`` CLI overrides to Config.""" from __future__ import annotations from dataclasses import dataclass from typing import TYPE_CHECKING, cast import orjson if TYPE_CHECKING: from lib_layered_config import Config CoercedValue = str | int | float | bool | None | list[obje...
bitranox/fake_winreg
src/fake_winreg/adapters/config/overrides.py
.py
9194c13f856c0fa2
7.45
7
"""Permission settings loader for config deployment. Provides functions to load permission defaults from configuration and compute effective permission modes for deployment targets. """ from __future__ import annotations from typing import TYPE_CHECKING from lib_layered_config import ( DEFAULT_APP_DIR_MODE, ...
bitranox/fake_winreg
src/fake_winreg/adapters/config/permissions.py
.py
7ee800f878eb18e2
7.45
7
"""Centralized logging initialization for all entry points. Provides a single source of truth for lib_log_rich runtime configuration, eliminating duplication between module entry (__main__.py) and console script (cli.py) while ensuring initialization happens exactly once. Contents: * :func:`init_logging` - idempo...
bitranox/fake_winreg
src/fake_winreg/adapters/logging/setup.py
.py
8c2d033e02b4803a
7.45
7
"""In-memory configuration adapters for testing. Provides configuration functions that satisfy the same Protocols as production adapters but operate entirely in memory -- no filesystem, no lib_layered_config. """ from __future__ import annotations import tempfile from pathlib import Path from typing import TYPE_CHEC...
bitranox/fake_winreg
src/fake_winreg/adapters/memory/config.py
.py
3639d3d1a79fe13a
7.45
7
"""Network adapter for DNS-based computer reachability checks. Used by ConnectRegistry to validate remote computer names. """ from __future__ import annotations import socket from fake_winreg.domain.helpers import get_first_part_of_the_key, strip_backslashes def is_computer_reachable(computer_name: str) -> bool: ...
bitranox/fake_winreg
src/fake_winreg/adapters/network.py
.py
d886da3cc81653ec
7.45
7
"""Stream-convert registries between formats without loading into memory. Supports SQLite (.db/.sqlite), JSON (.json), and .reg file formats. Uses the backend interface to stream key-by-key for memory efficiency. """ from __future__ import annotations from pathlib import Path from typing import TYPE_CHECKING from f...
bitranox/fake_winreg
src/fake_winreg/adapters/persistence/convert.py
.py
756f0751edb67fb4
7.45
7
"""Import/export functions for JSON registry snapshots. These functions work with the currently active backend, allowing data to be loaded from or saved to JSON files regardless of which backend implementation is in use. """ from __future__ import annotations import base64 from pathlib import Path from typing import...
bitranox/fake_winreg
src/fake_winreg/adapters/persistence/json_io.py
.py
58e6936961417cb2
7.45
7
"""Application ports — callable Protocol definitions for adapter functions. Each Protocol class defines a ``__call__`` method whose signature exactly matches the corresponding adapter function. Existing module-level functions satisfy these protocols automatically via structural subtyping (PEP 544). System Role: ...
bitranox/fake_winreg
src/fake_winreg/application/ports.py
.py
3e5066628b97bef4
7.45
7
"""Composition root wiring adapters to application ports.""" from __future__ import annotations from dataclasses import dataclass from typing import TYPE_CHECKING from ..adapters.config.deploy import deploy_configuration from ..adapters.config.display import display_config # Configuration services from ..adapters.c...
bitranox/fake_winreg
src/fake_winreg/composition/__init__.py
.py
3d899e584bb5294f
7.45
7
"""Winreg-compatible argument validation helpers. Extracted from api.py to keep the public API module focused on registry operations. These mirror the validation behavior of the real Windows winreg module. """ from __future__ import annotations import sys from typing import Any from .handles import PyHKEY def che...
bitranox/fake_winreg
src/fake_winreg/domain/_validators.py
.py
c34338a7b8c06e9c
7.45
7
"""Type-safe domain enums for output formats and deployment targets.""" from __future__ import annotations from enum import Enum class OutputFormat(str, Enum): """Output format options for configuration display. Defines valid output format choices for the config command. Inherits from str to allow dire...
bitranox/fake_winreg
src/fake_winreg/domain/enums.py
.py
0002b2b66f698cb3
7.45
7
"""Registry handle types wrapping fake registry keys. Provides HKEYType and PyHKEY (context manager) that mirror the Windows winreg handle objects, plus thread-safe handle ID generation. """ from __future__ import annotations import threading from typing import TYPE_CHECKING from .constants import KEY_READ if TYPE...
bitranox/fake_winreg
src/fake_winreg/domain/handles.py
.py
d08d768f0244e30e
7.45
7
"""Pure string helper functions for registry key path manipulation.""" from __future__ import annotations def strip_backslashes(input_string: str) -> str: r"""Remove leading and trailing backslashes. >>> strip_backslashes(r'\\test\\\\') 'test' """ return input_string.strip("\\") def get_first_...
bitranox/fake_winreg
src/fake_winreg/domain/helpers.py
.py
b452f5f99275a627
7.45
7
"""In-memory registry backend wrapping FakeRegistry. This is the default backend — all data lives in Python dicts in memory. Equivalent to the original fake_winreg behavior before backends were introduced. """ from __future__ import annotations from typing import TYPE_CHECKING from .registry import ( FakeRegist...
bitranox/fake_winreg
src/fake_winreg/domain/memory_backend.py
.py
842ede2b47b1044b
7.45
7
"""Core registry data structures and operations. Provides the in-memory representation of a Windows registry: hives, keys, and values, plus functions to create and retrieve them. """ from __future__ import annotations import time from typing import TYPE_CHECKING from .constants import ( HKEY_CLASSES_ROOT, H...
bitranox/fake_winreg
src/fake_winreg/domain/registry.py
.py
d24432ed4b89be51
7.45
7
import re def style_to_object(style_str): """Converts CSS style string to a JavaScript object (dictionary in Python terms).""" style_tuples = [tuple(s.split(':')) for s in style_str.split(';') if s] style_dict = {re.sub(r'([a-z])-([a-z])', lambda x: x.group(1) + x.group(2).upper(), k.strip()): v.strip() fo...
rgerum/saenopy
docs/source/images/extract_convert.py
.py
af4113671cdaf5ff
7.64
18
import numpy as np def make_from_polar(r: float, theta: float, phi: float) -> np.ndarray: """ Convert from polar coordinates to cartesian coordinates """ # get sine and cosine of the angles ct = np.cos(theta) st = np.sin(theta) cp = np.cos(phi) sp = np.sin(phi) # and convert to car...
rgerum/saenopy
saenopy/build_beams.py
.py
6a1a4e79d28af8e1
7.64
18
import numpy as np def cg(A: np.ndarray, b: np.ndarray, maxiter: int = 1000, tol: float = 0.00001, verbose: bool = False): """ solve the equation Ax=b with the conjugate gradient method """ def norm(x): return np.inner(x.flatten(), x.flatten()) # calculate the total force "amplitude" normb = ...
rgerum/saenopy
saenopy/conjugate_gradient.py
.py
684fbbc708389867
7.64
18
from qtpy import QtCore, QtGui, QtWidgets def format(color, style=''): """Return a QTextCharFormat with the given attributes.""" _color = QtGui.QColor(color) _format = QtGui.QTextCharFormat() _format.setForeground(_color) if 'bold' in style: _format.setFontWeight(QtGui.QFont.Bold) if '...
rgerum/saenopy
saenopy/gui/code/syntax.py
.py
f3578423e9c00c56
7.64
18
# -*- coding: utf-8 -*- """ Data and Metadata holder for different satellites """ import copy import rasterio from pathlib import Path import pandas as pd import re from pyintdem.models.band import Band import numpy as np import json from zipfile import ZipFile def format_band_name(band_name): band_number = re.fi...
jamal919/pyIntertidalDEM
pyintdem/data.py
.py
ffd1d2026023c0c0
7.45
7
# -*- coding: utf-8 -*- # Extracted from pycaz/utils/geometry.py # https://github.com/jamal919/pycaz import cartopy.crs as ccrs from pyproj import CRS import numpy as np def buffer_extent(extent, buffer, xmin=0, ymin=-90, xmax=360, ymax=90): """ Apply a buffer to a given extent :param extent: Extent as [...
jamal919/pyIntertidalDEM
pyintdem/geometry.py
.py
ace1841f94dc7a05
7.45
7
# -*- coding: utf-8 -*- import numpy as np import geopandas as gpd from pyintdem.geometry import bounds2extent, extent2geometries def create_tiles_layout(extent, dx=1, dy=1, rounding=True, extent_convension='cartopy'): """Compute a GeoDataframe with specified tile layout Args: extent (array): [w, e,...
jamal919/pyIntertidalDEM
pyintdem/gridding.py
.py
e046377f2b8a98ae
7.45
7
#!/usr/bin/env python # -*- coding: utf-8 -*- from pathlib import Path import matplotlib.colors as mcl import matplotlib.pyplot as plt import numpy as np from osgeo import gdal from .band import Band class RGB(object): def __init__(self, red, green, blue): """ RGB band using in the red-green-bl...
jamal919/pyIntertidalDEM
pyintdem/models/rgb.py
.py
1e0ff9e43b9d68dd
7.45
7
# -*- coding: utf-8 -*- import json import logging import warnings from pathlib import Path import cartopy import cartopy.crs as ccrs import geopandas as gpd import matplotlib.pyplot as plt import numpy as np import requests from shapely.geometry import Polygon, shape logger = logging.getLogger(__name__) data_sou...
jamal919/pyIntertidalDEM
pyintdem/sources/s2/coverage.py
.py
f5daca96ffc7c9ee
7.45
7
# -*- encoding: utf-8 -*- import gc import logging from pathlib import Path import numpy as np from skimage import measure import geopandas as gpd from shapely import LineString from rioxarray.exceptions import NoDataInBounds from tqdm.autonotebook import tqdm from pyintdem import read_file from pyintdem.models.band ...
jamal919/pyIntertidalDEM
pyintdem/workflows/khan2019.py
.py
48bceb12bb73c048
7.45
7
"""Windowed AUROC assesses agreement between reactivities and base-pairing.""" import numpy as np from sklearn.metrics import auc, roc_curve from rnavigate import plots # TODO: refactor as subclass of rnavigate.Sample class WindowedAUROC: """Compute and display windowed AUROC analysis. This analysis comput...
Weeks-UNC/RNAvigate
rnavigate/analysis/auroc.py
.py
2a7283f32caee472
7.62
16
"""SequenceChecker analysis used to inspect sequence differences. Given a list of samples, we can inspect which data keywords belong to the samples, which sequences match up perfectly, and inspect the differences between sequences. """ import numpy as np import pandas as pd from rnavigate import data class Sequenc...
Weeks-UNC/RNAvigate
rnavigate/analysis/check_sequence.py
.py
209aec1e5a2c71e0
7.62
16
"""LogCompare compares reactivity profiles for significant differences. This analysis requires replicates. """ import numpy as np import pandas as pd from scipy.optimize import minimize_scalar from rnavigate import Sample, data # TODO: refactor as a subclass of rnavigate.Sample class LogCompare(Sample): """Com...
Weeks-UNC/RNAvigate
rnavigate/analysis/logcompare.py
.py
2a9fe5c343440e8e
7.62
16
"""Performs low SHAPE, low Shannon entropy analysis Citation: Siegfried, N., Busan, S., Rice, G. et al. RNA motif discovery by SHAPE and mutational profiling (SHAPE-MaP). Nat Methods 11, 959-965 (2014). https://doi.org/10.1038/nmeth.3029 Typical usage example:: import rnavigate as rnav my_sample ...
Weeks-UNC/RNAvigate
rnavigate/analysis/lowss.py
.py
05ab6f5fcc644f70
7.62
16
"""annotations.py contains Annotations and subclasses.""" import re import numpy as np import pandas as pd from rnavigate import data class Annotation(data.Sequence): """Basic annotation class to store 1D features of an RNA sequence Each feature type must be a seperate instance. Feature types include: ...
Weeks-UNC/RNAvigate
rnavigate/data/annotation.py
.py
6cb44916a82bfc7c
7.62
16
import matplotlib as mpl import numpy as np class ScalarMappable(mpl.cm.ScalarMappable): """Used to map scalar values to a color and to create a colorbar plot. Parameters ---------- cmap : str, tuple, float, or list A valid mpl color, list of valid colors or a valid colormap name normaliz...
Weeks-UNC/RNAvigate
rnavigate/data/colors.py
.py
85546ff613f024c0
7.62
16
"""The PDB object to represent tertiary structures with atomic coordinates. This data can be used to filter interactions by 3D distance, and to visualize profile and interactions data on interactive 3D structures. """ import Bio.PDB import numpy as np from rnavigate import data class PDB(data.Sequence): """A c...
Weeks-UNC/RNAvigate
rnavigate/data/pdb.py
.py
2f3ea7dcd81d4dd6
7.62
16
"""Parsing function for rnavigate.Sample data_keywords.""" from pathlib import Path from rnavigate import data __all__ = ["data_keyword_defaults", "create_data", "get_sequence"] _required = object() data_keyword_defaults = { "sequence": {"data_class": data.Sequence}, "shapemap": {"data_class": data.SHAPEMa...
Weeks-UNC/RNAvigate
rnavigate/data_loading.py
.py
d4af7f23947b68c7
7.62
16
"""Plotting class for sequence alignments.""" from rnavigate import plots class Alignment(plots.Plot): """Class for plotting sequence alignments. Parameters ---------- num_samples : int The number of samples to plot. Always 2. rows : int, optional The number of rows of plots. Alw...
Weeks-UNC/RNAvigate
rnavigate/plots/alignment.py
.py
eefb3bc667f9135a
7.62
16