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
"""Schema utils for commonmeta-py""" from __future__ import annotations from functools import lru_cache from os import path from typing import Any import orjson as json from .base_utils import normalize_xml_dict # jsonschema and xmlschema are imported inside the functions that use them, not # at module scope: betw...
front-matter/commonmeta-py
commonmeta/schema_utils.py
.py
ced958cbe0bd0af0
7.65
19
"""Web translators for commonmeta. Using BeautifulSoup to extract metadata from web pages.""" from __future__ import annotations import re from typing import TYPE_CHECKING from furl import furl from .doi_utils import doi_as_url if TYPE_CHECKING: from bs4 import BeautifulSoup def web_translator(soup: Beautifu...
front-matter/commonmeta-py
commonmeta/translators.py
.py
628d321d9ec29898
7.65
19
"""Bibtex writer for commonmeta-py""" from __future__ import annotations from typing import TYPE_CHECKING from bibtexparser.bibdatabase import BibDatabase from bibtexparser.bwriter import BibTexWriter from bibtexparser.customization import page_double_hyphen from ..author_utils import authors_as_string from ..base_...
front-matter/commonmeta-py
commonmeta/writers/bibtex_writer.py
.py
a0fa9bf444d0fbad
7.65
19
"""Citation writer for commonmeta-py""" from __future__ import annotations import re from typing import TYPE_CHECKING import orjson as json from citeproc import ( Citation, CitationItem, CitationStylesBibliography, CitationStylesStyle, formatter, ) from citeproc.source.json import CiteProcJSON fr...
front-matter/commonmeta-py
commonmeta/writers/citation_writer.py
.py
347d9a807fc8c4e6
7.65
19
"""Commonmeta writer for commonmeta-py""" from __future__ import annotations import re from typing import TYPE_CHECKING from ..base_utils import compact, omit, presence, wrap from ..schema_utils import COMMONMETA_SCHEMA_URI if TYPE_CHECKING: from ..metadata import Metadata, MetadataList def collapse_whitespac...
front-matter/commonmeta-py
commonmeta/writers/commonmeta_writer.py
.py
3be72abd933d01c0
7.65
19
"""CSL-JSON writer for commonmeta-py""" from __future__ import annotations from typing import TYPE_CHECKING from ..base_utils import compact, parse_attributes, presence, wrap from ..constants import CM_TO_CSL_TRANSLATIONS from ..date_utils import get_date_parts from ..doi_utils import doi_from_url from ..utils impor...
front-matter/commonmeta-py
commonmeta/writers/csl_writer.py
.py
ae82580e61ac2051
7.65
19
"""ORCID writer for commonmeta-py. Writes a commonmeta *person* entity as `ORCID 3.0 record JSON <https://info.orcid.org/documentation/>`_ - the shape the ORCID API's ``/record`` endpoint serves (identity under ``person``, employments and educations under ``activities-summary``), and the inverse of :mod:`commonmeta.re...
front-matter/commonmeta-py
commonmeta/writers/orcid_writer.py
.py
8d663c865fac80ec
7.65
19
"""RIS writer for commonmeta-py""" from __future__ import annotations from typing import TYPE_CHECKING from ..base_utils import compact, parse_attributes, wrap from ..constants import CM_TO_RIS_TRANSLATIONS from ..doi_utils import doi_from_url from ..utils import to_ris if TYPE_CHECKING: from ..metadata import ...
front-matter/commonmeta-py
commonmeta/writers/ris_writer.py
.py
a5b3a630d351f380
7.65
19
"""ROR writer for commonmeta-py. Writes a commonmeta *organization* entity as a `ROR v2 API <https://ror.readme.io/v2/docs/data-structure>`_ record: the inverse of :mod:`commonmeta.readers.ror_reader`, so a ROR record read and written back returns to its original shape. Only what commonmeta models is written. A ROR r...
front-matter/commonmeta-py
commonmeta/writers/ror_writer.py
.py
d184f79e8395f6b7
7.65
19
import collections import logging import re from abc import ABC, abstractmethod from typing import Dict import dateparser import lxml.etree import newspaper import readability import trafilatura from boilerpy3 import extractors as bp3_extractors from bs4 import BeautifulSoup from goose3 import Goose from lxml.html imp...
mediacloud/metadata-lib
mcmetadata/content.py
.py
aab4d2968f367bb1
7.64
18
import logging import re from typing import Optional import py3langid as langid import trafilatura.utils logger = logging.getLogger(__name__) meta_tag_pattern1 = re.compile( r"<meta[^>]* (?:name|property)=.dc\.language.[^>]* content=\"([^\"]+)\"", re.S | re.I, ) meta_tag_pattern2 = re.compile( r"<meta[^>...
mediacloud/metadata-lib
mcmetadata/languages.py
.py
5b4957730b957832
7.64
18
""" Incantations for reqeusts to allow fetching from as many sites as Scrapy does. This was originally in mediacloud/story-indexer, but copied to metadata-lib to enable more mediacloud projects to consistently fetch web pages. WARNING: Do NOT use this if you care about data security/privacy. This has been added to me...
mediacloud/metadata-lib
mcmetadata/requests_arcana.py
.py
846139005535136b
7.64
18
import hashlib import logging import os import mcmetadata.webpages as webpages test_dir = os.path.dirname(os.path.realpath(__file__)) fixtures_dir = os.path.join(test_dir, "fixtures") # mcmetadata.webpages.DEFAULT_TIMEOUT_SECS = 500 # reset to a longer timeout for tests logger = logging.getLogger(__name__) def re...
mediacloud/metadata-lib
mcmetadata/test/__init__.py
.py
07313ce703a56149
8.14
18
import datetime as dt import unittest from parameterized import parameterized from .. import dates from . import read_fixture class TestDates(unittest.TestCase): @parameterized.expand( [ # subhead ( "https://web.archive.org/web/https://www.sun-sentinel.com/commun...
mediacloud/metadata-lib
mcmetadata/test/test_dates.py
.py
9f5986f773c58820
7.14
18
""" Extracted from django.utils.html """ from html.parser import HTMLParser class MLStripper(HTMLParser): def __init__(self): super().__init__(convert_charrefs=False) self.reset() self.fed = [] def handle_data(self, d): self.fed.append(d) def handle_entityref(self, name)...
mediacloud/metadata-lib
mcmetadata/text.py
.py
7d814609041d6c91
7.64
18
import logging import re import string from html import unescape from typing import Optional from . import text logger = logging.getLogger(__name__) SHORT_TITLE_THRESHOLD = 20 title_meta_pattern = "(?:og:title|hdl|twitter:title|dc.title|dcterms.title|title)" meta_tag_pattern_1 = re.compile( r"<meta[^>]*(?:name|...
mediacloud/metadata-lib
mcmetadata/titles.py
.py
e2906d44975b9fea
7.64
18
import hashlib import ipaddress import logging import pathlib import re from typing import Optional import tldextract import url_normalize from furl import furl from .urlshortners import URL_SHORTENER_HOSTNAMES # a list of high-volume domains that Media Cloud has historically ingested from, but are not news domains ...
mediacloud/metadata-lib
mcmetadata/urls.py
.py
ee571af05dfbbac2
7.64
18
""" Run URLs from our production system through the pipeline and save a CSV that lets us compare results to see if this code produces similar metadata to the system the heuristics were extracted from. Useful for validating that we are getting results we expect from the code as we evaluate different libraries and soluti...
mediacloud/metadata-lib
scripts/generate_comparison.py
.py
37a321fd0a84c6ec
7.64
18
#!/usr/bin/python # # Dummy test file for some of the e2e tests. import unittest class CoverageOutputTest(unittest.TestCase): def test_stuff(self): """Test that the flux capacitor is correctly calibrated.""" self.assertEqual(2, 2)
please-build/python-rules
test/coverage_output_test.py
.py
1447ca7d38a82635
7
9
import os import pytest def run(test_names, args): """Custom test runner entry point. This is fairly minimal and serves mostly to demonstrate how to define this as an entry point. Args: test_names: The names of the original test modules to be run (i.e. the things that were sr...
please-build/python-rules
test/custom_runner/runner.py
.py
02ac8c79531b1990
7
9
"""Test that data for a test isn't also packed into the .pex.""" import os import subprocess import unittest import zipfile class DataDepTest(unittest.TestCase): def test_cannot_import_data_dep(self): """Test that the file didn't get packed into the pex.""" import __main__ as pex_main wi...
please-build/python-rules
test/data_dep_only_test.py
.py
908add49f27f0af9
8
9
"""Test on deps, data, requires and provides.""" import os import subprocess import unittest class DataDepTest(unittest.TestCase): def test_direct_dep(self): """Test that we can import the module directly.""" from test import data_dep self.assertEqual(42, data_dep.the_answer()) def ...
please-build/python-rules
test/data_dep_test.py
.py
0418f057231da103
8
9
from importlib.metadata import PackagePath, files, version, distributions import os import unittest class DistributionMetadataTest(unittest.TestCase): """Tests that the pex meta path finder in ModuleDirImport is able to extract distribution metadata directly from a .dist-info directory inside the pex file. ...
please-build/python-rules
test/distribution_metadata_test.py
.py
571091e6a12ce7e2
8
9
"""Test for passing flags to python_test.""" import sys import unittest class FlagsTest(unittest.TestCase): def test_flags(self): self.assertIn("--test_flag", sys.argv)
please-build/python-rules
test/flags_test.py
.py
e60d28d8dae11a20
7
9
import sys import unittest import zipfile class InterpreterNotIncludedTest(unittest.TestCase): def test_interpreter_is_not_included(self): """Test that we don't include any in-repo interpreter in the .pex file.""" zf = zipfile.ZipFile(sys.argv[0]) names = [name for name in zf.namelist() i...
please-build/python-rules
test/interpreter_not_included_test.py
.py
55d5dac2032611c5
8
9
"""Tests for namespaced packages that share common folders.""" import unittest class NamespacedPackagesTest(unittest.TestCase): def test_namespaced_packages_are_importable(self): from google.api import auth_pb2 from google.protobuf import message self.assertIsNotNone(auth_pb2.AuthProvider...
please-build/python-rules
test/namespaced_packages_test.py
.py
fb441a4dc02faa80
7.5
9
import unittest class TestProtoLibrary(unittest.TestCase): def test_can_import_library(self): """Test that we can import the library. The real test is at build time, this is really just here to make sure that it gets built, and we might as well verify things are OK. """ f...
please-build/python-rules
test/proto_test.py
.py
df602d8662e7a144
7.5
9
""" The tests below test out the relative imports within a package """ from test.pytest.relative_imports import greetings, name def test_function_call(): assert greetings() == 'hello world' assert 1 == 1 def test_name(): assert name == 'TM'
please-build/python-rules
test/pytest/test_relative_imports.py
.py
12ef748bfc1063a0
7
9
"""Tests on the pytest runner framework.""" # This isn't normally necessary for pytest, but proves that we're using the correct runner # (otherwise unittest will just not call any of the test functions and report success) import pytest def test_answer(): """Deceptively simple test, from their examples. In t...
please-build/python-rules
test/pytest/test_runner.py
.py
5a3a196f24cf7369
8
9
"""This exists only as a test harness for examining slightly non-trivial coverage output.""" import sys from collections import defaultdict def calculate_answer(a, b): return a * b def the_answer(): return calculate_answer( 6, 7, )
please-build/python-rules
test/python_coverage.py
.py
6824d3100f3c57b3
7
9
import sys import unittest class PythonCoverageTest(unittest.TestCase): """Tests that we can import parts of the coverage module. By default it's not trivial to import binary modules from inside a pex. Also we need to package relevant versions of the tracer module, which can't work for every OS, but it'd...
please-build/python-rules
test/python_coverage_test.py
.py
79865999222a84e2
8
9
import importlib.resources import unittest class ResourcesTest(unittest.TestCase): """Tests that PexDistribution is able to provide access to files that are part of a distribution via the importlib.resources API. """ def test_read_resource_text_file(self): init = importlib.resources.files("py...
please-build/python-rules
test/resources_test.py
.py
ca0e146d28b6fe60
7.5
9
import sys import unittest class NoSiteTest(unittest.TestCase): def test_no_site_flag_passed(self): """Ensures that the Python interpreter was invoked with the -S option.""" self.assertTrue(sys.flags.no_site)
please-build/python-rules
test/site/no_site_test.py
.py
aef57fedbda8289b
7
9
import sys import unittest class SiteTest(unittest.TestCase): def test_no_site_flag_not_passed(self): """Ensures that the Python interpreter was *not* invoked with the -S option.""" self.assertFalse(sys.flags.no_site)
please-build/python-rules
test/site/site_test.py
.py
52b277106dbe1a4c
7
9
"""Tests on source stripping.""" import os import subprocess import unittest import zipfile class StripSourceTest(unittest.TestCase): def setUp(self): self.filename = [x for x in os.environ['DATA'].split(' ') if x.endswith('.pex')][0] def test_can_run_binary(self): """Test that the dependen...
please-build/python-rules
test/strip_source_test.py
.py
29ee22d00d17f2fd
8
9
import unittest class ZipUnsafeTest(unittest.TestCase): """Test importing something that requires zip-unsafety and exploding the pex.""" def test_can_import(self): from third_party.python.confluent_kafka import cimpl self.assertIsNotNone(cimpl)
please-build/python-rules
test/zip_unsafe_test.py
.py
c0bc09df37b25766
7
9
"""Zipfile entry point which supports auto-extracting itself based on zip-safety.""" import os import runpy import sys # Put this pex on the path before anything else. PEX = os.path.abspath(sys.argv[0]) # This might get overridden down the line if the pex isn't zip-safe. PEX_PATH = PEX sys.path = [PEX_PATH] + sys.pat...
please-build/python-rules
tools/please_pex/pex/pex_main.py
.py
2c550beff920e597
7.5
9
"""Customised test runner to output in JUnit-style XML.""" import os import sys # This will get templated in by the build rules. TEST_NAMES = '__TEST_NAMES__'.split(',') def initialise_coverage(): """Imports & initialises the coverage module.""" import coverage from coverage import control as coverage_c...
please-build/python-rules
tools/please_pex/pex/pex_test_main.py
.py
add0f8131698db17
8
9
"""Internal module for Please builtins.""" from collections import defaultdict from importlib import import_module, machinery from importlib.abc import MetaPathFinder from importlib.metadata import Distribution from importlib.util import spec_from_loader import itertools import os import re import sys import tempfile ...
please-build/python-rules
tools/please_pex/pex/plz.py
.py
efb0c96b9a8d0726
7.5
9
"""Forms for the adminalerts app""" from django import forms from django.conf import settings from django.utils import timezone # Projectroles dependency from projectroles.forms import SODARMartorWidget, SODARModelForm from adminalerts.models import AdminAlert # Local constants EMAIL_HELP_CREATE = 'Send alert as e...
bihealth/sodar-core
adminalerts/forms.py
.py
0b6a44d05f4f31ad
7.57
13
"""Models for the adminalerts app""" import uuid from django.conf import settings from django.db import models from django.utils import timezone from martor.models import MartorField # Access Django user model AUTH_USER_MODEL = getattr(settings, 'AUTH_USER_MODEL', 'auth.User') class AdminAlert(models.Model): ...
bihealth/sodar-core
adminalerts/models.py
.py
e59b7125f5cad6d7
7.57
13
"""Plugins for the adminalerts app""" from typing import Optional from django.contrib.auth import get_user_model from django.contrib.auth.models import AnonymousUser from django.urls import reverse from django.utils import timezone # Projectroles dependency from projectroles.models import SODAR_CONSTANTS from projec...
bihealth/sodar-core
adminalerts/plugins.py
.py
556338f528918e2f
7.57
13
"""Tests for models in the adminalerts app""" from django.contrib.auth import get_user_model from django.forms.models import model_to_dict from django.utils import timezone from test_plus.test import TestCase from adminalerts.models import AdminAlert User = get_user_model() class AdminAlertMixin: """Helper m...
bihealth/sodar-core
adminalerts/tests/test_models.py
.py
7e4b30bf6b691b4b
8.07
13
"""Tests for UI view permissions in the adminalerts app""" from django.test import override_settings from django.urls import reverse # Projectroles dependency from projectroles.tests.base import SiteAppPermissionTestBase from adminalerts.tests.test_models import AdminAlertMixin class AdminalertsPermissionTestBase(...
bihealth/sodar-core
adminalerts/tests/test_permissions.py
.py
b35b238fd3554997
7.07
13
"""Tests for Ajax view permissions in the adminalerts app""" from django.test import override_settings from django.urls import reverse # Projectroles dependency from projectroles.tests.base import SiteAppPermissionTestBase from adminalerts.tests.test_models import AdminAlertMixin class TestAdminAlertActiveToggleAj...
bihealth/sodar-core
adminalerts/tests/test_permissions_ajax.py
.py
fb6b14b061047726
8.07
13
"""Plugin tests for the adminalerts app""" from test_plus.test import TestCase from django.urls import reverse # Projectroles dependency from projectroles.plugins import SiteAppPluginPoint from adminalerts.models import AdminAlertDismissal from adminalerts.urls import urlpatterns from adminalerts.tests.test_models ...
bihealth/sodar-core
adminalerts/tests/test_plugins.py
.py
02464980051243e4
8.07
13
"""UI tests for the adminalerts app""" from django.urls import reverse from django.utils import timezone from selenium.common.exceptions import NoSuchElementException from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as ec from selenium.webdriver.support.ui import ...
bihealth/sodar-core
adminalerts/tests/test_ui.py
.py
cf9dc3c147406b50
7.07
13
"""Tests for UI views in the adminalerts app""" from django.conf import settings from django.core import mail from django.test import override_settings from django.urls import reverse from django.utils import timezone from test_plus.test import TestCase # Projectroles dependency from projectroles.app_settings import...
bihealth/sodar-core
adminalerts/tests/test_views.py
.py
b8935791c2b4ca9c
7.07
13
"""Tests for Ajax views in the adminalerts app""" import json from django.urls import reverse from adminalerts.models import AdminAlertDismissal from adminalerts.tests.test_views import AdminalertsViewTestBase class TestAdminAlertActiveToggleAjaxView(AdminalertsViewTestBase): """Tests for AdminAlertActiveToggl...
bihealth/sodar-core
adminalerts/tests/test_views_ajax.py
.py
3b16f101741b0285
8.07
13
"""Ajax views for the adminalerts app""" from django.http import HttpResponseBadRequest from rest_framework.response import Response # Projectroles dependency from projectroles.views_ajax import SODARBasePermissionAjaxView from adminalerts.models import AdminAlert, AdminAlertDismissal class AdminAlertActiveToggle...
bihealth/sodar-core
adminalerts/views_ajax.py
.py
f0ec4e3003e708ee
7.57
13
"""Backend API for the appalerts app""" from typing import Optional from django.contrib.auth import get_user_model from djangoplugins.models import Plugin from appalerts.models import AppAlert, ALERT_LEVELS # Projectroles dependency from projectroles.models import Project User = get_user_model() class AppAlert...
bihealth/sodar-core
appalerts/api.py
.py
c94f782b630e43db
7.57
13
"""Models for the appalerts app""" import uuid from django.core.exceptions import ValidationError from django.conf import settings from django.db import models from djangoplugins.models import Plugin # Projectroles dependency from projectroles.models import Project # Access Django user model AUTH_USER_MODEL = geta...
bihealth/sodar-core
appalerts/models.py
.py
29d6db1047db37b0
7.57
13
"""Backend API tests for the appalerts app""" from django.forms.models import model_to_dict from django.urls import reverse from djangoplugins.models import Plugin from test_plus.test import TestCase # Projectroles dependency from projectroles.models import SODAR_CONSTANTS from projectroles.plugins import PluginAPI ...
bihealth/sodar-core
appalerts/tests/test_api.py
.py
ed4ac10993a2f8a7
8.07
13
"""Model tests for the appalerts app""" from typing import Optional from django.contrib.auth import get_user_model from django.core.exceptions import ValidationError from django.forms.models import model_to_dict from django.urls import reverse from djangoplugins.models import Plugin from test_plus.test import TestCa...
bihealth/sodar-core
appalerts/tests/test_models.py
.py
0f1ffd066adb57c1
7.07
13
"""Tests for view permissions in the appalerts app""" from django.test import override_settings from django.urls import reverse # Projectroles dependency from projectroles.tests.base import SiteAppPermissionTestBase from appalerts.tests.test_models import AppAlertMixin class AppalertsPermissionTestBase(AppAlertMix...
bihealth/sodar-core
appalerts/tests/test_permissions.py
.py
09adf3f7999c2a92
7.07
13
"""Tests for template tags in the appalerts app""" from django.contrib.auth import get_user_model from test_plus.test import TestCase from appalerts.templatetags import appalerts_tags as tags from appalerts.tests.test_models import AppAlertMixin User = get_user_model() # Local constants ALERT_MSG = 'Test message...
bihealth/sodar-core
appalerts/tests/test_templatetags.py
.py
4ecec66f8ffd2839
8.07
13
"""UI tests for the appalerts app""" import time from django.urls import reverse from selenium.common.exceptions import NoSuchElementException from selenium.webdriver.common.by import By from selenium.webdriver.remote.webelement import WebElement from selenium.webdriver.support import expected_conditions as ec from ...
bihealth/sodar-core
appalerts/tests/test_ui.py
.py
e878e66e30a16a87
7.07
13
"""UI views for the appalerts app""" from django.contrib import messages from django.http import HttpResponseRedirect from django.shortcuts import redirect from django.urls import reverse from django.views.generic import ListView, View from django.conf import settings # Projectroles dependency from projectroles.app_s...
bihealth/sodar-core
appalerts/views.py
.py
5482327d538439c9
7.57
13
"""Ajax API views for the appalerts app""" from rest_framework.response import Response # Projectroles dependency from projectroles.views_ajax import SODARBaseAjaxView from appalerts.models import AppAlert class AppAlertStatusAjaxView(SODARBaseAjaxView): """View to get app alert status for user""" permiss...
bihealth/sodar-core
appalerts/views_ajax.py
.py
5ebd801a3e6d6373
7.57
13
"""Code that represents a shell command.""" from __future__ import annotations import typing as t from aiida.orm import InstalledCode __all__ = ('ShellCode',) class ShellCode(InstalledCode): """Code that represents a shell command. This code type is automatically generated by the :func:`~aiida_shell.engi...
aiidateam/aiida-shell
src/aiida_shell/data/code.py
.py
afe6f8e533bb8df4
7.62
16
"""Data plugin to store a reference to an entry point.""" from __future__ import annotations import typing as t from aiida.common.exceptions import EntryPointError from aiida.common.lang import type_check from aiida.common.log import AIIDA_LOGGER from aiida.orm import Data from aiida.plugins.entry_point import get_e...
aiidateam/aiida-shell
src/aiida_shell/data/entry_point.py
.py
7eb8c83afc9f61ff
7.62
16
"""Data plugin to store (almost) any Python object by pickling it.""" from __future__ import annotations import importlib.metadata import io import typing as t import dill from aiida.common.log import AIIDA_LOGGER from aiida.orm import SinglefileData __all__ = ('PickledData',) LOGGER = AIIDA_LOGGER.getChild('pickl...
aiidateam/aiida-shell
src/aiida_shell/data/pickled.py
.py
bff5a3cc4180958c
7.62
16
"""Module with test fixtures.""" from __future__ import annotations import collections import pathlib import shutil import tempfile import typing as t import uuid import pytest from aiida.common import exceptions from aiida.common.datastructures import CalcInfo from aiida.common.folders import Folder from aiida.comm...
aiidateam/aiida-shell
tests/conftest.py
.py
6a4a31cc1e777ebe
8.12
16
"""Tests for :mod:`aiida_shell.data.code`.""" import pytest from aiida_shell.data.code import ShellCode def test_constructor(generate_computer): """Test initializing an instance.""" code = ShellCode( label='bash', computer=generate_computer(), filepath_executable='/bin/bash', ...
aiidateam/aiida-shell
tests/data/test_code.py
.py
cb3bb78f5e68463d
8.12
16
"""Tests for the :mod:`aiida_shell.data.entry_point` module.""" import pytest from aiida.orm import load_node from aiida.plugins.entry_point import get_entry_point from importlib_metadata import EntryPoint from aiida_shell.data.entry_point import EntryPointData InvalidEntryPoint = EntryPoint('b', 'a', group='c') Inc...
aiidateam/aiida-shell
tests/data/test_entry_point.py
.py
2a58afaa1b20c1e5
8.12
16
"""Tests for the :mod:`aiida_shell.data.pickled` module.""" import dill import pytest from aiida.orm import Node, load_node from aiida_shell.data.pickled import PickledData def test_constructor(): """Test the constructor of :class:`~aiida_shell.data.pickled.PickledData`.""" node = PickledData(None) asse...
aiidateam/aiida-shell
tests/data/test_pickled.py
.py
2ec6d29d5d5204cb
8.12
16
"""Tests for the :mod:`aiida_shell.parsers.shell` module.""" import copy import pathlib import pytest from aiida.orm import FolderData, List, SinglefileData from aiida_shell.calculations.shell import ShellJob @pytest.fixture def create_retrieved_temporary(tmp_path): """Create a temporary directory to serve as ...
aiidateam/aiida-shell
tests/parsers/test_shell.py
.py
92a44c14bd3a8a54
8.12
16
"""Tests for the :mod:`aiida_shell.launch` module.""" import datetime import json import pathlib import shutil import pytest from aiida.engine import WorkChain, run_get_node, workfunction from aiida.orm import AbstractCode, Computer, Float, InstalledCode, Int, PortableCode, RemoteData, SinglefileData, Str from aiida...
aiidateam/aiida-shell
tests/test_launch.py
.py
f6af56ba5f3bbcf2
8.12
16
from __future__ import annotations import math from collections.abc import Callable, Collection, Iterable from typing import SupportsFloat, cast, overload from scipy.interpolate import interp1d # type: ignore[import-untyped] from . import Smoothing, Utils class PlottingDependencyError(RuntimeError): """Raised...
LukasB97/ORCA
orca/Curve.py
.py
910fc62269079f5d
7.5
9
""" Application Configuration (config.py) Purpose: Stores the configuration used by the application. Classes: BackupConfig Settings for backup files. AppConfig Main application settings, including Google Cloud resources and optional backup configuration. """ from dataclasses impo...
alphagov/govuk-knowledge-graph-gcp
docker/docdb-bq-loader/models/config.py
.py
c3588b2c613f8211
7.57
13
""" MongoDB Document Cleaner (sanitizers.py) This script prepares MongoDB data so it can be safely saved into databases like BigQuery without causing errors. It does this by fixing inconsistent fields and removing empty (None) values. Functions: 1. serialize_and_strip_nulls() : Converts special MongoDB data types i...
alphagov/govuk-knowledge-graph-gcp
docker/docdb-bq-loader/utils/sanitizers.py
.py
0561959d7798183d
7.57
13
import os import time import sshconf from threading import Thread from cryptography.hazmat.primitives.asymmetric import rsa from cryptography.hazmat.primitives import serialization def generate_ssh_key_pair(identity_file): """ Generates an SSH key pair and writes them to the specified identity file. :p...
osbuild/cloud-image-val
lib/ssh_lib.py
.py
84a19eadf50eb3ce
7.57
13
""" Advanced CI test selection logic for cloud-image-val: - If ONLY specific test methods in a cloud test file are changed, run only those methods for that cloud. - If ONLY specific test methods in a generic test file are changed, run only those methods for all clouds. - If any other files or logic are changed (includi...
osbuild/cloud-image-val
schutzbot/get_civ_config.py
.py
6c064caa8a3c2458
7.57
13
import pytest from schutzbot.get_civ_config import ( detect_if_only_specific_methods_changed, CLOUD_TEST_FILES, GENERIC_TEST_FILE ) def mock_get_method_changes_for_file(test_file): # Patch this function in tests return { CLOUD_TEST_FILES['aws']: {'test_aws_method1'}, CLOUD_TEST_FI...
osbuild/cloud-image-val
test/test_get_civ_config_logic.py
.py
db3f7465f8bf852f
8.07
13
import json import pytest from packaging import version import difflib from lib import console_lib from lib import test_lib def get_offer_or_vm_name(instance_data_azure_web): """ Helper function to get offer from Azure metadata, with VM name as fallback. Returns a tuple of (source_value, source_type) wh...
osbuild/cloud-image-val
test_suite/cloud/test_azure.py
.py
0441fc39f918afc1
8.07
13
import json import pytest @pytest.fixture def instance_data_oci_web(host): """ Fetch instance metadata from OCI IMDS (Instance Metadata Service). """ oci_metadata_url = 'http://169.254.169.254/opc/v2/instance/' command_to_run = f'curl -s -H "Authorization: Bearer Oracle" "{oci_metadata_url}"' ...
osbuild/cloud-image-val
test_suite/cloud/test_oci.py
.py
002a119d4dc3abc4
8.07
13
import os import re import time import pytest import requests from packaging import version from py.xml import html from pytest_html import extras from requests.adapters import HTTPAdapter from requests.packages.urllib3.util.retry import Retry from test_suite.generic import helpers from lib import test_lib, aws_lib ...
osbuild/cloud-image-val
test_suite/conftest.py
.py
40b99eff93f81c5e
8.07
13
import os import json from lib import test_lib INSTANCES_JSON_PATH = os.environ['CIV_INSTANCES_JSON'] def __get_instance_data_from_json(key_to_find, values_to_find, path=INSTANCES_JSON_PATH): with open(path, 'r') as f: instances_json_data = json.load(f) for instance in instances_json_data.values(): ...
osbuild/cloud-image-val
test_suite/generic/helpers.py
.py
2c13cd7bb648ddca
8.07
13
import pytest from lib import test_lib class TestsReboot: hostname_before_reboot_file = '/var/hostname_before_reboot' kmemleak_arg = 'kmemleak=on' def setup_before_reboot(self, host): with host.sudo(): host.run(f'hostname > {self.hostname_before_reboot_file}') host.run_tes...
osbuild/cloud-image-val
test_suite/generic/test_reboot.py
.py
0615cd4bac35fe05
8.07
13
import pytest from lib import console_lib from test_suite.rhel_devel import run_cloudx_components_testing """ CTC (Comprehensive Tests Cycle) refers to the RHEL testing phase were we thoroughly test our components on a specified RHEL version. There is also CTC2 which is another round in a later stage of SDLC. """ @p...
osbuild/cloud-image-val
test_suite/rhel_devel/ctc/test_ctc.py
.py
ef1fbab298421f86
7.07
13
"""Sphinx documentation configuration file.""" from datetime import datetime import os from pathlib import Path from ansys_sphinx_theme import ansys_favicon, get_version_match import jinja2 from tabulate import tabulate import yaml # Constants used for generating documentation DOC_SOURCE_DIR = Path(__file__).parent....
ansys/actions
doc/source/conf.py
.py
5fb66b504f4d1d94
7.65
19
# Copyright (C) 2022 - 2026 Synopsys, Inc. and ANSYS, Inc. All rights reserved. # SPDX-License-Identifier: MIT # # # 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, includi...
ansys/actions
python-utils/parse_doc_conf.py
.py
982991963b912566
7.65
19
# Copyright (C) 2022 - 2026 Synopsys, Inc. and ANSYS, Inc. All rights reserved. # SPDX-License-Identifier: MIT # # # 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, includi...
ansys/actions
python-utils/update_tag_references.py
.py
f435021cfd241e98
7.65
19
# Copyright (C) 2022 - 2026 Synopsys, Inc. and ANSYS, Inc. All rights reserved. # SPDX-License-Identifier: MIT # # # 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, includi...
ansys/actions
python-utils/versions.py
.py
3d386b4133102ada
7.65
19
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
datacommonsorg/import
pipeline/workflow/aggregation-helper/aggregation/bq_executor.py
.py
6cafa111117a2327
7.45
7
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
datacommonsorg/import
pipeline/workflow/aggregation-helper/aggregation/deleter.py
.py
d35b9f745e828a9d
7.45
7
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
datacommonsorg/import
pipeline/workflow/aggregation-helper/aggregation/e2e_tests/base.py
.py
202c910d60d6611c
7.95
7
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
datacommonsorg/import
pipeline/workflow/aggregation-helper/aggregation/e2e_tests/deletions_test.py
.py
1e767e8a26498f14
7.95
7
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
datacommonsorg/import
pipeline/workflow/aggregation-helper/aggregation/e2e_tests/embedding_generator_test.py
.py
b5225f9f567ee06c
7.95
7
# Copyright 2026 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, ...
datacommonsorg/import
pipeline/workflow/aggregation-helper/aggregation/e2e_tests/provenance_scoping_test.py
.py
7ee27c226ac2c1cf
7.95
7
#!/usr/bin/env python3 # Copyright 2023 Canonical Ltd. # See LICENSE file for licensing details. """Structured configuration for the Kafka charm.""" import logging import re from enum import Enum from typing import Literal from charms.data_platform_libs.v0.data_models import BaseConfigModel from pydantic import Fiel...
canonical/kafka-operator
common/single_kernel_kafka/core/structured_config.py
.py
5cbac23b86afe008
7.54
11
#!/usr/bin/env python3 # Copyright 2024 Canonical Ltd. # See LICENSE file for licensing details. """Event handlers for Juju Actions.""" import logging from typing import TYPE_CHECKING from ops.charm import ActionEvent from ops.framework import Object if TYPE_CHECKING: from ..core.models import KafkaCharmBase as...
canonical/kafka-operator
common/single_kernel_kafka/events/actions.py
.py
c159b503c108fad2
7.54
11
#!/usr/bin/env python3 # Copyright 2024 Canonical Ltd. # See LICENSE file for licensing details. """Balancer role core charm logic.""" import logging from subprocess import CalledProcessError from typing import TYPE_CHECKING, Literal from charms.data_platform_libs.v0.data_interfaces import RelationEvent from ops imp...
canonical/kafka-operator
common/single_kernel_kafka/events/balancer.py
.py
cd536a00ca513e3c
7.54
11
#!/usr/bin/env python3 # Copyright 2025 Canonical Ltd. # See LICENSE file for licensing details. """Event Handler for Kafka Connect related events.""" import logging from typing import TYPE_CHECKING from charms.data_platform_libs.v0.data_interfaces import PLUGIN_URL_NOT_REQUIRED from ops.charm import ( ConfigCha...
canonical/kafka-operator
common/single_kernel_kafka/events/connect/base.py
.py
a8bae72031fd8f3b
7.54
11
#!/usr/bin/env python3 # Copyright 2025 Canonical Ltd. # See LICENSE file for licensing details. """KafkaHandler class and methods.""" import logging from typing import TYPE_CHECKING from charms.data_platform_libs.v0.data_interfaces import ( KafkaRequirerEventHandlers, ) from ops.charm import RelationBrokenEvent...
canonical/kafka-operator
common/single_kernel_kafka/events/connect/kafka.py
.py
bacdb13d1ed4a523
7.54
11
#!/usr/bin/env python3 # Copyright 2025 Canonical Ltd. # See LICENSE file for licensing details. """Event Handler for Connect Client Provider events.""" import logging from typing import TYPE_CHECKING from charms.data_platform_libs.v0.data_interfaces import ( PLUGIN_URL_NOT_REQUIRED, IntegrationRequestedEven...
canonical/kafka-operator
common/single_kernel_kafka/events/connect/provider.py
.py
077e36e137e3a566
7.54
11
#!/usr/bin/env python3 # Copyright 2025 Canonical Ltd. # See LICENSE file for licensing details. """TLSHandler class and methods.""" import json import logging from typing import TYPE_CHECKING from charms.tls_certificates_interface.v3.tls_certificates import ( CertificateAvailableEvent, TLSCertificatesRequir...
canonical/kafka-operator
common/single_kernel_kafka/events/connect/tls.py
.py
527af445f9073122
7.54
11
#!/usr/bin/env python3 # Copyright 2025 Canonical Ltd. # See LICENSE file for licensing details. """Event Handler for user-defined secret events. User management on the Kafka Connect REST API could be done by defining secrets and granting their access to the charm. The flow for defining secrets and granting access t...
canonical/kafka-operator
common/single_kernel_kafka/events/connect/user_secrets.py
.py
c28276a8508c1cad
7.54
11
#!/usr/bin/env python3 # Copyright 2024 Canonical Ltd. # See LICENSE file for licensing details. """Handler for controller specific logic.""" import logging from typing import TYPE_CHECKING from ops import ( LeaderElectedEvent, Object, PebbleReadyEvent, RelationDepartedEvent, StartEvent, Upda...
canonical/kafka-operator
common/single_kernel_kafka/events/controller.py
.py
2a68bafc7eb476d8
7.54
11
#!/usr/bin/env python3 # Copyright 2024 Canonical Ltd. # See LICENSE file for licensing details. """Manager for handling Kafka OAuth configuration.""" import logging from typing import TYPE_CHECKING from charms.hydra.v0.oauth import ClientConfig, OAuthRequirer from ops.framework import EventBase, Object from ..core...
canonical/kafka-operator
common/single_kernel_kafka/events/oauth.py
.py
81e96a8400c2fa75
7.54
11