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 pytest import socket import os import numpy as np import xarray as xr from mom6_forge.vgrid import ( VGrid, _cell_center_to_layer_thickness, _cell_interface_to_layer_thickness, ) def _create_vgrid_dataset( layer_thickness, cell_center, cell_interface, var_names=("layer_thickness", ...
NCAR/mom6_forge
tests/test_vgrid.py
.py
226026d4f4240f53
7.02
10
"""Tests for Topo.write_ww3_input (the WW3 grid-preprocessor input writer).""" import numpy as np import pytest WW3_FILE_SUFFIXES = ("_x.inp", "_y.inp", "_bottom.inp", "_mapsta.inp") def test_write_ww3_input_creates_all_files(get_rect_topo_without_vc, tmp_path): topo = get_rect_topo_without_vc alias = topo....
NCAR/mom6_forge
tests/test_ww3_input.py
.py
5e3a1ec8f57f0766
8.02
10
""" Base 64 encoded text """ import binascii import regex as re from multidecoder.decoders.powershell import POWERSHELL_BYTES_TYPE from multidecoder.node import Node from multidecoder.registry import decoder from multidecoder.xor_helper import apply_xor_key, get_xorkey HTML_ESCAPE_RE = rb"&#(?:x[a-fA-F0-9]{1,4}|\d{...
CybercentreCanada/Multidecoder
src/multidecoder/decoders/base64.py
.py
0f0e18611bf06865
7.48
8
from multidecoder.hit import regex_hits from multidecoder.node import Node from multidecoder.registry import decoder EXECUTABLE_TYPE = "executable.filename" LIBRARY_TYPE = "executable.library.filename" EXT_MAP = {b".dll": LIBRARY_TYPE, b".exe": EXECUTABLE_TYPE} EXECUTABLE_RE = rb"(?i)\b\w+[.]exe\b" LIBRARY_RE = rb"(...
CybercentreCanada/Multidecoder
src/multidecoder/decoders/filename.py
.py
92fba99ce736c8e6
7.48
8
from binascii import Error as binascii_error from binascii import unhexlify import regex as re from multidecoder.node import Node from multidecoder.registry import decoder from multidecoder.xor_helper import apply_xor_key, get_xorkey HEX_RE = rb"((?:[a-f0-9]{2}){10,}|(?:[A-F0-9]{2}){10,})" HEX_SPACE_RE = rb"(?i)(?:[...
CybercentreCanada/Multidecoder
src/multidecoder/decoders/hex.py
.py
f8074ad33913298f
7.48
8
import struct import pefile import regex as re from multidecoder.node import Node from multidecoder.registry import decoder E_ELFANEW_OFFSET = 0x3C E_ELFANEW_FORMAT = "<I" E_ELFANEW_SIZE = struct.calcsize(E_ELFANEW_FORMAT) @decoder def find_pe_files(data: bytes) -> list[Node]: """Searches for any PE files with...
CybercentreCanada/Multidecoder
src/multidecoder/decoders/pe_file.py
.py
12a84d372f554303
7.48
8
from multidecoder.node import Node from multidecoder.registry import Registry, build_registry DEFAULT_DEPTH_LIMIT = 10 class Multidecoder: def __init__(self, decoders: Registry | None = None) -> None: self.decoders = decoders if decoders else build_registry() def scan(self, data: bytes, depth_limit:...
CybercentreCanada/Multidecoder
src/multidecoder/multidecoder.py
.py
5b6a8dff199a52a9
7.48
8
from __future__ import annotations from typing import TYPE_CHECKING if TYPE_CHECKING: from collections.abc import Iterator class Node: __slots__ = "type", "value", "obfuscation", "start", "end", "parent", "children" def __init__( self, type_: str, value: bytes, obfuscati...
CybercentreCanada/Multidecoder
src/multidecoder/node.py
.py
0fb7011a408e8157
7.48
8
""" Module for automatically registering and collecting decoder functions """ import importlib import inspect import os import pkgutil from collections.abc import Callable, Iterable from functools import partial from typing import TypeAlias import multidecoder import multidecoder.decoders from multidecoder.keyword im...
CybercentreCanada/Multidecoder
src/multidecoder/registry.py
.py
6e02bebdbb05f7d2
7.48
8
"""Helper functions for xor capabilities.""" import regex as re from multidecoder.node import Node # Supported by https://github.com/CYB3RMX/Qu1cksc0pe/blob/1a349826b248e578b0a2ec8b152eeeddf059c388/Modules/powershell_analyzer.py#L116 XOR_RE = rb"(?i)-b?xor\s*(\d{1,3})" def get_xorkey(data: bytes) -> int | None: ...
CybercentreCanada/Multidecoder
src/multidecoder/xor_helper.py
.py
a01f6cd447b7e45b
7.48
8
""" App for documenting REST APIs, generating spec files, and serving specs as a UI. Under the hood, this app uses drf-yasg ("Yet Another Swagger Generator for DRF") to generate API spec. It then uses Swagger to serve that spec. """ from django.apps import AppConfig, apps from django.core.exceptions import Improperly...
openedx/api-doc-tools
edx_api_doc_tools/apps.py
.py
051db14b453ee49e
7.45
7
""" Data definitions for API schemas. Mostly, we just use the definitions in drf_yasg.openapi """ from drf_yasg import openapi # Python 3 doesn't have a builtin `file` type, # so we need a constant instead. FILE_PARAM = 'file' # A map from builtin Python types to the corresponding OpenAPI type string constant. # ...
openedx/api-doc-tools
edx_api_doc_tools/data.py
.py
662499ca43012085
7.45
7
""" Utility functions internal to this package. """ import textwrap def dedent(text): """ Dedent multi-line text nicely. An initial empty line is ignored so that triple-quoted strings don't need to start with a backslash. """ if "\n" in text: first, rest = text.split("\n", 1) ...
openedx/api-doc-tools
edx_api_doc_tools/internal_utils.py
.py
33ed36ecf5d0f7d2
7.45
7
""" Utilities for annotating API views with schema info. External users: import these from __init__. """ from django.utils.decorators import method_decorator from drf_yasg.utils import swagger_auto_schema from rest_framework.viewsets import ViewSet from .internal_utils import dedent, split_docstring def schema_for(...
openedx/api-doc-tools
edx_api_doc_tools/view_utils.py
.py
91d7b3e8034d0bc0
7.45
7
""" Static example data for the edX Hedgehog API. """ from collections import namedtuple from uuid import UUID Hedgehog = namedtuple( 'Hedgehog', ('uuid', 'key', 'name', 'weight_grams', 'favorite_food', 'is_college_graduate'), ) def get_hedgehogs(): """ Get a list of Hedgehog objects that make up t...
openedx/api-doc-tools
example/data.py
.py
2c7254114a1672f6
7.45
7
""" REST API serializers for reading and writing to the edX Hedgehog Database. """ from rest_framework import serializers # pylint: disable=abstract-method class HedgehogSerializer(serializers.Serializer): """ Serializer for a hedgehog. """ uuid = serializers.UUIDField() key = serializers.SlugF...
openedx/api-doc-tools
example/serializers.py
.py
908e6e85e9ee5b2b
7.45
7
#!/usr/bin/env python """ Package metadata for edx_api_doc_tools. """ import os import re import sys from setuptools import setup # We open files with one-line shorthands, it's ok. # pylint: disable=consider-using-with def get_version(*file_paths): """ Extract the version string from the file at the given...
openedx/api-doc-tools
setup.py
.py
c9e81d71e3f35937
7.45
7
""" Tests for API docs tooling. """ import json import os.path from unittest.mock import patch import pytest from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.test import SimpleTestCase from django.test.utils import override_settings from edx_api_doc_tools.apps impo...
openedx/api-doc-tools
tests/test_doc_tools.py
.py
ad5a6516d4d3381f
7.95
7
""" Make sure our example API works, so that we're not testing our doc tools on a broken API. """ import json from django.test import SimpleTestCase from django.test.utils import override_settings from example import urls as example_urls @override_settings(ROOT_URLCONF=example_urls.__name__) class HedgehogViewTest...
openedx/api-doc-tools
tests/test_example.py
.py
40710dd47988d3af
7.95
7
#!/usr/bin/env python3 """ Strip portions of the HTML pages that we don't need """ import sys from pathlib import Path from re import sub from bs4 import BeautifulSoup DOC_ROOTS = [ '../sublime-text/www.sublimetext.com/docs', '../sublime-merge/www.sublimemerge.com/docs', ] def delete_skins(soup): """St...
SublimeText/sublime-text-docset
src/fix_html.py
.py
d293424e12831b80
7.54
11
from hashlib import sha256 import logging from pathlib import Path import secrets import string from typing import List from fastapi import FastAPI, status from fastapi.staticfiles import StaticFiles import orjson from pydantic import BaseModel from starlette.requests import Request from starlette.responses import JSO...
jacopofar/grammar-quiz
backend/app.py
.py
5b2bd3107bdb94d5
7.48
8
from authlib.common.security import generate_token from authlib.integrations.starlette_client import OAuth from fastapi import FastAPI, HTTPException from starlette.middleware.sessions import SessionMiddleware from starlette.requests import Request from starlette.responses import RedirectResponse from backend.config i...
jacopofar/grammar-quiz
backend/auth.py
.py
08a73359f03c1c29
7.48
8
import argparse from collections import Counter from csv import reader import json from random import Random from sys import maxunicode from typing import Dict, Tuple, Set from unicodedata import category import icu # word breakers instances _breakers = {} # translation table to remove punctuation or spaces # this c...
jacopofar/grammar-quiz
scripts/generate_cards/generate.py
.py
a9c83e18576f87a8
7.48
8
""" Check that dependencies follow a set of rules. """ import re from typing import List from ordered_set import OrderedSet from dep_check.dependency_finder import IParser from dep_check.models import Dependency, MatchingRules, Module, ModuleWildcard class NotAllowedDependencyException(Exception): """ Exce...
lumapps/dep-check
dep_check/checker.py
.py
6b3ae09c905ba7ae
7.64
18
""" Implementation of configuration reader and writer """ import inspect from pathlib import Path from typing import Iterator from dep_check.models import Module, SourceCode, SourceFile def _get_python_module(path: Path) -> Module: """ Returns the full module "path" to the given path """ name = None...
lumapps/dep-check
dep_check/infra/file_system.py
.py
feaace853f8cbef2
7.64
18
""" Implementations of IDependenciesPrinter """ from dataclasses import asdict, dataclass from enum import Enum from pathlib import Path from subprocess import check_output from sys import stdin, stdout from typing import Dict, Iterable, Iterator, List, Optional, Tuple import yaml from jinja2 import Template from de...
lumapps/dep-check
dep_check/infra/io.py
.py
7e018cdfa8968e6b
7.64
18
#! /usr/bin/env python3 """ Check dependencies of the project """ import argparse import logging import os import sys from dataclasses import dataclass from pathlib import Path from typing import Any, Callable from dep_check.infra.file_system import source_file_iterator from dep_check.infra.io import ( Graph, ...
lumapps/dep-check
dep_check/main.py
.py
634a064bfddd8567
7.64
18
""" Build rules more restrictive rules from existing source use case. """ from abc import ABC, abstractmethod from typing import Dict, Iterator from dep_check.dependency_finder import IParser, get_dependencies from dep_check.models import Dependencies, Module, ModuleWildcard, SourceFile from .app_configuration impor...
lumapps/dep-check
dep_check/use_cases/build.py
.py
8735e3764e821a9c
7.64
18
""" Draws a graph of the dependencies between modules """ from abc import ABC, abstractmethod from collections import defaultdict from typing import Dict, Iterator, Optional from ordered_set import OrderedSet from dep_check.dependency_finder import IParser, get_dependencies from dep_check.models import ( Depende...
lumapps/dep-check
dep_check/use_cases/draw_graph.py
.py
89fea80fd74d75ae
7.64
18
""" Common use cases interfaces. """ import enum from abc import ABC, abstractmethod from dataclasses import dataclass, field from dep_check.models import Dependencies, DependencyRules class UnusedLevel(enum.Enum): IGNORE = "ignore" WARNING = "warning" ERROR = "error" @dataclass class Configuration: ...
lumapps/dep-check
dep_check/use_cases/interfaces.py
.py
3c14be3436ca7b12
7.64
18
from typing import Iterable import pytest from dep_check.infra.std_lib_filter import StdLibSimpleFilter from dep_check.models import SourceFile from dep_check.use_cases.app_configuration import ( AppConfiguration, AppConfigurationSingleton, ) from .fakefile import FILE_WITH_LOCAL_IMPORT, FILE_WITH_STD_IMPORT...
lumapps/dep-check
tests/conftest.py
.py
6993e32d983c5ea8
8.14
18
from unittest.mock import Mock from pytest import raises from dep_check.use_cases.app_configuration import ( AppConfigurationAlreadySetException, AppConfigurationSingleton, ) def test_app_configuration_already_set() -> None: """ Test that App configuration singleton can not be defined if already set...
lumapps/dep-check
tests/test_app_config.py
.py
e0be7d53414d9d09
7.14
18
""" Test build configuration use case. """ from typing import Iterator from unittest.mock import Mock from ordered_set import OrderedSet from dep_check.infra.python_parser import PythonParser from dep_check.models import ModuleWildcard, SourceFile from dep_check.use_cases.build import BuildConfigurationUC from dep_c...
lumapps/dep-check
tests/test_build.py
.py
fc2d5c9bd1d7c67f
7.14
18
""" Test check use case. """ from unittest.mock import Mock import pytest from ordered_set import OrderedSet from dep_check.infra.python_parser import PythonParser from dep_check.models import Module, ModuleWildcard, SourceCode, SourceFile from dep_check.use_cases.check import ( CheckDependenciesUC, Dependen...
lumapps/dep-check
tests/test_check.py
.py
c112ea3ab05406cf
7.14
18
""" Test check use case. """ from typing import List from pytest import raises from dep_check.checker import NotAllowedDependencyException, check_dependency from dep_check.infra.python_parser import PythonParser from dep_check.models import ( Dependency, MatchingRule, MatchingRules, Module, Modul...
lumapps/dep-check
tests/test_checker.py
.py
be15e473c4ada32e
7.14
18
""" Test graph use case """ from typing import Iterator from unittest.mock import Mock, patch from ordered_set import OrderedSet from dep_check.infra.io import Graph, GraphDrawer from dep_check.infra.python_parser import PythonParser from dep_check.models import Dependency, Module, SourceFile from dep_check.use_case...
lumapps/dep-check
tests/test_draw_graph.py
.py
66fda20b272cc27a
7.14
18
""" Test functions in models module. """ from pytest import raises from dep_check.models import Module, get_parent, iter_all_modules from .fakefile import GLOBAL_DEPENDENCIES class TestGetParent: """ Test get_parent function. """ @staticmethod def test_empty() -> None: """ Test...
lumapps/dep-check
tests/test_models.py
.py
60b72d8968f0d3f6
7.14
18
""" Tests about get_dependencies function. """ import re from ordered_set import OrderedSet from dep_check.dependency_finder import get_dependencies, get_import_from_dependencies from dep_check.infra.python_parser import PythonParser from dep_check.models import Dependency, Module, ModuleWildcard, SourceCode, Source...
lumapps/dep-check
tests/test_parser.py
.py
815eb3884877cd28
7.14
18
# -*- coding: utf-8 -*- """ Created on Thu Jun 1 11:56:34 2023 @author: Ye Kyaw Thu, Visiting Professor, LST, NECTEC, Thailand How to Run: python 7sim.py -m all ref.txt hyp.txt python 7sim.py -m cosine "သမီးတော်" "သမားတော်" python 7sim.py -m lcs_ratio "သမီးတော်" "သမားတော်" """ import argparse import te...
ye-kyaw-thu/tools
python/7sim.py
.py
981827204ef13126
7.65
19
# -*- coding: utf-8 -*- """ Created on Wed May 31 09:43:04 2023 @author: Ye Kyaw Thu, Visiting Professor, LST, NECTEC, Thailand """ import sys from nltk.translate.bleu_score import sentence_bleu, corpus_bleu from nltk.translate.nist_score import sentence_nist, corpus_nist from nltk.translate.ribes_score i...
ye-kyaw-thu/tools
python/8eval.py
.py
ef29284095f137e6
7.65
19
# -*- coding: utf-8 -*- """ Created on Thu Jun 22 16:29:27 2023 @author: Ye Kyaw Thu, Visiting Professor, LST, NECTEC, Thailand Mean Opinion Score Evaluation Script for TTS experiments. How to run: $ python MOS_eval.py --help $ python MOS_eval.py <wavefiles_folder> <log_folder> $ python MOS_eval.py wavefiles log ""...
ye-kyaw-thu/tools
python/MOS_eval.py
.py
b505f928ff5b1cc9
7.65
19
""" for converting arrow files to a plain text file or CSV file. Written by Ye Kyaw Thu, LU Lab., Myanmar How to use: python arrow2text.py <folder_path> Last updated: 24 Nov 2024 """ import os import sys from datasets import Dataset def decide_output_format(column_names): """ Decide whether to output as plain...
ye-kyaw-thu/tools
python/arrow2text.py
.py
57d6219e7f86a7e3
7.65
19
""" For checking tag distributions. Written by Ye Kyaw Thu, LU Lab., Myanmar. Last updated: 26 May 2024. Usage: (py3.8) ye@lst-gpu-server-197:~/ye/exp/entc$ python ./check_corpus_tag_distribution.py --corpus ./data/my_news.shuf.txt """ import argparse from collections import Counter def count_tags(file_path): wit...
ye-kyaw-thu/tools
python/check_corpus_tag_distribution.py
.py
d03a6992e696a6ce
7.65
19
""" Useful for cleaning invisible characters such as ZWNJ, ZWSP, non Burmese characters, Burmese numbers and all symbols. (ဒီ python code က ဗမာစာ NLP အလုပ်အတွက် တကယ်အသုံးဝယ်ပါတယ်။ နံပါတ်တွေကိုလည်း ဖယ်ထားတယ်။ syllable dictionary ဆောက်ဖို့နဲ့ language model မဆောက်ခင်မှာ cleaning လုပ်ဖို့အတွက် သုံးခဲ့တယ်။) Written by Ye...
ye-kyaw-thu/tools
python/clean_non_burmese.py
.py
bd3ed9feafad5164
7.65
19
# -*- coding: utf-8 -*- """ conversion from left-to-right format to conllu format Last updated: 13 Jul, 2023 @author: Ye Kyaw Thu, LU Lab, Myanmar How to run: python convert_to_conllu.py --input .\corpus\mypos_5lines.txt --output mypos_5lines.conllu """ import argparse from typing import List, Tuple ...
ye-kyaw-thu/tools
python/convert_to_conllu.py
.py
a1c607912224e6a7
7.65
19
# -*- coding: utf-8 -*- """ conversion from left-to-right format to Spacy NER Json format Last updated: 13 Jul, 2023 @author: Ye Kyaw Thu, LU Lab, Myanmar How to run: python convert_to_spacyNER_json.py --input .\corpus\mypos_5lines.txt --output mypos_5lines.json """ import argparse import json def p...
ye-kyaw-thu/tools
python/convert_to_spacyNER_json.py
.py
766f5dcbd160b5fc
7.65
19
# -*- coding: utf-8 -*- """ Created on Thu Jun 29 20:40:49 2023 @author: Ye Kyaw Thu, Visiting Professor, LST, NECTEC, Thailand. How to run: python cut_columns.py -i myg2p.txt -o dict.txt -c 2 python cut_columns.py -i myg2p.txt -o dict.txt -c 3,5 python cut_columns.py -i myg2p.txt -o dict.txt -c 2,4-5 """ #!/usr/bin...
ye-kyaw-thu/tools
python/cut_columns.py
.py
e90b1dfc3a59a41c
7.65
19
""" Evaluation on ngram LM with test file. Written by Ye Kyaw Thu, LU Lab., Myanmar. Last updated: 11 Feb 2024 Usage: time python ./eval_ngram_lm.py --language_model ./model/5gram.arpa \ --vocab_file ./corpus/vocab.txt --test_data ./corpus/test1.txt --perplexity time python ./eval_ngram_lm.py --language_model ./mode...
ye-kyaw-thu/tools
python/eval_ngram_lm.py
.py
4e53ea057edcbb6f
7.65
19
# -*- coding: utf-8 -*- """ Last updated on Fri Jun 30 09:24:58 2023 @author: Ye Kyaw Thu, Visiting Professor, LST, NECTEC, Thailand. """ #How to run: #python extract_filename_parts.py -d _ -c 2 -t count -f 'F:\NECTEC\Project\MyanmarSpeech\MyanmarSpeech' #python extract_filename_parts.py -d _ -c 2 -t count...
ye-kyaw-thu/tools
python/extract_filename_parts.py
.py
e743bfe0f04f71aa
7.65
19
import shutil import json import logging import os from pathlib import Path from asposepdfcloud import ApiClient, PdfApi, HighlightAnnotation, Rectangle, Color, Point, AnnotationFlags, HorizontalAlignment, VerticalAlignment, AnnotationType # Configure logging logging.basicConfig(level=logging.INFO, format="%(a...
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/Annotations/annotations_helper.py
.py
cf45980d3dd5b391
7.54
11
from annotations_helper import Config, PdfAnnotationsHelper, logging from asposepdfcloud import PdfApi class PdfDelPageAnnotations: """Class for managing PDF annotations using Aspose PDF Cloud API.""" def __init__(self, pdf_api: PdfApi, helper: PdfAnnotationsHelper): self.pdfApi = pdf_api ...
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/Annotations/delete_page_annotations.py
.py
98f3834d933952db
7.54
11
from annotations_helper import Config, PdfAnnotationsHelper, logging from asposepdfcloud import PdfApi class PdfDalTextAnnotations: """Class for managing PDF annotations using Aspose PDF Cloud API.""" def __init__(self, pdf_api: PdfApi, helper: PdfAnnotationsHelper): self.pdfApi = pdf_api ...
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/Annotations/delete_text_annotation.py
.py
fe900a42d1468023
7.54
11
from annotations_helper import Config, PdfAnnotationsHelper, logging from asposepdfcloud import PdfApi, AnnotationsInfoResponse class PdfGetAnnotationById: """Class for managing PDF annotations using Aspose PDF Cloud API.""" def __init__(self, pdf_api: PdfApi, helper: PdfAnnotationsHelper): self....
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/Annotations/get_annotation_by_id.py
.py
4c208442cac1a465
7.54
11
from annotations_helper import Config, PdfAnnotationsHelper, logging from asposepdfcloud import PdfApi, AnnotationsInfoResponse class PdfGetAnnotations: """Class for managing PDF annotations using Aspose PDF Cloud API.""" def __init__(self, pdf_api: PdfApi, helper: PdfAnnotationsHelper): self.pdf...
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/Annotations/get_annotations.py
.py
20c4f1971272b16a
7.54
11
from annotations_helper import Config, PdfAnnotationsHelper, logging from asposepdfcloud import PdfApi, TextAnnotationResponse class PdfReplaceAnnotations: """Class for managing PDF annotations using Aspose PDF Cloud API.""" def __init__(self, pdf_api: PdfApi, helper: PdfAnnotationsHelper): self....
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/Annotations/replace_annotation.py
.py
d1d62662eb59de84
7.54
11
import shutil import json import logging from pathlib import Path from asposepdfcloud import ApiClient, PdfApi, AttachmentInfo # Configure logging logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") class Config: """Configuration parameters.""" CREDENTIALS_...
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/Attachments/add/appendAttachments.py
.py
1915baafcdd3bc42
7.54
11
import shutil import json import logging from pathlib import Path from asposepdfcloud import ApiClient, PdfApi, AttachmentsResponse, AttachmentResponse, Attachment # Configure logging logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") class Config: """Configurati...
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/Attachments/get/getAttachmentAndSave.py
.py
abf5f99de72e95cc
7.54
11
import shutil import json import logging from pathlib import Path from asposepdfcloud import ApiClient, PdfApi, Color, Bookmark # Configure logging logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") class Config: """Configuration parameters.""" CREDENTIALS_F...
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/Bookmarks/add/appendBookmarks.py
.py
87f36af802841f4f
7.54
11
import shutil import json import logging from pathlib import Path from asposepdfcloud import ApiClient, PdfApi, BookmarkResponse # Configure logging logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") class Config: """Configuration parameters.""" CREDENTIAL...
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/Bookmarks/get/getBookmarkByPathAndShow.py
.py
3726c6a376dfc7aa
7.54
11
import shutil import json import logging from pathlib import Path from asposepdfcloud import ApiClient, PdfApi, BookmarksResponse # Configure logging logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") class Config: """Configuration parameters.""" CREDENTIA...
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/Bookmarks/get/getBookmarksAndShow.py
.py
12df3e65f860058b
7.54
11
import shutil import json import logging from pathlib import Path from asposepdfcloud import ApiClient, PdfApi, AsposeResponse # Configure logging logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") class Config: """Configuration parameters.""" CREDENTIALS_...
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/Bookmarks/remove/removeBookmark.py
.py
d32744dbe035b8bb
7.54
11
import shutil import json import logging from pathlib import Path from asposepdfcloud import ApiClient, PdfApi, Bookmark, BookmarksResponse, BookmarkResponse class Config: """Configuration parameters.""" CREDENTIALS_FILE = Path(r"settings/credentials.json") LOCAL_FOLDER = Path(r"test_data") P...
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/Bookmarks/replace/replaceBookmark.py
.py
e4b9ce7af64f8856
7.54
11
import os import shutil import json import logging from pathlib import Path from asposepdfcloud import ApiClient, PdfApi # Configure logging logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") class CompareMain: def __init__(self, credentials_file: Path): self.pd...
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/Compares/compares_helper.py
.py
802d2b57aa5bfc60
7.54
11
import shutil import json import logging from pathlib import Path from asposepdfcloud import ApiClient, PdfApi, OptimizeOptions # Configure logging logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") class Config: """Configuration parameters.""" CREDENTIALS...
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/CompressDocument/compressPdf.py
.py
04c50e8e80284a3b
7.54
11
import shutil import json import logging import pathlib import math from asposepdfcloud import ApiClient, PdfApi, Direction, PageMode, PageLayout, DocumentConfig, DocumentProperties, DocumentProperty, DisplayProperties, DefaultPageConfig # Configure logging logging.basicConfig(level=logging.INFO, format="%(asc...
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/CreateDocument/createPdf.py
.py
b3b39f1643245b26
7.54
11
import shutil import json import logging from pathlib import Path import base64 from asposepdfcloud import ApiClient, PdfApi, CryptoAlgorithm # Configure logging logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") class Config: """Configuration parameters.""" ...
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/EncryptDecrypt/decryptDocument.py
.py
b4a46bdbc4ab741c
7.54
11
import shutil import json import logging from pathlib import Path import base64 from asposepdfcloud import ApiClient, PdfApi, CryptoAlgorithm # Configure logging logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") class Config: """Configuration parameters.""" ...
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/EncryptDecrypt/encryptDocument.py
.py
c3cb45f33f91906d
7.54
11
import shutil import json import logging from pathlib import Path from asposepdfcloud import ApiClient, PdfApi, ImageFooter, HorizontalAlignment # Configure logging logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") class Config: """Configuration parameters.""" ...
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/HeaderFooter/appendImageFooter.py
.py
a59e5d459c552e30
7.54
11
import shutil import json import logging from pathlib import Path from asposepdfcloud import ApiClient, PdfApi, ImageHeader, HorizontalAlignment, TextHorizontalAlignment # Configure logging logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") class Config: """Confi...
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/HeaderFooter/appendImageHeader.py
.py
02310274ba9ea4aa
7.54
11
import shutil import json import logging from pathlib import Path from asposepdfcloud import ApiClient, PdfApi, TextFooter, HorizontalAlignment, TextHorizontalAlignment # Configure logging logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") class Config: """Config...
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/HeaderFooter/appendTextFooter.py
.py
69ecb7eff822e1c2
7.54
11
import shutil import json import logging from pathlib import Path from asposepdfcloud import ApiClient, PdfApi, TextHeader, HorizontalAlignment, TextHorizontalAlignment # Configure logging logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") class Config: """Config...
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/HeaderFooter/appendTextHeader.py
.py
d910cf90b2e5c4d4
7.54
11
import shutil import json import logging from pathlib import Path from asposepdfcloud import ApiClient, PdfApi, LinkAnnotation, LinkActionType, LinkHighlightingMode, Color, Link, Rectangle # Configure logging logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") class ...
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/Links/add/appendLink.py
.py
02b0e2de36763a25
7.54
11
import shutil import json import logging from pathlib import Path from asposepdfcloud import ApiClient, PdfApi # Configure logging logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") class Config: """Configuration parameters.""" CREDENTIALS_FILE = Path(r"se...
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/Links/get/getLinksAndShow.py
.py
d7a1389b0d16af8e
7.54
11
import shutil import json import logging from pathlib import Path from asposepdfcloud import ApiClient, PdfApi, AsposeResponse # Configure logging logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") class Config: """Configuration parameters.""" CREDENTIALS_...
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/Links/remove/removeLink.py
.py
a08830e33fd01515
7.54
11
import shutil import json import logging from pathlib import Path from asposepdfcloud import ApiClient, PdfApi, LinkAnnotationsResponse, LinkAnnotationResponse class Config: """Configuration parameters.""" CREDENTIALS_FILE = Path(r"settings/credentials.json") LOCAL_FOLDER = Path(r"test_data") ...
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/Links/replace/replaceLink.py
.py
b68ad0be23f39532
7.54
11
import shutil import json import logging from pathlib import Path from asposepdfcloud import ApiClient, PdfApi, DocumentPagesResponse # Configure logging logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") class Config: """Configuration parameters.""" CREDE...
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/Pages/add/appendNewPage.py
.py
619ec8fa76f9d05b
7.54
11
import shutil import json import logging from pathlib import Path from asposepdfcloud import ApiClient, PdfApi, DocumentPagesResponse # Configure logging logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") class Config: """Configuration parameters.""" CREDE...
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/Pages/get/getPageInfoAndSavePng.py
.py
f58857fff14707da
7.54
11
import shutil import json import logging from pathlib import Path from asposepdfcloud import ApiClient, PdfApi, AsposeResponse # Configure logging logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") class Config: """Configuration parameters.""" CREDENTIALS_FI...
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/Pages/move/movePageNewPosition.py
.py
cddb3baf8dd05f63
7.54
11
import shutil import json import logging from pathlib import Path from asposepdfcloud import ApiClient, PdfApi # Configure logging logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") class Config: """Configuration parameters.""" CREDENTIALS_FILE = Path(r"sett...
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/Pages/remove/removePage.py
.py
91e0bbc582023c5d
7.54
11
import shutil import json import logging from pathlib import Path from asposepdfcloud import ApiClient, PdfApi, Stamp, AsposeResponse, HorizontalAlignment, StampType # Configure logging logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") class Config: """Configura...
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/Pages/stamp/pageAppendTextStamp.py
.py
cc2da0e6b23e212a
7.54
11
import shutil import json import logging from pathlib import Path from asposepdfcloud import ApiClient, PdfApi, WordCountResponse # Configure logging logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(levelname)s - %(message)s") class Config: """Configuration parameters.""" CREDENTIALS...
aspose-pdf-cloud/Aspose.PDF-Cloud-SDK-for-Python
Uses-Cases/Pages/wordsCount/wordsCountOnPages.py
.py
5b5fd04b662018e4
7.54
11
import numpy as np import pytest import tabcorr from scipy.interpolate import interp1d @pytest.mark.parametrize("tpcf", ["wp", "ds"]) @pytest.mark.parametrize("interpolator", [True, False]) def test_separate_gal_type(halotab, model, tpcf, interpolator): # Test the consistency of separate_gal_type, i.e., the tota...
johannesulf/TabCorr
tests/test_general.py
.py
d963583ad4385bb9
7.13
17
import logging from contextvars import ContextVar from insights import dr from insights_messaging.watchers import Watched log = logging.getLogger(__name__) archive_context_var = ContextVar("archive_context_ids", default=None) class ArchiveContextIdsInjectingFilter(logging.Filter): """ A filter which inject...
RedHatInsights/insights-core-messaging
insights_messaging/consumers/__init__.py
.py
64955e048d719107
7.52
10
import json import logging import os import signal from confluent_kafka import Consumer as ConfluentConsumer from prometheus_client import Gauge, Info from insights_messaging.consumers import Consumer, RequeueError, archive_context_var log = logging.getLogger(__name__) running = True def handle_signal(signal, fra...
RedHatInsights/insights-core-messaging
insights_messaging/consumers/kafka.py
.py
9ff22ed091b56613
7.52
10
from collections import ChainMap as _ChainMap from string import Template def _infer_type(v): if not v: return if v.lower() in ["true", "false"]: return v.lower() == "true" for conv in [int, float]: try: return conv(v) except Exception: pass r...
RedHatInsights/insights-core-messaging
insights_messaging/template.py
.py
969c492958dbedc0
7.52
10
""" Tests for DefaultingTemplate — a string.Template subclass with default values. DefaultingTemplate extends Python's string.Template to support ``${var:default}`` syntax used in YAML configuration files. This allows operators to provide fallback values for optional settings without requiring every environment varia...
RedHatInsights/insights-core-messaging
insights_messaging/tests/test_defaulting_template.py
.py
7b0dd8d4a2262879
8.02
10
""" Tests for downloader implementations. Downloaders provide a context manager ``get(src)`` that yields a local file path for the consumer to process. These tests cover the local filesystem, HTTP, and S3 downloaders. """ import os from unittest.mock import MagicMock, patch import pytest from requests.exceptions im...
RedHatInsights/insights-core-messaging
insights_messaging/tests/test_downloaders.py
.py
b7d7515555f9ba15
8.02
10
from insights_messaging.appbuilder import AppBuilder config = """ plugins: service: logging_configurator: name: insights_messaging.tests.test_get_logging_config.custom_log_config logging: version: 1 disable_existing_loggers: false loggers: "": level: ...
RedHatInsights/insights-core-messaging
insights_messaging/tests/test_get_logging_config.py
.py
baaae5891b522c91
8.02
10
""" Tests for Kafka consumer context helpers. This module tests the ``update_archive_context_ids`` helper and the ``ArchiveContextIdsInjectingFilter`` logging filter. Note: The ``Kafka`` consumer class itself requires a live confluent-kafka connection and is tested via integration tests, not here. """ import logging...
RedHatInsights/insights-core-messaging
insights_messaging/tests/test_kafka_consumer.py
.py
a04681ebee4306b1
8.02
10
""" Tests for KafkaMetrics Prometheus gauge updates. """ import json import pytest @pytest.mark.parametrize( ("gauge_attr", "label_kwargs", "expected"), [ pytest.param( "KAFKA_CONSUMER_REBALANCE_COUNT", {"type": "consumer", "client_id": "test-client-1"}, 42, ...
RedHatInsights/insights-core-messaging
insights_messaging/tests/test_kafka_metrics.py
.py
4f18e12946badc25
8.02
10
""" This test module ensures default and custom engines load correctly from configuration. """ import yaml from insights_messaging.appbuilder import AppBuilder from insights_messaging.engine import Engine class CustomEngine(Engine): pass class MockFS: pass class MockFormat: pass CONFIG1 = yaml.loa...
RedHatInsights/insights-core-messaging
insights_messaging/tests/test_pluggable_engine.py
.py
5d87aee4f4281cc9
7.02
10
from itertools import combinations import logging import networkx as nx from networkx.exception import NetworkXNoPath import numpy as np import os import sys import operator import scipy from scipy.spatial import Voronoi from scipy.ndimage import filters from shapely.geometry import LineString, MultiLineString, Point, ...
Gregor-Mendel-Institute/TRG-ImageProcessing
CoreProcessingPipelineScripts/CNN/Mask_RCNN/mrcnn/src_get_centerline.py
.py
00487faddb82f35a
7.6
15
from __future__ import annotations import logging from contextlib import contextmanager from importlib.metadata import PackageNotFoundError, version from pathlib import Path from types import TracebackType from typing import Any, Iterator, Literal, Self from urllib.parse import parse_qs, urljoin, urlparse from httpx ...
NASA-IMPACT/csda-client
src/csda_client/client.py
.py
46251f1bd2c70015
7.5
9
class RequestIdKeyAlreadySetError(Exception): """ Raised when the request already contains a request id. This most likely means that request_id_middleware is applied twice, or that something else also sets the request id in the request. """ def __init__(self, existing_request_id: str): ...
messa/aiohttp-request-id-logging
aiohttp_request_id_logging/errors.py
.py
83a4ca56373528d6
7.56
12
import logging from aiohttp import web from aiohttp.web_log import AccessLogger as _AccessLogger from .context import request_id, REQUEST_ID_KEY def setup_logging_request_id_prefix(prefix_format: str = "[req:{request_id}] ") -> None: """ Wrap logging record factory so that every log record gets two extra at...
messa/aiohttp-request-id-logging
aiohttp_request_id_logging/logging_setup.py
.py
c03cc12dc5e57ccd
7.56
12
from aiohttp import web from aiohttp.typedefs import Handler from aiohttp.web_exceptions import HTTPException from asyncio import CancelledError from collections.abc import Callable from contextlib import AbstractContextManager, ExitStack from logging import getLogger from typing import Any import warnings from .conte...
messa/aiohttp-request-id-logging
aiohttp_request_id_logging/middleware.py
.py
1e0bbc08497da931
7.56
12
from os import getpid from secrets import token_urlsafe _SKIP_CHARS = "1lI2ZO0" def random_request_id_factory(length: int = 7) -> str: """ Generate a random request id - a URL-safe string of the given length. Visually ambiguous characters (1/l/I, 2/Z, O/0) and the URL-safe punctuation (_, -) are ne...
messa/aiohttp-request-id-logging
aiohttp_request_id_logging/request_id_factories.py
.py
5ce4e93db2c24b92
7.56
12
""" Demonstrates how to customize the RequestIdMiddleware behavior by passing parameters to its constructor - no subclassing needed. Shown here: - request_id_factory: generate sequential request ids instead of random ones - log_request_start: log a custom request start message - request_id_header_name: return the req...
messa/aiohttp-request-id-logging
examples/demo_customization_injection.py
.py
c611dd46dd38f5b1
7.56
12
""" Demonstrates how to customize the RequestIdMiddleware behavior by subclassing it and overriding class attributes and methods. Shown here: - request_id_header_name: default overridden by a class attribute - request_id_factory: default changed in __init__ - sequential ids instead of random ones - get_request_id: ...
messa/aiohttp-request-id-logging
examples/demo_customization_subclassing.py
.py
ded514b774327caa
7.56
12
""" Demonstrates the backward compatible request_id_middleware() usage - the wrapper function kept for applications written against the pre-1.0 API. The legacy RequestIdContextAccessLogger name (an alias of RequestIdAccessLogger) is used here intentionally for the same reason. New code should use the RequestIdMiddlewar...
messa/aiohttp-request-id-logging
examples/demo_legacy.py
.py
05f516b54e6f8373
7.56
12