Repository navigation
Releases: jose-pr/repopath
Release list
v0.1.1
Added
SVNPath: a read-only path in a Subversion repository served over HTTP by
mod_dav_svn, built onpathapi.httpalone.SVNPath("trunk/README", instance=URL, ref=None, username=None, password=None, token=None, backend=None): astat()is one
PROPFIND, a listing onePROPFINDwithDepth: 1whose children keep their stat,
refis a revision number read through the revision stub the server announces, the md5
and sha1 digests come with the stat (checksum(), without reading the file), and a link
is read withreadlink()and followed on its last name. Properties are asked for by
name: anallpropreply can be invalid XML.RepoPath(type="svn", instance=URL)returns
one;RepoPath.kinds()lists"svn".SourceForgePath("README", project="docutils", mount="code", ref=None, instance=None, backend=None): the Subversion tool of a SourceForge project, found through the site's
REST API once per backend. A Git or Mercurial tool isNotImplementedError, a missing
projectFileNotFoundError.RepoPath(type="sourceforge", project=...)returns one.- The schemes
svn+https:,svn+http:(SVNURIPath) andsourceforge:
(SourceForgeURIPath) inrepopath.uri, registered through theuripath.schemesentry
points like the others.svn:(svnserve) is not one of them. RepoBackend(auth=(user, password)), sent asAuthorization: Basic, and
allow_redirects=onRepoBackend.request().GiteaPath("src/mod.py", owner="acme", repo="widgets", ref=None, instance=None, token=None, backend=None): a read-only path in a repository on Gitea or Forgejo, through
the REST API athttps://<instance>/api/v1. The default instance and the only one detected
iscodeberg.org; any other needsRepoPath(type="gitea", instance=HOST), and"forgejo"
is another name of the kind. Directories are read through the Git Trees API in pages of
1,000 (the contents API answers a directory whole, 15 s for 2,000 entries), file bodies
with oneGETof therawroute; the server answers405toHEAD, so none is sent. A
symlink is a file that reads as its target, a submodule an empty directory, and a file in
Git LFS reads as the pointer Git holds, with the pointer's size. A private repository and
a missing one are bothFileNotFoundError; an unknown token isPermissionError.- The scheme
gitea:(GiteaURIPath,gitea://[TOKEN@]host/owner/repo/path?ref=REF) in
repopath.uri, declared in theuripath.schemesentry points like the others (runpip install -e .again after updating an editable checkout), andrepo://codeberg.org/...,
which detects the kind. The token in the user slot is hidden fromstr(),repr()and
every message, as forgithub:andgitlab:. ALIASES, a class attribute of a kind: other namestype=takes for it.RepoPath.kinds()
listsTYPEonly.
Changed
- The
uriextra requirespathapi-uri>=0.1.1,<0.2(it allowed>=0.1.0):
0.1.1 hides the userinfo of every scheme whose class marks it a secret, which the
repo:,github:,gitlab:andgitea:classes do, so a token is never shown in
str()orrepr()of aSource.pip install "repopath[uri]"upgrades it.
Full Changelog: v0.1.0...v0.1.1
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