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 |
|---|---|---|---|---|---|---|
import webBackend.models as models
import requests
import json
import time
def getUserJson(userID: str):
"""
Gets User JSON from Database.
Parameters:
userID (str): User ID
Returns:
dict: User Json
"""
return json.loads(models.Users.objects.get(user=str(userID)).cache)
... | ArthurVardevanyan/Analytics-for-Spotify | webBackend/credentials.py | .py | 85a9a3d088f83693 | 7.45 | 7 |
# Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# 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 require... | ros-tooling/ros-github-scripts | ros_github_scripts/generate_contribution_report.py | .py | 10c217d78eeca2e1 | 7.5 | 9 |
# Copyright 2021 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# 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 require... | ros-tooling/ros-github-scripts | test/test_linters.py | .py | 4da6be895381a713 | 7 | 9 |
from __future__ import annotations
__all__ = [
"TopOTheHourBotConfiguration",
"TopOTheHourBot",
]
from dataclasses import dataclass
from typing import override
from websockets import WebSocketClientProtocol
from .system import Client
from .utilities import Configuration
@dataclass(slots=True, kw_only=True... | TopOTheHourBot/TopOTheHourBot | topothehourbot/core.py | .py | 8238fdaa7296eae2 | 7.54 | 11 |
from __future__ import annotations
__all__ = [
"PathLike",
"Configuration",
]
import dataclasses
import os
import pickle
from dataclasses import dataclass
from typing import Optional, Self
type PathLike = str | bytes | os.PathLike
@dataclass(slots=True, kw_only=True)
class Configuration:
@classmethod
... | TopOTheHourBot/TopOTheHourBot | topothehourbot/utilities/configuration.py | .py | 7bd25fcf5f3add0d | 7.54 | 11 |
# Copyright (c) 2024 Reciprocal Space Ship
# SPDX-License-Identifier: MIT
"""iterative TV-based phase retrieval"""
from __future__ import annotations
import numpy as np
import reciprocalspaceship as rs
import structlog
from .metadata import TvIterationMetadata, TvScanMetadata
from .rsmap import Map
from .settings i... | rs-station/meteor | meteor/iterative.py | .py | cdd05327b0febe80 | 7.48 | 8 |
# Copyright (c) 2024 Reciprocal Space Ship
# SPDX-License-Identifier: MIT
"""MTZ input/output helper functions"""
from __future__ import annotations
import re
from .settings import (
COMPUTED_AMPLITUDE_COLUMNS,
COMPUTED_PHASE_COLUMNS,
OBSERVED_AMPLITUDE_COLUMNS,
OBSERVED_INTENSITY_COLUMNS,
OBSER... | rs-station/meteor | meteor/mtzio.py | .py | 2c32dbd55f6c3f1d | 7.48 | 8 |
# Copyright (c) 2024 Reciprocal Space Ship
# SPDX-License-Identifier: MIT
"""(anisotropic) scaling of crystallographic datasets"""
from __future__ import annotations
from collections.abc import Callable
from enum import StrEnum
import numpy as np
import pandas as pd
import scipy.optimize as opt
import structlog
fr... | rs-station/meteor | meteor/scale.py | .py | f5445c7ebede62dd | 7.48 | 8 |
# Copyright (c) 2024 Reciprocal Space Ship
# SPDX-License-Identifier: MIT
"""computing structure factors from models"""
from pathlib import Path
import gemmi
from .rsmap import Map
def gemmi_structure_to_calculated_map(
structure: gemmi.Structure,
*,
high_resolution_limit: float,
map_sampling: flo... | rs-station/meteor | meteor/sfcalc.py | .py | 5d859fd60c6a9b90 | 7.48 | 8 |
# Copyright (c) 2024 Reciprocal Space Ship
# SPDX-License-Identifier: MIT
"""total variation denoising of maps"""
from __future__ import annotations
from collections.abc import Sequence
from typing import Literal, overload
import numpy as np
import structlog
from skimage.restoration import denoise_tv_chambolle
fro... | rs-station/meteor | meteor/tv.py | .py | 486989ee591c5cbc | 7.48 | 8 |
# Copyright (c) 2024 Reciprocal Space Ship
# SPDX-License-Identifier: MIT
"""crystallographic helper functions"""
from __future__ import annotations
from collections.abc import Sequence
from typing import TYPE_CHECKING, Literal, TypeAlias, overload
import gemmi
import numpy as np
import reciprocalspaceship as rs
im... | rs-station/meteor | meteor/utils.py | .py | 898f9187bbaa47e3 | 7.48 | 8 |
# Copyright (c) 2024 Reciprocal Space Ship
# SPDX-License-Identifier: MIT
"""map quality assessment: negentropy and negentropy maximization"""
from __future__ import annotations
from collections.abc import Callable, Sequence
import numpy as np
from scipy.optimize import minimize_scalar
from scipy.stats import diffe... | rs-station/meteor | meteor/validate.py | .py | 3dd09488a5e9c2fe | 7.48 | 8 |
import argparse
import json
import os
from generating.generating import TARGETS
from typing import Any, Dict, List, Tuple, Optional
class Config:
"""
A finalized configuration for the compiler run.
The object deals with loading in all the options from different source,
verifying them and decid... | farkon00/cont | config.py | .py | 23ad1e6cafd5e31a | 7.64 | 18 |
import sys
from dataclasses import dataclass
from typing import List, Tuple, Dict, Set, Optional, Any, Generator
from enum import Enum, auto
from functools import reduce
from parsing.op import Op
class InternalAssertionError(Exception):
"""Error used in case there is an assertion needed in cont"""
... | farkon00/cont | state.py | .py | 3b4431ff437ee171 | 7.64 | 18 |
from abc import ABC, abstractmethod
from typing import List, Tuple, Dict, Optional
from state import State, Proc, cont_assert
class Type(ABC):
"""An abstract class for all cont types"""
def __hash__(self) -> int:
return hash(self.text_repr())
@abstractmethod
def __eq__(self, othe... | farkon00/cont | type_checking/types.py | .py | 3874a5abb91e9df2 | 7.64 | 18 |
"""Devpi PyPI to test with."""
from __future__ import annotations
import random
import socket
import string
import sys
import sysconfig
from contextlib import closing
from pathlib import Path
from subprocess import PIPE, Popen, run # ruff:ignore[suspicious-subprocess-import]
from threading import Thread
from typing ... | tox-dev/devpi-process | src/devpi_process/__init__.py | .py | 1fefd055009364c4 | 7.52 | 10 |
# 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, ... | GoogleCloudPlatform/composer-utilities | composer_cluster_policy/tests/test_cluster_policy.py | .py | f931edda193f1f70 | 8.04 | 11 |
/**
* 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 ... | GoogleCloudPlatform/composer-utilities | control_panel/src/components/DagEditView.test.js | .js | 6c7ec98a7b064e2c | 7.04 | 11 |
/**
* 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 ... | GoogleCloudPlatform/composer-utilities | control_panel/src/components/EndpointView.test.js | .js | 5976077538f7102d | 7.04 | 11 |
/**
* 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 ... | GoogleCloudPlatform/composer-utilities | control_panel/src/components/Sidebar.test.js | .js | 53602fa2338a6700 | 7.04 | 11 |
/**
* 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 ... | GoogleCloudPlatform/composer-utilities | control_panel/src/context/EnvironmentContext.test.js | .js | 4a6fb76e5374c993 | 7.04 | 11 |
# Copyright 2025 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, ... | GoogleCloudPlatform/composer-utilities | dag_parsing_profiler/linter_core.py | .py | 037512cec62124b6 | 7.54 | 11 |
"""
Copyright 2022 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
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, soft... | GoogleCloudPlatform/composer-utilities | environment_diff/src/environment_diff/lib/difference.py | .py | d306ae41d98d64f6 | 7.54 | 11 |
"""
Copyright 2022 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
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, soft... | GoogleCloudPlatform/composer-utilities | environment_diff/src/environment_diff/lib/strategies/diff_airflow_config.py | .py | 9e6a25d0d573f031 | 7.54 | 11 |
"""
Copyright 2022 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
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, soft... | GoogleCloudPlatform/composer-utilities | environment_diff/src/environment_diff/lib/strategies/diff_env_image.py | .py | 440f28bebcd41c7b | 7.54 | 11 |
"""
Copyright 2022 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
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, soft... | GoogleCloudPlatform/composer-utilities | environment_diff/src/environment_diff/lib/strategies/diff_env_variables.py | .py | d980ded5434179e3 | 7.54 | 11 |
"""
Copyright 2022 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
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, soft... | GoogleCloudPlatform/composer-utilities | environment_diff/src/environment_diff/lib/strategies/diff_pypi_packages.py | .py | 1db9b934694cd8b4 | 7.54 | 11 |
"""
Copyright 2022 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
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, soft... | GoogleCloudPlatform/composer-utilities | environment_diff/src/environment_diff/lib/strategies/strategy.py | .py | 1a9e40150532ad71 | 7.54 | 11 |
#!/usr/bin/env python
"""Collection of functions to compare 2 CSLC HDF5 contents and metadata"""
import argparse
import os
import h5py
import numpy as np
from osgeo import gdal
# from compass.utils.h5_helpers import DATA_PATH, ROOT_PATH
ROOT_PATH = '/'
DATA_PATH = '/data'
def cmd_line_parser():
"""Command lin... | nasa/opera-sds-pge | .ci/scripts/cslc_s1/cslc_s1_compare.py | .py | 6b728cf30a914d6b | 7.66 | 20 |
#!/usr/bin/env python3
"""
==================
diff_dswx_files.py
==================
Python program to perform Quality Assurance Test on a directory of NetCDF4 files.
This script searches for files with a .tif file extension and calls a subprocess
script, dswx_comparison.py, located in the dswx_s1_x.y.z directory shown... | nasa/opera-sds-pge | .ci/scripts/dswx_s1/diff_dswx_files.py | .py | a6f26cf2d94e753e | 7.66 | 20 |
#!/usr/bin/env python3
"""
======================
process_metric_data.py
======================
Post process the csv file returned when metric data is collected
"""
import csv
import os
import sys
def remove_unwanted_lines(csv_file, file_name, expected_column_count):
"""
Remove all lines without data from... | nasa/opera-sds-pge | .ci/scripts/metrics/process_metric_data.py | .py | 9605e92e5d0f9aed | 7.66 | 20 |
#!/usr/bin/env python3
"""
============
runconfig.py
============
Module for parsing and validating run configuration files for OPERA PGEs.
This module is adapted for OPERA from the NISAR PGE R2.0.0 util/l1_l2_runconfig.py
Original Author: David White
Adapted By: Scott Collins
"""
import os
from os.path import abs... | nasa/opera-sds-pge | src/opera/pge/base/runconfig.py | .py | 423d08d589949add | 7.66 | 20 |
#!/usr/bin/env python3
"""
==============
tropo_pge.py
==============
Module defining the implementation for the TROPO PGE.
"""
import re
from datetime import datetime, timedelta
from os import listdir
from os.path import abspath, basename, getsize, join, splitext
from opera.pge.base.base_pge import PgeExecutor
from... | nasa/opera-sds-pge | src/opera/pge/tropo/tropo_pge.py | .py | 159399bb3de0e9d9 | 7.66 | 20 |
#!/usr/bin/env python3
# Original Author: David White
# Adapted By: Jim Hofman
"""
============
pge_main.py
============
Instantiates and runs an OPERA Product Generation Executable (PGE) instance.
The PGE type instantiated is determined from the provided RunConfig.
"""
import argparse
import os
from importlib imp... | nasa/opera-sds-pge | src/opera/scripts/pge_main.py | .py | 5ac97c176809d34e | 7.66 | 20 |
#!/usr/bin/env python3
"""
====
test
====
The unit-level regression test module for the OPERA PGE Subsystem.
"""
import os
import pathlib
import types
from importlib.resources import as_file, files
from typing import Union, ContextManager
Package = Union[types.ModuleType, str]
Resource = Union[str, os.PathLike]
... | nasa/opera-sds-pge | src/opera/test/__init__.py | .py | ef4f4e9a31022d7d | 8.16 | 20 |
#!/usr/bin/env python3
"""
=================
test_runconfig.py
=================
Unit tests for the pge/runconfig.py module.
"""
import os
import tempfile
import unittest
from os.path import join
from opera.test import path
from importlib.resources import files
from yamale import YamaleError
from opera.pge import ... | nasa/opera-sds-pge | src/opera/test/pge/base/test_runconfig.py | .py | d8d0326587eb5d90 | 8.16 | 20 |
#!/usr/bin/env python3
"""
===================
test_tropo_pge.py
===================
Unit tests for the pge/tropo/tropo_pge.py module.
"""
import glob
import os
import random
import tempfile
import unittest
from io import StringIO
from os import listdir
from os.path import abspath, exists, join
from pathlib import Pa... | nasa/opera-sds-pge | src/opera/test/pge/tropo/test_tropo_pge.py | .py | 4a7232a57df9b245 | 8.16 | 20 |
#!/usr/bin/env python3
"""
=================
test_main_pge.py
=================
Unit tests for the pge/base_pge.py module.
"""
import os
import subprocess
import tempfile
import unittest
from os.path import abspath, join
from pathlib import Path
from opera.test import path
from opera.pge import PgeExecutor, RunConf... | nasa/opera-sds-pge | src/opera/test/scripts/test_pge_main.py | .py | e56f6c01880ec3df | 8.16 | 20 |
#!/usr/bin/env python
"""
=====================
test_dataset_utils.py
=====================
Unit tests for the util/dataset_utils.py module.
"""
import os
import unittest
from os.path import abspath, join
from re import match
from opera.test import path
from opera.util.dataset_utils import get_hls_filename_fields... | nasa/opera-sds-pge | src/opera/test/util/test_dataset_utils.py | .py | c82cf96ed0697c48 | 8.16 | 20 |
#!/usr/bin/env python
"""
===============
test_metfile.py
===============
Unit tests for the util/metfile.py module.
"""
import os
import tempfile
import unittest
from os.path import abspath, exists
from opera.test import path
from opera.util.metfile import MetFile
class MetFileTestCase(unittest.TestCase):
"""... | nasa/opera-sds-pge | src/opera/test/util/test_metfile.py | .py | 32cee39c68d215e5 | 8.16 | 20 |
#!/usr/bin/env python
"""
==================
test_tiff_utils.py
==================
Unit tests for the util/tiff_utils.py module.
"""
import os
import unittest
from datetime import datetime
from os.path import abspath, join
from unittest import skipIf
from opera.test import path
from opera.util.tiff_utils import g... | nasa/opera-sds-pge | src/opera/test/util/test_tiff_utils.py | .py | e03f25e43aa20c09 | 8.16 | 20 |
# -*- coding: utf-8 -*-
import pathlib
from collections import defaultdict
from setuptools import setup, find_packages
def get_requirements(path):
"""Parse runtime requirements file."""
with open(path) as depfile:
return [
line.strip()
for line in depfile
if line.st... | moldyn/dcTMD | setup.py | .py | a7742e020317ee77 | 7.63 | 17 |
# -*- coding: utf-8 -*-
"""
Class for defining typing.
In this module all type hint types are defined. Adapted copy of the file with
the same name from MoSAIC (github.com/moldyn/MoSAIC).
MIT License
Copyright (c) 2021-2022, Daniel Nagel, Victor Tanzel
All rights reserved.
"""
import numpy as np
from beartype.typing ... | moldyn/dcTMD | src/dcTMD/_typing.py | .py | 24923461ef39021b | 7.63 | 17 |
import glob
import re
import numpy as np
from tqdm import tqdm
from beartype import beartype
from beartype.typing import List, Union
class FeatureSet:
"""
A class to create a array based on trajectory features.
This array is later on used to calculate similarities
between trajectories.
The class ... | moldyn/dcTMD | src/dcTMD/featureset.py | .py | ea9e0b2dd2ec9d0f | 7.63 | 17 |
# -*- coding: utf-8 -*-
# MIT License
# Copyright (c) 2021-2023, Miriam Jäger
# All rights reserved.
"""Submodule handling the input/output operations."""
__all__ = ['write_output']
import glob
from pathlib import Path
import numpy as np
from beartype import beartype
from beartype.typing import Tuple, Union
from dcT... | moldyn/dcTMD | src/dcTMD/io.py | .py | bc8892d75437b315 | 7.63 | 17 |
# -*- coding: utf-8 -*-
# MIT License
# Copyright (c) 2022, Victor Tänzel, Miriam Jäger
# All rights reserved.
"""Classes that store constraint force data as work or force time traces.
The resulting force or work sets are needed for further analysis.
"""
__all__ = ['WorkSet', 'ForceSet', 'save', 'load']
import jobli... | moldyn/dcTMD | src/dcTMD/storing.py | .py | 94b7c57fdd33769a | 7.63 | 17 |
# -*- coding: utf-8 -*-
# MIT License
# Copyright (c) 2022, Victor Tänzel, Miriam Jäger
# All rights reserved.
"""Functions used for bootstrapping."""
__all__ = ['bootstrapping']
import sys
import tqdm
import numpy as np
from beartype import beartype
from beartype.typing import Callable, Optional, Union
from dcTMD._t... | moldyn/dcTMD | src/dcTMD/utils/_bootstrapping.py | .py | 04a5dd25d109107e | 7.63 | 17 |
# -*- coding: utf-8 -*-
# MIT License
# Copyright (c) 2021-2023, Miriam Jäger
# All rights reserved.
"""Simple plot functions for dcTMD results."""
from __future__ import annotations
import sys
from typing import TYPE_CHECKING, Optional, Tuple, Union
from matplotlib import pyplot as plt
import numpy as np
from scipy... | moldyn/dcTMD | src/dcTMD/utils/plotting.py | .py | 542abe247ebf42f9 | 7.63 | 17 |
"""Create test data."""
import dcTMD
from dcTMD.storing import save, WorkSet, ForceSet
from dcTMD.dcTMD import WorkEstimator, ForceEstimator
from dcTMD.io import write_output
import numpy as np
# define variables
velocity = 0.001
res = 1
res10 = 10
verbose = True
temperature = 300
n_resamples = 100
seed = 42
sigma = ... | moldyn/dcTMD | tests/create_testdata.py | .py | b4dd4e0c2baf021f | 7.13 | 17 |
# -*- coding: utf-8 -*-
"""Tests for the cli script.
MIT License
Copyright (c) 2021-2022, Miriam Jäger
All rights reserved.
"""
from click.testing import CliRunner
from dcTMD.__main__ import main
from os.path import dirname, join
HERE = dirname(__file__)
TEST_FILE_DIR = join(HERE, 'testdata')
def test_main_work_mod... | moldyn/dcTMD | tests/test___main__.py | .py | e67109c1689a8029 | 7.13 | 17 |
# -*- coding: utf-8 -*-
"""Tests for the clustering module."""
import numpy as np
from os.path import dirname, join
import pytest
from dcTMD import storing, dcTMD
VELOCITY = 0.001
RESOLUTION = 1
RESOLUTION10 = 10
VERBOSE = True
TEMPERATURE = 300
SIGMA = 0.1
MODE = 'nearest'
HERE = dirname(__file__)
TEST_FILE_DIR = j... | moldyn/dcTMD | tests/test_dcTMD.py | .py | cebbe52989e3a08a | 8.13 | 17 |
import os
import numpy as np
import pytest
import shutil
from dcTMD.featureset import FeatureSet
from os.path import dirname, join
from pathlib import Path
HERE = dirname(__file__)
TEST_FILE_DIR = join(HERE, 'testdata')
# create fixtures for 2D case
@pytest.fixture
def filenames_2d():
fname = os.path.join(TEST_F... | moldyn/dcTMD | tests/test_featureset.py | .py | a3759f4ce426dde0 | 7.13 | 17 |
# -*- coding: utf-8 -*-
"""Tests for the smoothing module.
MIT License
Copyright (c) 2021-2023, Miriam Jäger
All rights reserved.
"""
import pytest
import numpy as np
from os.path import dirname, join
from dcTMD.dcTMD import WorkEstimator
from dcTMD.storing import load
from dcTMD.utils import gaussfilter_friction
V... | moldyn/dcTMD | tests/test_smoothing.py | .py | f8e509c949944270 | 8.13 | 17 |
# -*- coding: utf-8 -*-
"""
Tests for the storing module.
MIT License
Copyright (c) 2021-2022, Victor Tänzel
All rights reserved.
"""
import dcTMD
import pytest
import os
import glob
import numpy as np
VELOCITY = 0.001
RESOLUTION = 1
VERBOSE = True
TEMPERATURE = 300
INDICES = np.array([1, 3, 5])
HERE = os.path.dirna... | moldyn/dcTMD | tests/test_storing.py | .py | fe4b2a093d18c631 | 7.13 | 17 |
from pathlib import Path
from gofra.cache.vcs import try_create_cache_gitignore
INCLUDED_CLEANUP_EXTENSIONS = {"", ".s", ".o"}
EXCLUDED_CLEANUP_FILENAMES = {".gitignore"}
def prepare_build_cache_directory(path: Path) -> None:
"""Try to create and fill cache directory with required files."""
if path.exists()... | kirillzhosul/gofra | gofra/cache/directory.py | .py | 2fd8ac3037826770 | 7.66 | 20 |
from pathlib import Path
from gofra.cache.vcs import try_create_cache_gitignore
def test_create_cache_gitignore(tmp_path: Path) -> None:
try_create_cache_gitignore(tmp_path)
def test_create_cache_gitignore_existing(tmp_path: Path) -> None:
(tmp_path / ".gitignore").touch()
try_create_cache_gitignore(tm... | kirillzhosul/gofra | gofra/cache/tests/test_vcs.py | .py | fb83196cfdee6ac0 | 7.16 | 20 |
from hashlib import md5
from pathlib import Path
from gofra.cli.parser.arguments import CLIArguments
from libgofra.hir.module import Module
def _is_file_modified_after(a: Path, b: Path) -> bool:
"""Return true if *b* is modified after than *a*."""
a_mat = a.stat().st_mtime
b_mat = b.stat().st_mtime
r... | kirillzhosul/gofra | gofra/cli/mod_hashing.py | .py | f1498ffbc44296bb | 7.66 | 20 |
import sys
from sys import stderr, stdout
from typing import Literal, NoReturn
type MessageLevel = Literal["INFO", "ERROR", "WARNING", "SUCCESS", "CMD"]
class CLIColor:
RED = "\033[91m"
GREEN = "\033[92m"
RESET = "\033[0m"
YELLOW = "\033[93m"
def cli_message(level: MessageLevel, text: str, *, verbo... | kirillzhosul/gofra | gofra/cli/output.py | .py | 370eb490ae60d182 | 7.66 | 20 |
from __future__ import annotations
from pathlib import Path
from typing import TYPE_CHECKING, Literal, cast, get_args, get_type_hints
from gofra.cli.output import cli_fatal_abort
from gofra.cli.parser.arguments import CLIArguments
from libgofra.codegen.config import CodegenConfig
from libgofra.linker.profile import L... | kirillzhosul/gofra | gofra/cli/parser/parser.py | .py | cbeabef2207f890d | 7.66 | 20 |
"""Readline wrapper.
Notice that Windows isn't working, so it will probably raise ImportError
"""
import contextlib
import readline
import warnings
from collections.abc import Callable
from pathlib import Path
READLINE_DEFAULT_HISTORY_LENGTH = 1000
def finalize_readline(history_filepath: Path) -> None:
with co... | kirillzhosul/gofra | gofra/cli/readline.py | .py | fb2621ba2ddc2489 | 7.66 | 20 |
from __future__ import annotations
import sys
from pathlib import Path
from gofra.cli.output import cli_message
def cli_get_executable_program() -> str:
"""Get path to executable which is first argument (e.g `gofra ...`)."""
return Path(sys.argv[0]).name
def warn_on_improper_installation(executable: str) ... | kirillzhosul/gofra | gofra/executable.py | .py | bca83547d2896d84 | 7.66 | 20 |
"""Assembler module to assemble programs in Gofra language into executables."""
from __future__ import annotations
from collections.abc import Iterable
from concurrent.futures import Future, ThreadPoolExecutor
from typing import TYPE_CHECKING
from libgofra.assembler.drivers._get_assembler_driver import get_assembler... | kirillzhosul/gofra | libgofra/assembler/assembler.py | .py | 5ddaa4de73bed3a1 | 7.66 | 20 |
from abc import ABC, abstractmethod
from collections.abc import Sequence
from pathlib import Path
from subprocess import CompletedProcess
from libgofra.targets.target import Target
class AssemblerDriverProtocol(ABC):
@property
@abstractmethod
def name(self) -> str:
raise NotImplementedError
... | kirillzhosul/gofra | libgofra/assembler/drivers/_driver_protocol.py | .py | 1a834bc0486ae3b9 | 7.66 | 20 |
from collections.abc import Iterable
from libgofra.assembler.drivers.wabt import WabtAssemblerDriver
from libgofra.assembler.errors import NoAssemblerDriverError
from libgofra.targets.target import Target
from ._driver_protocol import AssemblerDriverProtocol
from .clang import ClangAssemblerDriver
_drivers = [ClangA... | kirillzhosul/gofra | libgofra/assembler/drivers/_get_assembler_driver.py | .py | 3dfa116ba7e0a914 | 7.66 | 20 |
from __future__ import annotations
from pathlib import Path
from platform import system
from shutil import which
from subprocess import CalledProcessError, CompletedProcess, TimeoutExpired, run
from typing import TYPE_CHECKING, Final, assert_never
from libgofra.assembler.drivers._driver_protocol import AssemblerDrive... | kirillzhosul/gofra | libgofra/assembler/drivers/clang.py | .py | 17c0bc4cfb5735f9 | 7.66 | 20 |
from __future__ import annotations
from pathlib import Path
from shutil import which
from subprocess import CompletedProcess, run
from typing import TYPE_CHECKING
from libgofra.assembler.drivers._driver_protocol import AssemblerDriverProtocol
if TYPE_CHECKING:
from collections.abc import Sequence
from libgo... | kirillzhosul/gofra | libgofra/assembler/drivers/wabt.py | .py | e6438a58537c2b58 | 7.66 | 20 |
from __future__ import annotations
from typing import Any, Dict, List, Optional, Union
from warnings import warn
import biocframe
import biocutils as ut
from genomicranges import GenomicRanges
from ._combineutils import (
check_assays_are_equal,
merge_assays,
merge_se_colnames,
merge_se_rownames,
... | BiocPy/summarizedexperiment | src/summarizedexperiment/SummarizedExperiment.py | .py | bc284592c521fc20 | 7.45 | 7 |
from typing import Any
from biocframe import BiocFrame, from_pandas
__author__ = "jkanche"
__copyright__ = "jkanche"
__license__ = "MIT"
def _sanitize_frame(frame, num_rows: int):
frame = frame if frame is not None else BiocFrame({}, number_of_rows=num_rows)
if is_pandas(frame):
frame = from_pandas... | BiocPy/summarizedexperiment | src/summarizedexperiment/_frameutils.py | .py | d78b3e0d94cad17a | 7.45 | 7 |
"""initial schema
Revision ID: 3db4d63d21e4
Revises:
Create Date: 2026-04-23 11:07:51.007515
"""
from __future__ import annotations
from collections.abc import Sequence
import sqlalchemy as sa
from alembic import op
revision: str = '3db4d63d21e4'
down_revision: str | None = None
branch_labels: str | Sequence[str... | mgiovani/my-instants-discord-bot | bot/db/migrations/versions/3db4d63d21e4_initial_schema.py | .py | 784a179eb8747c77 | 7.48 | 8 |
# -*- coding: utf-8 -*-
"""
For Wrapping interactions with the Cloudera CDP CLI
"""
from cdpy.common import CdpSdkBase
from cdpy.iam import CdpyIam
from cdpy.environments import CdpyEnvironments
from cdpy.datahub import CdpyDatahub
from cdpy.datalake import CdpyDatalake
from cdpy.ml import CdpyMl
from cdpy.de import ... | cloudera-labs/cdpy | src/cdpy/cdpy.py | .py | babb7f0169306108 | 7.52 | 10 |
# -*- coding: utf-8 -*-
# Copyright 2026 Cloudera, Inc. All Rights Reserved.
#
# 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 re... | cloudera-labs/cdpy | tests/test_environments.py | .py | e48fb1b4e265235c | 8.02 | 10 |
import inspect
import signal
import socket
import sys
from pathlib import Path
import qtawesome as qta
from appdirs import AppDirs
from qtstrap import OPTIONS, BaseAppInfo
from qtstrap.extras.style import apply_theme
from .qt import *
class AppConfigError(Exception):
"""Error raised if the AppInfo hasn't been ... | qtstrap/qtstrap | src/qtstrap/base_application.py | .py | 86da9829d962f42d | 7.52 | 10 |
from qtstrap import *
import qtawesome as qta
from .panel import Panel, Sidebar
class ActivityBar(BaseToolbar):
"""Icon strip that toggles sidebar panels.
Auto-populates from a Sidebar's registered panels. A settings button
is included by default at the bottom.
Works with any object exposing `toggle... | qtstrap/qtstrap | src/qtstrap/chassis/activity_bar.py | .py | ed0c5aa06a1ea0b8 | 7.52 | 10 |
from qtstrap import *
import qtawesome as qta
class Panel(QWidget):
"""Base class for sidebar panels. Subclassing Panel is the registration.
Subclasses define:
name: unique identifier (used for lookup, required)
display_name: human-readable name (shown in tooltip, optional — defaults to name)... | qtstrap/qtstrap | src/qtstrap/chassis/panel.py | .py | 6ca99df7c0e1b6b6 | 7.52 | 10 |
from qtstrap import *
from qtpy.QtCore import Qt
class StatusBarItem(QWidget):
"""Marker base class for auto-discovered status bar items.
Subclass this and your widget appears in the status bar. The only
requirement is being a QWidget subclass — the contribution IS the widget.
Class attributes:
... | qtstrap/qtstrap | src/qtstrap/chassis/status_bar.py | .py | 33a84c7ea5c8e33b | 7.52 | 10 |
from qtstrap import *
import json
class Page(QWidget):
"""Base class for tab pages with serialization. Subclassing is registration.
Subclasses define:
page_type: unique identifier (required, used for save/load)
page_name: default name for new pages (optional, defaults to page_type)
Regis... | qtstrap/qtstrap | src/qtstrap/chassis/tab_panel.py | .py | 023429352b07689d | 7.52 | 10 |
from qtstrap import *
def format(color, style=''):
"""
Return a QTextCharFormat with the given attributes.
"""
_format = QTextCharFormat()
_format.setForeground(QColor(color))
if 'bold' in style:
_format.setFontWeight(QFont.Bold)
if 'italic' in style:
_format.setFontItalic(... | qtstrap/qtstrap | src/qtstrap/extras/code_editor/highlighters/python.py | .py | 037c645b1f838ff9 | 7.52 | 10 |
from qtstrap import *
import typing
import time
class CommandRegistry(QObject):
def __init__(self) -> None:
super().__init__()
self.registry = {}
self.commands = []
def register_command(self, command):
self.registry[command.text()] = command
self.commands.append(comman... | qtstrap/qtstrap | src/qtstrap/extras/command_palette/command_palette.py | .py | 81c784d449a0ac2a | 7.52 | 10 |
import logging
import sys
from qtstrap import OPTIONS
from .async_database_handler import AsyncDatabaseHandler
from .log_widget import (
LogMonitorDockWidget,
LogMonitorDropdown,
LogMonitorWidget,
)
# Backwards compat: downstream apps may import DatabaseHandler by name.
# It is now always the async handl... | qtstrap/qtstrap | src/qtstrap/extras/log_monitor/__init__.py | .py | 530e41b729dc6b5f | 7.52 | 10 |
"""
AsyncDatabaseHandler - Non-blocking logging to SQLite.
This handler queues log records and flushes them to the database in batches,
preventing the main thread from blocking on every log call.
Performance comparison:
- DatabaseHandler: ~2.2ms per log (synchronous INSERT)
- AsyncDatabaseHandler: ~0.01ms per log (qu... | qtstrap/qtstrap | src/qtstrap/extras/log_monitor/async_database_handler.py | .py | efe83c01dee6ce2b | 7.52 | 10 |
"""qtstrap promise layer — re-exports promisio plus Qt-specific helpers.
The core promise implementation is vendored verbatim from promisio
(https://github.com/miguelgrinberg/promisio) in `_promisio.py`.
Do not modify that file — copy upstream fixes in directly.
This module adds Qt-specific helpers:
- wait_for_signal... | qtstrap/qtstrap | src/qtstrap/extras/promise/__init__.py | .py | d3b3dc6943133ba3 | 7.52 | 10 |
"""`graphsense bulk <operation>` — direct access to /bulk.json / /bulk.csv."""
from __future__ import annotations
from typing import Optional
import rich_click as click
from graphsense.cli.context import CliContext
from graphsense.ext import io as io_mod
from graphsense.ext import output as out_mod
pass_ctx = clic... | graphsense/graphsense-lib | clients/python/graphsense/cli/bulk_cmd.py | .py | 82937f61aa55c5df | 7.64 | 18 |
"""Shared Click context for all `gs` commands."""
from __future__ import annotations
import os
import sys
from dataclasses import dataclass, field
from typing import Optional
import rich_click as click
from graphsense.ext.client import GraphSense
@dataclass
class CliContext:
api_key: Optional[str] = None
... | graphsense/graphsense-lib | clients/python/graphsense/cli/context.py | .py | 722d17e734480f3f | 7.64 | 18 |
"""Friendly handling of REST errors raised from inside CLI commands.
The generated client raises subclasses of `graphsense.exceptions.ApiException`
on non-2xx responses (404 → NotFoundException, 401 → UnauthorizedException,
etc.). Without intervention these surface as raw tracebacks. Wrapping the
root command's `invok... | graphsense/graphsense-lib | clients/python/graphsense/cli/errors.py | .py | 4b40a8aee0481afb | 7.64 | 18 |
"""`graphsense gs ...` — read GraphSense `.gs` save files (graph + pathfinder).
The extraction commands `txs` and `addresses` emit a uniform
`[{"network", "id"}, ...]` shape that feeds directly into `lookup-tx`
and `lookup-address` via the standard
`--address-jq '[].id' --network-jq '[].network'` selectors.
Example:
... | graphsense/graphsense-lib | clients/python/graphsense/cli/gs.py | .py | f4e250fdf2513b34 | 7.64 | 18 |
"""`graphsense file scan-for-addresses` — scan files/blobs for crypto addresses.
Extraction is deliberately permissive; the real filter is checksum validation
(via the vendored, stdlib-only ``graphsense.address_scan.validators``), which
removes the many address-shaped false positives found in database dumps
(hashes, s... | graphsense/graphsense-lib | clients/python/graphsense/cli/scan.py | .py | e2d29b6362460c61 | 7.64 | 18 |
"""
Backward compatibility types for v5 client migration.
These types provide .value property access for types that were previously
wrapped in ModelSimple classes (Height, Actors, TxInputs, etc.).
"""
from typing import TypeVar, Generic, Iterator, List, Any
class CompatInt(int):
"""
Integer subclass that pr... | graphsense/graphsense-lib | clients/python/graphsense/compat.py | .py | 798c6c976a4cb9f8 | 7.64 | 18 |
"""Decide between per-item calls and the /bulk endpoint."""
from __future__ import annotations
import csv
import io
import sys
from concurrent.futures import ThreadPoolExecutor
from typing import Any, Callable, Iterable, Iterator, Optional
DEFAULT_BULK_THRESHOLD = 10
# The server bounds how many items one bulk requ... | graphsense/graphsense-lib | clients/python/graphsense/ext/bulk.py | .py | 868e938ee09f8ac8 | 7.64 | 18 |
"""Install a one-shot stderr warning whenever the server reports that a
called endpoint is deprecated (via RFC 8594 `Deprecation` / `Sunset` headers).
Hook strategy: monkey-patch the bound `call_api` method on a given ApiClient
instance so we can inspect the RESTResponse headers. This is non-invasive —
it does not tou... | graphsense/graphsense-lib | clients/python/graphsense/ext/deprecation.py | .py | 76187335c78977fc | 7.64 | 18 |
"""Input parsing for the CLI: detect JSON / CSV / plain lines from a stream
or string, and extract a list of ids given a selector (jmespath / column).
"""
from __future__ import annotations
import csv
import io
import json
from typing import Any, Iterable, Optional
def detect_format(sample: str) -> str:
"""Best... | graphsense/graphsense-lib | clients/python/graphsense/ext/io.py | .py | 2bffb096f2c61169 | 7.64 | 18 |
"""Output writers: JSON / JSONL / CSV -> stdout, file (-o) or directory (-d)."""
from __future__ import annotations
import csv
import inspect
import json
import os
import sys
from contextlib import contextmanager
from typing import Any, Iterable, Iterator, Optional
from graphsense.ext.client import _model_to_dict
... | graphsense/graphsense-lib | clients/python/graphsense/ext/output.py | .py | d96bab0b4fd293f0 | 7.64 | 18 |
"""Public selector API; thin re-exports for code outside the CLI that
just wants to run a jmespath query or a CSV column pick.
The heavy-lifting lives in `graphsense.ext.io`; this module exists so
library users can `from graphsense.ext.selectors import select_json` without
touching CLI internals.
"""
from __future__ ... | graphsense/graphsense-lib | clients/python/graphsense/ext/selectors.py | .py | d98bcc306c9f93de | 7.64 | 18 |
"""
Data attributes for events within the architecture subdomain `learning`.
These attributes follow the form of attr objects specified in OEP-49 data
pattern.
"""
import json
import socket
from datetime import datetime, timezone
from uuid import UUID, uuid1
import attr
import attrs
from django.conf import settings
... | openedx/openedx-events | openedx_events/data.py | .py | 8c1263e2a820b0e9 | 7.57 | 13 |
"""
Classes and utility functions for the event bus.
This module includes the entry points for the producer and consumer.
API:
- ``get_producer`` returns an ``EventBusProducer`` singleton that should be used for sending all events
to the Event Bus. The backing implementation is chosen via the Django setting ``EVEN... | openedx/openedx-events | openedx_events/event_bus/__init__.py | .py | 8fead70b1e8c0eee | 7.57 | 13 |
"""
Serialize events to Avro records.
"""
import io
import json
import attr
import fastavro
from .custom_serializers import DEFAULT_CUSTOM_SERIALIZERS
from .schema import schema_from_signal
DEFAULT_SERIALIZERS = {serializer.cls: serializer.serialize for serializer in DEFAULT_CUSTOM_SERIALIZERS}
def _get_non_attrs_... | openedx/openedx-events | openedx_events/event_bus/avro/serializer.py | .py | a8b7b2f980d80c89 | 7.57 | 13 |
"""Test interplay of the various Avro helper classes"""
import io
import os
from datetime import datetime
from typing import Any, List, Union, get_args, get_origin
from unittest import TestCase
from uuid import UUID, uuid4
from ccx_keys.locator import CCXLocator
from fastavro import schemaless_reader, schemaless_write... | openedx/openedx-events | openedx_events/event_bus/avro/tests/test_avro.py | .py | 63d8e8f0f63bac9b | 8.07 | 13 |
"""Test custom servializers"""
from unittest import TestCase
from uuid import UUID, uuid4
from ccx_keys.locator import CCXLocator
from openedx_events.event_bus.avro.custom_serializers import CcxCourseLocatorAvroSerializer, UuidAvroSerializer
class TestCCXLocatorSerailizer(TestCase):
"""Test case for CCXLocator ... | openedx/openedx-events | openedx_events/event_bus/avro/tests/test_custom_serializers.py | .py | 9013a10e1c025898 | 7.07 | 13 |
"""
Utility methods and classes for testing various modules in event_bus.avro.
"""
import re
from datetime import datetime
import attr
from opaque_keys.edx.keys import CourseKey
from openedx_events.event_bus.avro.custom_serializers import BaseCustomTypeAvroSerializer
from openedx_events.event_bus.avro.deserializer im... | openedx/openedx-events | openedx_events/event_bus/avro/tests/test_utilities.py | .py | c89690a26d97a1a9 | 8.07 | 13 |
"""
Tests for event bus implementation loader.
"""
import copy
import re
import sys
import warnings
from contextlib import contextmanager
from unittest import TestCase
import pytest
from django.test import override_settings
from openedx_events.data import EventsMetadata
from openedx_events.event_bus import _try_load... | openedx/openedx-events | openedx_events/event_bus/tests/test_loader.py | .py | 3f15f079bbf26f63 | 7.07 | 13 |
"""
Makes ``consume_events`` management command available.
"""
import json
import logging
from django.core.management.base import BaseCommand
from openedx_events.event_bus import make_single_consumer
from openedx_events.tooling import load_all_signals
logger = logging.getLogger(__name__)
class Command(BaseCommand)... | openedx/openedx-events | openedx_events/management/commands/consume_events.py | .py | a627a67374aeefd2 | 7.57 | 13 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.