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
"""This module provides the `QuestionValidator` class, which is responsible for validating questions in a questionnaire schema. It checks for the presence of answer labels when there are multiple answers, ensuring that the schema adheres to the expected structure and requirements for questions with multiple answers. C...
ONSdigital/eq-questionnaire-validator
app/validators/questions/question_validator.py
.py
04dd840c13e02255
7.3
3
"""This module contains the RoutingValidator class, which validates routing rules within a questionnaire schema. Classes: RoutingValidator """ from app.validators.rules.rule_validator import RulesValidator from app.validators.validator import Validator class RoutingValidator(Validator): """Validator for rou...
ONSdigital/eq-questionnaire-validator
app/validators/routing/routing_validator.py
.py
e7a744daa5ff36e6
7.3
3
"""This module contains functions to resolve the JSON type of various sources in a questionnaire schema. Functions: resolve_answer_source_json_type resolve_calculated_summary_source_json_type resolve_grand_calculated_summary_source_json_type resolve_metadata_source_json_type resolve_list_source_jso...
ONSdigital/eq-questionnaire-validator
app/validators/routing/types.py
.py
2b8cf69679e1686a
7.3
3
"""Validate that rules are correctly formed and reference valid answer options and answer types. Classes: Operator RulesValidator """ from app import error_messages from app.answer_type import AnswerOptionType, AnswerType from app.validators.questionnaire_schema import get_answer_type from app.validators.rout...
ONSdigital/eq-questionnaire-validator
app/validators/rules/rule_validator.py
.py
6e120ab2d6bb9184
7.3
3
"""Define the base class for all validators. Classes: Validator """ from collections.abc import Mapping class Validator: """Base class for validators. All validators inherit from this class and implement the validate method to perform validation on a given schema element. Attributes: sc...
ONSdigital/eq-questionnaire-validator
app/validators/validator.py
.py
7d0ecca43daeb8c5
7.3
3
"""This module contains the ValueSourceValidator class, which is responsible for validating value sources in a questionnaire schema. Classes: ValueSourceValidator """ from functools import cached_property from typing import ClassVar from app.validators.validator import Validator class ValueSourceValidator(Vali...
ONSdigital/eq-questionnaire-validator
app/validators/value_source_validator.py
.py
c8ae5bdc131e2bde
7.3
3
import itertools from collections.abc import Callable, Mapping from json import load from pathlib import Path from typing import Any from jsonschema import Draft202012Validator as DraftValidator from jsonschema import ValidationError from jsonschema.exceptions import SchemaError from referencing import Registry, Resou...
ONSdigital/eq-questionnaire-validator
tests/helpers/schema_validator.py
.py
a5566538d67ec461
7.8
3
from dataiku.connector import Connector from dataikuapi.utils import DataikuException from safe_logger import SafeLogger from rest_api_client import RestAPIClient from dku_utils import ( get_dku_key_values, get_endpoint_parameters, parse_keys_for_json, get_value_from_path, get_secure_credentials, decode_csv...
dataiku/dss-plugin-api-connect
python-connectors/api-connect_dataset/connector.py
.py
7b8cd60b9b396a07
7.35
4
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Checks if valid news files are created for changes in the project.""" import argparse import logging import pathlib import re import sys from typing import Union, Optional, Iterab...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/assert_news.py
.py
8dbea3f53ddc1883
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Check tracked files against the project's recorded secret registry.""" import argparse import logging import subprocess import sys from pathlib import Path from typing import List...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/detect_secrets.py
.py
60acca086529dfec
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Generates documentation.""" import argparse import logging import os import shutil import sys from pathlib import Path from continuous_delivery_scripts.language_specifics import ...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/generate_docs.py
.py
2d61e29a6ff33f41
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Handles usage of towncrier for automated changelog generation and pyautoversion for versioning.""" import sys import argparse import logging import os import subprocess from cont...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/generate_news.py
.py
1cb7057f941474f8
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Determine the project new version.""" import sys from typing import Optional import argparse import logging from continuous_delivery_scripts.utils.versioning import calculate_ver...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/get_version.py
.py
4e6d068fbf10f5d7
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Language plugins Loader.""" import logging from typing import Optional, Dict, cast, Set, Type from continuous_delivery_scripts.utils.configuration import configuration, Configura...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/language_specifics.py
.py
92821fa6db9b1ec6
7.8
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Apply copyright and licensing to all source files present in a project. This is to comply with OpenChain certification; https://github.com/OpenChain-Project/Curriculum/blob/master...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/license_files.py
.py
a94a6b017d47e871
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Basic plugin.""" import logging from pathlib import Path from typing import TYPE_CHECKING, Optional from continuous_delivery_scripts.utils.definitions import CommitType from cont...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/plugins/basic.py
.py
16c3880dfa81e70a
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Plugin for CI projects.""" import logging from pathlib import Path from typing import TYPE_CHECKING, Optional from continuous_delivery_scripts.utils.configuration import ( co...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/plugins/ci.py
.py
75257030487dffa0
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Plugin for Docker projects.""" import logging from pathlib import Path from typing import TYPE_CHECKING, Optional from continuous_delivery_scripts.utils.definitions import Commit...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/plugins/docker.py
.py
3dc410d9d5173929
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Plugin for CI projects.""" import logging import os from pathlib import Path from subprocess import check_call from typing import List from continuous_delivery_scripts.plugins.ci...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/plugins/github_actions.py
.py
1a2a79a834697c39
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Plugin for Golang projects.""" import json import logging import os import shutil from pathlib import Path from subprocess import check_call, check_output from typing import TYPE_...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/plugins/golang.py
.py
09cab25f12651dc6
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Plugin for Python projects.""" import logging import shutil import sys from pathlib import Path from subprocess import check_call from typing import TYPE_CHECKING, List, Optional ...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/plugins/python.py
.py
b75e27f15cef72be
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Script providing information about licensing and third party IP in order to comply with OpenChain. The current script uses the SDK provided by the SPDX organisation (i.e. https://...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/report_third_party_ip.py
.py
50fe8d9aa78579e9
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Definition of dependency SPDX Document.""" from typing import TYPE_CHECKING if TYPE_CHECKING: from spdx.document import ExternalDocumentRef class DependencySpdxDocumentRef:...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/spdx_report/spdx_dependency.py
.py
2295af8398733020
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Definition of an SPDX Document.""" from pathlib import Path from typing import TYPE_CHECKING, List, Optional from continuous_delivery_scripts.spdx_report.spdx_dependency import (...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/spdx_report/spdx_document.py
.py
22a5f3449c488fcc
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Definition of an SPDX File.""" from pathlib import Path from typing import TYPE_CHECKING, Optional from continuous_delivery_scripts.spdx_report.spdx_helpers import ( determin...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/spdx_report/spdx_file.py
.py
2e4eb861c69bf584
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Facilities regarding SPDX. SPDX file (i.e. tag-value format) https://github.com/OpenChain-Project/curriculum/blob/master/guides/including_license_info.rst https://github.com/david...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/spdx_report/spdx_helpers.py
.py
bc11df903f4de6dc
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Definition of an SPDX Package.""" from dataclasses import dataclass from pathlib import Path from typing import TYPE_CHECKING, List, Optional from continuous_delivery_scripts.spd...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/spdx_report/spdx_package.py
.py
4b574e69c719d11f
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Definition of an SPDX report for a Python project.""" from pathlib import Path import os from typing import Optional, List, cast, Tuple, Dict from continuous_delivery_scripts.spd...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/spdx_report/spdx_project.py
.py
c1cf98f0e1d0e12f
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Summary generators.""" import datetime import jinja2 import logging from pathlib import Path from typing import List, Tuple, Optional, Dict, Any from continuous_delivery_scripts....
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/spdx_report/spdx_summary.py
.py
eb473a4ca0090060
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Orchestrates release process.""" import argparse import datetime import logging import sys from pathlib import Path from typing import TYPE_CHECKING, Optional, Tuple, Dict from c...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/tag_and_release.py
.py
7a82c8b21f3834fb
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Record the project's accepted secret registry using detect-secrets.""" import argparse import logging import re import subprocess import sys from pathlib import Path from typing i...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/update_secrets_registry.py
.py
a1e2c1fc83cb5dc6
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Helpers for interacting with AWS services such as S3. Based on the Python SDK called BOTO https://aws.amazon.com/sdk-for-python/. """ import boto3 import logging import os from p...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/utils/aws_helpers.py
.py
14f39c29e108f669
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Utilities in charge of fetching configuration values for the ci scripts.""" import enum import logging import os from abc import ABC, abstractmethod from typing import Any, List, ...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/utils/configuration.py
.py
3bc1a83de5cda190
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Place to store generic project concepts for the ci scripts.""" import enum from typing import List UNKNOWN = "unknown" class CommitType(enum.Enum): """Type of commits.""" ...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/utils/definitions.py
.py
2c93dc5bd9f377d2
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Helpers with regards to actions on the filesystem.""" import os import tempfile import shutil import platform import logging from wcmatch.pathlib import Path as EnhancedPath, GLOB...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/utils/filesystem_helpers.py
.py
ce9db420154e1a96
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Helpers for calculating hashes or UUID.""" import hashlib import uuid from pathlib import Path def generate_uuid_based_on_str(string: str) -> str: """Generates a UUID based ...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/utils/hash_helpers.py
.py
d5346492f2f919cf
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Base class for all Language plugins.""" import logging from abc import ABC, abstractmethod from pathlib import Path from typing import TYPE_CHECKING, Optional, Dict, List from co...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/utils/language_specifics_base.py
.py
aea48fb3d9e2e0e1
7.8
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Helpers for logging errors according to severity of the exception.""" import logging from .configuration import configuration, ConfigurationVariable from typing import Any, Option...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/utils/logging.py
.py
b957b43ee4679c5a
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Helpers with regards to news files.""" import enum import pathlib import logging from datetime import datetime from typing import Any, Optional logger = logging.getLogger(__name_...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/utils/news_file.py
.py
8c85815e20f11520
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Utilities for retrieving NoOp's package information.""" import logging from continuous_delivery_scripts.utils.package_helpers import ProjectMetadata, ProjectMetadataFetcher logg...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/utils/noop/package_helpers.py
.py
8355da76f503059b
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Utilities for retrieving Python's package information.""" import logging from abc import ABC, abstractmethod from typing import Any, Dict, List, Optional from continuous_delivery...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/utils/package_helpers.py
.py
f3159e940bfcfb6c
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Utilities for retrieving Python's package information.""" import importlib.metadata as importlib_metadata import logging import re import subprocess import sys from typing import ...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/utils/python/package_helpers.py
.py
fc753eaa08a4d892
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Utilities regarding string handling.""" from functools import total_ordering import jellyfish from dataclasses import dataclass from typing import Iterable, Tuple @total_orderi...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/utils/string_helpers.py
.py
2773582607f28f86
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Third party licences.""" import re import json from dataclasses import dataclass from importlib.util import find_spec from license_expression import Licensing, LicenseExpression,...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/utils/third_party_licences.py
.py
d7f107f2f5098bde
7.3
3
# # Copyright (C) 2020-2026 Arm Limited or its affiliates and Contributors. All rights reserved. # SPDX-License-Identifier: Apache-2.0 # """Helpers with regards to versioning.""" import logging import os from auto_version import auto_version_tool from typing import Optional, Tuple, Dict from continuous_delivery_scrip...
ARMmbed/continuous-delivery-scripts
continuous_delivery_scripts/utils/versioning.py
.py
df69005836b7d6f9
7.3
3
"""Test event handler and main() of new_account_iam_role. This is testing a rather basic lambda function, so the tests are basic as well: - test arguments to main() - test some of the functions invoked by main() - test event handler arguments """ from datetime import datetime import json import os import...
plus3it/terraform-aws-org-new-account-iam-role
lambda/tests/test_new_account_iam_role.py
.py
d0ca05e36a09b482
7.8
3
"""Test Terraform installation of new_account_iam_role. Verifies the Terraform configuration by: - verifying the init/plan and apply are successful, - verifying the Terraform output, - verifying a "dry run" of the lambda is successful, - executing the lambda to verify the libraries are installed. """ ...
plus3it/terraform-aws-org-new-account-iam-role
tests/test_terraform_install.py
.py
0a33edc388b7e52e
7.8
3
#!/usr/bin/env python3 """Example of using JournaldHandler with extra fields and concurrent logging.""" import concurrent.futures import random import time from concurrent.futures import ThreadPoolExecutor from itertools import cycle import logbook from logbook import Logger, Processor from chameleon_log.journald im...
hongquan/chameleon-log
examples/journald-extra-fields.py
.py
402e693d3f8068cc
7.24
2
#!/usr/bin/env python3 """Simple example of using JournaldHandler with Logbook.""" import getpass import platform import logbook from logbook import Processor from chameleon_log.journald import JournaldHandler def main() -> None: """Main function demonstrating JournaldHandler usage.""" # Create a JournaldH...
hongquan/chameleon-log
examples/journald-simple.py
.py
20c2afa96590da2c
7.24
2
#!/usr/bin/env python3 """Simple example of using SentryHandler with Logbook.""" from __future__ import annotations import json import os import logbook import sentry_sdk from chameleon_log.sentry import SentryHandler def main() -> None: """Main function demonstrating SentryHandler usage.""" # If SENTRY_D...
hongquan/chameleon-log
examples/sentry-simple.py
.py
4a89f835feac886c
7.24
2
from __future__ import annotations import os from typing import TYPE_CHECKING if TYPE_CHECKING: from logbook import LogLevel from .journald import JournaldHandler from .rich import RichHandler def is_connected_journald() -> bool: """ Detect if the current process is connected to systemd journa...
hongquan/chameleon-log
src/chameleon_log/detectors.py
.py
67982a143256c6fd
7.24
2
""" Journald handler for Logbook. This module provides a handler that sends Logbook log records to the systemd `journald`_ with rich metadata and structured data support. .. note:: This module is only available when the ``journald`` extra is installed:: pip install chameleon_log[journald] If the ``journ...
hongquan/chameleon-log
src/chameleon_log/journald.py
.py
a4bce5d1425b8a76
7.24
2
from __future__ import annotations import logging from typing import TYPE_CHECKING import logbook from logbook import LogRecord from logbook.compat import LoggingHandler as _LoggingHandler if TYPE_CHECKING: from logbook.handlers import LogFilter class StdLoggingHandler(_LoggingHandler): """ Handler fo...
hongquan/chameleon-log
src/chameleon_log/legacy.py
.py
0711bfb495167712
7.24
2
from __future__ import annotations import sys from collections.abc import Iterable from http import HTTPMethod from pathlib import Path from typing import IO, TYPE_CHECKING from logbook.base import ( NOTSET, LogRecord, ) from logbook.handlers import StreamHandler from rich import get_console from rich.console...
hongquan/chameleon-log
src/chameleon_log/rich.py
.py
c82894dbb87137d9
7.24
2
""" Logbook handler that sends event to Sentry (https://docs.sentry.io/) .. note:: This module is only available when the ``sentry`` extra is installed:: pip install chameleon_log[sentry] If the ``sentry`` extra is not installed, ``SentryHandler`` will be available but will be a no-op handler that does n...
hongquan/chameleon-log
src/chameleon_log/sentry.py
.py
fb95b3e7992048f5
7.24
2
from typing import Optional class Error(Exception): """Base class for exceptions in this module.""" pass class CsvNotFoundError(Error): def __init__(self, tube_rack_barcode: str, message: Optional[str] = None): """Raised when a CSV file named after a tube rack barcode is not found in the NFS. ...
sanger/wrangler
wrangler/exceptions.py
.py
e06239d66ffc3126
7
0
import pprint from logging import Handler, Logger from slack import WebClient from slack.errors import SlackApiError class SlackHandler(Handler): def __init__(self, token, channel_id): Handler.__init__(self) self.client = WebClient(token) self.channel_id = channel_id def emit(self, r...
sanger/wrangler
wrangler/utils.py
.py
f1586b28c409ada8
7
0
# Copyright (c) 2014 Museum Victoria # Modifications (c) 2019-2026 ACMI # This software is released under the MIT license. """Balena device controls managed by the balena-nodel image.""" import os import socket import sys import time try: from urllib import quote from urllib2 import HTTPError, Request, urlop...
ACMILabs/balena-nodel
managed-node/script.py
.py
364bd3e25f04f024
7.15
1
#!/usr/bin/env python import logging import argparse from lexicalanalysis import CorpusIterator from xmlbuilder import parse_xml_file, save_xml, XmlAttributes, XmlElements from itertools import chain def load_component(file_name): """Loads the XML from component file specified by `file_name`. Parameters ...
romanian-parlamint/parsers
apply-corrections.py
.py
b19e3fd96330ce68
7
0
import re NAME_REPLACEMENT_PATTERNS = [r'\s*-\s*', r'\s+'] def build_speaker_id(speaker_name): """Builds the id of the speaker from its name. Parameters ---------- speaker_name: str The name of the speaker. Returns ------- speaker_id: str The id of the speaker. """ ...
romanian-parlamint/parsers
common.py
.py
dc4a82845c6ebd9e
7
0
from collections import defaultdict from collections.abc import Mapping from copy import deepcopy from enum import Enum from typing import Any, Union from .registry import notifications _StrOrEnum = Union[str, type[Enum]] COMMON_CONTEXT = "__common__" class DummyContext: context = defaultdict(dict) def up...
City-of-Helsinki/django-ilmoitin
django_ilmoitin/dummy_context.py
.py
a1e475dc648325f7
7.24
2
import csv import logging import string import xml.etree.ElementTree as etree import zipfile from argparse import ArgumentParser logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO) TRANSLATION_TABLE = str.maketrans({p: None for p in string.punctuation}) de...
RePierre/corola-lemma
src/corpora/extract_lemma.py
.py
1522d484abee286b
7
0
from sklearn.model_selection import train_test_split import numpy as np def reshape(array, sample_dim): """ Reshapes the collection of arrays into a single numpy array. Parameters ---------- array: list of numpy arrays The list of numpy arrays to reshape into a single array. sample_di...
RePierre/corola-lemma
src/utils.py
.py
8dc338e560ae1a96
7
0
import uuid from dataclasses import dataclass from datetime import datetime from pathlib import Path from typing import List from gtagora.exception import AgoraException from gtagora.models.dataset import DatasetType from gtagora.models.exam import Exam from gtagora.models.patient import Patient from gtagora.models.se...
GyroTools/gtagora-connector-py
gtagora/models/import_json.py
.py
f7651d46a775a5c7
7.39
5
from gtagora.exception import AgoraException from gtagora.models.base import BaseModel from workbook.mask import DecodedMask, decode_full_mask # noqa: F401 (re-exported) from workbook.session import merge_contour_session, merge_mask_session from workbook.session import resolve_contour_buttons as _resolve_contour_butt...
GyroTools/gtagora-connector-py
gtagora/models/workbook.py
.py
d10f956b53fd4512
7.39
5
""" MIT License Copyright (c) 2018 Alexander Lee Copyright (c) 2020 toads 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 to use, cop...
toads/Tblog
Tblog/extension/markdowntoc.py
.py
cad6c74cdaa2c871
7.15
1
''' Stolen straight from https://stackoverflow.com/a/51337247/1224827 ''' try: import PIL import PIL.Image as PILimage from PIL import ImageDraw, ImageFont, ImageEnhance from PIL.ExifTags import TAGS, GPSTAGS import os import glob except ImportError as err: exit(err) class Wo...
blairg23/rename-images-to-datetime
testing.py
.py
111abecbabea14e6
7.5
0
#!/usr/bin/python3 # Copyright 2016, 2017 IBM Corp. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or ...
tessia-project/tessia-baselib
setup.py
.py
3e423ebdcbe85fe9
7.15
1
# Copyright 2016, 2017 IBM Corp. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
tessia-project/tessia-baselib
tessia/baselib/common/s3270/s3270pipeconnector.py
.py
e48138cfdd0981d4
7.15
1
# Copyright 2016, 2017 IBM Corp. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
tessia-project/tessia-baselib
tessia/baselib/guests/linux/linux.py
.py
347de0bb27e48e37
7.15
1
# Copyright 2026 IBM Corp. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, sof...
tessia-project/tessia-baselib
tessia/baselib/guests/linux/storage/disk_qcow2.py
.py
d2676d834c4083ee
7.15
1
# Copyright 2016, 2017 IBM Corp. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
tessia-project/tessia-baselib
tessia/baselib/hypervisors/__init__.py
.py
8d135a50855ea3fe
7.15
1
# Copyright 2020 IBM Corp. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, sof...
tessia-project/tessia-baselib
tessia/baselib/hypervisors/hmc/messages.py
.py
beccff5631e5839e
7.15
1
# Copyright 2016, 2017 IBM Corp. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writin...
tessia-project/tessia-baselib
tessia/baselib/hypervisors/kvm/guest.py
.py
59a24e64326d5889
7.15
1
# Copyright 2017 IBM Corp. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, sof...
tessia-project/tessia-baselib
tessia/baselib/hypervisors/kvm/storage/disk.py
.py
89a3d365e4da74fb
7.15
1
"""Synthetic benchmark for lazy sequence DataLoader throughput. Examples -------- Run with default settings: python benchmarks/solrad_correction/sequence_dataloader.py Run with custom parameters: python benchmarks/solrad_correction/sequence_dataloader.py --rows 100000 --batch-size 256 """ import time from ty...
Bruno-Mascarenhas/micrometeorology
benchmarks/solrad_correction/sequence_dataloader.py
.py
f649c24cd5a54a62
7.15
1
"""Rewrite the lab's solar-geometry CSV as a parquet beside it. Run once, and again whenever the lab replaces the CSV. The CSV stays the source of truth; this only adds the derived form the pipeline prefers to read. Usage ----- :: uv run python scripts/converter_teorica.py --data data """ import time from pathl...
Bruno-Mascarenhas/micrometeorology
scripts/converter_teorica.py
.py
8ed3f3655e756552
7.15
1
"""Figure of the cumulative clearness index F(Kt) with the Escobedo sky conditions. The publication companion of the ``clearness_index_cumulative`` artifact the climatology exporter writes: same computation, same frozen edges, same published bounds, so a figure in a paper and the curve on the site cannot disagree. Ev...
Bruno-Mascarenhas/micrometeorology
scripts/plot_clearness_cumulative.py
.py
3e3ea0df1e4b4fd3
7.15
1
"""Publication figure of the Kt-Kd plane with the three published diffuse-fraction models. The paper companion of the ``labmim-ktkd-v1`` artifact the sky page reads: both come from :mod:`micrometeorology.stats.ktkd`, so a figure in a paper and the curve on the site cannot disagree about the same record. Marques Filho...
Bruno-Mascarenhas/micrometeorology
scripts/plot_ktkd.py
.py
5625dfc2d7d794fe
7.15
1
"""Atomic file writes: temp file in the same directory + ``os.replace``. Every artifact the allsky pipeline writes — parquet manifests and their meta sidecars, embedding shards + index + meta, training checkpoints, metrics CSV/JSON, evaluation reports and Colab bundles — is written through :func:`atomic_write`. The p...
Bruno-Mascarenhas/micrometeorology
src/allsky/atomic.py
.py
35bd781084d4add9
7.15
1
"""Export a self-contained Colab bundle (tar.gz) of a prepared dataset. :func:`export_colab_bundle` packs everything a Colab (or any offline) session needs to train on a locally prepared dataset into a single ``tar.gz``: - the manifest parquet and its ``.meta.json`` sidecar; - the persisted split artifact (when prese...
Bruno-Mascarenhas/micrometeorology
src/allsky/bundle.py
.py
b1535470b8806113
7.15
1
"""Haurwitz (1945) clear-sky global irradiance and the clear-sky index k*. Provides the single-parameter Haurwitz clear-sky model for global horizontal irradiance (GHI) — a function of the solar zenith angle only, with no aerosol/water-vapour inputs — and the derived **clear-sky index** ``k* = GHI / GHI_cs``. Unlike ...
Bruno-Mascarenhas/micrometeorology
src/allsky/clearsky.py
.py
fc75fad789b98792
7.15
1
"""``precompute-embeddings`` CLI: DINOv2 (or fake) embeddings for a manifest. Reads a :class:`~allsky.config.PrepareConfig` YAML (whose ``embeddings`` section pins backbone / pooling / batch / device / shard-size / dtype), loads the v2 manifest, builds the visual backbone and runs the resumable, atomically-written ext...
Bruno-Mascarenhas/micrometeorology
src/allsky/cli/embeddings.py
.py
964f04c04c4ce6ae
7.15
1
"""``extract-frames`` CLI command. Extracts timestamped JPEG frames from a single all-sky timelapse video. The ``video.timestamps`` field of a :class:`allsky.config.PrepareConfig` (built-in defaults when ``--config`` is omitted) selects the frame -> wall-clock time mapping, the same way ``prepare-local`` and ``sync-a...
Bruno-Mascarenhas/micrometeorology
src/allsky/cli/frames.py
.py
6e4b38247a871376
7.15
1
"""``train`` CLI command — multimodal experiment training. ``allsky train`` runs a multimodal experiment declared by an ``experiment: true`` config (see ``configs/allsky/experiments/``); anything else — a config that is not an experiment config, or no config at all — is rejected with a pointer to those configs. torch...
Bruno-Mascarenhas/micrometeorology
src/allsky/cli/train.py
.py
d2975a9e1c253694
7.15
1
"""Build-time temporal alignment for image <-> sensor pairing. :class:`CenterFrame` maps each video frame to the single nearest sensor record within a maximum distance, carrying a stable string ``id`` that is stored in the manifest sidecar meta so a loaded dataset knows which pairing produced it. It is what :func:`all...
Bruno-Mascarenhas/micrometeorology
src/allsky/data/alignment.py
.py
ead09658b30c93d1
7.15
1
"""Manifest v2 contracts: column registry, QC flags, sky classes, paths. This module pins the on-disk schema of the multimodal dataset manifest — the byte contract every other ``allsky.data`` module (and the training/embedding stack downstream) codes against. It is deliberately dependency-light (stdlib plus typing on...
Bruno-Mascarenhas/micrometeorology
src/allsky/data/contracts.py
.py
cfd01c2e84799ff4
7.15
1
"""Shared duration parsing/formatting utilities.""" from __future__ import annotations import re _PART = re.compile( r"(\d+)\s*(w(?:eeks?)?|d(?:ays?)?|h(?:ours?)?|m(?:in(?:utes?)?)?)", re.IGNORECASE, ) _UNITS: dict[str, int] = {"w": 10080, "d": 1440, "h": 60, "m": 1} def parse_duration_minutes(s: str) -> i...
dragonpaw/discord-bot
dragonpaw_bot/duration.py
.py
ad680a8a5ae56197
7
0
"""Per-guild member journal — the shared record plugins write into. Lives in core rather than under plugins/ because gc.log() writes to it; plugins/journal/ owns only the command surface. """ from __future__ import annotations from datetime import UTC, datetime from typing import Literal import pydantic import stru...
dragonpaw/discord-bot
dragonpaw_bot/journal.py
.py
b7a70e33e2052bd0
7
0
"""Logging configuration for Dragonpaw Bot. Call configure_logging() once at startup, before any other imports log. All modules then use ``structlog.get_logger()`` directly. """ import io import logging import sys from typing import Any import structlog _RESET = "\033[0m" def _fg(r: int, g: int, b: int) -> str: ...
dragonpaw/discord-bot
dragonpaw_bot/logging.py
.py
40243c9aa2f32147
7
0
"""Activity tracker models and score calculation.""" from __future__ import annotations import enum import math import time import pydantic class ContributionKind(enum.StrEnum): TEXT = "text" MEDIA = "media" REACTION = "reaction" VC = "vc" CONTRIBUTION_VALUES: dict[ContributionKind, float] = { ...
dragonpaw/discord-bot
dragonpaw_bot/plugins/activity/models.py
.py
ec1097492c27d6df
7
0
from __future__ import annotations from typing import TYPE_CHECKING import hikari import lightbulb import structlog from dragonpaw_bot import journal if TYPE_CHECKING: from dragonpaw_bot.bot import DragonpawBot logger = structlog.get_logger(__name__) loader = lightbulb.Loader() def display_name_change( ...
dragonpaw/discord-bot
dragonpaw_bot/plugins/journal/listeners.py
.py
9d9ffa3eb37fb6dd
7
0
"""Roles de la app (humanos). No son los tokens de los ESP32.""" # admin: todo. # veterinario: operación completa; no ve otros usuarios, ni accounting, ni authorization. # operario: solo lectura; clima, producción y pastoreo; sin calidad. ROLES = { "admin": { "label": "Administrador", "modules": { ...
harveybc/data-logger
app/roles.py
.py
0446a0560fc0f86e
7.3
3
"""SQLite de documentos (acopio, calidad, pesaje). No es el almacén de sensores.""" from __future__ import annotations import sqlite3 from pathlib import Path from typing import Any SCHEMA = """ CREATE TABLE IF NOT EXISTS recoleccion ( id INTEGER PRIMARY KEY, fecha TEXT NOT NULL, codigo_productor TEXT, ruta T...
harveybc/data-logger
app/store.py
.py
529a16d6eabc123e
7.3
3
from __future__ import annotations import json import re import sqlite3 from dataclasses import dataclass from datetime import date from urllib import request as urllib_request @dataclass class ParsedQuery: """Result of parsing a natural language question into structured filters.""" categories: list[str] ...
amitrke/docorganizer
chat-rag/app/query_parser.py
.py
dcafe47e696e5c6c
7
0
import json import re import sqlite3 from datetime import date from urllib import request from urllib.error import HTTPError OPENROUTER_REFERER = "https://github.com/amitrke/docorganizer" OPENROUTER_TITLE = "docorganizer" PROVIDER_DEFAULTS: dict[str, dict[str, object]] = { "ollama": {"base_url": "http://localhost...
amitrke/docorganizer
docorg/ai.py
.py
6014ffc4237ae874
7
0
from pathlib import Path import yaml DEFAULT_CONFIG_PATH = Path("config.yaml") def load_config(path: Path = DEFAULT_CONFIG_PATH) -> dict: with open(path) as f: cfg = yaml.safe_load(f) # Resolve relative paths against the config file's directory base = Path(path).parent for key in ("inbox", "...
amitrke/docorganizer
docorg/config.py
.py
2403b9e57a7406e0
7
0
from pathlib import Path def _ocr_page_text(page) -> str: """Render a PDF page to an image and run OCR if dependencies are available.""" try: import pytesseract from PIL import Image except ImportError: return "" # 200 DPI is usually enough for OCR while keeping memory reasona...
amitrke/docorganizer
docorg/extractor.py
.py
5cbdccbe912c3ca1
7
0
import re import shutil from pathlib import Path def _safe_dest(target_dir: Path, filename: str) -> Path: """ Return a destination path that does not already exist. If <filename> is taken, append _2, _3, … to the stem (F13a). """ dest = target_dir / filename if not dest.exists(): retur...
amitrke/docorganizer
docorg/filer.py
.py
fb2a6eb7bc45c49d
7
0
from __future__ import annotations from pathlib import Path def is_host_neutral_path(stored_path: str) -> bool: """Return True when a DB filepath uses host-neutral roots.""" normalized = stored_path.replace("\\", "/") return normalized.startswith("documents/") or normalized.startswith("inbox/") def to_...
amitrke/docorganizer
docorg/pathing.py
.py
9a6225b2da17b6d9
7
0