Skip to main content

Python capability decorator for creating modular applications

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/capability/<>/pages/<>
    运行方法:
        http://127.0.0.1:5000/capability/<>/methods/<>

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

gitee: https://gitee.com/iiixxxiii/py-capability-decorator.git

使用

安装

pip install pycapabilitydecorator

示例

最简单的用法

# simple.py
from pycapabilitydecorator  import capability

# ---- 最简单能力接入
@capability.option()
def function1():
    return {
        "code": 0,
        "message": "[function1]成功"
    }

启动

python simple.py  server

执行方法 参数m 或者 method

curl http://127.0.0.1:5000/methods/simple/function1

访问页面

curl http://127.0.0.1:5000/pages/simple/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

python -m twine upload dist/*


pippy地址:
https://pypi.org/project/pycapabilitydecorator/

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.3.tar.gz (17.8 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.3-py3-none-any.whl (18.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pycapabilitydecorator-0.0.3.tar.gz
  • Upload date:
  • Size: 17.8 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.3.tar.gz
Algorithm Hash digest
SHA256 1a09c6a429be341c59b7c6d25ac94a2eb1b16f99003b952a26ebda2afab43cb2
MD5 d08d4cb97633defdaab0af8dc14aef15
BLAKE2b-256 684f615cfde5a511686b5953a5c58bfca1eb0a95b4f5035554b08f609bb975d3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for pycapabilitydecorator-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 43119162a3561f076abc3194209b944918b5ce55c909ab7da2510b9e6a0ae659
MD5 e76bbf907fe6f638ff087ef3218dc6fd
BLAKE2b-256 6aab17e407aa53b140528641edc87bb5dc3a51742fc67aaeac2822a886cc1bcc

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