Weblate 的 Python API

安装

Python API 是单独发布的,你需要安装 Weblate 客户端 (wlc) 才能拥有它。

pip install wlc

wlc

WeblateException

exception wlc.WeblateException

所有异常的基类。

Weblate

class wlc.Weblate(key='', url=None, config=None)
参数
  • key (str) – 用户密钥

  • url (str) – API 服务器 URL,如果未指定则使用默认值

  • config (wlc.config.WeblateConfig) – 配置对象,覆盖任何其他参数。

API 的访问类,定义 API 密钥和可选的 API URL。

get(path)
参数

path (str) – 请求路径

返回类型

object

执行单个 API GET 调用。

post(path, **kwargs)
参数

path (str) – 请求路径

返回类型

object

执行单个 API GET 调用。

wlc.config

WeblateConfig

class wlc.config.WeblateConfig(section='wlc')
参数

section (str) – 要使用的配置部分

遵循 XDG 规范的配置文件解析器。

load(path=None)
参数

path (str) – 从中加载配置的路径。

从文件中加载配置,如果未指定配置文件,,则从XDG路径(/etc/xdg/wlc)中的”wlc”配置文件(~/.config/wlc)加载配置。

wlc.main

wlc.main.main(settings=None, stdout=None, args=None)
参数
  • settings (list) – 设置为元组列表覆盖

  • stdout (object) – 用于打印输出的 stdout 文件对象,使用 sys.stdout 作为默认值

  • args (list) – 要处理的命令行参数,使用 sys.args 作为默认值

命令行界面的主要入口点。

@wlc.main.register_command(command)

main() 所用的主解析器中注册 Command 类的装饰器。

Command

class wlc.main.Command(args, config, stdout=None)

调用命令的主类。