The repo:, github: and gitlab: schemes
Needs uripath: pip install "repopath[uri]".
repopath.uri
The repo:, github: and gitlab: schemes of uripath: RepoURIPath,
GitHubURIPath and GitLabURIPath, URI paths that delegate to a GitHubPath
or a GitLabPath.
Importing this module needs uripath: pip install "repopath[uri]". uripath
loads it by itself, through the uripath.schemes entry points, the first time
a path of one of the schemes is used.
GitHubURIPath(*args, **kwargs)
Bases: RepoURIPath
github: scheme (github://[TOKEN@]host/owner/repo/path?ref=REF):
read-only access to a GitHub repository tree via the REST contents API,
done by a GitHubPath. host defaults to github.com (API at
api.github.com); any other host is GitHub Enterprise (API at
https://{host}/api/v3). The kind is fixed whatever the host. See
RepoURIPath for the token and the ref.
Source code in src/repopath/uri.py
66 67 68 69 70 | |
instance
property
The host (and port) of the service, in the case a URL spells it.
kind
property
The name of the kind of repository this path reads ("github",
"gitlab").
ref
property
The branch, tag or commit of the ?ref= query, or None.
repo
property
The name of the repository.
repo_owner
property
The owner of the repository: the first segment (the group path of a
GitLab project in a subgroup, ended by /-/).
repo_path
property
The path inside the repository, with no leading or trailing /.
GitLabURIPath(*args, **kwargs)
Bases: RepoURIPath
gitlab: scheme (gitlab://[TOKEN@]host[:port]/owner/repo/path?ref=REF):
read-only access to a GitLab project's repository tree via the REST API
v4, done by a GitLabPath. A project in a subgroup is addressed with
GitLab's own /-/ separator, as in its web URLs:
gitlab://host/group/subgroup/project/-/path/in/repo; without the
separator the first two segments are owner and repository. host defaults
to gitlab.com; a self-hosted instance is just a different host (and
port), always at https://{host}/api/v4. See RepoURIPath for the token
and the ref.
Source code in src/repopath/uri.py
66 67 68 69 70 | |
instance
property
The host (and port) of the service, in the case a URL spells it.
kind
property
The name of the kind of repository this path reads ("github",
"gitlab").
ref
property
The branch, tag or commit of the ?ref= query, or None.
repo
property
The name of the repository.
repo_owner
property
The owner of the repository: the first segment (the group path of a
GitLab project in a subgroup, ended by /-/).
repo_path
property
The path inside the repository, with no leading or trailing /.
RepoURIPath(*args, **kwargs)
Bases: DelegatingURIPath
repo: scheme (repo://instance/owner/repo/path?ref=REF): read-only
access to a repository on a hosting service, done by the path of its kind
(a GitHubPath or a GitLabPath) on the backend of this path. The kind is
detected from the host: github.com and gitlab.com (and www.); any
other host is a ValueError that names github://host/... and
gitlab://host/..., which pin the kind on any host. ref (branch, tag or
commit) is optional and carried in the ?ref= query; without one the
service's default branch is read.
Auth: a bearer token given as the user slot of the URI,
repo://TOKEN@host/..., or as its password slot,
repo://x-access-token:TOKEN@host/... (the oauth2:TOKEN of GitLab
too); the backend keyword wins if both are given. Because the user slot
can be the secret, str(), repr(), as_posix() and as_uri(sanitize=True),
and so every message of an exception, drop the WHOLE userinfo for these
schemes; as_uri() still round-trips it. The tree is read-only.
Source code in src/repopath/uri.py
66 67 68 69 70 | |
backend
instance-attribute
instance
property
The host (and port) of the service, in the case a URL spells it.
kind
property
The name of the kind of repository this path reads ("github",
"gitlab").
ref
property
The branch, tag or commit of the ?ref= query, or None.
repo
property
The name of the repository.
repo_owner
property
The owner of the repository: the first segment (the group path of a
GitLab project in a subgroup, ended by /-/).
repo_path
property
The path inside the repository, with no leading or trailing /.
as_posix()
Source code in src/repopath/uri.py
100 101 102 103 | |
is_local()
Whether the tree is on this machine: never. The host of the URI is a hosting service and is not resolved.
Source code in src/repopath/uri.py
109 110 111 112 | |