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 |
|---|---|---|---|---|---|---|
"""API management class and base class for the different end points."""
from abc import ABC
from collections.abc import Mapping
from dataclasses import dataclass
from typing import Any, TypedDict, TypeVar
import orjson
from ..errors import (
AiounifiException,
LoginRequired,
NoPermission,
TwoFaTokenR... | Kane610/aiounifi | aiounifi/models/api.py | .py | 4be9e5dde43e9a97 | 7.98 | 89 |
"""Clients are devices on a UniFi network."""
from dataclasses import dataclass
from typing import Self, TypedDict, cast
from .api import ApiItem, ApiRequest
class TypedClient(TypedDict):
"""Client type definition."""
_id: str
_is_guest_by_uap: bool
_is_guest_by_ugw: bool
_is_guest_by_usw: bool... | Kane610/aiounifi | aiounifi/models/client.py | .py | 51d791d8e51c5909 | 7.98 | 89 |
"""Python library to enable integration between Home Assistant and UniFi."""
from dataclasses import KW_ONLY, dataclass
from ssl import SSLContext
from typing import Literal
from aiohttp import ClientSession
@dataclass
class Configuration:
"""Console configuration."""
session: ClientSession
host: str
... | Kane610/aiounifi | aiounifi/models/configuration.py | .py | da2ae6b360b9c64c | 7.98 | 89 |
"""DPI Restrictions as part of a UniFi network."""
from dataclasses import dataclass
from typing import Self, TypedDict
from .api import ApiItem, ApiRequest
class TypedDPIRestrictionApp(TypedDict):
"""DPI restriction app type definition."""
_id: str
apps: list[str]
blocked: bool
cats: list[str]... | Kane610/aiounifi | aiounifi/models/dpi_restriction_app.py | .py | 25621294c6a89263 | 7.98 | 89 |
"""DPI Restrictions as part of a UniFi network."""
from dataclasses import dataclass
from typing import NotRequired, Self, TypedDict
from .api import ApiItem, ApiRequest
@dataclass
class DpiRestrictionGroupListRequest(ApiRequest):
"""Request object for DPI restriction group list."""
@classmethod
def cr... | Kane610/aiounifi | aiounifi/models/dpi_restriction_group.py | .py | f669dd60aa6d8419 | 7.98 | 89 |
"""Event messages on state changes."""
from __future__ import annotations
import enum
import logging
from typing import TypedDict, final
from .api import ApiItem
LOGGER = logging.getLogger(__name__)
class EventKey(enum.Enum):
"""Key as part of event data object.
"data": [{"key": "EVT_LU_Disconnected"}].
... | Kane610/aiounifi | aiounifi/models/event.py | .py | 8ad252fcbba34d3a | 7.98 | 89 |
"""Firewall policies as part of a UniFi network."""
from dataclasses import dataclass
from typing import NotRequired, Self, TypedDict
from .api import ApiItem, ApiRequestV2
class FirewallPolicySchedule(TypedDict):
"""Schedule settings for firewall policy."""
mode: str
repeat_on_days: list[str]
time... | Kane610/aiounifi | aiounifi/models/firewall_policy.py | .py | 9a3e7c69f6d63503 | 7.98 | 89 |
"""Firewall zones as part of a UniFi network."""
from dataclasses import dataclass
from typing import NotRequired, Self, TypedDict
from .api import ApiItem, ApiRequestV2
class TypedFirewallZone(TypedDict):
"""Firewall zone type definition."""
_id: str
name: str
attr_no_edit: bool
default_zone: ... | Kane610/aiounifi | aiounifi/models/firewall_zone.py | .py | 3f291b4d43beb1e0 | 7.98 | 89 |
"""Messages from websocket."""
from __future__ import annotations
from dataclasses import dataclass
import enum
import logging
from typing import Any, Self
LOGGER = logging.getLogger(__name__)
class MessageKey(enum.Enum):
"""Message as part of meta object of event.
"meta": {"rc": "ok", "message": "device:... | Kane610/aiounifi | aiounifi/models/message.py | .py | c74c7922f845e96e | 7.98 | 89 |
"""Object-oriented network configurations as part of a UniFi network."""
from dataclasses import dataclass
from enum import StrEnum
from typing import NotRequired, Self, TypedDict
from .api import ApiItem, ApiRequestV2
class ObjectOrientedNetworkInternetMode(StrEnum):
"""Possible internet access modes for secur... | Kane610/aiounifi | aiounifi/models/object_oriented_network_config.py | .py | ff2c47a47f176090 | 7.98 | 89 |
"""Device outlet implementation."""
import enum
from .api import ApiItem
from .device import TypedDeviceOutletTable
class OutletCapability(enum.IntFlag):
"""Outlet capabilities."""
RELAY = 1
METERING = 2
class Outlet(ApiItem):
"""Represents an outlet."""
raw: TypedDeviceOutletTable
@pro... | Kane610/aiounifi | aiounifi/models/outlet.py | .py | 1155c4a40ec07677 | 7.98 | 89 |
"""Device port implementation."""
from __future__ import annotations
from enum import StrEnum
import logging
from typing import cast
from .api import ApiItem
from .device import TypedDevicePortTable
LOGGER = logging.getLogger(__name__)
class PortMedia(StrEnum):
"""Enum for network port media types."""
GI... | Kane610/aiounifi | aiounifi/models/port.py | .py | 99ab9ddc98a7b820 | 7.98 | 89 |
"""Port forwarding in a UniFi network."""
from dataclasses import dataclass
from typing import NotRequired, Self, TypedDict
from .api import ApiItem, ApiRequest
class TypedPortForward(TypedDict):
"""Port forward type definition."""
_id: str
dst_port: str
enabled: NotRequired[bool]
fwd_port: str... | Kane610/aiounifi | aiounifi/models/port_forward.py | .py | 8bd4cd48f91fd51e | 7.98 | 89 |
"""Site is a specific grouping in a UniFi network."""
from dataclasses import dataclass
from typing import Self, TypedDict
from .api import ApiItem, ApiRequest
class TypedSite(TypedDict):
"""Site description."""
_id: str
attr_hidden_id: str
attr_no_delete: bool
desc: str
name: str
role:... | Kane610/aiounifi | aiounifi/models/site.py | .py | f3caad666258d9cf | 7.98 | 89 |
"""UniFi speedtest models."""
from __future__ import annotations
from dataclasses import dataclass
from typing import Any, NotRequired, TypedDict
from .api import ApiItem, ApiRequest, ApiRequestV2, TypedApiResponse
class TypedSpeedtestStatus(TypedDict):
"""Speedtest status type definition."""
download_mbp... | Kane610/aiounifi | aiounifi/models/speedtest.py | .py | b8f92a5b5cf57c7e | 8.48 | 89 |
"""UniFi system information model."""
from __future__ import annotations
from dataclasses import dataclass
from typing import TypedDict
from .api import ApiItem, ApiRequest
class TypedSystemInfo(TypedDict):
"""System information type definition."""
anonymous_controller_id: str
autobackup: bool
bui... | Kane610/aiounifi | aiounifi/models/system_information.py | .py | 06ad54deafb34672 | 7.98 | 89 |
"""Traffic routes as part of a UniFi network."""
from dataclasses import dataclass
from enum import StrEnum
from typing import NotRequired, Self, TypedDict
from .api import ApiItem, ApiRequestV2
class MatchingTarget(StrEnum):
"""Possible matching targets for a traffic rule."""
DOMAIN = "DOMAIN"
IP = "I... | Kane610/aiounifi | aiounifi/models/traffic_route.py | .py | 9e6abb62e3fe216d | 7.98 | 89 |
"""Traffic rules as part of a UniFi network."""
from dataclasses import dataclass
from typing import NotRequired, Self, TypedDict
from .api import ApiItem, ApiRequestV2
class BandwidthLimit(TypedDict):
"""Bandwidth limit type definition."""
download_limit_kbps: int
enabled: bool
upload_limit_kbps: ... | Kane610/aiounifi | aiounifi/models/traffic_rule.py | .py | d48932ab0aa7b976 | 7.98 | 89 |
"""Hotspot vouchers as part of a UniFi network."""
from dataclasses import dataclass
from datetime import datetime, timedelta
from enum import StrEnum
from typing import NotRequired, Self, TypedDict
from .api import ApiItem, ApiRequest
class VoucherStatus(StrEnum):
"""Voucher status."""
VALID_ONE = "VALID_... | Kane610/aiounifi | aiounifi/models/voucher.py | .py | e9773a90ea316a97 | 7.98 | 89 |
"""WLANs as part of a UniFi network."""
from dataclasses import dataclass
import io
from typing import Any, NotRequired, Self, TypedDict
import segno.helpers
from .api import ApiItem, ApiRequest
class TypedWlan(TypedDict):
"""Wlan type definition."""
_id: str
bc_filter_enabled: bool
bc_filter_list... | Kane610/aiounifi | aiounifi/models/wlan.py | .py | f571c2eee8c8977e | 7.98 | 89 |
#!/usr/bin/env python3
"""Compare two builds measured in interleaved rounds.
``check_benchmark.py`` compares one measurement per side, which is right for the
PR gate: there, both sides are built and measured once in the same job, and
within-job noise is ~0.3%.
That does not hold when the two sides need *separate buil... | namecheap/fast_mail_parser | .github/scripts/ab_median.py | .py | 4cf3525c0e1c8744 | 7.91 | 66 |
#!/usr/bin/env python3
"""Generate the RFC-feature .eml corpus used by tests/test_rfc_corpus.py.
The goal is a stable, checked-in set of messages that exercise the email/MIME
RFCs fast_mail_parser is expected to handle, so the parser's behavior on each
feature is locked against regressions (including across native-bin... | namecheap/fast_mail_parser | tests/generate_rfc_corpus.py | .py | 267cce4bb6001e1b | 8.41 | 66 |
from fast_mail_parser import PyMail, parse_email
def test__attachments_are_available(attachment_mail: PyMail):
# The fixture is a multipart/mixed with an HTML body, an inline PNG, and a
# plain-text body. Only the PNG is an attachment: the container is MIME
# structure and the two text parts are bodies.
... | namecheap/fast_mail_parser | tests/test_attachments.py | .py | 75a9a5209edc9f7d | 7.41 | 66 |
"""Tests for `PyMail.date_parsed`.
`date` stays the raw header string; `date_parsed` resolves it to a
timezone-aware `datetime` in UTC, computed on access.
Expected epochs below are taken from the stdlib's own interpretation
(`email.utils.parsedate_to_datetime`). mailparse and the stdlib agree on offset
handling -- m... | namecheap/fast_mail_parser | tests/test_date_parsed.py | .py | 1334577edff037e2 | 8.41 | 66 |
"""Body-decode error tests for parse_email (issue #24).
Previously `src/mail_parser.rs` decoded part bodies with
`get_body_raw().unwrap_or_default()` / `get_body().unwrap_or_default()`, which
silently turned a failed transfer-encoding decode (e.g. invalid base64) into an
empty body. That hid corruption from the caller... | namecheap/fast_mail_parser | tests/test_decode_errors.py | .py | ee9b0cb1c2c7c854 | 8.41 | 66 |
"""Executes the Python snippets in docs/migrating.md against the built wheel.
A migration guide whose snippets have drifted from the API is worse than no
guide, so the document is the test: every ```python block is extracted and
executed in document order in one shared namespace, exactly as a reader
following the guid... | namecheap/fast_mail_parser | tests/test_docs_snippets.py | .py | c5af709732aa417c | 8.41 | 66 |
"""DoS-hardening tests for parse_email (issue #21).
These exercise the additive guards added in src/mail_parser.rs:
- MAX_INPUT_BYTES = 100 MiB (oversized payload rejection)
- MAX_MIME_DEPTH = 256 (MIME recursion-depth cap)
Both limits sit far above any realistic email, so normal messages parse fine.
"""
... | namecheap/fast_mail_parser | tests/test_dos_limits.py | .py | 2a9d341160e36886 | 8.41 | 66 |
"""Tests for the empty-string sentinel on missing Subject/Date headers.
Contract documented and exercised here:
When a parsed message lacks a ``Subject`` or ``Date`` header, the parser does
NOT raise and does NOT return ``None``. Instead each missing field is reported
as the empty string ``""``.
This mirrors the Rus... | namecheap/fast_mail_parser | tests/test_empty_fields.py | .py | 6e7496002f43d0e7 | 7.41 | 66 |
"""Characterization tests for known-wrong behaviour.
Unlike the rest of the suite, these assert what the parser currently does, not
what it should do. Each one pins an open bug so that:
- the behaviour is described in executable form rather than only in an issue, and
- fixing it is a deliberate act -- the test fails ... | namecheap/fast_mail_parser | tests/test_known_issues.py | .py | a78b8fd49616c6e5 | 8.41 | 66 |
"""Invariants the project relies on but never checked.
Both of these are silent when broken: nothing raises, no test elsewhere notices,
and the damage shows up outside CI -- in a consumer's type checker, or in a
fixture that no longer matches the generator that is supposed to reproduce it.
"""
import functools
import... | namecheap/fast_mail_parser | tests/test_packaging_invariants.py | .py | 547749c041861ca1 | 8.41 | 66 |
"""The panic backstop at the FFI boundary (#102).
A Rust panic does not abort the process -- PyO3 catches it and raises
`pyo3_runtime.PanicException`. But that derives from `BaseException`, so the
`except Exception` around a mail pipeline's parse call does not catch it, and one
crafted message takes the worker down wi... | namecheap/fast_mail_parser | tests/test_panic_backstop.py | .py | 95ebe1302ef5c741 | 8.41 | 66 |
"""Peak memory of a payload handed to the parser (#96).
Every payload used to be copied into Rust-owned memory before any parsing began,
so a batch cost its own size again in duplicates while the caller still held the
originals. Payloads that are `bytes` are now borrowed.
Two things make this measurable at all:
**An... | namecheap/fast_mail_parser | tests/test_payload_memory.py | .py | 3dbad1c6b95656c1 | 8.41 | 66 |
"""Checks the README's Python against the API it documents.
`docs/migrating.md` is executed end to end by `test_docs_snippets.py`, because it
was written to be read top-to-bottom and its snippets define their own inputs.
The README is not like that: its blocks are illustrative and reference a `payload`
the reader supp... | namecheap/fast_mail_parser | tests/test_readme_snippets.py | .py | 789cc23924d5053e | 8.41 | 66 |
"""Differential compatibility suite: fast_mail_parser vs the stdlib `email`.
Every fixture is parsed by both this library and `email` (policy=default), and
the two are compared on the surface they both model: subject, body text,
attachments, headers, addresses, and the date instant.
The point is not that the two agre... | namecheap/fast_mail_parser | tests/test_stdlib_parity.py | .py | 3cd6c87765acebbc | 8.41 | 66 |
# MIT License
#
# Copyright (c) 2020 Aruba, a Hewlett Packard Enterprise company
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights... | aruba/pycentral | pycentral/classic/audit_logs.py | .py | 74d8ed08562a00e2 | 7.89 | 60 |
# MIT License
#
# Copyright (c) 2020 Aruba, a Hewlett Packard Enterprise company
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights... | aruba/pycentral | pycentral/classic/device_inventory.py | .py | 60dd86053852f6e7 | 7.89 | 60 |
# MIT License
#
# Copyright (c) 2020 Aruba, a Hewlett Packard Enterprise company
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights... | aruba/pycentral | pycentral/classic/refresh_api_token.py | .py | e3ce36a6c9d0576f | 7.89 | 60 |
# (C) Copyright 2025 Hewlett Packard Enterprise Development LP.
# MIT License
from pycentral.exceptions.pycentral_error import PycentralError
class LoginError(PycentralError):
"""Exception raised when login or authentication fails.
This exception is raised when authentication to Central fails,
... | aruba/pycentral | pycentral/exceptions/login_error.py | .py | 55fbc040f53ac249 | 7.89 | 60 |
# (C) Copyright 2025 Hewlett Packard Enterprise Development LP.
# MIT License
from typing import Any
class PycentralError(Exception):
"""Base exception class for all pycentral-specific errors.
This exception serves as the base class for all custom exceptions in the pycentral library.
It provides common ... | aruba/pycentral | pycentral/exceptions/pycentral_error.py | .py | fefff4afb2d9c2d2 | 7.89 | 60 |
# (C) Copyright 2025 Hewlett Packard Enterprise Development LP.
# MIT License
from pycentral.exceptions.pycentral_error import PycentralError
class ResponseError(PycentralError):
"""Exception raised when an API response indicates an error.
This exception is raised when the API returns an error response, suc... | aruba/pycentral | pycentral/exceptions/response_error.py | .py | 46dc01aafc501900 | 7.89 | 60 |
# (C) Copyright 2025 Hewlett Packard Enterprise Development LP.
# MIT License
from pycentral.exceptions.pycentral_error import PycentralError
class VerificationError(PycentralError):
"""Exception raised when verification checks fail during pycentral operations.
This exception is raised when verific... | aruba/pycentral | pycentral/exceptions/verification_error.py | .py | 4a8a854c0ea5fc52 | 7.89 | 60 |
# (C) Copyright 2025 Hewlett Packard Enterprise Development LP.
# MIT License
from ..utils import GLP_URLS, generate_url
from ..utils.glp_utils import rate_limit_check, check_progress
import time
# This is the single input size limit for using the POST request endpoint for adding subscriptions.
INPUT_SIZE = 5
# This ... | aruba/pycentral | pycentral/glp/subscriptions.py | .py | acde68042c0f3577 | 7.89 | 60 |
# (C) Copyright 2025 Hewlett Packard Enterprise Development LP.
# MIT License
"""MSP-aware extension of NewCentralBase.
Use :class:`MSPBase` instead of :class:`NewCentralBase` when operating
as a Managed Service Provider (MSP). The class inherits all base functionality
and adds :meth:`get_tenant_connection`, which p... | aruba/pycentral | pycentral/msp/msp_base.py | .py | 050225db79076bad | 7.89 | 60 |
from ..base import NewCentralBase
from ..exceptions import LoginError
class TenantBase(NewCentralBase):
"""
A tenant-scoped connection owned by MSPBase.
Not intended to be instantiated directly — obtain instances via
MSPBase.get_tenant_connection().
On a 401 response, _renew_token() renews the p... | aruba/pycentral | pycentral/msp/tenant_base.py | .py | 8413c271bfe4bd98 | 7.89 | 60 |
from .scope_base import ScopeBase
API_ATTRIBUTE_MAPPING = {
"deviceCount": "device_count",
"id": "id",
"scopeName": "name",
"description": "description",
}
REQUIRED_ATTRIBUTES = ["name", "id"]
class Device_Group(ScopeBase):
"""This class holds device groups and all of its attributes & related m... | aruba/pycentral | pycentral/scopes/device_group.py | .py | 2973eaad3cad40df | 7.89 | 60 |
# (C) Copyright 2025 Hewlett Packard Enterprise Development LP.
# MIT License
from .scope_maps import ScopeMaps
from ..utils.scope_utils import (
fetch_attribute,
)
scope_maps = ScopeMaps()
class ScopeBase:
"""Base class for all scope elements, such as Site, Site_Collection, and Device.
Provides common... | aruba/pycentral | pycentral/scopes/scope_base.py | .py | 234c1b16d95fe442 | 7.89 | 60 |
#!/usr/bin/env python
# encoding: utf-8
#
# Copyright © 2019, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
from ..core import uri_as_str
from .service import Service
class Concepts(Service):
"""Assigns concepts to natural language text documents according to a
... | sassoftware/python-sasctl | src/sasctl/_services/concepts.py | .py | 9792f01e431fd9b5 | 7.86 | 52 |
#!/usr/bin/env python
# encoding: utf-8
#
# Copyright © 2019, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
import os
from pathlib import Path
from sasctl.utils.cli import sasctl_command
from .folders import Folders
from .service import Service
class Files(Service):... | sassoftware/python-sasctl | src/sasctl/_services/files.py | .py | d0b84202edf34a7c | 7.86 | 52 |
#!/usr/bin/env python
# encoding: utf-8
#
# Copyright © 2019, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
from sasctl.utils.cli import sasctl_command
from .service import Service
class Folders(Service):
"""The Folders API provides an organizational structure fo... | sassoftware/python-sasctl | src/sasctl/_services/folders.py | .py | fbca91a03c73c337 | 7.86 | 52 |
#!/usr/bin/env python
# encoding: utf-8
#
# Copyright © 2019, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
"""A stateless, memory-resident, high-performance program execution service."""
import re
from collections import OrderedDict
from math import isnan
from .servi... | sassoftware/python-sasctl | src/sasctl/_services/microanalytic_score.py | .py | ff3b0a8da742d8b0 | 7.86 | 52 |
#!/usr/bin/env python
# encoding: utf-8
#
# Copyright © 2019, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
"""Enables publishing objects such as models to various destinations."""
import re
from .model_repository import ModelRepository
from .service import Service
fr... | sassoftware/python-sasctl | src/sasctl/_services/model_publish.py | .py | 9dc9a2673187fb80 | 7.86 | 52 |
#!/usr/bin/env python
# encoding: utf-8
#
# Copyright © 2019, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
from .service import Service
class Projects(Service):
_SERVICE_ROOT = "/projects"
list_projects, get_project, update_project, delete_project = Service.... | sassoftware/python-sasctl | src/sasctl/_services/projects.py | .py | 25054fe717e5635d | 7.86 | 52 |
#!/usr/bin/env python
# encoding: utf-8
#
# Copyright © 2019, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
from ..core import RestObj
from .service import Service
LOW = 0
MEDIUM = 1
HIGH = 2
_LOD_VALUES = {LOW: "thumbnail", MEDIUM: "normal", HIGH: "entireSection"}
... | sassoftware/python-sasctl | src/sasctl/_services/report_images.py | .py | 5f029d6d84c3d8e3 | 7.86 | 52 |
#!/usr/bin/env python
# encoding: utf-8
#
# Copyright © 2019, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
from .service import Service
class Reports(Service):
"""Creates, reads, updates, and deletes reports, report states, and content.
See Also
--------... | sassoftware/python-sasctl | src/sasctl/_services/reports.py | .py | 0a1b9727cabad6b5 | 7.86 | 52 |
#!/usr/bin/env python
# encoding: utf-8
#
# Copyright © 2022, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
"""The SAS Logon service provides standard OAuth endpoints for client management."""
from ..core import HTTPError
from .service import Service
class SASLogon(S... | sassoftware/python-sasctl | src/sasctl/_services/saslogon.py | .py | 438cd87feb972cd0 | 7.86 | 52 |
import requests
from requests import HTTPError
import sys
from pathlib import Path
import json
from typing import Dict, Union, Optional
from ..core import current_session, delete, get, sasctl_command, RestObj
from .cas_management import CASManagement
from .model_repository import ModelRepository
from .service import ... | sassoftware/python-sasctl | src/sasctl/_services/score_definitions.py | .py | 5460e8c7fcd8ffa2 | 7.86 | 52 |
import json
import time
import warnings
from packaging.version import Version
from typing import Union
import pandas as pd
from requests import HTTPError
from .cas_management import CASManagement
from ..core import current_session
from .score_definitions import ScoreDefinitions
from .service import Service
class Sc... | sassoftware/python-sasctl | src/sasctl/_services/score_execution.py | .py | 4b7644e3ea7b05a5 | 7.86 | 52 |
#!/usr/bin/env python
# encoding: utf-8
#
# Copyright © 2019, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
from ..core import current_session, uri_as_str
from .service import Service
class SentimentAnalysis(Service):
"""The Sentiment Analysis API is used to perf... | sassoftware/python-sasctl | src/sasctl/_services/sentiment_analysis.py | .py | f33ee4961c05e84a | 7.86 | 52 |
#!/usr/bin/env python
# encoding: utf-8
#
# Copyright © 2019, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
"""Base functionality for all services."""
import logging
import time
import warnings
from urllib.parse import quote
from .. import core
from ..core import HTTP... | sassoftware/python-sasctl | src/sasctl/_services/service.py | .py | df17a686b287c067 | 7.86 | 52 |
#!/usr/bin/env python
# encoding: utf-8
#
# Copyright © 2019, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
from ..core import current_session, uri_as_str
from .service import Service
class TextCategorization(Service):
"""Categorizes natural language text documen... | sassoftware/python-sasctl | src/sasctl/_services/text_categorization.py | .py | 455734a7bacca4c4 | 7.86 | 52 |
#!/usr/bin/env python
# encoding: utf-8
#
# Copyright © 2019, SAS Institute Inc., Cary, NC, USA. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0
from sasctl.core import current_session, uri_as_str
from .service import Service
class TextParsing(Service):
"""The Text Parsing API parses natural langua... | sassoftware/python-sasctl | src/sasctl/_services/text_parsing.py | .py | 23e71a2fc24c5fd5 | 7.86 | 52 |
# pylint: disable=redefined-outer-name
# pylint: disable=unused-argument
# pylint: disable=unused-variable
# pylint: disable=too-many-arguments
from typing import Annotated
from fastapi import APIRouter, Depends
from models_library.api_schemas_webserver.catalog import CatalogServiceGet
from models_library.generics i... | ITISFoundation/osparc-simcore | api/specs/web-server/_catalog_tags.py | .py | 991e61ca0df491c5 | 7.37 | 54 |
"""Common utils for OAS script generators"""
import inspect
import sys
from collections.abc import Callable
from pathlib import Path
from typing import (
Annotated,
Any,
NamedTuple,
Optional,
Union,
get_args,
get_origin,
)
from common_library.json_serialization import json_dumps
from commo... | ITISFoundation/osparc-simcore | api/specs/web-server/_common.py | .py | 8c879921cba3294e | 8.37 | 54 |
# pylint: disable=redefined-outer-name
# pylint: disable=unused-argument
# pylint: disable=unused-variable
# pylint: disable=too-many-arguments
from fastapi import APIRouter
from fastapi.responses import FileResponse
from simcore_service_webserver._meta import API_VTAG
router = APIRouter(
prefix=f"/{API_VTAG}",
... | ITISFoundation/osparc-simcore | api/specs/web-server/_exporter.py | .py | 38dacc381b49ef4e | 7.37 | 54 |
# pylint: disable=redefined-outer-name
# pylint: disable=unused-argument
# pylint: disable=unused-variable
# pylint: disable=too-many-arguments
from typing import Annotated, Any
from fastapi import APIRouter, Depends, status
from models_library.generics import Envelope
from models_library.rest_error import Enveloped... | ITISFoundation/osparc-simcore | api/specs/web-server/_long_running_tasks.py | .py | 8889b04e5e3116d1 | 8.37 | 54 |
# pylint: disable=redefined-outer-name
# pylint: disable=unused-argument
# pylint: disable=unused-variable
# pylint: disable=too-many-arguments
from _common import assert_handler_signature_against_model
from fastapi import APIRouter, status
from models_library.api_schemas_directorv2.dynamic_services import DynamicSer... | ITISFoundation/osparc-simcore | api/specs/web-server/_projects_nodes.py | .py | 97a067cf22bc7d92 | 7.37 | 54 |
# pylint: disable=redefined-outer-name
# pylint: disable=unused-argument
# pylint: disable=unused-variable
# pylint: disable=too-many-arguments
from typing import Annotated
from fastapi import APIRouter, Body, Depends
from models_library.api_schemas_webserver.projects import (
ProjectGet,
ProjectStateOutputS... | ITISFoundation/osparc-simcore | api/specs/web-server/_projects_states.py | .py | efad8a92ce9b928c | 7.37 | 54 |
# pylint: disable=redefined-outer-name
# pylint: disable=unused-argument
# pylint: disable=unused-variable
# pylint: disable=too-many-arguments
from fastapi import APIRouter
from models_library.api_schemas_webserver.projects import ProjectGet
from models_library.generics import Envelope
from models_library.projects i... | ITISFoundation/osparc-simcore | api/specs/web-server/_projects_tags.py | .py | b4aa34e55a775c21 | 8.37 | 54 |
# pylint: disable=redefined-outer-name
# pylint: disable=unused-argument
# pylint: disable=unused-variable
# pylint: disable=too-many-arguments
from typing import Any
from fastapi import APIRouter
from fastapi.responses import HTMLResponse
from simcore_service_webserver.constants import INDEX_RESOURCE_NAME
from simc... | ITISFoundation/osparc-simcore | api/specs/web-server/_statics.py | .py | f47de02da07e319e | 7.37 | 54 |
# pylint: disable=redefined-outer-name
# pylint: disable=unused-argument
# pylint: disable=unused-variable
# pylint: disable=too-many-arguments
from typing import Annotated
from _common import as_query
from fastapi import APIRouter, Depends, status
from models_library.api_schemas_long_running_tasks.tasks import TaskG... | ITISFoundation/osparc-simcore | api/specs/web-server/_studies_dispatcher.py | .py | 790efb0a1f979348 | 8.37 | 54 |
# pylint: disable=redefined-outer-name
# pylint: disable=unused-argument
# pylint: disable=unused-variable
# pylint: disable=too-many-arguments
import importlib
import json
from fastapi import FastAPI
from fastapi.routing import APIRoute
from servicelib.fastapi.openapi import create_openapi_specs
from simcore_service... | ITISFoundation/osparc-simcore | api/specs/web-server/openapi.py | .py | 4b4c45d3e4ecf60e | 8.37 | 54 |
# Note: initially copied from https://github.com/florimondmanca/httpx-sse/blob/master/src/httpx_sse/_decoders.py
from __future__ import annotations
import json
import inspect
from types import TracebackType
from typing import TYPE_CHECKING, Any, Generic, TypeVar, Iterator, Optional, AsyncIterator, cast
from typing_ext... | trycourier/courier-python | src/courier/_streaming.py | .py | 2692933fac25d717 | 7.75 | 30 |
from __future__ import annotations
from os import PathLike
from typing import (
IO,
TYPE_CHECKING,
Any,
Dict,
List,
Type,
Tuple,
Union,
Mapping,
TypeVar,
Callable,
Iterable,
Iterator,
Optional,
Sequence,
AsyncIterable,
)
from typing_extensions import (
... | trycourier/courier-python | src/courier/_types.py | .py | 9c823eea62b21c08 | 7.75 | 30 |
from __future__ import annotations
from typing import Any
from typing_extensions import override
from ._proxy import LazyProxy
class ResourcesProxy(LazyProxy[Any]):
"""A proxy for the `courier.resources` module.
This is used so that we can lazily import `courier.resources` only when
needed *and* so tha... | trycourier/courier-python | src/courier/_utils/_resources_proxy.py | .py | ff558026cb299d64 | 7.75 | 30 |
import logging
import functools
import matplotlib.pyplot as plt
import seaborn as sns
from cylinter.modules.aggregateData import aggregateData
from cylinter.modules.selectROIs import selectROIs
from cylinter.modules.intensityFilter import intensityFilter
from cylinter.modules.areaFilter import areaFilter
from cylinte... | labsyspharm/cylinter | cylinter/components.py | .py | 75d4cd93b40d9ba1 | 7.78 | 36 |
"""Unified runner — starts all three NCM MCP servers concurrently.
Usage:
python -m ncm_mcp_servers
All servers run in a single process using asyncio. Each binds to its
own port (default: 3001, 3002, 3003). Transport defaults to Streamable HTTP
with stateless mode enabled for both 2026-07-28 and legacy clients.
... | cradlepoint/api-samples | ncm_mcp_servers/__main__.py | .py | 627a87ebc9dc24d1 | 7.75 | 30 |
"""NCM Cloud Services MCP Server entry point.
Manages users, subscriptions, private cellular networks, and
NetCloud Exchange via the NCM v3 API.
Tools (13 total):
- get_users, manage_user
- get_subscriptions, manage_subscription
- get_networks, manage_network, get_radios, manage_radio, manage_sim
- get_exchange_sites... | cradlepoint/api-samples | ncm_mcp_servers/ncm_cloud_services/server.py | .py | 515c44b4f644ed2e | 7.75 | 30 |
"""MCP tools for NCM subscription and licensing management.
Provides:
- get_subscriptions: Query subscriptions
- manage_subscription: Upgrade/downgrade/unlicense devices
"""
from typing import List, Optional
from ncm_mcp_servers.shared.error_handler import (
handle_exception,
handle_ncm_response,
validat... | cradlepoint/api-samples | ncm_mcp_servers/ncm_cloud_services/tools/subscriptions.py | .py | d72261db9f8ce5f7 | 7.75 | 30 |
"""MCP tools for NCM user management.
Consolidates user CRUD into:
- get_users: Query/list users
- manage_user: Create, update, delete, change role
"""
from typing import Optional
from ncm_mcp_servers.shared.error_handler import (
handle_exception,
handle_ncm_response,
validate_required_params,
)
def r... | cradlepoint/api-samples | ncm_mcp_servers/ncm_cloud_services/tools/users.py | .py | ef81f301b9e3769c | 7.75 | 30 |
"""NCM Fleet Management MCP Server entry point.
Manages routers, groups, accounts, locations, configurations,
firmware, and products via the NCM v2 API.
Tools (17 total):
- get_routers, manage_router, reboot_router, reboot_group
- get_groups, manage_group
- get_accounts, manage_subaccount
- get_locations, manage_loca... | cradlepoint/api-samples | ncm_mcp_servers/ncm_fleet/server.py | .py | c88f4d1b7ee84495 | 7.75 | 30 |
"""MCP tools for NCM configuration management.
Provides:
- get_configuration_managers: Query config sync status
- patch_config: Apply partial config updates to a router or group
- put_router_config: Full config replacement for a router
- copy_router_config: Copy config between routers
- resume_updates: Resume suspende... | cradlepoint/api-samples | ncm_mcp_servers/ncm_fleet/tools/configurations.py | .py | 2078dce786f0174d | 7.75 | 30 |
"""MCP tools for NCM firmware and product information.
Consolidates firmware + products into a single tool:
- get_firmware: Query firmware versions, optionally by product
"""
from typing import Optional
from ncm_mcp_servers.shared.error_handler import (
handle_exception,
handle_ncm_response,
validate_req... | cradlepoint/api-samples | ncm_mcp_servers/ncm_fleet/tools/firmware.py | .py | daa53619225ce9c2 | 7.75 | 30 |
"""MCP tools for NCM location management.
Consolidates location operations into:
- get_locations: Query current and historical locations
- manage_location: Create or delete locations
"""
from typing import Optional
from ncm_mcp_servers.shared.error_handler import (
handle_exception,
handle_ncm_response,
... | cradlepoint/api-samples | ncm_mcp_servers/ncm_fleet/tools/locations.py | .py | fa7b9f9c19f5ced6 | 7.75 | 30 |
"""NCM Monitoring MCP Server entry point.
Monitors network health: net devices, alerts/logs, and speed tests
via the NCM v2 API.
Tools (6 total):
- get_net_devices, get_net_device_health, get_net_device_metrics
- get_logs
- create_speed_test, get_speed_test
"""
import os
import sys
from typing import Optional, cast
... | cradlepoint/api-samples | ncm_mcp_servers/ncm_monitoring/server.py | .py | c6ff064f4d817755 | 7.75 | 30 |
"""MCP tools for NCM net device monitoring.
Consolidates net device metrics into:
- get_net_devices: Query/list net devices
- get_net_device_health: Get cellular health scores
- get_net_device_metrics: Unified metrics retrieval (signal, usage, wan, modem)
"""
from typing import Optional
from ncm_mcp_servers.shared.e... | cradlepoint/api-samples | ncm_mcp_servers/ncm_monitoring/tools/net_devices.py | .py | 47ac69dea0c5042f | 7.75 | 30 |
"""MCP tools for NCM speed tests.
Provides:
- create_speed_test: Run speed tests on net devices or all modems on a router
- get_speed_test: Check speed test status/results
"""
from typing import Optional
from ncm_mcp_servers.shared.error_handler import (
handle_exception,
handle_ncm_response,
validate_re... | cradlepoint/api-samples | ncm_mcp_servers/ncm_monitoring/tools/speed_tests.py | .py | d7c4305a76ac57c2 | 8.25 | 30 |
"""Credential loading for NCM MCP Servers.
Reads API credentials from a JSON file or environment variables.
Credential resolution order:
1. JSON file at the path specified by NCM_CREDENTIALS_FILE env var
2. JSON file at the default path: /app/credentials.json (Docker) or ./credentials.json
3. Environment variables (X... | cradlepoint/api-samples | ncm_mcp_servers/shared/credentials.py | .py | 0a8ab83384f88576 | 7.75 | 30 |
"""Error handler module for NCM MCP Servers.
Translates ncm.py responses and exceptions into structured MCP responses.
All output is sanitized to ensure API credentials never appear in responses.
"""
import os
from typing import Any, Dict, List, Optional
from requests.exceptions import ConnectionError, Timeout, Requ... | cradlepoint/api-samples | ncm_mcp_servers/shared/error_handler.py | .py | c1d7ba00c3718e49 | 7.75 | 30 |
"""Structured logging configuration for NCM MCP Servers.
Provides JSON-formatted log output for containerized deployments
and human-readable output for local development.
Usage:
from ncm_mcp_servers.shared.logging import get_logger
logger = get_logger("ncm_fleet")
logger.info("Server started", extra={"por... | cradlepoint/api-samples | ncm_mcp_servers/shared/logging.py | .py | 6962e6dc3eb21306 | 7.75 | 30 |
"""
This file contains a sample using the functions in the utils module
to poll the alerts endpoint for all new alerts on your account.
The sample process_alert() function just prints any new alert to the console,
but you can replace it with anything you want (e.g., code to send an email
to your admin, write the alert ... | cradlepoint/api-samples | scripts/alerts.py | .py | 38c5a722efdae081 | 7.75 | 30 |
from typing import TYPE_CHECKING
from django.core.exceptions import FieldDoesNotExist
from django.db import models
from django_ltree.fields import PathValue
if TYPE_CHECKING:
from django_ltree.models import TreeModel
LABEL_WIDTHS = {
"SmallAutoField": 5,
"SmallIntegerField": 5,
"PositiveSmallIntege... | mariocesar/django-ltree | django_ltree/managers.py | .py | 2b334d5d1098a008 | 7.94 | 75 |
from typing import Self
from django.contrib.postgres.indexes import BTreeIndex, GistIndex
from django.db import models
from django.db.models.functions import Concat
from .fields import PathField, PathValue
from .functions import NLevel, Subpath
from .managers import TreeManager, resolve_path
class TreeModel(model... | mariocesar/django-ltree | django_ltree/models.py | .py | b64ff567bbe70dd2 | 7.94 | 75 |
import pytest
from tests.taxonomy.models import Taxonomy
TEST_DATA = """
Bacteria
Plantae
Animalia.Chordata.Mammalia.Carnivora.Canidae.Canis.Canis lupus
Animalia.Chordata.Mammalia.Carnivora.Canidae.Canis.Canis rufus
Animalia.Chordata.Mammalia.Carnivora.Canidae.Urocyon.Urocyon cinereoargenteus
Animalia.Chordata.Mammali... | mariocesar/django-ltree | tests/conftest.py | .py | 4ed0d6391929129a | 8.44 | 75 |
from django_ltree.managers import TreeManager
from django.db import models
from django_ltree.models import TreeModel
class Taxonomy(TreeModel):
label_size = 2
name = models.TextField()
def __str__(self):
return f"{self.name}"
# return "{}: {}".format(self.path, self.name)
def __rep... | mariocesar/django-ltree | tests/taxonomy/models.py | .py | cb5a66c2ca746d31 | 7.44 | 75 |
import pytest
from tests.taxonomy.models import Taxonomy
pytestmark = pytest.mark.django_db
def test_lookups_pattern_matching():
"""Test basic lquery pattern matching with existing Taxonomy model."""
# Create some test data using the existing Taxonomy model
a = Taxonomy.t_objects.create(name="Tenant A")
... | mariocesar/django-ltree | tests/test_lookups.py | .py | b144fad9be589894 | 7.44 | 75 |
"""
File models for videer
Handles file objects and their properties
"""
import os
import logging
import logging.handlers
from collections import deque
from typing import Optional, List, Dict, Any
# A damaged source encoded with -err_detect can make FFmpeg emit an error line per packet. Keeping all of them
# costs gi... | hclivess/videer | models/file_models.py | .py | 85baac6cbe10bc50 | 7.74 | 29 |
"""
AviSynth Handler for videer
Handles AviSynth script generation and management
"""
import os
import multiprocessing
from typing import Dict, Any, Optional
from models.file_models import VideoFile
from utils.ffmpeg_utils import has_audio_stream
class AviSynthHandler:
"""Handles AviSynth+ script generation"""
... | hclivess/videer | modules/avisynth_handler.py | .py | 77936bc6134ef575 | 7.74 | 29 |
"""
File Manager module for videer
Handles file queue management and file operations
"""
import os
from typing import List, Optional
from PySide6.QtCore import QObject, Signal
from models.file_models import VideoFile, FileQueue, canonical_path
from config import VIDEO_EXTENSIONS
from utils.naturalsort import natural_... | hclivess/videer | modules/file_manager.py | .py | 47134b8a7672f8be | 7.74 | 29 |
"""
Preset Manager for videer
Handles saving and loading presets
"""
import os
import json
from typing import Dict, Any, List, Optional
from PySide6.QtCore import QObject
from PySide6.QtWidgets import QInputDialog, QMessageBox, QFileDialog
from config import QUALITY_PRESETS, DEFAULT_SETTINGS, DEFAULTS_FILE, APP_VERSI... | hclivess/videer | modules/preset_manager.py | .py | b8aa010c9a07491c | 7.74 | 29 |
# -*- coding: utf-8 -*-
"""
mslib.conftest
~~~~~~~~~~~~~~
common definitions for py.test
This file is part of MSS.
:copyright: Copyright 2016-2017 Reimar Bauer
:copyright: Copyright 2016-2026 by the MSS team, see AUTHORS.
:license: APACHE-2.0, see LICENSE for details.
Licensed under... | Open-MSS/MSS | conftest.py | .py | 3f47abc74197e3c9 | 8.45 | 80 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.