swh.lister.phabricator.lister module

class swh.lister.phabricator.lister.PhabricatorLister(url=None, instance=None, override_config=None)[source]

Bases: swh.lister.core.indexing_lister.IndexingHttpLister

PATH_TEMPLATE = '?order=oldest&attachments[uris]=1&after=%s'
DEFAULT_URL = 'https://forge.softwareheritage.org/api/diffusion.repository.search'
MODEL

alias of swh.lister.phabricator.models.PhabricatorModel

LISTER_NAME = 'phabricator'
request_params(identifier)[source]

Override the default params behavior to retrieve the api token

Credentials are stored as:

credentials:
phabricator:
<instance>:
  • username: <account> password: <api-token>

request_headers()[source]

(Override) Set requests headers to send when querying the Phabricator API

get_model_from_repo(repo)[source]
get_next_target_from_response(response)[source]

Find the next server endpoint identifier given the entire response.

Implementation of this method depends on the server API spec and the shape of the network response object returned by the transport_request method.

Parameters

response (transport response) – response page from the server

Returns

index of next page, possibly extracted from a next href url

transport_response_simplified(response)[source]
Convert the server response into list of a dict for each repo in the

response, mapping columns in the lister’s MODEL class to repo data.

Implementation of this method depends on the server API spec and the shape of the network response object returned by the transport_request method.

Parameters

response – response object from the server.

Returns

list of repo MODEL dicts

( eg. [{‘uid’: r[‘id’], etc.} for r in response.json()] )

filter_before_inject(models_list)[source]

(Overrides) IndexingLister.filter_before_inject Bounds query results by this Lister’s set max_index.

disable_deleted_repo_tasks(index, next_index, keep_these)[source]

(Overrides) Fix provided index value to avoid:

  • database query error

  • erroneously disabling some scheduler tasks

db_first_index()[source]

(Overrides) Filter results by Phabricator instance

Returns

the smallest indexable value of all repos in the db

db_last_index()[source]

(Overrides) Filter results by Phabricator instance

Returns

the largest indexable value of all instance repos in the db

db_query_range(start, end)[source]

(Overrides) Filter the results by the Phabricator instance to avoid disabling loading tasks for repositories hosted on a different instance.

Returns

a list of sqlalchemy.ext.declarative.declarative_base objects

with indexable values within the given range for the instance

swh.lister.phabricator.lister.get_repo_url(attachments)[source]

Return url for a hosted repository from its uris attachments according to the following priority lists: * protocol: https > http * identifier: shortname > callsign > id