Weblate 的 Python API

安裝

The Python API is shipped separately, you need to install the Weblate 用戶端 (wlc) to have it.

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) -- User key

  • url (str) -- API server 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.

Access class to the API, define API key and optionally API URL.

get(path)
參數:

path (str) -- Request path

回傳型別:

object

執行單個 API GET 呼叫。

post(path, **kwargs)
參數:

path (str) -- Request path

回傳型別:

object

執行單個 API GET 呼叫。

wlc.config

WeblateConfig

class wlc.config.WeblateConfig(section='wlc')
參數:

section (str) -- Configuration section to use

XDG規範之後的配置文件解析器。

load(path=None)
參數:

path (str) -- 從中載入配置的路徑。

Loads configuration from path when it is specified. Otherwise it loads the discovered global configuration file and then the nearest project configuration file (.weblate, .weblate.ini, or weblate.ini) from the current directory or its parents.

wlc.main

wlc.main.main(settings=None, stdout=None, args=None)
參數:
  • settings (list) -- 作為元組清單覆寫的設定

  • stdout (object) -- stdout file object for printing output, uses sys.stdout as default

  • args (list) -- Command-line arguments to process, uses sys.args as default

命令列介面的主要入口點。

@wlc.main.register_command(command)

註冊 Command 裝飾器類別在主要解析程式 main() 中。

Command

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

用於呼叫指令的主類別。