pygitpub package

Subpackages

Submodules

pygitpub.configs module

All configurations for pygitpub

class pygitpub.configs.ConfigAlgo[source]

Bases: Config

Parameters to control the algorithm

affiliation = 'owner'
base_dir = '~/git'
dryrun = False
fork = True
owner_login = None
private = True
public = True
repos = []
show_extra = True
class pygitpub.configs.ConfigCleanup[source]

Bases: Config

Parameters to control the cleanup

delete_non_push_runs = False
class pygitpub.configs.ConfigGithub[source]

Bases: Config

Parameters for your github account

apikey = <pytconf.param.Unique object>
class pygitpub.configs.ConfigOutput[source]

Bases: Config

Parameters to control output

verbose = False
class pygitpub.configs.ConfigRuns[source]

Bases: Config

Parameters to control how workflow runs are queried

api = 'graphql'

pygitpub.main module

main entry point to the program

pygitpub.main.cleanup() → None[source]
pygitpub.main.cleanup_repo(repo: Repository) → list[str][source]
pygitpub.main.clone_all() → None[source]
pygitpub.main.config() → None[source]
pygitpub.main.fix_metadata() → None[source]
pygitpub.main.for_each_repo(func: Callable[[Repository], list[str]]) → None[source]

run func on every repo in parallel and print the lines it returns, in repo order

pygitpub.main.get_affiliation() → str[source]

validate the affiliation parameter and return it in the form github wants

pygitpub.main.get_base_dir() → str[source]
pygitpub.main.get_github(**kwargs: Any) → Github[source]
pygitpub.main.get_parallel_github() → Github[source]

A client for walking the repos from several threads. The default client sleeps 0.25s before every request, which serializes the threads and alone made cleanup take 15 minutes; that pause is dropped. The 1s pause between writes stays, so parallel deletes do not trip github’s secondary limits.

pygitpub.main.get_repo_folder(repo) → str[source]
pygitpub.main.get_workflow_names(repo: Repository) → dict[int, str][source]

a run’s own name is not always its workflow’s (pages runs are ‘pages build and deployment’ of workflow ‘pages-build-deployment’)

pygitpub.main.graphql_bad_runs(bad_state: Callable[[str], bool], bad_conclusion: Callable[[str], bool]) → list[tuple[str, str, str, int]][source]

Return (repo full name, workflow name, conclusion, run id) for every workflow that is not green on the default branch head commit of a repo.

Resolving statusCheckRollup is slow on github’s side (~4.5s per 50 repos) and cursor pagination would run the pages one after another, so the repos are split into small batches, each batch is one query with an aliased repository field per repo, and the batches run in parallel. Repos whose rollup state is bad then get one more query each to name the workflows. Only the head commit of the default branch is looked at, so a failed run on another branch, or a scheduled run on an older commit, does not show.

pygitpub.main.graphql_show_runs(bad_state: Callable[[str], bool], bad_conclusion: Callable[[str], bool]) → None[source]
pygitpub.main.homepage_fix() → None[source]
pygitpub.main.is_failing_conclusion(conclusion: str) → bool[source]
pygitpub.main.is_failing_state(state: str) → bool[source]
pygitpub.main.main()[source]
pygitpub.main.pages_check() → None[source]
pygitpub.main.pages_check_repo(repo: Repository) → list[str][source]
pygitpub.main.path_exists(repo: Repository, path: str) → bool[source]
pygitpub.main.pull_all() → None[source]
pygitpub.main.repos_json() → None[source]
pygitpub.main.repos_list() → None[source]
pygitpub.main.repos_show_homepage() → None[source]
pygitpub.main.repos_show_pages() → None[source]
pygitpub.main.runs_show() → None[source]
pygitpub.main.runs_show_failing() → None[source]
pygitpub.main.runs_show_not_success() → None[source]
pygitpub.main.runs_show_running() → None[source]
pygitpub.main.workflows_rerun_failing() → None[source]
pygitpub.main.workflows_run() → None[source]
pygitpub.main.workflows_run_repo(repo: Repository) → list[str][source]
pygitpub.main.yield_repos(g: Github | None = None)[source]

pygitpub.static module

version which can be consumed from within the module

Module contents

Initialize the module