phabricator

Phabricator module.

wmflib.phabricator.create_phabricator(bot_config_file: str, section: str = 'phabricator_bot', dry_run: bool = True) phabricator.Phabricator[source]

Initialize the Phabricator client from the bot config file.

Examples

from wmflib.phabricator import create_phabricator
phab_client = create_phabricator('/path/to/config.ini')
phab_client.task_comment('T12345', 'Message')
Parameters
  • bot_config_file (str) –

    the path to the configuration file for the Phabricator bot, with the following structure:

    [section_name]
    host = https://phabricator.example.com/api/
    username = phab-bot
    token = api-12345
    

  • section (str, optional) – the name of the section of the configuration file where to find the required parameters.

  • dry_run (bool, optional) – whether this is a DRY-RUN.

Returns

a Phabricator instance.

Return type

wmflib.phabricator.Phabricator

Raises

wmflib.phabricator.PhabricatorError – if unable to get all the required parameters from the bot configuration file, or to initialize the Phabricator client.

exception wmflib.phabricator.PhabricatorError[source]

Bases: wmflib.exceptions.WmflibError

Custom exception class for errors of the Phabricator class.

class wmflib.phabricator.Phabricator(phabricator_client: phabricator.Phabricator, dry_run: bool = True)[source]

Bases: object

Class to interact with a Phabricator website.

Initialize the Phabricator client from the bot config file.

Parameters
  • phabricator_client (phabricator.Phabricator) – a Phabricator client instance.

  • dry_run (bool, optional) – whether this is a DRY-RUN.

task_comment(task_id: str, comment: str) None[source]

Add a comment on a Phabricator task.

Parameters
  • task_id (str) – the Phabricator task ID (e.g. T12345) to be updated.

  • comment (str) – the message to add to the task.

Raises

wmflib.phabricator.PhabricatorError – if unable to update the task.