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:
object
Context manager to make commits as a specific user.
Sets the following environment variables:
GIT_COMMITTER_NAME
GIT_COMMITTER_EMAIL
GIT_AUTHOR_NAME
GIT_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:
RuntimeError
Custom exception class to indicate the GitHub rate limit has been exceeded and no further requests should be made.
-
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
) – IfTrue
yieldsRepository
objects. Otherwise, yieldsShortRepository
objects. 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.User
object for the authenticated user.
-
iter_repos
(github, users=(), orgs=())[source]¶ Returns an iterator over the repositories belonging to all
users
and allorgs
.New in version 0.5.0.