GHIA package

exports

ghia.main()

CLI entrypoint, initializes the Click main command

ghia.create_app(config_filename=None, session=<requests.sessions.Session object>)

Create a configured Flask application

Parameters
  • config_filename (str, optional) – config file to use, UNUSED

  • session (class:requests.session.Session, optional) – the current session

Returns

Flask application

Return type

class:flask.app.Flask

ghia.cli module

Logic of the CLI batch interface

ghia.cli.batch_process(config, reposlugs)

Process all issues in given repos synchronously

Parameters
  • config (class:configparser.ConfigParser) – full configuration

  • reposlugs (tuple) – owner/repository GitHub reposlugs

async ghia.cli.batch_process_async(config, reposlugs)

Process all issues in given repos asynchronously

Parameters
  • config (class:configparser.ConfigParser) – full configuration

  • reposlugs (tuple) – owner/repository GitHub reposlugs

ghia.cli.click_validate_config_auth(ctx, param, value)

Validate and parse auth rules file (Click callback)

Parameters
  • ctx (class:click.Context) – Click context

  • param (dict) – Click params

  • value (class:click.File) – auth config file

Returns

validated and parsed auth config

Return type

class:configparser.ConfigParser

ghia.cli.click_validate_config_rules(ctx, param, value)

Validate and parse config rules file (Click callback)

Parameters
  • ctx (class:click.Context) – Click context

  • param (dict) – Click params

  • value (class:click.File) – rules config file

Returns

validated and parsed rules config

Return type

class:configparser.ConfigParser

ghia.cli.click_validate_reposlug(ctx, param, value)

Validate reposlugs (Click callback)

Parameters
  • ctx (class:click.Context) – Click context

  • param (dict) – Click params

  • value (tuple) – reposlugs to validate

Returns

validated reposlugs

Return type

str

ghia.cli.main()

CLI entrypoint, initializes the Click main command

ghia.github module

GitHub communication core module

ghia.github.add_fallback_label(session, issue, config, verbose)

Add a fallback label to an issue

Parameters
  • session (class:requests.session.Session) – the current session

  • issue (dict) – processed issue

  • config (dict) – app configuration

  • verbose (bool) – print status and errors

Returns

False on failure, True otherwise

Return type

bool

ghia.github.check_match(issue, patterns)

Check if any pattern matches the given issue

Parameters
  • issue (dict) – issue to match against

  • patterns (list) – patterns to try to match

Returns

True if any pattern matches

Return type

bool

ghia.github.gather_issues(session, reposlug, token)

Fetch all issues from the provided repo synchronously

Parameters
  • session (class:requests.session.Session) – the current session

  • reposlug (str) – GitHub reposlug “owner/repository”

  • token (str) – GitHub access token

Returns

gathered issues

Return type

list

async ghia.github.gather_issues_async(session, reposlug, token)

Fetch all issues from the provided repo

Parameters
  • session (class:aiohttp.ClientSession) – the current session asynchronously

  • reposlug (str) – GitHub reposlug “owner/repository”

  • token (str) – GitHub access token

Returns

gathered issues

Return type

list

ghia.github.gather_issues_error(reposlug)

Print error regarding issue listing and exit

Parameters

reposlug (str) – GitHub reposlug “owner/repository”

ghia.github.get_gh_login(session, token)

Get GitHub login from an access token

Parameters
  • session (class:requests.sessions.Session) – current session

  • token (str) – GitHub access token

:return GitHub login (name) :rtype str

ghia.github.print_assign_diff(old, new, issue=None)

Print a colored diff in assignees

Names are sorted alphabetically, case-insensitive

Parameters
  • old (list) – original assignees

  • new (list) – new assignees

ghia.github.print_issue_update_error(issue)

Print a colored error about issue update failure

Parameters

issue (dict) – processed issue

ghia.github.process_issue(session, issue, config, verbose=False)

Process a single issue

Parameters
  • session (class:requests.session.Session) – the current session

  • issue (dict) – the issue to process

  • config (dict) – app configuration

  • verbose (bool, optional) – print status and errors

Returns

False on failure, True otherwise

Return type

bool

ghia.github.reassign(session, token, old, new, issue, verbose)

Assign given users to issue

Parameters
  • session (class:requests.session.Session) – the current session

  • token (str) – GitHub access token

  • old (list) – original assignees

  • new (list) – new assignees

  • issue (dict) – issue to assign users to

  • verbose (bool) – print status and errors

Returns

False on failure, True otherwise

Return type

bool

ghia.helpers module

Various helper functions

ghia.helpers.load_config(config_file)

Parse a configuration file

Parameters

config_file (file) – configuration file

Returns

parsed configparser configuration

Return type

class:configparser.ConfigParser

ghia.helpers.load_config_auth(config_parser)

Convert an auth cfparser config into a dictionary

Parameters

config_parser – configparser configuration

Returns

configuration as a dictionary

Return type

dict

ghia.helpers.load_config_multiple(paths)

Parse and merge multiple configuration files

Parameters

paths (list) – paths to the configuration files

Returns

fused configuration dictionary

Return type

dict

ghia.helpers.load_config_rules(config_parser)

Convert a rules cfparser config into a dictionary

Parameters

config_parser – configparser configuration

Returns

configuration as a dictionary

Return type

dict

ghia.web module

Flask server as a GitHub webhook receiver

ghia.web.create_app(config_filename=None, session=<requests.sessions.Session object>)

Create a configured Flask application

Parameters
  • config_filename (str, optional) – config file to use, UNUSED

  • session (class:requests.session.Session, optional) – the current session

Returns

Flask application

Return type

class:flask.app.Flask

ghia.web.index()

The default web entry point (GET+POST / route)

ghia.web.webapp_gh_issue_handler()

Handler for incoming issue webhooks

ghia.web.webapp_gh_validate()

Validate github webhook using secret if applicable