API References

class ghproject.GitHubAPI(repo_name: str, repo_owner: str, github_token: str)[source]

Bases: object

Create a project board with issues in a GitHub repository

Parameters
  • repo_name (str) – Name of the repository

  • repo_owner (str) – Name of the organization or GitHub user that owns the repository

  • github_token (str) – GitHub Personal Access Token

Examples

>>> import os
>>> from ghproject import GitHubAPI
>>>
>>> # Setup arguments
>>> repo_name = "my_repository"
>>> repo_owner = "username" # Github user name or organization name
>>> token = os.environ["GITHUB_TOKEN"]
>>> path_issues = "./md_files"
>>> project_name = "My project"
>>>
>>> # Instantiate repo and call functions
>>> repo = GitHubAPI(repo_name, repo_owner, token)
>>> repo.load_markdown_files(path_issues)
>>> repo.push_project(project_name)
>>> repo.push_issues()
>>> repo.add_issues_to_project(project_name)
add_issues_to_project(project_name: str, column_name: Optional[str] = None)[source]

Add uploaded issues to project board

Parameters
  • project_name (str) – name of the project board to add the issues to

  • column_name (str, optional) – name of the column to add the issues to, defaults to first column

get_columns(project_name: str)[source]

Get column names and id’s from a project

Parameters

project_name (str) – Name of the project board

Returns

Dictionary with [column_name:column_id] as [key:value]

Return type

dict

get_issues()[source]

Get issues from GitHub repository

get_projects()[source]

Get projects from GitHub repository

load_markdown_files(path: str)[source]

Import markdown files for uploading as issues. The first line of the markdown file will become the issue title (can be preceeded by a #), while the remainder of the markdown file will be converted into the issue body.

Parameters

path (str) – Path to local directory with markdown files

push_issues()[source]

Upload issues to GitHub repository

Parameters

labels (list, optional) – List of issue labels, by default [“documentation”]

push_project(project_name: str, columns: list = ['To do', 'In progress', 'Done'])[source]

Push project to GitHub repository

Parameters
  • project_name (str) – Name of the project

  • columns (list, optional) – List of column names to be created in the project board, defaults to [“To do”, “In progress”, “Done”]

ghproject.init_logger(logger_name='ghproject')[source]

Initialize ghproject logger.

Parameters

logger_name (str) – name of the logger, default is ghproject

ghproject.set_logger_level(loglevel: str, logger_name='ghproject')[source]

Update logging level to given loglevel.

Parameters
  • loglevels – Can be ‘DEBUG’, ‘INFO’, ‘WARNING’, ‘ERROR’, ‘CRITICAL’.

  • logger_name – Default is “ghproject”. Change if logger name should be different.