Python libraries

lib.tools

exception lib.tools.NotComparableVersions[source]

Bases: exceptions.Exception

lib.tools.branch_has_change(branch, change, repo_path)[source]
lib.tools.get_branches(repo_path)[source]
lib.tools.get_newer_branches(my_branch, repo_path)[source]
lib.tools.get_parser_comment_added(description=None)[source]

Build the parser for comment-added hook type

lib.tools.get_parser_pc(description=None)[source]

Build the parser for patchset-created hook type

lib.tools.ver_is_newer(branch1, branch2)[source]

Returns true if branch1 isnewer than branch2, according to:

(X+1).Y > X.(Y+1) > X.Y > X.Y.Z

lib.bz

class lib.bz.Bug(product, status, title, flags, target_rel, milestone, component, classification, external_bugs)[source]

Bases: object

Bug structure

class lib.bz.Bugzilla(user=None, passwd=None, url='https://bugzilla.redhat.com/xmlrpc.cgi')[source]

Bases: object

Bugzilla Object

extract_bug_info(bug_id)[source]

Extract parameters from bz ticket

Parameters:bug_id – bug number
Return bug object:
 bug object that will hold all the bug data info
static extract_flags(list_of_dicts)[source]

Get bugzilla bug flags

Parameters:list_of_dicts – list of dict flags

:return dict of flag names (key) and flag statuses (value)

static get_bug_ids(bug_urls)[source]

Get bug id from bug url

Parameters:bug_urls – list of bug urls
Returns:set of unique bug ids
static get_bug_urls(commit, bz_server='https://bugzilla.redhat.com')[source]

Get bug urls from the passed commit

Parameters:
  • commit – commit message string
  • bz_server – bugzilla server
Returns:

list of bug urls or empty list

get_external(bug_id, external_bug_id, ensure_product=None)[source]
update_bug(bug_id, **fields)[source]
update_external(bug_id, external_bug_id, ext_type_id, status=None, description=None, branch=None, ensure_product=None)[source]
wrap(dictionary)[source]
exception lib.bz.WrongProduct[source]

Bases: exceptions.Exception

lib.gerrit

class lib.gerrit.Change[source]
static get_ci_reviewers_name()[source]
static get_ci_value(by_users=None)[source]

Get the global patchset CI flag value, taking into account that +1 is more prioritary than -1

Parameters:
  • change – dict with the change info as returned by Gerrit.query
  • by_users – list of user names whose reviews will be taken into account to calculate the global value, if empty or None will not filter the reviewers
static get_flag_values(flag_name, by_users=None)[source]
Parameters:
  • change – dict with the change info as returned by Gerrit.query
  • flag_name – Name of the flag to get the review values for
  • by_users – List of users to filter the reviews by, if empty or not set will get them all
static get_reviewers_name(flag_name)[source]
static has_code_change()[source]
class lib.gerrit.Gerrit(server)[source]

Bases: object

generate_cmd(action, *options)[source]
query(query, all_approvals=False, all_reviewers=False, comment=False, commit_message=False, current_patch_set=False, dependencies=False, files=False, patch_sets=False, start=0, submit_records=False, out_format='json')[source]
query_patchsets(*args, **kwargs)[source]
review(commit, project, message, review=None, verify=None, ci=None)[source]

lib.config

Configuration

The cofiguration for the hooks is extracted from a hireachical structure, it will try to get the configuration, most prioritary first, from:

  • ../config: that is, the parent directory of this file, in a file name config
  • $GIT_DIR/hooks/config: That is (when running from gerrit) the hooks dir

inside the git repository, a file named config.

Multilines are not yet supported and the file should be bash compatible, as it might be used from bash scripts.

It’s a slightly different behavior than the bash conf.sh lib as this module is not yet finished.

API

class lib.config.Config(files=None)[source]

Bases: dict

read(filename)[source]
lib.config.load_config()[source]
lib.config.unquote(string)[source]