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 dataclasses import dataclass, field
from textual.theme import Theme
@dataclass
class ThemeConfig:
"""Configuration for theme preferences."""
current_theme: str = "textual-dark"
available_themes: list[str] | None = field(default=None)
def __post_init__(self):
if self.available_themes is ... | closeio/close-mongo-ops-manager | src/close_mongo_ops_manager/theme_manager.py | .py | 33f586a93178acf5 | 7.5 | 9 |
from textual.binding import Binding
from textual.app import ComposeResult
from textual.containers import Vertical, Center
from textual.screen import ModalScreen
from textual.widgets import Footer, Static, OptionList
from textual.widgets.option_list import Option
class ThemeScreen(ModalScreen):
id = "theme_screen"... | closeio/close-mongo-ops-manager | src/close_mongo_ops_manager/theme_screen.py | .py | 2c5b9b869934ff64 | 7.5 | 9 |
"""Shared test fixtures for close-mongo-ops-manager test suite."""
import pytest
from unittest.mock import AsyncMock, MagicMock
@pytest.fixture
def sample_mongodb_operation():
"""Return a realistic MongoDB operation with all common fields."""
return {
"type": "op",
"host": "mongodb-server:270... | closeio/close-mongo-ops-manager | tests/conftest.py | .py | 43c333f12549aa68 | 8 | 9 |
import logging
from close_mongo_ops_manager.config_manager import ConfigManager
from close_mongo_ops_manager.theme_manager import ThemeConfig
def test_load_theme_config_logs_warning_on_invalid_json(tmp_path, caplog):
manager = ConfigManager()
manager.config_file = tmp_path / "config.json"
manager.config_... | closeio/close-mongo-ops-manager | tests/test_config_manager.py | .py | 9448ce3259b6ae0b | 7 | 9 |
"""Tests for FilterBar component."""
from textual.app import App, ComposeResult
from textual.widgets import Input
from close_mongo_ops_manager.filterbar import FilterBar
from close_mongo_ops_manager.messages import FilterChanged
class FilterBarTestApp(App):
"""Test app with a FilterBar."""
def __init__(sel... | closeio/close-mongo-ops-manager | tests/test_filterbar.py | .py | 8d299e37a2edee67 | 7 | 9 |
"""Tests for KillConfirmation screen."""
from textual.app import App, ComposeResult
from close_mongo_ops_manager.kill_confirmation_screen import KillConfirmation
class KillConfirmTestApp(App):
"""Test app that pushes the KillConfirmation screen."""
def __init__(self, operations: list[str]):
super()... | closeio/close-mongo-ops-manager | tests/test_kill_confirmation_screen.py | .py | 2f488c47c1ae6e7d | 7 | 9 |
"""Tests for OperationDetailsScreen."""
from textual.app import App, ComposeResult
from textual.widgets import TextArea
from close_mongo_ops_manager.operation_details_screen import OperationDetailsScreen
class DetailsTestApp(App):
"""Test app that pushes the OperationDetailsScreen."""
def __init__(self, op... | closeio/close-mongo-ops-manager | tests/test_operation_details_screen.py | .py | b8684498fe5cab05 | 7 | 9 |
"""Tests for OperationsView component."""
import pytest
from textual.app import App
from close_mongo_ops_manager.operations_view import OperationsView
@pytest.fixture
def operations_view():
"""Create an OperationsView instance for testing."""
return OperationsView()
class OperationsViewTestApp(App):
"... | closeio/close-mongo-ops-manager | tests/test_operations_view.py | .py | 1984c097bf71473a | 7 | 9 |
"""Tests for StatusBar component."""
from textual.app import App
from close_mongo_ops_manager.statusbar import StatusBar
class StatusBarTestApp(App):
"""Test app for mounting StatusBar (not collected by pytest)."""
def compose(self):
yield StatusBar(refresh_interval=2.0)
async def test_set_connec... | closeio/close-mongo-ops-manager | tests/test_statusbar.py | .py | 754e08e093afcab8 | 7 | 9 |
"""Tests for ThemeManager and ThemeConfig."""
from close_mongo_ops_manager.theme_manager import ThemeConfig, ThemeManager
def test_theme_config_defaults():
"""Test ThemeConfig initializes with correct defaults."""
config = ThemeConfig()
assert config.current_theme == "textual-dark"
assert "textual-da... | closeio/close-mongo-ops-manager | tests/test_theme_manager.py | .py | 7256a77ce9e77df9 | 8 | 9 |
"""Tests for ThemeScreen."""
from textual.app import App, ComposeResult
from textual.widgets import OptionList
from close_mongo_ops_manager.theme_screen import ThemeScreen
class ThemeTestApp(App):
"""Test app that pushes the ThemeScreen."""
def __init__(self, themes: list[str], current: str):
super... | closeio/close-mongo-ops-manager | tests/test_theme_screen.py | .py | efded72aacd72815 | 7 | 9 |
import subprocess
import sys
from hexagon.support.output.printer import log
def check_gh_cli():
"""Check if gh CLI is installed and authenticated"""
if not _is_gh_installed():
log.panel(
"GitHub CLI (gh) is not installed. Please install it first:\n"
" [b]brew install gh[/b]\n... | lt-mayonesa/hexagon | cli/checks/check_gh_cli.py | .py | 83f4ee6f29125bbc | 7.63 | 17 |
"""
Utilities for parsing and filtering unified diffs.
This module provides functions for working with git-style unified diffs,
including parsing diffs into per-file chunks and filtering files that
should be skipped (lock files, large generated files, etc.).
"""
from typing import Dict, List, Tuple
# Lock file patte... | lt-mayonesa/hexagon | cli/pull_requests/diff_utils.py | .py | 2cc9895892702c3c | 7.63 | 17 |
from typing import Any, Optional
from pydantic import validator
from hexagon.domain.env import Env
from hexagon.domain.tool import ActionTool
from hexagon.support.input.args import ToolArgs, Arg, OptionalArg
from hexagon.support.output.printer import log
class Args(ToolArgs):
last_name: OptionalArg[str] = Arg(
... | lt-mayonesa/hexagon | hexagon/actions/__templates/custom_tool/__init__.py | .py | eb8046d808ae1679 | 7.63 | 17 |
from typing import List, Callable
class HexagonError(Exception):
"""Base class for all Hexagon errors."""
def __init__( # noqa: B042
self, error_printer: Callable, exit_status: int = 1 # noqa: B042
) -> None: # noqa: B042
super().__init__("hexagon error")
self.exit_status = exi... | lt-mayonesa/hexagon | hexagon/domain/hexagon_error.py | .py | 7940250bf4e9b4dc | 7.63 | 17 |
import time
from hexagon.domain.env import Env
from hexagon.domain.hooks.execution import ToolExecutionData
from hexagon.domain.tool import ActionTool
from hexagon.support.hooks import HexagonHooks
def execution_hook(func):
"""
Decorator to add a hook to a tool execution, it will be called before and after t... | lt-mayonesa/hexagon | hexagon/runtime/execute/execution_hook.py | .py | 3a8ac8e485a0df6c | 7.63 | 17 |
from dataclasses import dataclass
from typing import Callable, List, Optional
from hexagon.domain.env import Env
from hexagon.domain.tool import FunctionTool, GroupTool, Tool, ToolType
@dataclass
class FlatTool:
"""
A leaf tool together with its full ancestor path through the group tree.
``path_tools`` ... | lt-mayonesa/hexagon | hexagon/runtime/execute/list_view.py | .py | 2642ed8d839f03b0 | 7.63 | 17 |
"""General decoding functions."""
from rdflib import Graph, URIRef, Literal, RDF
from ..modules import arguments as args
from ..modules.logger import initialize_logger
from ..modules.sparql_queries import GET_ELEMENT_AND_TYPE
from ..modules.utils_graph import ontouml_ref, load_ontouml_vocabulary
LOGGER = initialize_... | OntoUML/ontouml-json2graph | json2graph/decoder/decode_general.py | .py | ce0c11bff38544bd | 7.59 | 14 |
"""JSON decode functions."""
from rdflib import Graph, URIRef, Literal, RDF, XSD
from ..decoder.decode_general import clean_null_data, count_elements_graph
from ..decoder.decode_obj_class import create_class_properties
from ..decoder.decode_obj_diagram import create_diagram_properties
from ..decoder.decode_obj_elemen... | OntoUML/ontouml-json2graph | json2graph/decoder/decode_main.py | .py | 7e7cde44aef0bc5e | 7.59 | 14 |
"""Functions to decode specificities of the object Diagram.
Function's nomenclatures:
- Functions that set one property are named: set_<subject>_<predicate>_<object>.
- Functions that set multiple object properties are named: set_<subject>_relations.
- Functions that set multiple data properties are named:... | OntoUML/ontouml-json2graph | json2graph/decoder/decode_obj_diagram.py | .py | 3d24e2b82df5a71b | 7.59 | 14 |
"""Functions to decode specificities of the object ElementView.
Function's nomenclatures:
- Functions that set one property are named: set_<subject>_<predicate>_<object>.
- Functions that set multiple object properties are named: set_<subject>_relations.
- Functions that set multiple data properties are na... | OntoUML/ontouml-json2graph | json2graph/decoder/decode_obj_elementview.py | .py | 573ae8e8d4903b96 | 7.59 | 14 |
"""Functions to decode specificities of the object Generalization.
Function's nomenclatures:
- Functions that set one property are named: set_<subject>_<predicate>_<object>.
- Functions that set multiple object properties are named: set_<subject>_relations.
- Functions that set multiple data properties are... | OntoUML/ontouml-json2graph | json2graph/decoder/decode_obj_generalization.py | .py | 8200158d48a78355 | 7.59 | 14 |
"""Functions to decode specificities of the object GeneralizationSet.
Function's nomenclatures:
- Functions that set one property are named: set_<subject>_<predicate>_<object>.
- Functions that set multiple object properties are named: set_<subject>_relations.
- Functions that set multiple data properties ... | OntoUML/ontouml-json2graph | json2graph/decoder/decode_obj_generalizationset.py | .py | 9e023adf21812bd8 | 7.59 | 14 |
"""Functions to decode specificities of the object Package.
Function's nomenclatures:
- Functions that set one property are named: set_<subject>_<predicate>_<object>.
- Functions that set multiple object properties are named: set_<subject>_relations.
- Functions that set multiple data properties are named:... | OntoUML/ontouml-json2graph | json2graph/decoder/decode_obj_package.py | .py | 53d0c58ddbfa0bf4 | 7.59 | 14 |
"""Functions to decode specificities of the object Path.
Function's nomenclatures:
- Functions that set one property are named: set_<subject>_<predicate>_<object>.
- Functions that set multiple object properties are named: set_<subject>_relations.
- Functions that set multiple data properties are named: se... | OntoUML/ontouml-json2graph | json2graph/decoder/decode_obj_path.py | .py | 08631157e7d5f848 | 7.59 | 14 |
"""Functions to decode specificities of the object Project.
Function's nomenclatures:
- Functions that set one property are named: set_<subject>_<predicate>_<object>.
- Functions that set multiple object properties are named: set_<subject>_relations.
- Functions that set multiple data properties are named:... | OntoUML/ontouml-json2graph | json2graph/decoder/decode_obj_project.py | .py | 2a2bc1ea7d3b6b29 | 7.59 | 14 |
"""Functions to decode specificities of the object Property.
Function's nomenclatures:
- Functions that set one property are named: set_<subject>_<predicate>_<object>.
- Functions that set multiple object properties are named: set_<subject>_relations.
- Functions that set multiple data properties are named... | OntoUML/ontouml-json2graph | json2graph/decoder/decode_obj_property.py | .py | a98ec006b91dd7d3 | 7.59 | 14 |
"""Functions to decode specificities of the object RectangularShare.
Function's nomenclatures:
- Functions that set one property are named: set_<subject>_<predicate>_<object>.
- Functions that set multiple object properties are named: set_<subject>_relations.
- Functions that set multiple data properties a... | OntoUML/ontouml-json2graph | json2graph/decoder/decode_obj_rectangularshape.py | .py | 9eaa14b19cabc4c1 | 7.59 | 14 |
"""Functions to decode specificities of the object Relation.
Function's nomenclatures:
- Functions that set one property are named: set_<subject>_<predicate>_<object>.
- Functions that set multiple object properties are named: set_<subject>_relations.
- Functions that set multiple data properties are named... | OntoUML/ontouml-json2graph | json2graph/decoder/decode_obj_relation.py | .py | a96dc3f22b733603 | 7.59 | 14 |
"""Validate OntoUML cardinalities and apply the configured handling policy."""
import re
import warnings
INVALID_CARDINALITY_POLICIES = ("preserve", "repair", "error")
_EXACT_CARDINALITY = re.compile(r"^[0-9]+$")
_RANGE_CARDINALITY = re.compile(r"^(?P<lower>[0-9]+)\.\.(?P<upper>[0-9]+|\*)$")
_REPAIR_PATTERNS = (
... | OntoUML/ontouml-json2graph | json2graph/modules/cardinalities.py | .py | 1440b5268032178a | 7.59 | 14 |
"""Create deterministic, content-derived namespaces for OntoUML JSON documents."""
import hashlib
import json
import uuid
from typing import Any
from urllib.parse import urlsplit
# This namespace is derived once from the JSON2Graph persistent project URI with
# uuid.uuid5(uuid.NAMESPACE_URL, "https://w3id.org/ontouml... | OntoUML/ontouml-json2graph | json2graph/modules/content_identity.py | .py | e237351ad49b3147 | 7.59 | 14 |
"""IO functions used in diverse occasions."""
import json
import os
import warnings
from rdflib import Graph, URIRef
from .errors import report_error_io_read, report_error_io_write
from .logger import initialize_logger
from .utils_graph import rename_uriref_resource, fix_uri
LOGGER = initialize_logger()
class JSO... | OntoUML/ontouml-json2graph | json2graph/modules/input_output.py | .py | 9836808adcf822a1 | 7.59 | 14 |
"""Warning messages generated during the decoding process to be displayed to users must be concentrated in this module \
whenever possible."""
import inspect
from . import arguments as args
from .errors import report_error_end_of_switch
from .logger import initialize_logger
from ..decoder.decode_general import get_st... | OntoUML/ontouml-json2graph | json2graph/modules/messages.py | .py | 8a0a7b3ee64bd355 | 7.59 | 14 |
"""Validate diagrammatic references to model elements and apply the configured policy."""
import warnings
UNRESOLVED_MODEL_ELEMENT_POLICIES = ("preserve", "omit", "error")
class UnresolvedModelElementWarning(UserWarning):
"""Warn that an ElementView references an element absent from the project model."""
clas... | OntoUML/ontouml-json2graph | json2graph/modules/model_element_references.py | .py | 9fbc3b17d6aac97f | 7.59 | 14 |
"""Handle path-point order that the OntoUML Vocabulary cannot represent."""
import warnings
from collections.abc import Iterable
from rdflib import Graph, Literal, RDFS, URIRef
PATH_ORDER_POLICIES = ("warn", "comment")
class PathPointOrderWarning(UserWarning):
"""Warn that path-point order is absent from the v... | OntoUML/ontouml-json2graph | json2graph/modules/path_order.py | .py | e7bff35c24b7228c | 7.59 | 14 |
"""Validation helpers for legacy textual values on diagrammatic Text shapes."""
import warnings
class UnsupportedTextValueWarning(UserWarning):
"""Warn that a Text shape contains content unsupported by the vocabulary."""
def warn_if_text_value_is_unsupported(text_shape: dict) -> None:
"""Warn when a legacy... | OntoUML/ontouml-json2graph | json2graph/modules/text_values.py | .py | 6a91ef1055340877 | 7.59 | 14 |
"""Build optional provenance metadata for OntoUML JSON transformations."""
import hashlib
import json
from datetime import datetime, timezone
from functools import lru_cache
from pathlib import Path
from typing import Mapping
from rdflib import BNode, Graph, Literal, Namespace, RDF, URIRef, XSD
from .metadata import... | OntoUML/ontouml-json2graph | json2graph/modules/transformation_metadata.py | .py | ca982004f015e632 | 7.59 | 14 |
"""Util functions related to graphs."""
import os
import urllib
from rdflib import Graph, URIRef
from .errors import report_error_io_read
from .logger import initialize_logger
from .metadata import METADATA
LOGGER = initialize_logger()
def ontouml_ref(entity: str) -> URIRef:
"""Receive the name of the OntoUML... | OntoUML/ontouml-json2graph | json2graph/modules/utils_graph.py | .py | 3bd7947aaa3c0ef5 | 7.59 | 14 |
"""Functions that performs validations for different functions or parameters used in the software."""
import inspect
import os
from .errors import report_error_invalid_parameter, report_error_requirement_not_met
def validate_arg_input(input_path: str, decode_all: bool) -> None:
"""Validate the input path receiv... | OntoUML/ontouml-json2graph | json2graph/modules/utils_validations.py | .py | bebc9e686e002a98 | 7.59 | 14 |
"""Auxiliary test functions."""
import glob
import os
from rdflib import Graph
from rdflib.compare import graph_diff, to_isomorphic
from json2graph.modules import arguments as args
from json2graph.modules.input_output import safe_write_graph_file
from json2graph.modules.metadata import METADATA
from json2graph.modul... | OntoUML/ontouml-json2graph | json2graph/tests/test_aux.py | .py | faf3a8ee6a83332e | 8.09 | 14 |
"""Validate generated references and executable documentation examples."""
import shlex
import shutil
import subprocess
import sys
from pathlib import Path
from rdflib import RDF, Graph, Namespace
from update_documentation import CLI_REFERENCE_RELATIVE_PATH, render_cli_help
REPOSITORY_ROOT = Path(__file__).resolve(... | OntoUML/ontouml-json2graph | json2graph/tests/test_documentation.py | .py | 53bbf5838e8c4859 | 8.09 | 14 |
"""
Non-interactive cookie-file check for the `cookie` CLI subcommand.
Reports whether a cookie file is configured/auto-detected and whether it
looks like a valid YouTube cookies export, or prints setup guidance if not.
Usage: python src/cookie_check.py
"""
import sys
from pathlib import Path
sys.path.insert(0, str(... | MGPoirot/web2mp3 | src/cookie_check.py | .py | d6504f40f4275d43 | 7.45 | 7 |
from initialize import music_dir, daemon_dir, log_dir, disp_daemons, glob, Path
import logging
import subprocess
import time
from utils import get_url_platform, get_path_components, track_exists, clip_path_length, call_with_backoff
import os
import index
from download_errors import classify_download_error
from tag_man... | MGPoirot/web2mp3 | src/download_daemon.py | .py | 82620e2f0df262af | 7.45 | 7 |
"""Classify yt-dlp / download exceptions as permanent vs retryable."""
from __future__ import annotations
import re
from typing import Literal
Kind = Literal["permanent", "retryable"]
# Checked first so cookie/bot/network wording wins over a generic "unavailable".
_RETRYABLE_PATTERNS = (
re.compile(r"sign in to ... | MGPoirot/web2mp3 | src/download_errors.py | .py | 847c1a41332d9eb9 | 7.45 | 7 |
"""
PTY-driven subprocess runner.
Each submission spawns a fresh `python src/main.py --sync <url>` attached to
a pseudo-terminal (not a plain pipe) -- see GUI_PLAN.md for why a PTY is
needed: it's what makes the child's stdout line-buffered and its input()
prompts flush immediately, exactly like a real interactive ter... | MGPoirot/web2mp3 | src/gui/runner.py | .py | 2910f2c9c19a0c23 | 7.45 | 7 |
"""
SQLite-backed GUI submission history, mirroring src/index.py's pattern.
Each row tracks one GUI submission (one URL, one spawned CLI subprocess).
The full live/finished transcript is stored separately as plain text in
TRANSCRIPTS_DIR, named by submission id.
Uses a fresh short-lived connection per call rather tha... | MGPoirot/web2mp3 | src/gui/sessions.py | .py | 9a513259c969044a | 7.45 | 7 |
from initialize import index_path, Path
from utils import input_is
from typing import List, Optional, Tuple
import json
import sqlite3
import sys
import time
DB_PATH = index_path / "index.sqlite3"
_conn: sqlite3.Connection | None = None
def _ensure_schema(conn: sqlite3.Connection) -> None:
conn.execute(
... | MGPoirot/web2mp3 | src/index.py | .py | 1f3536eb35fd3e24 | 7.45 | 7 |
from urllib.error import HTTPError
from spotipy.oauth2 import SpotifyOAuth
import os
import shutil
import spotipy
import eyed3
import pathlib
import time
from glob import glob as dumb_glob
from typing import List
eyed3.log.setLevel("ERROR")
class Path(type(pathlib.Path())):
# Subclass from pathlib.Path that ad... | MGPoirot/web2mp3 | src/initialize.py | .py | fd1002e636da6741 | 7.45 | 7 |
from __future__ import annotations
import logging
import sys
import time
from logging.handlers import RotatingFileHandler
from pathlib import Path
from typing import Optional
def configure_logger(
name: str = "web2mp3",
log_file: Optional[str | Path] = None,
*,
console: bool = True,
level: int = ... | MGPoirot/web2mp3 | src/logging_setup.py | .py | e7fdc55a4343396b | 7.45 | 7 |
import initialize
from utils import _parse_retry_after_seconds
from tag_manager import get_track_tags, manual_track_tags
from spotipy.exceptions import SpotifyException
import requests
import logging
from typing import Tuple, List
# PSA: strictly define all substring patterns to avoid conflicts
# the name of the modul... | MGPoirot/web2mp3 | src/modules/spotify.py | .py | 9783307fff0a8ccb | 7.45 | 7 |
from initialize import music_dir, Path
import pickle
import os
import inspect
from datetime import datetime
import json
import sys
import re
from glob import iglob
from time import sleep
import random
from importlib import import_module
from json.decoder import JSONDecodeError
from collections.abc import Iterable
impor... | MGPoirot/web2mp3 | src/utils.py | .py | ffd7c0434f1a395d | 7.45 | 7 |
from abc import ABC, abstractmethod
from collections.abc import Iterable, Mapping
from typing import Final, Literal
from luxonis_ml.typing import LoaderMultiOutput, Params
from luxonis_ml.utils import AutoRegisterMeta, Registry
AUGMENTATION_ENGINES: Final[Registry[type["AugmentationEngine"]]] = Registry(
name="au... | luxonis/luxonis-ml | luxonis_ml/data/augmentations/base_engine.py | .py | 0f42e2157b2d2fa8 | 7.65 | 19 |
import random
from typing import Any
import albumentations as A
import numpy as np
from albumentations.core.composition import TransformsSeqType
from loguru import logger
from typing_extensions import override
from .batch_transform import BatchTransform
from .utils import instance_count, yield_batches
class BatchCo... | luxonis/luxonis-ml | luxonis_ml/data/augmentations/batch_compose.py | .py | 8b53a5c04b0230c4 | 7.65 | 19 |
from typing import Any
import albumentations as A
import cv2
import numpy as np
from typing_extensions import override
from luxonis_ml.typing import RGB
from luxonis_ml.utils.color import Color, ColorLike
class LetterboxResize(A.DualTransform):
"""Augmentation that resizes an image with padding to
maintain ... | luxonis/luxonis-ml | luxonis_ml/data/augmentations/custom/letterbox_resize.py | .py | 4d913eb66fd92045 | 7.65 | 19 |
from typing import Any
from pydantic import Field, field_validator
from typing_extensions import deprecated
from luxonis_ml.data.utils import ImageType, MediaType
from luxonis_ml.typing import BaseModelExtraForbid
@deprecated(
"LuxonisComponent is deprecated and will be removed in a future release."
)
class Lux... | luxonis/luxonis-ml | luxonis_ml/data/datasets/source.py | .py | 4758b0553d1e6088 | 7.65 | 19 |
from abc import ABC, abstractmethod
from pathlib import Path
from typing import TYPE_CHECKING
if TYPE_CHECKING:
from luxonis_ml.data.exporters.exporter_utils import PreparedLDF
class BaseExporter(ABC):
"""Base class for dataset exporters.
Attributes:
dataset_identifier: Name or identifier used f... | luxonis/luxonis-ml | luxonis_ml/data/exporters/base_exporter.py | .py | 0d867bde0af9aa65 | 7.65 | 19 |
"""Rewriting exported native records to older LDF versions.
`DatasetRecord` forbids extra fields, so a record written by a newer
luxonis-ml fails to validate on an older install -- LDF 2.1 added
``sample_metadata``, which nothing older accepts. Exporting to an older
version therefore drops every field introduced above... | luxonis/luxonis-ml | luxonis_ml/data/exporters/ldf_downgrade.py | .py | b655ad1a7da78d8e | 7.65 | 19 |
import csv
import json
from collections import OrderedDict, defaultdict
from pathlib import Path
from typing import Any, cast
import numpy as np
from PIL import Image
from luxonis_ml.data.exporters.base_exporter import BaseExporter
from luxonis_ml.data.exporters.exporter_utils import (
PreparedLDF,
check_grou... | luxonis/luxonis-ml | luxonis_ml/data/exporters/segmentation_mask_directory_exporter.py | .py | 46c13b5ec7ba0276 | 7.65 | 19 |
"""Use RWZI data to create a model consisting of FlowBoundary (RWZI) and Terminal (effluent locations)."""
# %% imports
import logging
from collections import Counter
import contextily as ctx
import geopandas as gpd
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from ribasim import Node
from r... | Deltares/Ribasim-NL | notebooks/create_rwzi_model.py | .py | 62b2c8dcff1f865e | 7.42 | 6 |
import base64
import datetime
import hashlib
import hmac
import json
import time
from typing import Dict, Optional, Union, List
import requests
from ._credentials import AccessKey, AuthToken
from ._errors import LaraApiError
class LaraObject:
"""
This serves as a base class for all Lara API returned objects... | translated/lara-python | src/lara_sdk/_client.py | .py | 3da5396f53c46fdf | 7.5 | 9 |
from typing import Any
from fontTools.misc.roundTools import otRound
from foundrytools import Font
class FixItalicAngleError(Exception):
"""Raised when an error occurs while fixing the italic angle of a font."""
def run(
font: Font, min_slant: float = 2.0, italic: bool = True, oblique: bool = False
) -> d... | ftCLI/FoundryTools | foundrytools/app/fix_italic_angle.py | .py | b94400f8fc112197 | 7.54 | 11 |
# pylint: disable=import-outside-toplevel
from collections import Counter
from foundrytools import Font
class FixMonospaceError(Exception):
"""Raised when an error occurs in the fix_monospace method."""
# Copied from fontbakery/profiles/shared_conditions.py
def _get_glyph_metrics_stats(font: Font) -> dict[str,... | ftCLI/FoundryTools | foundrytools/app/fix_monospace.py | .py | 8d725f4311e53631 | 7.54 | 11 |
from typing import Any
from afdko.otfautohint.__main__ import _validate_path
from afdko.otfautohint.autohint import ACOptions, FontInstance, fontWrapper, openFont
from foundrytools import Font
from foundrytools.utils.misc import restore_flavor
from foundrytools.utils.path_tools import get_temp_file_path
class OTFAu... | ftCLI/FoundryTools | foundrytools/app/otf_autohint.py | .py | e40ef5e0c9789c66 | 7.54 | 11 |
from afdko import checkoutlinesufo
from foundrytools import Font
from foundrytools.utils.misc import restore_flavor
from foundrytools.utils.path_tools import get_temp_file_path
class CheckOutlinesError(Exception):
"""Raised when an error occurs while checking the CFF table."""
def run(font: Font, drop_hinting_... | ftCLI/FoundryTools | foundrytools/app/otf_check_outlines.py | .py | 4bda239ce73ac6e9 | 7.54 | 11 |
from foundrytools import Font
class OTFDehintError(Exception):
"""Raised when an error occurs while dehinting a font."""
def run(font: Font, drop_hinting_data: bool = False) -> bool:
"""
Dehint a PostScript font.
:param font: The font to dehint.
:type font: Font
:param drop_hinting_data: If... | ftCLI/FoundryTools | foundrytools/app/otf_dehint.py | .py | 2c3196c4cabeb87e | 7.54 | 11 |
"""
This module provides functionality to recalculate the standard horizontal and vertical stem widths
(**StdHW** and **StdVW**) and the horizontal and vertical stem snap arrays (**StemSnapH** and
**StemSnapV**) for OpenType font files.
The module includes the following key functions:
1. **_get_report**:
Generates... | ftCLI/FoundryTools | foundrytools/app/otf_recalc_stems.py | .py | b3120616aac5a100 | 7.54 | 11 |
from collections import Counter
from typing import Literal
from foundrytools import Font
UPPERCASE_LETTERS = [chr(i) for i in range(65, 91)] # A-Z
UPPERCASE_DESCENDERS = ["J", "Q"]
LOWERCASE_LETTERS = [chr(i) for i in range(97, 123)] # a-z
LOWERCASE_DESCENDERS = ["f", "g", "j", "p", "q", "y"]
LOWERCASE_ASCENDERS = ... | ftCLI/FoundryTools | foundrytools/app/otf_recalc_zones.py | .py | b4cc5b7d2b4f1316 | 7.54 | 11 |
from io import BytesIO
from fontTools.ttLib import TTFont
from ttfautohint import ttfautohint
from foundrytools import Font
from foundrytools.constants import T_HEAD
class TTFAutohintError(Exception):
"""An error that occurred during TrueType auto-hinting."""
def run(font: Font) -> bool:
"""
Autohint ... | ftCLI/FoundryTools | foundrytools/app/ttf_autohint.py | .py | 892f4a09094ae7a1 | 7.54 | 11 |
from dehinter.font import dehint
from foundrytools import Font
class TTFDehintError(Exception):
"""An error occurred while dehinting a TrueType font."""
def run(font: Font) -> bool:
"""
Dehint a TrueType font.
:param font: The Font to dehint.
:type font: Font
:raises NotImplementedError: I... | ftCLI/FoundryTools | foundrytools/app/ttf_dehint.py | .py | 4ed68add19fa4431 | 7.54 | 11 |
from typing import cast
from fontTools.ttLib.tables._f_v_a_r import Axis, NamedInstance
from fontTools.varLib.instancer import OverlapMode, instantiateVariableFont
from foundrytools import Font
from foundrytools.constants import T_GSUB, NameIds
class Var2StaticError(Exception):
"""Raised when an error occurs du... | ftCLI/FoundryTools | foundrytools/app/var2static.py | .py | b6efea0489044641 | 7.54 | 11 |
import contextlib
from typing import Any
from fontTools.cffLib import PrivateDict, TopDict
from fontTools.pens.recordingPen import RecordingPen
from fontTools.pens.roundingPen import RoundingPen
from fontTools.pens.t2CharStringPen import T2CharStringPen
from fontTools.ttLib import TTFont
from fontTools.ttLib.tables.C_... | ftCLI/FoundryTools | foundrytools/core/tables/cff_.py | .py | ba56ab7b68a788d6 | 7.54 | 11 |
from copy import deepcopy
from fontTools.ttLib import TTFont
from fontTools.ttLib.tables._c_m_a_p import table__c_m_a_p
from foundrytools.constants import T_CMAP
from foundrytools.core.tables.default import DefaultTbl
from foundrytools.lib.unicode import (
cmap_from_glyph_names,
setup_character_map,
updat... | ftCLI/FoundryTools | foundrytools/core/tables/cmap.py | .py | 67a440b859312750 | 7.54 | 11 |
from typing import Generic, TypeVar
from fontTools.ttLib import TTFont
from fontTools.ttLib.tables.DefaultTable import DefaultTable
from foundrytools.utils.bits_tools import update_bit
T = TypeVar("T", bound=DefaultTable)
class DefaultTbl(Generic[T]):
"""
Manages font table data with functionality for dete... | ftCLI/FoundryTools | foundrytools/core/tables/default.py | .py | ce1754c553f2947f | 7.54 | 11 |
from fontTools.ttLib import TTFont
from fontTools.ttLib.tables._f_v_a_r import table__f_v_a_r
from foundrytools.constants import T_FVAR
from foundrytools.core.tables.default import DefaultTbl
class FvarTable(DefaultTbl): # pylint: disable=too-few-public-methods
"""This class extends the fontTools ``fvar`` table... | ftCLI/FoundryTools | foundrytools/core/tables/fvar.py | .py | e7a609c9eab9d079 | 7.54 | 11 |
from fontTools.ttLib import TTFont
from fontTools.ttLib.tables.G_D_E_F_ import table_G_D_E_F_
from foundrytools.constants import T_GDEF
from foundrytools.core.tables.default import DefaultTbl
class GdefTable(DefaultTbl): # pylint: disable=too-few-public-methods
"""This class is a wrapper for the ``GDEF`` table.... | ftCLI/FoundryTools | foundrytools/core/tables/gdef.py | .py | bf476a93452ec7de | 7.54 | 11 |
from fontTools.pens.recordingPen import DecomposingRecordingPen
from fontTools.pens.ttGlyphPen import TTGlyphPen
from fontTools.ttLib import TTFont
from fontTools.ttLib.tables._g_l_y_f import table__g_l_y_f
from foundrytools.constants import T_FPGM, T_GLYF
from foundrytools.core.tables.default import DefaultTbl
from f... | ftCLI/FoundryTools | foundrytools/core/tables/glyf.py | .py | a6709ffd10bb0554 | 7.54 | 11 |
import logging
from fontTools.ttLib import TTFont
from fontTools.ttLib.tables.G_S_U_B_ import table_G_S_U_B_
from foundrytools.constants import T_GSUB
from foundrytools.core.tables.default import DefaultTbl
logger = logging.getLogger(__name__)
class GsubTable(DefaultTbl): # pylint: disable=too-few-public-methods
... | ftCLI/FoundryTools | foundrytools/core/tables/gsub.py | .py | 0a5a3ce6978fcb26 | 7.54 | 11 |
from fontTools.ttLib import TTFont
from fontTools.ttLib.tables._h_m_t_x import table__h_m_t_x
from foundrytools.constants import T_HMTX
from foundrytools.core.tables.default import DefaultTbl
class HmtxTable(DefaultTbl): # pylint: disable=too-few-public-methods
"""This class extends the fontTools ``hmtx`` table... | ftCLI/FoundryTools | foundrytools/core/tables/hmtx.py | .py | 1e215132ce30ea95 | 7.54 | 11 |
from fontTools.ttLib import TTFont
from fontTools.ttLib.tables._k_e_r_n import table__k_e_r_n
from foundrytools.constants import T_CMAP, T_KERN
from foundrytools.core.tables.default import DefaultTbl
class KernTable(DefaultTbl): # pylint: disable=too-few-public-methods
"""This class extends the fontTools ``kern... | ftCLI/FoundryTools | foundrytools/core/tables/kern.py | .py | 02a3957aa0daec2a | 7.54 | 11 |
# pylint: disable=too-many-public-methods
from collections.abc import Iterable
from copy import deepcopy
from fontTools.misc.timeTools import timestampToString
from fontTools.ttLib import TTFont
from fontTools.ttLib.tables._n_a_m_e import (
_MAC_LANGUAGE_CODES,
_WINDOWS_LANGUAGE_CODES,
NameRecord,
tabl... | ftCLI/FoundryTools | foundrytools/core/tables/name.py | .py | e2bfaa7246711a51 | 7.54 | 11 |
from collections.abc import Callable, Generator
from dataclasses import dataclass
from pathlib import Path
from fontTools.ttLib.ttCollection import TTCollection
from fontTools.ttLib.ttFont import TTLibError
from foundrytools.core.font import Font
__all__ = ["FinderError", "FinderFilter", "FinderOptions", "FontFinder... | ftCLI/FoundryTools | foundrytools/lib/font_finder.py | .py | dbf27c5062c4f7c7 | 7.54 | 11 |
import itertools
from collections.abc import Callable, Mapping
import pathops
from fontTools.cffLib import CFFFontSet
from fontTools.misc.psCharStrings import T2CharString
from fontTools.misc.roundTools import noRound, otRound
from fontTools.pens.t2CharStringPen import T2CharStringPen
from fontTools.pens.ttGlyphPen im... | ftCLI/FoundryTools | foundrytools/lib/pathops.py | .py | de6bb58019461823 | 7.54 | 11 |
def is_nth_bit_set(x: int, n: int) -> bool:
"""
Check if the nth bit of an integer x is set.
:param x: The number to check
:type x: int
:param n: The bit to check
:type n: int
:return: True if the nth bit is set, False otherwise
:rtype: bool
"""
return bool(x & (1 << n))
def s... | ftCLI/FoundryTools | foundrytools/utils/bits_tools.py | .py | eaeebf8e86245c78 | 7.54 | 11 |
from typing import Any
from scim2_models import Resource
from scim2_models import ResourceType
from ..utils import CheckContext
from ..utils import CheckResult
from ..utils import Status
from ..utils import check_result
from ..utils import checker
def _model_from_resource_type(
context: CheckContext, resource_t... | python-scim/scim2-tester | scim2_tester/checkers/resource_get.py | .py | 513b16d92d96d99c | 7.98 | 8 |
from scim2_models import ServiceProviderConfig
from ..utils import CheckContext
from ..utils import CheckResult
from ..utils import Status
from ..utils import check_result
from ..utils import checker
from ._discovery_utils import _test_discovery_endpoint_methods
@checker("*", "discovery", "service-provider-config")
... | python-scim/scim2-tester | scim2_tester/checkers/service_provider_config.py | .py | 40a85c4d59190039 | 7.98 | 8 |
"""Utility functions for discovering available tags and resources."""
from scim2_tester.utils import get_registered_tags
def get_all_available_tags() -> list[str]:
"""Get all available tags from the global registry.
This function returns tags that have been registered by checker decorators
throughout th... | python-scim/scim2-tester | scim2_tester/discovery.py | .py | 461787ed7c7f49d0 | 7.98 | 8 |
import base64
import random
import uuid
from enum import Enum
from inspect import isclass
from typing import TYPE_CHECKING
from typing import Any
from pydantic import Base64Bytes
from pydantic import BaseModel
from scim2_models import ComplexAttribute
from scim2_models import Extension
from scim2_models import Mutabil... | python-scim/scim2-tester | scim2_tester/filling.py | .py | 5a35806a1e7f6d3d | 7.98 | 8 |
import functools
import sys
import types
from dataclasses import dataclass
from dataclasses import field
from enum import Enum
from enum import auto
from typing import Any
from scim2_client import SCIMClientError
from scim2_client.engines.httpx import SyncSCIMClient
from scim2_models import BaseModel
from scim2_models... | python-scim/scim2-tester | scim2_tester/utils.py | .py | 17e47a0d91313eef | 7.98 | 8 |
"""Test the main checker functionality."""
import pytest
from httpx import Client
from scim2_client.engines.httpx import SyncSCIMClient
from scim2_client.engines.werkzeug import TestSCIMClient
from werkzeug.test import Client as WerkzeugClient
from scim2_tester.checker import check_server
from scim2_tester.utils impo... | python-scim/scim2-tester | tests/test_checker.py | .py | 3a85dcfebee6a5bd | 7.98 | 8 |
"""Test discovery endpoints functionality."""
from scim2_client import SCIMClientError
from scim2_tester.checkers._discovery_utils import _test_discovery_endpoint_methods
from scim2_tester.utils import Status
def test_discovery_endpoint_methods_return_405(httpserver, testing_context):
"""Test that discovery end... | python-scim/scim2-tester | tests/test_discovery.py | .py | 0337707b482d4b1d | 7.98 | 8 |
"""Test service provider config functionality."""
from scim2_models import Context
from scim2_models import ServiceProviderConfig
from scim2_tester.checkers.service_provider_config import (
service_provider_config_endpoint,
)
from scim2_tester.checkers.service_provider_config import (
service_provider_config_... | python-scim/scim2-tester | tests/test_service_provider_config.py | .py | 8af8206d47c7deab | 7.98 | 8 |
__all__ = [
"Auth",
"JwtToken",
]
import time
from dataclasses import dataclass
from typing import Optional
import jwt
@dataclass
class Auth:
"""Authentication details for the ArangoDB instance.
Attributes:
username (str): Username.
password (str): Password.
encoding (str): ... | arangodb/python-arango-async | arangoasync/auth.py | .py | d7a6a9cf5fc8bc00 | 7.6 | 15 |
__all__ = ["Cursor"]
from collections import deque
from typing import Any, Deque, List, Optional
from arangoasync.errno import HTTP_NOT_FOUND
from arangoasync.exceptions import (
CursorCloseError,
CursorCountError,
CursorEmptyError,
CursorNextError,
CursorStateError,
)
from arangoasync.executor i... | arangodb/python-arango-async | arangoasync/cursor.py | .py | 45024eb4da71131e | 7.6 | 15 |
__all__ = [
"HTTPClient",
"AioHTTPClient",
"DefaultHTTPClient",
]
from abc import ABC, abstractmethod
from ssl import SSLContext, create_default_context
from typing import Any, Optional
from aiohttp import (
BaseConnector,
BasicAuth,
ClientSession,
ClientTimeout,
TCPConnector,
clie... | arangodb/python-arango-async | arangoasync/http.py | .py | c64c672cc6ea1411 | 7.6 | 15 |
__all__ = ["AsyncJob"]
import asyncio
from typing import Callable, Generic, Optional, TypeVar
from arangoasync.connection import Connection
from arangoasync.errno import HTTP_NOT_FOUND
from arangoasync.exceptions import (
AsyncJobCancelError,
AsyncJobClearError,
AsyncJobResultError,
AsyncJobStatusErr... | arangodb/python-arango-async | arangoasync/job.py | .py | 07d70f0f3c5a61f9 | 7.6 | 15 |
__all__ = [
"Method",
"Request",
]
from enum import Enum, auto
from typing import Any, Optional
from arangoasync.auth import Auth
from arangoasync.typings import Params, RequestHeaders
from arangoasync.version import __version__
class Method(Enum):
"""HTTP methods enum: GET, POST, PUT, PATCH, DELETE, HE... | arangodb/python-arango-async | arangoasync/request.py | .py | cfdf8c7a84a1ffa4 | 7.6 | 15 |
__all__ = [
"HostResolver",
"SingleHostResolver",
"RoundRobinHostResolver",
"DefaultHostResolver",
"get_resolver",
]
from abc import ABC, abstractmethod
from typing import List, Optional
class HostResolver(ABC):
"""Abstract base class for host resolvers.
Args:
host_count (int): N... | arangodb/python-arango-async | arangoasync/resolver.py | .py | 89cb2640892496bb | 7.6 | 15 |
__all__ = [
"Response",
]
from typing import Optional
from arangoasync.request import Method
from arangoasync.typings import Json, ResponseHeaders
class Response:
"""HTTP response.
Parameters:
method (Method): HTTP method.
url (str): API URL.
headers (dict): Response headers.
... | arangodb/python-arango-async | arangoasync/response.py | .py | 54c9e85a0b72ae1d | 7.6 | 15 |
from uuid import uuid4
def generate_db_name():
"""Generate and return a random database name.
Returns:
str: Random database name.
"""
return f"test_database_{uuid4().hex}"
def generate_col_name():
"""Generate and return a random collection name.
Returns:
str: Random collect... | arangodb/python-arango-async | tests/helpers.py | .py | d34aa5cbedaacb6e | 7.1 | 15 |
import time
import pytest
from arangoasync.auth import JwtToken
from arangoasync.client import ArangoClient
from arangoasync.compression import DefaultCompressionManager
from arangoasync.exceptions import (
AccessTokenCreateError,
AccessTokenDeleteError,
AccessTokenListError,
ServerEncryptionError,
)
... | arangodb/python-arango-async | tests/test_client.py | .py | 1bb4fa24aa965c6f | 7.1 | 15 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.