mirror of
https://github.com/openSUSE/osc.git
synced 2024-11-10 06:46:15 +01:00
parse_disturl function
This commit is contained in:
parent
816a982acf
commit
75cd1dcfa6
15
osc/core.py
15
osc/core.py
@ -31,6 +31,7 @@ except ImportError:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
DISTURL_RE = re.compile(r"^(?P<bs>.*)://(?P<apiurl>.*?)/(?P<project>.*?)/(?P<repository>.*?)/(?P<revision>.*)-(?P<source>.*)$")
|
||||||
BUFSIZE = 1024*1024
|
BUFSIZE = 1024*1024
|
||||||
store = '.osc'
|
store = '.osc'
|
||||||
|
|
||||||
@ -1530,6 +1531,20 @@ def is_package_dir(d):
|
|||||||
return os.path.exists(os.path.join(d, store, '_project')) and \
|
return os.path.exists(os.path.join(d, store, '_project')) and \
|
||||||
os.path.exists(os.path.join(d, store, '_package'))
|
os.path.exists(os.path.join(d, store, '_package'))
|
||||||
|
|
||||||
|
def parse_disturl(disturl):
|
||||||
|
"""Parse a disturl, returns tuple (apiurl, project, source, repository,
|
||||||
|
revision), else raises an oscerr.WrongArgs exception
|
||||||
|
"""
|
||||||
|
|
||||||
|
m = DISTURL_RE.match(disturl)
|
||||||
|
if not m:
|
||||||
|
raise oscerr.WrongArgs("`%s' does not look like disturl")
|
||||||
|
|
||||||
|
apiurl = m.group('apiurl')
|
||||||
|
if apiurl.split('.')[0] != 'api':
|
||||||
|
apiurl = 'https://api.' + ".".join(apiurl.split('.')[1:])
|
||||||
|
return (apiurl, m.group('project'), m.group('source'), m.group('repository'), m.group('revision'))
|
||||||
|
|
||||||
|
|
||||||
def slash_split(l):
|
def slash_split(l):
|
||||||
"""Split command line arguments like 'foo/bar' into 'foo' 'bar'.
|
"""Split command line arguments like 'foo/bar' into 'foo' 'bar'.
|
||||||
|
Loading…
Reference in New Issue
Block a user