Weblate 的 Python API¶
安装¶
Python API 是单独发布的,你需要安装 Weblate 客户端 (wlc) 才能拥有它。
pip install wlc
wlc¶
WeblateException¶
- exception wlc.WeblateException¶
所有异常的基类。
Weblate¶
- class wlc.Weblate(key='', url=None, config=None, retries=0, status_forcelist=None, allowed_methods=None, backoff_factor=0, timeout=300)¶
- 参数:
key (str) -- 用户密钥
url (str) -- API 服务器 URL,如果未指定则使用默认值。
config (wlc.config.WeblateConfig) -- 配置对象,覆盖任何其他参数。
retries (int) -- HTTP 重试的总数。
status_forcelist (list) -- HTTP status codes that should trigger retries.
allowed_methods (list) -- HTTP methods that may be retried.
backoff_factor (float) -- Retry backoff factor passed to urllib3.
timeout (int) -- HTTP request timeout in seconds.
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) -- 从中加载配置的路径。
Loads configuration from
pathwhen it is specified. Otherwise it loads the discovered global configuration file and then the nearest project configuration file (.weblate,.weblate.ini, orweblate.ini) from the current directory or its parents.
wlc.main¶
- wlc.main.main(settings=None, stdout=None, args=None)¶
- 参数:
settings (list) -- 设置为元组列表覆盖
stdout (object) -- 用于打印输出的 stdout 文件对象,使用
sys.stdout作为默认值args (list) -- 要处理的命令行变量,使用
sys.args作为默认值
命令行界面的主要入口点。
Command¶
- class wlc.main.Command(args, config, stdout=None)¶
调用命令的主类。