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 |
|---|---|---|---|---|---|---|
#!/usr/bin/env python3
"""
U-BOOT HACK - Intercepta o autoboot (1s janela) pra cair no shell U-Boot.
De la: modifica bootargs pra init=/bin/sh (shell puro sem IPC).
"""
import serial
import time
import sys
PORT = '/dev/ttyUSB0'
BAUD = 115200
def send_uboot(ser, cmd, wait=1.5):
"""Envia comando pro ... | wangcai0124/camera-hack | scripts/uboot_hack.py | .py | 1edb896714bb73af | 7.56 | 12 |
#! /usr/bin/env python
import os
import shutil
import subprocess
import tempfile
import sys
import logging
import argparse
# Configure logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S'
)
DEV_DIR = os.path.join(os.getcwd(), "_d... | canonical/wordpress-k8s-operator | docs/_dev/get_vale_conf.py | .py | 5c0373d40d28c31a | 7.6 | 15 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Populate the local jupyter-cache from the CI-executed tutorial notebook artifact.
Downloads the ``tutorial-notebook`` artifact produced by the Execute Tutorial Notebook
workflow for the current commit and caches it so that ``make html-with-a... | canonical/wordpress-k8s-operator | docs/_extensions/cache_notebook_from_artifact.py | .py | f900461fcc3eed1f | 7.6 | 15 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Sphinx extension to fetch pre-executed tutorial notebook from GitHub releases."""
import json
import logging
import os
import tempfile
import time
import urllib.request
from pathlib import Path
from urllib.error import URLError
logger = log... | canonical/wordpress-k8s-operator | docs/_extensions/fetch_tutorial_notebook.py | .py | 2369508fd6179e9d | 7.6 | 15 |
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
"""User-defined exceptions used by WordPress charm."""
import ops.model
__all__ = [
"WordPressBlockedStatusException",
"WordPressInstallError",
"WordPressMaintenanceStatusException",
"WordPressStatusException",
"WordPressWa... | canonical/wordpress-k8s-operator | src/exceptions.py | .py | 9f0c719f4a3de946 | 7.6 | 15 |
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
"""Wordpress charm state."""
import dataclasses
import logging
import os
import typing
import ops
# pylint: disable=no-name-in-module
from pydantic import BaseModel, HttpUrl, ValidationError
logger = logging.getLogger(__name__)
class Charm... | canonical/wordpress-k8s-operator | src/state.py | .py | 099cb8f885cbec46 | 7.6 | 15 |
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
"""Module for commonly used internal types in WordPress charm."""
from typing import Any, NamedTuple, Optional, Union
class CommandExecResult(NamedTuple):
"""Result of executed command from WordPress container.
Attrs:
return_... | canonical/wordpress-k8s-operator | src/types_.py | .py | 48f69d16280845c0 | 7.6 | 15 |
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
"""Fixtures for the wordpress integration tests."""
import configparser
import json
import re
import secrets
from pathlib import Path
from typing import AsyncGenerator, Dict, Optional
import pytest
import pytest_asyncio
import swiftclient
impo... | canonical/wordpress-k8s-operator | tests/integration/conftest.py | .py | 3aed54d080f02755 | 8.1 | 15 |
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
"""Helper classes and functions for integration tests."""
import asyncio
import html
import inspect
import json
import logging
import mimetypes
import re
import secrets
import time
from typing import (
Any,
Awaitable,
Callable,
... | canonical/wordpress-k8s-operator | tests/integration/helper.py | .py | 01485e5d6bf41b2f | 7.1 | 15 |
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
"""Integration tests for WordPress charm COS integration."""
import functools
import pytest
import requests
from juju.action import Action
from juju.client._definitions import FullStatus
from tests.integration.helper import WordpressApp, wait... | canonical/wordpress-k8s-operator | tests/integration/test_cos_grafana.py | .py | 33c6062cd3b8f885 | 8.1 | 15 |
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
"""Integration tests for WordPress charm COS integration."""
import functools
from typing import Iterable
import kubernetes
import pytest
import requests
from juju.client._definitions import FullStatus
from tests.integration.helper import Wor... | canonical/wordpress-k8s-operator | tests/integration/test_cos_loki.py | .py | bb6b712b9e893e79 | 8.1 | 15 |
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
"""Integration tests for WordPress charm ingress integration."""
import kubernetes
import pytest
import requests
from tests.integration.helper import WordpressApp
@pytest.mark.usefixtures("prepare_mysql", "prepare_nginx_ingress")
async def t... | canonical/wordpress-k8s-operator | tests/integration/test_ingress.py | .py | a95139513a3014bd | 8.1 | 15 |
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
"""Fixtures for WordPress charm unit tests."""
import typing
import unittest
import unittest.mock
import ops.pebble
import ops.testing
import pytest
from charm import WordpressCharm
from tests.unit.wordpress_mock import WordpressPatch
@pyte... | canonical/wordpress-k8s-operator | tests/unit/conftest.py | .py | 5441ba66df7b9bd2 | 7.1 | 15 |
# Copyright 2026 Canonical Ltd.
# See LICENSE file for licensing details.
"""Unit tests for the CI-artifact notebook cache helper."""
import importlib.util
import io
import json
import sys
import zipfile
from pathlib import Path
import pytest
_MODULE_PATH = (
Path(__file__).resolve().parents[2]
/ "docs"
... | canonical/wordpress-k8s-operator | tests/unit/test_cache_notebook_from_artifact.py | .py | 28e23d9cad2b4359 | 7.1 | 15 |
# Copyright 2024 Canonical Ltd.
# See LICENSE file for licensing details.
# pylint:disable=protected-access,unused-argument
"""Mocking and patching system for testing WordPress charm."""
import contextlib
import io
import json
import re
import textwrap
import typing
import unittest.mock
import mysql.connector
impor... | canonical/wordpress-k8s-operator | tests/unit/wordpress_mock.py | .py | 440c52a92a6a4dfa | 7.1 | 15 |
class Brokers:
def __init__(self, britive) -> None:
self.britive = britive
self.base_url = f'{self.britive.base_url}/resource-manager/remote-broker/brokers'
def list(self, status: str = '') -> list:
"""
List brokers with ability to filter by status.
:param status: Filte... | britive/python-sdk | src/britive/access_broker/brokers.py | .py | 728320edc96bb0c1 | 7.45 | 7 |
import requests
class Permissions:
def __init__(self, britive) -> None:
self.britive = britive
self.base_url = f'{self.britive.base_url}/resource-manager'
def create(
self,
resource_type_id: str,
name: str,
description: str = '',
checkin_file: str = Non... | britive/python-sdk | src/britive/access_broker/resources/permissions.py | .py | cb2bdc4a14e459da | 7.45 | 7 |
class ResponseTemplates:
def __init__(self, britive) -> None:
self.britive = britive
self.base_url = f'{self.britive.base_url}/resource-manager/response-templates'
def create(
self,
template_data: str,
name: str,
description: str = '',
is_console_enabled:... | britive/python-sdk | src/britive/access_broker/response_templates.py | .py | f570b5560b527966 | 7.45 | 7 |
class AdvancedSettings:
def __init__(self, britive, base_url: str = '/apps/{}/advanced-settings') -> None:
self.britive = britive
self.base_url = self.britive.base_url + base_url
def create(self, entity_id: str, settings: dict) -> dict:
"""
Create Advanced Settings for a specifi... | britive/python-sdk | src/britive/application_management/advanced_settings.py | .py | a30898170a8e4a1c | 7.45 | 7 |
valid_user_account_mappings = {
'email': [{'name': 'email', 'description': 'Email'}],
'username': [{'name': 'username', 'description': 'Username'}],
}
class Applications:
def __init__(self, britive) -> None:
self.britive = britive
self.base_url = f'{self.britive.base_url}/apps'
def li... | britive/python-sdk | src/britive/application_management/applications.py | .py | 5f8967f5d17d26db | 7.45 | 7 |
class EnvironmentGroups:
def __init__(self, britive) -> None:
self.britive = britive
self.base_url = f'{self.britive.base_url}/apps'
def create(self, application_id: str, name: str, description: str = '', parent_id: str = None) -> dict:
"""
Create a new environment group inside ... | britive/python-sdk | src/britive/application_management/environment_groups.py | .py | f729e660388f0498 | 7.45 | 7 |
class Environments:
def __init__(self, britive) -> None:
self.britive = britive
self.base_url = f'{self.britive.base_url}/apps'
def create(self, application_id: str, name: str, description: str = '', parent_group_id: str = None) -> dict:
"""
Create a new environment inside the s... | britive/python-sdk | src/britive/application_management/environments.py | .py | c2b9dd7d57102eca | 7.45 | 7 |
class ManagedPermissions:
def __init__(self, britive) -> None:
self.britive = britive
self.base_url = f'{self.britive.base_url}/apps'
def create(
self,
application_id: str,
name: str,
permissions: list,
description: str = '',
type: str = 'role',
... | britive/python-sdk | src/britive/application_management/managed_permissions.py | .py | 53a36c1afac28af7 | 7.45 | 7 |
from britive import exceptions
from britive.application_management.advanced_settings import AdvancedSettings
from .additional_settings import AdditionalSettings
from .permissions import Permissions
from .policies import Policies
from .session_attributes import SessionAttributes
creation_defaults = {
'delegationEn... | britive/python-sdk | src/britive/application_management/profiles/__init__.py | .py | a8f7020c25b59ea8 | 7.45 | 7 |
import json
from typing import Literal, Union
class Policies:
def __init__(self, britive) -> None:
self.britive = britive
self.base_url = f'{self.britive.base_url}/paps'
def build( # noqa: PLR0913,PLR0917
self,
name: str,
description: str = '',
draft: bool = F... | britive/python-sdk | src/britive/application_management/profiles/policies.py | .py | 3d536cefaccfa0c7 | 7.45 | 7 |
class Scans:
def __init__(self, britive) -> None:
self.britive = britive
self.base_url = f'{self.britive.base_url}/apps'
def scan(self, application_id: str, environment_id: str = None, org_scan_only: bool = False) -> dict:
"""
Initiate a scan of the provided application and opti... | britive/python-sdk | src/britive/application_management/scans.py | .py | fcf37bf09f2f3e4e | 7.45 | 7 |
import os
from datetime import datetime, timedelta, timezone
from sys import stderr
from urllib import parse
import requests
from ..exceptions import BritiveException
class Logs:
def __init__(self, britive) -> None:
self.britive = britive
self.base_url = f'{self.britive.base_url}/logs/v2'
d... | britive/python-sdk | src/britive/audit_logs/logs.py | .py | e6ca7f7ce3ce7154 | 7.45 | 7 |
import contextlib
import jmespath
from jmespath.exceptions import EmptyExpressionError, ParseError
class Webhooks:
def __init__(self, britive) -> None:
self.britive = britive
self.base_url = f'{self.britive.base_url}/v1/notification-service/logs/webhooks'
def create_or_update(self, notificat... | britive/python-sdk | src/britive/audit_logs/webhooks.py | .py | 3ca76c681d0badd1 | 7.45 | 7 |
import os
import time
import requests
from . import __version__
from .access_broker import AccessBroker
from .application_management import ApplicationManagement
from .audit_logs import AuditLogs
from .exceptions import (
RootEnvironmentGroupNotFound,
TenantMissingError,
TenantUnderMaintenance,
TokenM... | britive/python-sdk | src/britive/britive.py | .py | fc5f121c2adbc745 | 7.45 | 7 |
from datetime import datetime
class Banner:
def __init__(self, britive) -> None:
self.britive = britive
self.base_url = f'{self.britive.base_url}/settings/banner'
def get(self) -> dict:
"""
Get the banner configuration.
:returns: Details of the banner.
"""
... | britive/python-sdk | src/britive/global_settings/banner.py | .py | 299f28abc58223d6 | 7.45 | 7 |
import sys
from copy import deepcopy
from io import StringIO
import pytest
from jsonc import JSONDecodeError, dump, dumps, load, loads
def test_loads():
assert loads("{// comment \n}") == {}
assert loads("{// comment \r}") == {}
assert loads("{// comment \r\n}") == {}
assert loads("{}// comment") ==... | n-takumasa/json-with-comments | tests/test_jsonc.py | .py | 1296de88d2274988 | 7.15 | 19 |
# Collections.py
#
# Copyright (c) 2019-2021 Couchbase, 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 req... | couchbaselabs/couchbase-lite-python | CouchbaseLite/Collections.py | .py | 206f330d4e34acd0 | 7.5 | 9 |
# Database.py
#
# Copyright (c) 2019-2021 Couchbase, 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 requir... | couchbaselabs/couchbase-lite-python | CouchbaseLite/Database.py | .py | 62b59faa2849aec7 | 7.5 | 9 |
# Document.py
#
# Copyright (c) 2019 Couchbase, 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 required by... | couchbaselabs/couchbase-lite-python | CouchbaseLite/Document.py | .py | 5692da3e32294f1d | 7.5 | 9 |
from dataclasses import dataclass
from enum import IntEnum
from ._PyCBL import ffi, lib
from .common import *
class ReplicatorActivityLevel(IntEnum):
"""CBLReplicatorActivityLevel enum values (from CBLReplicator.h)."""
STOPPED = 0 # The replicator is unstarted, finished, or hit a fatal error.
OFFLINE... | couchbaselabs/couchbase-lite-python | CouchbaseLite/Replicator.py | .py | a0561e6a0d101e79 | 7.5 | 9 |
# common.py
#
# Copyright (c) 2019-2021 Couchbase, 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 required... | couchbaselabs/couchbase-lite-python | CouchbaseLite/common.py | .py | 1629831425e9962d | 7.5 | 9 |
"""审计日志集成示例 — 展示如何在 Agent 执行流程中集成审计功能
本示例展示:
1. 在 Agent 执行前后记录审计日志
2. 记录操作耗时
3. 处理异常情况
4. 支持会话关联
用法:
uv run python .agents/scripts/audit_integration_example.py
"""
from __future__ import annotations
import time
from dataclasses import dataclass
from typing import Any, Callable
# 添加父目录到路径
import sys
from pathli... | xinetzone/tao | apps/chaos/.agents/scripts/audit_integration_example.py | .py | 516cd4e0199fa546 | 7.42 | 6 |
#!/usr/bin/env python3
"""Check N×N cross-links between philosophy documents.
Scans docs/general/philosophy/ for all .md files (excluding index.md
and cultivation/ subdirectory), then verifies that each document's
"延伸阅读" section contains links to every other philosophy document.
Usage:
python .agents/scripts/chec... | xinetzone/tao | apps/chaos/.agents/scripts/check-philosophy-links.py | .py | 147425d4674557d4 | 7.42 | 6 |
"""constraints-check — 校验 .agents/constraints.toml 合规性
验证 Layer 2 操作性约束:强约束不可违反、弱约束提警告、Role 绑定文件是否存在。
这是"规范即代码"的体现——AgentForge 自己的 CI 第一个跑这个检查。
"""
from __future__ import annotations
import sys
from pathlib import Path
# Windows 终端 UTF-8 编码支持
if sys.platform == 'win32':
sys.stdout.reconfigure(encoding='utf-8')
... | xinetzone/tao | apps/chaos/.agents/scripts/check_constraints.py | .py | d8d010cdb0b09660 | 7.42 | 6 |
"""校验 Markdown 文档中的相对路径引用是否有效。
默认扫描根目录 README.md、CHANGELOG.md、AGENTS.md,提取所有
``[text](path)`` 形式的相对路径链接,并验证其在文件系统中存在。
设计要点:
- 跳过 http/https 外链、邮件链接、锚点链接与 file:/// 绝对路径。
- 支持 ``path#L1-L100`` 行号锚点形式(仅校验路径部分)。
- 支持 ``path#fragment`` 文档内锚点(仅校验路径部分)。
- 路径相对当前 Markdown 文件解析;目录引用以末尾 ``/`` 标识。
退出码:
0 - ... | xinetzone/tao | apps/chaos/.agents/scripts/check_doc_links.py | .py | fa72b204254446aa | 7.42 | 6 |
"""校验 docs/ 目录结构遵循 tech/general 双轨分类规范。
规则:
R1. docs/ 顶层除 ``index.md`` 外不应直接存在 ``.md`` 业务文档
(所有项目技术文档应位于 ``docs/tech/``,通用知识应位于 ``docs/general/``)。
R2. ``docs/tech/index.md`` 与 ``docs/general/index.md`` 必须存在
(作为双轨子入口,不得带 ``orphan: true``)。
R3. ``docs/tech/`` 与 ``docs/general/`` 子目录内允许任意结构,但... | xinetzone/tao | apps/chaos/.agents/scripts/check_docs_structure.py | .py | 1994e60cd99f938f | 7.42 | 6 |
"""EU AI Act Compliance Checker — 校验 Agent 配置是否符合 EU AI Act 要求
针对 EU AI Act 三条款(Art 12/14/15)的合规性校验:
- Article 12: 记录留存(Record-Keeping)
- Article 14: 人类监督(Human Oversight)
- Article 15: 鲁棒性(Robustness)
用法:
uv run python .agents/scripts/check_eu_ai_act.py [OPTIONS]
选项:
--constraints PATH 指定 constraints.tom... | xinetzone/tao | apps/chaos/.agents/scripts/check_eu_ai_act.py | .py | 663689115b73bf24 | 7.42 | 6 |
"""
PDF→Markdown 转换结果质量检查脚本
功能:
- 基础属性检查(大小、行数、字符数)
- Markdown 结构检查(标题层级、空文件检测)
- 内容完整性检查(关键章节存在性)
- 与原始 PDF 页数映射对比
- 生成质量评分报告
用法:
python check_markdown_quality.py <markdown.md> [--pdf original.pdf] [--verbose]
示例:
python check_markdown_quality.py book.md --pdf book.pdf
"""
import argpar... | xinetzone/tao | apps/chaos/.agents/scripts/check_markdown_quality.py | .py | e68f71b25e27c6d5 | 7.42 | 6 |
"""预编译检查所有 Python 文件的语法正确性,防止 Python 2 残留语法进入 CI。
与 ruff/pyright 互补:ruff 侧重风格与常见错误,py_compile 侧重语法正确性(如
``except X, Y:`` 这类 Python 2 语法在 ruff 当前规则下不会被捕获)。
退出码:
0 - 所有 .py 文件语法正确
1 - 至少一个文件存在语法错误
2 - 运行时错误(如目录不存在)
"""
from __future__ import annotations
import argparse
import py_compile
import sys
from pa... | xinetzone/tao | apps/chaos/.agents/scripts/check_py_syntax.py | .py | 8c6ea431891b468b | 7.42 | 6 |
"""审计日志清理脚本 — EU AI Act Article 12 合规实现
定期清理过期审计日志,满足 EU AI Act 记录留存要求:
- 默认保留 365 天
- 自动压缩旧日志
- 提供清理统计报告
用法:
# 手动清理
uv run python .agents/scripts/cleanup_audit_logs.py
# 指定保留天数
uv run python .agents/scripts/cleanup_audit_logs.py --retention-days 365
# 干运行(不实际删除)
uv run python .agents/script... | xinetzone/tao | apps/chaos/.agents/scripts/cleanup_audit_logs.py | .py | 0202351d8b1c22fb | 7.42 | 6 |
"""
预下载 marker-pdf 所需模型脚本
功能:
- 预下载 marker-pdf 所有依赖模型到本地缓存
- 支持指定模型存储目录(便于团队共享)
- 显示下载进度和磁盘占用
用法:
python download_marker_models.py [options]
示例:
# 下载到默认缓存目录
python download_marker_models.py
# 下载到指定共享目录(团队复用)
python download_marker_models.py --cache-dir D:\\shared\\marker-models
"""
... | xinetzone/tao | apps/chaos/.agents/scripts/download_marker_models.py | .py | 26b453e50dbf5ef4 | 7.42 | 6 |
"""
PDF → Markdown 全流程转换脚本
功能:
- 环境自动检测与安装
- 支持单文件/分批转换
- 自动合并输出
- 转换质量检查
用法:
python pdf_to_markdown.py <input.pdf> [options]
示例:
# 基础转换(自动判断是否需要分批)
python pdf_to_markdown.py book.pdf
# 强制分批转换
python pdf_to_markdown.py book.pdf --batch-size 20
# 指定输出
python pdf_to_markdo... | xinetzone/tao | apps/chaos/.agents/scripts/pdf_to_markdown.py | .py | a61e75f4d711967f | 7.42 | 6 |
"""
PDF 分批转 Markdown 脚本(解决大 PDF 内存占用问题)
用法:
python pdf_to_markdown_batch.py <input.pdf> [--batch-size N] [--output-dir DIR]
示例:
python pdf_to_markdown_batch.py book.pdf --batch-size 20 --output-dir ./output
"""
import argparse
import math
import os
import subprocess
import sys
from pathlib import Path
def ... | xinetzone/tao | apps/chaos/.agents/scripts/pdf_to_markdown_batch.py | .py | 652ab0cf3d51c6a5 | 7.42 | 6 |
#!/usr/bin/env python3
"""Export AgentForge skills with platform-specific path variable adaptation.
AgentForge skills use ``{baseDir}`` as the path variable pointing to the
current skill directory. Different agent runtimes use different conventions:
- Claude Code: ``${CLAUDE_SKILL_DIR}``
- OpenAI Codex: original path... | xinetzone/tao | apps/chaos/.agents/scripts/skill-export.py | .py | b3c9146521818104 | 7.42 | 6 |
from __future__ import annotations
import argparse
import re
import sys
import tomllib
from pathlib import Path
# 严格模式(strict)下与必填同等的最小集
REQUIRED_SECTIONS_MIN = [
("Skill ID/Name", r"(?:Skill\s*(?:ID|Name|唯一标识)|Name)"),
("Description", r"(?:Description|功能描述|功能|用途|Summary)"),
]
# 推荐章节:strict 模式下视为必填,relaxed 模... | xinetzone/tao | apps/chaos/.agents/scripts/validation/validate_skill_md.py | .py | 95644ab7eda8c024 | 7.42 | 6 |
"""PDF -> Markdown 拆分脚本(参数化通用版本).
读取 `pdf_extract.py` 产物(`pdf_raw_text.txt` + `pdf_page_meta.json`),
按帛书本《老子》体例(德经在前、道经在后)拆分为格式规范的 Markdown 文件。
输出结构::
<output_dir>/
├── index.md
├── images/cover.png(如提供 --cover)
├── front-matter/
│ ├── copyright.md
│ ├── author.md
│ ├── preface.md
... | xinetzone/tao | apps/chaos/.agents/skills/pdf-to-markdown/scripts/pdf_to_markdown.py | .py | c1fc16f51aa21625 | 7.42 | 6 |
"""English academic PDF -> Markdown splitting script.
Reads the output of `pdf_extract.py` (`pdf_raw_text.txt` + `pdf_page_meta.json`),
identifies English academic paper structure and splits into a Markdown file set.
Output structure::
<output_dir>/
├── index.md # Paper metadata + toctree
├─... | xinetzone/tao | apps/chaos/.agents/skills/pdf-to-markdown/scripts/pdf_to_markdown_en.py | .py | 86f7c3d993d6c610 | 7.42 | 6 |
"""pytest 配置与共享 fixtures:动态生成含中文章节标题的测试 PDF。"""
from __future__ import annotations
import json
from pathlib import Path
import pytest
SKILL_DIR = Path(__file__).resolve().parent.parent
SCRIPTS_DIR = SKILL_DIR / "scripts"
SCHEMA_PATH = SKILL_DIR / "schemas" / "page-meta.schema.json"
def _detect_cjk_font() -> Path ... | xinetzone/tao | apps/chaos/.agents/skills/pdf-to-markdown/tests/conftest.py | .py | 8223c2c9fc35e90f | 7.92 | 6 |
#!/usr/bin/env python3
"""
Aggregate individual run results into benchmark summary statistics.
Reads grading.json files from run directories and produces:
- run_summary with mean, stddev, min, max for each metric
- delta between with_skill and without_skill configurations
Usage:
python aggregate_benchmark.py <ben... | xinetzone/tao | apps/chaos/.agents/skills/skill-creator/scripts/aggregate_benchmark.py | .py | 51c3682537c1cb14 | 7.42 | 6 |
#!/usr/bin/env python3
"""Generate an HTML report from run_loop.py output.
Takes the JSON output from run_loop.py and generates a visual HTML report
showing each description attempt with check/x for each test case.
Distinguishes between train and test queries.
"""
import argparse
import html
import json
import sys
fr... | xinetzone/tao | apps/chaos/.agents/skills/skill-creator/scripts/generate_report.py | .py | 9ecce91bf9b76609 | 7.42 | 6 |
#!/usr/bin/env python3
"""Improve a skill description based on eval results.
Takes eval results (from run_eval.py) and generates an improved description
by calling `claude -p` as a subprocess (same auth pattern as run_eval.py —
uses the session's Claude Code auth, no separate ANTHROPIC_API_KEY needed).
"""
import arg... | xinetzone/tao | apps/chaos/.agents/skills/skill-creator/scripts/improve_description.py | .py | 183a3f3a1cacfafe | 7.42 | 6 |
#!/usr/bin/env python3
"""
Skill Packager - Creates a distributable .skill file of a skill folder
Usage:
python utils/package_skill.py <path/to/skill-folder> [output-directory]
Example:
python utils/package_skill.py skills/public/my-skill
python utils/package_skill.py skills/public/my-skill ./dist
"""
im... | xinetzone/tao | apps/chaos/.agents/skills/skill-creator/scripts/package_skill.py | .py | 3106a3d38239dd61 | 7.42 | 6 |
#!/usr/bin/env python3
"""Run the eval + improve loop until all pass or max iterations reached.
Combines run_eval.py and improve_description.py in a loop, tracking history
and returning the best description found. Supports train/test split to prevent
overfitting.
"""
import argparse
import json
import random
import s... | xinetzone/tao | apps/chaos/.agents/skills/skill-creator/scripts/run_loop.py | .py | f9993a0a169d1042 | 7.42 | 6 |
import importlib.util
import os
import sys
from cats.executor.function.transport_port import as_transport_port
from cats.utils import wait_for_directory
_TRANSPORT_PORT_HINT = (
'Process transport callables must accept a `transport` argument '
'(TransportPort: migrate / stage_for_plant). Recreate the Order wi... | DynamicalSystemsGroup/cats | cats/executor/function/processor.py | .py | b0c45ee6fea518ed | 7.65 | 19 |
"""Executor-owned narrowing of Structure transport to Process TransportPort.
CFL 4A / INTEROP: Executor wires ports. ``as_transport_port`` is Node execution
machinery — not part of the Order-addressed Function CID tree. Process owns
the ``TransportPort`` Protocol (``data/input/function/process/transport_port.py``,
TYP... | DynamicalSystemsGroup/cats | cats/executor/function/transport_port.py | .py | 9fef637675d44d42 | 7.65 | 19 |
"""Structure half of the Architectural Quantum (PaaS + Plant/InfraStructure)."""
from cats.executor.structure._tf import (
modules_installed,
read_applied_structure_id,
write_applied_structure_id,
)
from cats.executor.structure.infrastructure import InfraStructure
from cats.executor.structure.plant import P... | DynamicalSystemsGroup/cats | cats/executor/structure/__init__.py | .py | c7b753bb03a4260e | 7.65 | 19 |
import importlib.util
import json
import os
import re
import stat
import sys
from cats.utils import subproc_run
APPLIED_STRUCTURE_MARKER = '.applied-structure.id'
LEGACY_APPLIED_STRUCTURE_MARKER = '.applied-structure.cid'
TF_STATE_LOCK_INFO = '.terraform.tfstate.lock.info'
def _load_transport_utils_module(structure... | DynamicalSystemsGroup/cats | cats/executor/structure/_tf.py | .py | fcd5dd3f13fae9c2 | 7.65 | 19 |
import importlib.util
import os
import shutil
import subprocess
import sys
from cats.executor.structure._tf import (
_load_transport_utils_module,
_terraform_output,
configure_terraform_data_dir,
ensure_integration_cache_env,
ensure_provider_binaries_executable,
heal_stale_terraform_state_lock,... | DynamicalSystemsGroup/cats | cats/executor/structure/infrastructure.py | .py | 8ec6397389c3802f | 7.65 | 19 |
import importlib.util
import os
import sys
from cats.executor.structure._tf import (
_terraform_output,
read_applied_structure_id,
)
class Plant:
"""Composed, read-only accessor over the deployed Plant (`module.plant`
in main.tf): the kind cluster + Helm releases that constitute the
dynamically s... | DynamicalSystemsGroup/cats | cats/executor/structure/plant.py | .py | 86fc847b41582e32 | 7.65 | 19 |
"""Data Product manufacturing cell (Software / Manufacturing factory).
CAT Node is a Data Product on a Data Mesh. Factory accepts a content-addressed
Order, stages materials via ContentMesh (through Runtime.initBOMcar), assembles
Function + Structure (AQ halves), and produces an ephemeral Executor.
Not Structure's Pl... | DynamicalSystemsGroup/cats | cats/factory/factory.py | .py | c49d26f44481314f | 7.65 | 19 |
"""AddressStore — content-addressed reads: CAS ``ni:``, ``hl:``, or HTTP URI.
Legacy IPFS CIDs (``Qm…`` / ``bafy…``) fail closed (§6s).
"""
from __future__ import annotations
import json
import os
import re
from typing import Any
from urllib.parse import urlparse
from urllib.request import Request, urlopen
from cats... | DynamicalSystemsGroup/cats | cats/network/address_store/store.py | .py | 07550726da94234b | 7.65 | 19 |
"""Bootstrap (repo-default) ContentStore probe helpers."""
import importlib.util
import os
import sys
def _bootstrap_content_store_utils_path(cats_home):
"""Repo-default content_store_utils.py (not Order-submitted Structure)."""
if not cats_home:
return None
return os.path.join(
cats_home,
... | DynamicalSystemsGroup/cats | cats/network/bootstrap.py | .py | dc4b7b0ab25881f9 | 7.65 | 19 |
"""Content refs (§6d/§6f): ``*_uri`` fetch; equality via ``ni:`` / ``hl:`` / legacy.
New mints write only ``*_uri`` (never ``*_cid``). Readers accept legacy dual-field
or CID-only graphs via ``ref_id``. Intake accepts ``hl:`` as an alias to ``ni:``.
"""
from __future__ import annotations
import re
from typing import ... | DynamicalSystemsGroup/cats | cats/network/cas/content_ref.py | .py | b3b7695e9308dc39 | 7.65 | 19 |
"""Digest / ``ni:`` identity helpers for CAS-over-HTTP (RFC 6920 sha-256)."""
from __future__ import annotations
import base64
import hashlib
import re
# Path-safe lowercase hex sha256 (64 chars).
_HEX_SHA256 = re.compile(r'^[0-9a-f]{64}$')
# CIDv0 / CIDv1 path segments (legacy).
_CID_SEGMENT = re.compile(r'^[A-Za-z0... | DynamicalSystemsGroup/cats | cats/network/cas/digest.py | .py | d6fe1ed3cacc07b8 | 7.65 | 19 |
"""Recursively inline ``*_uri`` refs in nested dicts (drop uri keys once expanded)."""
from __future__ import annotations
from collections.abc import Callable, Collection, Set
from typing import Any
FetchRef = Callable[[str, str], Any]
"""``fetch(stem, uri) -> payload``. Caller remaps ``uri`` to a locator if needed."... | DynamicalSystemsGroup/cats | cats/network/cas/flatten_refs.py | .py | 9f06f29cad107abe | 7.65 | 19 |
"""``hl:`` hashlink emit + parse (RFC/draft-shaped; §6f resolve + handoff)."""
from __future__ import annotations
import base64
import re
from cats.network.cas.digest import from_ni, is_ni_or_digest, to_ni
# Minimal hashlink: hl:<base64url-sha256>:<url> (draft-shaped).
_HL_SHA256 = re.compile(
r'^hl:([A-Za-z0-9_... | DynamicalSystemsGroup/cats | cats/network/cas/hashlink.py | .py | 5073538a83a1d94b | 7.65 | 19 |
"""Resolve Invoice stage refs: ``data_stages`` nest preferred, flat fallback."""
from __future__ import annotations
import json
from typing import Any
from cats.network.cas.content_ref import ref_id, ref_uri
from cats.network.cas.digest import from_ni, is_ni_or_digest
def _digest_key(content_id: str | None) -> str ... | DynamicalSystemsGroup/cats | cats/network/cas/invoice_stages.py | .py | 9751be5fea0c28a2 | 7.65 | 19 |
"""Locator index: content_id → HTTP locators (CAS-over-HTTP discovery)."""
from __future__ import annotations
import json
from pathlib import Path
from typing import Any
from cats.network.cas.digest import (
content_id_fs_key,
from_ni,
is_ni_or_digest,
to_ni,
)
from cats.network.cas.store import cas_l... | DynamicalSystemsGroup/cats | cats/network/cas/locators.py | .py | e58b1caf68d97939 | 7.65 | 19 |
"""Digest-keyed directory manifests for CAS-over-HTTP trees."""
from __future__ import annotations
import json
import os
from pathlib import Path
from typing import Any
from cats.network.cas.digest import is_ni_or_digest
from cats.network.cas.store import CasHttpStore
MANIFEST_TYPE = 'CasDirectoryManifest'
def bui... | DynamicalSystemsGroup/cats | cats/network/cas/manifest.py | .py | af60c1f35af112df | 7.65 | 19 |
"""Directory-manifest content-address equivalence (CAS trees).
Distinct from registry ``content_equiv`` (mesh.cat ≡ HTTP of envelope slots)
and from provenance DataFrame endpoint checks.
"""
from __future__ import annotations
from collections.abc import Callable
from typing import Any
HttpGetJson = Callable[[str], A... | DynamicalSystemsGroup/cats | cats/network/cas/manifest_equiv.py | .py | a26d7848c50d7375 | 7.65 | 19 |
"""Node-local digest-keyed CAS blob store (data plane; HTTP via LDP routes)."""
from __future__ import annotations
from pathlib import Path
from cats.network.cas.digest import (
from_ni,
is_ni_or_digest,
sha256_hex,
to_ni,
validate_digest_segment,
)
def cas_ldp_path(hex_digest: str) -> str:
... | DynamicalSystemsGroup/cats | cats/network/cas/store.py | .py | 06f2c7a4403287e7 | 7.65 | 19 |
"""Thin sync Kubo HTTP RPC client behind CatsIPFSClient.
Talks to the host daemon at http://{host}:{port}/api/v0/* with plain
`requests` POSTs — no ipfshttpclient / http+ip4 multiaddr stack.
ContentMesh reads and writes both go through this client (no `ipfs` CLI).
"""
from __future__ import annotations
import io
impo... | DynamicalSystemsGroup/cats | cats/network/clients/ipfs_client.py | .py | be4808f323f14680 | 7.65 | 19 |
"""Control-Feedback BOM packaging (JSON-LD + PROV-O + Data Integrity).
Phase 1: address refs + DID attribution.
Phase 1b: eddsa-jcs-2022 proof via ``sign_execution_bom``.
Stage lineage: ``prov:wasDerivedFrom`` between Invoice stage content ids.
Phase 2b / §6d: entity ``@id`` prefers HTTP URI; ``ni:`` as ``contentId``;... | DynamicalSystemsGroup/cats | cats/network/feedback/envelope.py | .py | 438d88e2326c4d9a | 7.65 | 19 |
"""Multibase base58 (prefix ``z``) helpers for did:key / Data Integrity."""
from __future__ import annotations
# Spec: https://github.com/multiformats/multibase
_BASE58_ALPHABET = b'123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
_BASE58_INDEX = {c: i for i, c in enumerate(_BASE58_ALPHABET)}
def b58encod... | DynamicalSystemsGroup/cats | cats/network/identity/multibase.py | .py | 6782d6562409672e | 7.65 | 19 |
"""CAT Node DID attribution and signing material (did:key; Phase 1b)."""
from __future__ import annotations
import base64
import json
import os
from pathlib import Path
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
from cats.n... | DynamicalSystemsGroup/cats | cats/network/identity/node_did.py | .py | 749141a98e09fe94 | 7.65 | 19 |
"""WebID profile bridge from Node ``did:key`` (Phase 2a Solid identity).
Emits a minimal JSON-LD WebID document that references the existing
``did:key`` verification method. Data Integrity proofs stay on ``did:key``;
the WebID is the Solid-facing agent identity for WAC.
"""
from __future__ import annotations
import j... | DynamicalSystemsGroup/cats | cats/network/identity/webid.py | .py | baac05f0c4d108d6 | 7.65 | 19 |
"""Disk-backed LDP index for signed ExecutionBom envelopes (control plane)."""
from __future__ import annotations
import json
from pathlib import Path
from typing import Any
from cats.network.cas.digest import content_id_fs_key
def bom_ldp_path(bom_cid: str) -> str:
"""Path under the Node base URL for a BOM LDP... | DynamicalSystemsGroup/cats | cats/network/ldp/bom_store.py | .py | 4524094fb2498cbc | 7.65 | 19 |
"""Fetch LDP / Solid BOM envelopes and verify Data Integrity proofs.
Accepts Node ``/ldp/boms/…`` URLs and Solid pod URLs — same GET +
``verify_execution_bom`` path (no protocol fork).
"""
from __future__ import annotations
from typing import Any
import requests
from cats.network.feedback import verify_execution_bo... | DynamicalSystemsGroup/cats | cats/network/ldp/client.py | .py | 911892273d6e72bd | 7.65 | 19 |
"""LDP Link / Allow header helpers for Node-hosted control-plane resources."""
from __future__ import annotations
LDP_NS = 'http://www.w3.org/ns/ldp#'
LDP_RESOURCE = f'{LDP_NS}Resource'
LDP_RDF_SOURCE = f'{LDP_NS}RDFSource'
LDP_BASIC_CONTAINER = f'{LDP_NS}BasicContainer'
def resource_link_header() -> str:
"""RFC... | DynamicalSystemsGroup/cats | cats/network/ldp/headers.py | .py | 9e267b35576deebc | 7.65 | 19 |
"""Linked Data Notifications announce for Solid BOM publish (Phase 2a / §6f).
After a successful Solid PUT, POST a minimal notification to configured
Inbox URLs (``SOLID_LDN_INBOX_URLS``, comma-separated). Best-effort: log
failures; never raise to the caller of Runtime.execute.
"""
from __future__ import annotations
... | DynamicalSystemsGroup/cats | cats/network/ldp/ldn.py | .py | 1af48e2a5e83557f | 7.65 | 19 |
"""Node-local LDP JSON resources for Order / Invoice (Phase 2b data-plane URIs)."""
from __future__ import annotations
import json
from pathlib import Path
from typing import Any, Literal
from cats.network.cas.digest import content_id_fs_key
ResourceKind = Literal['invoices', 'orders']
def resource_ldp_path(kind: ... | DynamicalSystemsGroup/cats | cats/network/ldp/resource_store.py | .py | 1640bfec074c395c | 7.65 | 19 |
"""Solid pod publisher for signed ExecutionBom envelopes (Phase 2a).
CSS-compatible HTTP PUT of ``application/ld+json`` under
``{SOLID_POD_BASE_URL}{SOLID_BOMS_PATH}/{bom_cid}``.
Auth (thin seam):
- ``SOLID_CLIENT_ACCESS_TOKEN`` → ``Authorization: Bearer …``
- else ``SOLID_CLIENT_ID`` + ``SOLID_CLIENT_SECRET`` → HTTP... | DynamicalSystemsGroup/cats | cats/network/ldp/solid_client.py | .py | 53ff1866f534a708 | 7.65 | 19 |
"""WAC bootstrap for the Solid BOM container (Phase 2a).
Creates the BOM container (if needed) and a minimal ACL granting the Node
agent ``acl:Write`` / ``acl:Append`` and configured readers ``acl:Read``.
"""
from __future__ import annotations
import json
import logging
import os
from typing import Any
from urllib.pa... | DynamicalSystemsGroup/cats | cats/network/ldp/wac.py | .py | efa4887fc2caad59 | 7.65 | 19 |
import os
from os.path import join, dirname, abspath
import pytest
import subprocess
# ref: https://pytest-with-eric.com/introduction/pytest-run-single-test/
# ref: https://medium.com/swlh/build-your-first-automated-test-integration-with-pytest-jenkins-and-docker-ec738ec43955
# ref: https://www.linkedin.com/pulse/ho... | lj020326/ansible-datacenter | files/python/test_inventory.py | .py | d78b92538bdd9d47 | 7.07 | 13 |
#!/usr/bin/env python
## source: https://github.com/alibaba/ansible-provider-docs/blob/master/contrib/inventory/openstack_inventory.py
# Copyright (c) 2012, Marco Vito Moscaritolo <marco@agavee.com>
# Copyright (c) 2013, Jesse Keating <jesse.keating@rackspace.com>
# Copyright (c) 2015, Hewlett-Packard Development Com... | lj020326/ansible-datacenter | inventory/openstack_inventory.py | .py | e6a4293437d67b77 | 7.57 | 13 |
## source: https://github.com/willthames/ansible/blob/generator_inventory_plugin/lib/ansible/plugins/inventory/generator.py
## ref: http://willthames.github.io/2017/11/01/generating-inventory.html
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
DOCUMENTATION = '''
name: ge... | lj020326/ansible-datacenter | plugins/inventory/generator.py | .py | 1c73ade8967efaaa | 7.57 | 13 |
#!/usr/bin/python
'''
source ~/tmp/ansible/hacking/env-setup
export PATH=$PATH:~/tmp/ansible/hacking/
test-module -m esxi_vib.py -a 'mock=yes name=esx-ui state=present'
export ANSIBLE_CONFIG=~/works/sysadm/ansible-study/esxi-mgmt/ansible.esxi.cfg
ansible -m esxi_vib 'name=esx-ui state=present' --check nest1-m8
'''
fr... | lj020326/ansible-datacenter | plugins/modules/esxi_vib.py | .py | 5202cca0d4f54433 | 7.57 | 13 |
#!/usr/bin/python
'''
source ~/tmp/ansible/hacking/env-setup
export PATH=$PATH:~/tmp/ansible/hacking/
test-module -m esxi_vm_list.py -a 'mock=yes'
export ANSIBLE_CONFIG=~/works/sysadm/ansible-study/esxi-mgmt/ansible.esxi.cfg
ansible -m esxi_vm_list nest1-m8
'''
from ansible.module_utils.basic import AnsibleModule
imp... | lj020326/ansible-datacenter | plugins/modules/esxi_vm_info.py | .py | 82c3ce4d6ff9be45 | 7.57 | 13 |
## source: https://github.com/freeipa/ansible-freeipa
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
ANSIBLE_METADATA = {
"metadata_version": "1.0",
"supported_by": "community",
"status": ["preview"],
}
DOCUMENTATION = """
---
module: ipacert
short_description: M... | lj020326/ansible-datacenter | plugins/modules/ipacert.py | .py | af93fdb6eb729cec | 7.57 | 13 |
## source: https://github.com/freeipa/ansible-freeipa
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
ANSIBLE_METADATA = {
"metadata_version": "1.0",
"supported_by": "community",
"status": ["preview"],
}
DOCUMENTATION = """
---
module: ipadelegation
short_descript... | lj020326/ansible-datacenter | plugins/modules/ipadelegation.py | .py | bceb5ed5c26b03ed | 7.57 | 13 |
## source: https://github.com/freeipa/ansible-freeipa
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
ANSIBLE_METADATA = {
"metadata_version": "1.0",
"supported_by": "community",
"status": ["preview"],
}
DOCUMENTATION = """
---
module: ipadnszone
short_description... | lj020326/ansible-datacenter | plugins/modules/ipadnszone.py | .py | ce28551c97dbc617 | 7.57 | 13 |
from iotaa import Asset, task
from uwtools.api.driver import AssetsTimeInvariant
from uwtools.api.logging import use_uwtools_logger
use_uwtools_logger()
class Answer(AssetsTimeInvariant):
@task
def answerfile(self):
"""
A file containing the answer.
"""
path = self.rundir / ... | ufs-community/uwtools | docs/sections/user_guide/cli/tools/execute/answer.py | .py | 6796a9bb1c276b97 | 7.63 | 17 |
from glob import glob
from pathlib import Path
import yaml
from pytest import fixture
from testbook import testbook
base = Path("fixtures/fs/config")
@fixture(scope="module")
def tb():
with testbook("fs.ipynb", execute=True) as tb:
yield tb
def test_fs_copy(load, tb):
# Get the config files as tex... | ufs-community/uwtools | notebooks/tests/test_fs.py | .py | ecc9e2b53ab5e377 | 7.13 | 17 |
"""
API access to ``uwtools`` configuration management tools.
"""
from __future__ import annotations
import os
from pathlib import Path
from typing import TYPE_CHECKING
from uwtools.config.formats.base import Config
from uwtools.config.formats.fieldtable import FieldTableConfig
from uwtools.config.formats.ini import... | ufs-community/uwtools | src/uwtools/api/config.py | .py | 492c333e124552df | 7.63 | 17 |
"""
API access to ``uwtools`` ecFlow support.
"""
from __future__ import annotations
from typing import TYPE_CHECKING, cast
from uwtools.ecflow import ECFLOW_PORT_MAX, ECFLOW_PORT_MIN
from uwtools.ecflow import realize as _realize
from uwtools.ecflow import server as _server
from uwtools.ecflow import validate as _v... | ufs-community/uwtools | src/uwtools/api/ecflow.py | .py | 4dfa3e71c128e7ec | 7.63 | 17 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.