SVN URL Parser - libvcs.parse.svn#

For svn, aka svn(1).

This module is an all-in-one parser and validator for Subversion URLs.

Note

Subversion isn’t seen as often these days, can you “rage against the dying of the light” and assure its light is not extinguished? Help assure SVN URL parsing is correct and robust. Visit the project tracker and give us a wave. This API won’t be stabilized until we’re confident Subversion is covered accurately and can handle all-terrain scenarios.

libvcs.parse.svn.DEFAULT_MATCHERS#

Core regular expressions. These are patterns understood by svn(1)

libvcs.parse.svn.PIP_DEFAULT_MATCHERS#

pip-style svn URLs.

Examples of PIP-style svn URLs (via pip.pypa.io):

MyProject @ svn+https://svn.example.com/MyProject
MyProject @ svn+ssh://svn.example.com/MyProject
MyProject @ svn+ssh://user@svn.example.com/MyProject

Refs (via pip.pypa.io):

MyProject @ -e svn+http://svn.example.com/svn/MyProject/trunk@2019
MyProject @ -e svn+http://svn.example.com/svn/MyProject/trunk@{20080101}

Notes

libvcs.parse.svn.RE_PATH =     ((?P<user>.*)@)?     (?P<hostname>([^/:]+))     (:(?P<port>\d{1,5}))?     (?P<separator>/)?     (?P<path>       (\w[^:.]*)     )? #
libvcs.parse.svn.RE_PIP_SCHEME =     (?P<scheme>       (         svn\+ssh|         svn\+https|         svn\+http|         svn\+file       )     ) #
libvcs.parse.svn.RE_SCHEME =     (?P<scheme>       (         file|http|https|svn|svn\+ssh       )     ) #
class libvcs.parse.svn.SvnURL(url)#

SVN repository location. Parses URLs on initialization.

Examples

>>> SvnURL(url='svn+ssh://svn.debian.org/svn/aliothproj/path/in/project/repository')
SvnURL(url=svn+ssh://svn.debian.org/svn/aliothproj/path/in/project/repository,
       scheme=svn+ssh,
       hostname=svn.debian.org,
       path=svn/aliothproj/path/in/project/repository,
       matcher=core-svn)
>>> myrepo = SvnURL(
...     url='svn+ssh://svn.debian.org/svn/aliothproj/path/in/project/repository'
... )
>>> myrepo.hostname
'svn.debian.org'
>>> myrepo.path
'svn/aliothproj/path/in/project/repository'
Parameters:

url (str) –

matcher#

name of the Matcher

Type:

str

hostname#
classmethod is_valid(url, is_explicit=False)#

Whether URL is compatible with VCS or not.

Examples

>>> SvnURL.is_valid(
...     url='svn+ssh://svn.debian.org/svn/aliothproj/path/in/project/repository'
... )
True
>>> SvnURL.is_valid(url='notaurl')
False
Parameters:
  • url (str) –

  • is_explicit (Optional[bool]) –

Return type:

bool

matcher#
path#
port#
ref#
scheme#
separator#
to_url()#

Return a svn(1)-compatible URL. Can be used with svn checkout.

Examples

>>> svn_url = SvnURL(
...     url='svn+ssh://[email protected]/vcs-python/libvcs'
... )
>>> svn_url
SvnURL(url=svn+ssh://[email protected]/vcs-python/libvcs,
        scheme=svn+ssh,
        user=my-username,
        hostname=my-server,
        path=vcs-python/libvcs,
        matcher=core-svn)

Switch repo libvcs -> vcspull:

>>> svn_url.path = 'vcs-python/vcspull'
>>> svn_url.to_url()
'svn+ssh://[email protected]/vcs-python/vcspull'

Switch user to “tom”:

>>> svn_url.user = 'tom'
>>> svn_url.to_url()
'svn+ssh://[email protected]/vcs-python/vcspull'
Return type:

str

url#
user#