Skip to main content

能力封装

Project description

PyCapabilityDecorator 说明文档

能力插件,将普通代码转换为能力插件

支持: 1. 定义 capability 元数据,包括初始化参数描述 (init_params) 和语言类型 (language_type)。 2. 注册顶级 CLI 命令(@option),支持可选的 alias,name 默认为函数名。 3. 添加顶级 --capability 选项输出所有 capability 元数据。 4. 添加顶级 init 命令执行初始化。 5. init_params 元数据描述初始化参数。 6. server(命令) 运行服务器 服务自动注册 pages 和 methods 页面模板路径 assets/pages 静态资源路径 assets/static

    运行页面:
        http://127.0.0.1:5000/pages/page=home.html
    运行方法:
        http://127.0.0.1:5000/methods?method=simple_function

生命周期: 1.register(命令) 注册 capability 元数据 2.init(命令) 初始化 3.start(命令) 启动能力 4.stop(命令) 停止能力 5.destroy(命令) 销毁能力

使用

安装

pip install pycapabilitydecorator

示例

最简单的用法

@capability.option()
def simple_function():
   return {
        "code": 0,
        "msg": "OK",
        "data": "这是最简单的能力"
    }

启动

python capability_simple.py  server

执行方法 参数m 或者 method

curl http://127.0.0.1:5000/methods?method=simple_function

访问页面

curl http://127.0.0.1:5000/pages?page=home.html

项目编译

# 构建
uv build



# 测试安装1
pip install dist/pycapabilitydecorator-0.0.1-py3-none-any.whl


# 测试安装2
pip install -e


# 运行示例文件

cd examples/simple

python capability_simple.py server


# 安装 twine
pip install twine

# 上传到 PyPI

twine upload --repository-url https://upload.pypi.org/legacy/ --username __token__ --password YOUR_PYPI_TOKEN dist/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pycapabilitydecorator-0.0.1.tar.gz (10.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pycapabilitydecorator-0.0.1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file pycapabilitydecorator-0.0.1.tar.gz.

File metadata

  • Download URL: pycapabilitydecorator-0.0.1.tar.gz
  • Upload date:
  • Size: 10.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.8.10

File hashes

Hashes for pycapabilitydecorator-0.0.1.tar.gz
Algorithm Hash digest
SHA256 5ae38e63bcb7d0c0756935b9daa43a80794238cbcda177f767e1c9707cd5ede3
MD5 c4d8e327263a068cb606161d0573e13b
BLAKE2b-256 aeed333801951a03804b74c7a77451ebef70c7e80f88075bed4754cb1987d17d

See more details on using hashes here.

File details

Details for the file pycapabilitydecorator-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pycapabilitydecorator-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1f5b55ccb2b92a13b86ee5736807565c2cbad60773e12b38bb030011abd2de59
MD5 4fe4f24af19137557d0c912d358c32a8
BLAKE2b-256 a30a53808375d9dcdf2ff4f9c8cf69760ae13a66222c3b2cc0adeaa85a7e3c06

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page