github3_utils¶
Handy utilities for github3.py.
Classes:
|
Context manager to make commits as a specific user. |
Exceptions:
|
Custom exception class to indicate the GitHub rate limit has been exceeded and no further requests should be made. |
Functions:
|
Contextmanager to echo the GitHub API rate limit before and after making a series of requests. |
|
Returns an iterator over the user or organisation's repositories. |
|
Retrieve a |
|
Returns an iterator over the repositories belonging to all |
|
Enable force push protection and configure status check enforcement. |
- class Impersonate(name, email)[source]¶
Bases:
objectContext manager to make commits as a specific user.
Sets the following environment variables:
GIT_COMMITTER_NAMEGIT_COMMITTER_EMAILGIT_AUTHOR_NAMEGIT_AUTHOR_EMAIL
Attention
Any changes to environment variables made during the scope of the context manager will be reset on exit.
Example:
name = "repo-helper[bot]" email = f"74742576+{name}@users.noreply.github.com" commit_as_bot = Impersonate(name=name, email=email) with commit_as_bot(): ...
- Parameters
Attributes:
- exception RateLimitExceeded(reset_time)[source]¶
Bases:
RuntimeErrorCustom exception class to indicate the GitHub rate limit has been exceeded and no further requests should be made.
- Parameters
reset_time (
datetime) – The time at which the rate limit will be reset.
Attributes:
The time at which the rate limit will be reset.
- echo_rate_limit(github, verbose=True)[source]¶
Contextmanager to echo the GitHub API rate limit before and after making a series of requests.
- get_repos(user_or_org, full=False)[source]¶
Returns an iterator over the user or organisation’s repositories.
New in version 0.5.0.
- Parameters
user_or_org (
Union[User,Organization])full (
bool) – IfTrueyieldsRepositoryobjects. Otherwise, yieldsShortRepositoryobjects. DefaultFalse.
- Return type
- Overloads
get_repos(user_or_org, full:Literal[True] ) ->Iterator[Repository]get_repos(user_or_org, full:Literal[False] = … ) ->Iterator[ShortRepository]
- get_user(github)[source]¶
Retrieve a
github3.users.Userobject for the authenticated user.
- iter_repos(github, users=(), orgs=())[source]¶
Returns an iterator over the repositories belonging to all
usersand allorgs.New in version 0.5.0.