Weblate’s Python API

Instalation

The Python API is shipped separately, you need to install Weblate Client:, wlc, to have it.

pip install wlc

wlc

WeblateException

exception wlc.WeblateException

Base class for all exceptions.

Weblate

class wlc.Weblate(key='', url=None, config=None)
Параметры:
  • key (str) – User key
  • url (str) – API server URL, if not specified default is used
  • config (WeblateConfig) – Configuration object, overrides any other parameters.

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

get(path)
Параметры:path (str) – Request path
Тип результата:object

Performs single API GET call.

post(path, **kwargs)
Параметры:path (str) – Request path
Тип результата:object

Performs single API GET call.

wlc.config

WeblateConfig

class wlc.config.WeblateConfig(section='wlc')
Параметры:section (str) – Configuration section to use

Configuration file parser following XDG specification.

load(path=None)
Параметры:path (str) – Path from which to load configuration.

Loads configuration from a file, if none is specified it loads from wlc configuration file placed in XDG configuration path (~/.config/wlc and /etc/xdg/wlc).

wlc.main

wlc.main.main(settings=None, stdout=None, args=None)
Параметры:
  • settings (list) – settings to override as list of tuples
  • stdout (object) – stdout file object for printing output, uses sys.stdout as default
  • args (list) – command line argumets to process, uses sys.args as default

Main entry point for command line interface.

@wlc.main.register_command(command)

Decorator to register Command class in main parser used by main().

Command

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

Main class for invoking commands.