Repository navigation
v0.1.0
The first release of repopath: the github:, gitlab: and git: schemes of
pathlib-next 0.9 (pathlib_next.uri.schemes) as a distribution of their own, and as
paths that need no URI. It needs Python 3.9 or newer and pathapi>=0.1.0,<0.2,
and nothing else; its one extra, uri, adds pathapi-uri>=0.1.0,<0.2 and with it the
schemes. Under Changed, the migration from pathlib-next comes in this order: the
table of names, the table of URIs, then every change of behaviour with what to do about
it.
It is built on pathapi, which was published as pathlib-next up to 0.10.0 (import
name pathlib_next); the old names below are the ones before the move.
Added
RepoPath,GitHubPathandGitLabPath: read-onlypathapi.Pathclasses for a
repository tree on GitHub (and GitHub Enterprise) or GitLab (and self-hosted GitLab),
over the services' REST APIs, with no URI and no library beyondpathapi.
GitHubPath("src/x.py", owner="acme", repo="widgets", ref="v1.2", instance="github.com", token=None, backend=None);GitLabPathtakes the same keywords and an owner that may
be a group path ("acme/team").repo_owner, the property of a path and of a URI path that names the account or group
that owns the repository. It is not calledowner, the namepathlib.Path.owner()has for
the user that owns a file.RepoPath(*segments, instance=..., type=None, **options)returns aGitHubPathor a
GitLabPath:typenames the kind ("github","gitlab"), and without it the kind
is detected frominstance(github.comandgitlab.com, in any case, with or
withoutwww.). Any other instance withouttypeis aValueErrorthat lists the
choices.RepoPath.kinds()lists the registered kinds, and a kind of your own is a
subclass whose class body setsTYPEandINSTANCES.repopath.uri, foruripath:RepoURIPath(therepo:scheme, with the kind
detected from the host),GitHubURIPath(github:) andGitLabURIPath(gitlab:),
which delegate to the paths above. The entry points are declared whether or not
uripathis installed, andimport repopathnever imports it. Importing
repopath.uriwithouturipathraises anImportErrorthat names
pip install "repopath[uri]".repopath.exceptions:RepoPathError, the base of what this package raises on its
own, withRateLimitError(also aBlockingIOError, errnoEAGAIN) and
BadReplyError(also anOSError, errnoEIO);InsecureTransportWarningis there
too.RepoBackendandBaseRepoBackendare inrepopath.RepoBackendis a context
manager and sends throughpathapi.http.
Changed
-
The names.
pathlib_next.uri.schemesnamed the classes of the three schemes with a
Pathsuffix:Was Is now schemes.github.GitHubPath(github:)repopath.uri.GitHubURIPath; the path that needs no URI isrepopath.GitHubPathschemes.gitlab.GitLabPath(gitlab:)repopath.uri.GitLabURIPath; without a URI,repopath.GitLabPathschemes.git.GitPath(git:)repopath.uri.RepoURIPath(repo:); without a URI,repopath.RepoPathschemes.git.GitHubGitPath,GitLabGitPath(git+github:,git+gitlab:)repopath.uri.GitHubURIPath,GitLabURIPath(github:,gitlab:)schemes.github.RepoBackend;schemes._gitrepo.BaseRepoBackendrepopath.RepoBackend,BaseRepoBackendschemes.github.InsecureTransportWarning(also inschemes.gitlab)repopath.InsecureTransportWarningpathlib-next[uri],pathlib-next[http]repopath[uri] -
The URIs.
git:,git+github:andgit+gitlab:do not exist any more, anduripath
treats a URI of one of them as a path of an unknown scheme. What to do: rewrite the
URIs.Was Is now git://github.com/o/r/f,git://gitlab.com/o/r/frepo://github.com/o/r/f,repo://gitlab.com/o/r/f(the kind is detected from the host)git+github://host/o/r/fgithub://host/o/r/fgit+gitlab://host/o/r/fgitlab://host/o/r/fgithub://host/o/r/f,gitlab://host/o/r/fthe same text repo://with a host that is notgithub.comorgitlab.comraisesURISyntaxError
(aValueError), asgit://did, and namesgithub://host/...and
gitlab://host/.... -
A path that has an owner and a repository is built from them, not from a URI:
GitHubPath("src/x.py", owner="acme", repo="widgets"). The URI classes keep the
propertiesrepo_owner,repo,repo_pathandref, and haveinstanceandkind. -
Rate limits and replies of the wrong shape have classes of their own. Was:
OSError(EAGAIN)andOSError(EIO). Is:RateLimitErrorandBadReplyError, which
are thoseOSErrortypes and carry the path asfilename. What to do: nothing;
catchRepoPathErrorto catch both. -
An error raised through a URI path names the URI in its message, whatever scheme
spelling built the path. -
A URI that holds no owner and no repository (
github://github.com/acme) is a path that
does not exist (FileNotFoundError,exists()isFalse) and no request is sent. Was:
a request for a repository with an empty name. -
An owner or a repository that is empty, is a
.or.., or (forGitHubPath) holds a
/is refused by the constructor withValueError. Was: refused when the API URL was
built. -
is_local()of a URI path of these schemes isFalsewithout resolving the host.
Was: the host name was looked up. -
Requests send
User-Agent: repopath/<version>instead ofUser-Agent: pathlib-next;
the version isrepopath.__version__. A backend'sheaders=still replaces it. -
The
requestsHTTP transport is provided bypathapi-requests.
RepoBackend(session=...)andRepoBackend(**requests_args)raise anImportError
naming that distribution without it. What to do: installpathapi-requests
where one of them is used; with it installed they send through its transport and
nothing else is configured. -
uritoolsis not a dependency of anything here, andrequestsis not installed with
the package.
Full Changelog: https://github.com/jose-pr/repopath/commits/v0.1.0