mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-15 07:22:29 +03:00
add srclib spec parser
This commit is contained in:
parent
8285f3d759
commit
b076e8cba7
3 changed files with 49 additions and 3 deletions
|
@ -63,7 +63,7 @@ import fdroidserver.metadata
|
|||
import fdroidserver.lint
|
||||
from fdroidserver import _
|
||||
from fdroidserver.exception import FDroidException, VCSException, NoSubmodulesException,\
|
||||
BuildException, VerificationException
|
||||
BuildException, VerificationException, MetaDataException
|
||||
from .asynchronousfilereader import AsynchronousFileReader
|
||||
|
||||
# The path to this fdroidserver distribution
|
||||
|
@ -1808,6 +1808,36 @@ def get_app_from_url(url):
|
|||
return app
|
||||
|
||||
|
||||
def parse_srclib_spec(spec):
|
||||
|
||||
if type(spec) != str:
|
||||
raise MetaDataException(_("can not parse scrlib spec "
|
||||
"(not a string): '{}'")
|
||||
.format(spec))
|
||||
|
||||
tokens = spec.split('@')
|
||||
if len(tokens) > 2:
|
||||
raise MetaDataException(_("could not parse srclib spec "
|
||||
"(too many '@' signs): '{}'")
|
||||
.format(spec))
|
||||
elif len(tokens) < 2:
|
||||
raise MetaDataException(_("could not parse srclib spec "
|
||||
"(no ref specified): '{}'")
|
||||
.format(spec))
|
||||
|
||||
name = tokens[0]
|
||||
ref = tokens[1]
|
||||
number = None
|
||||
subdir = None
|
||||
|
||||
if ':' in name:
|
||||
number, name = name.split(':', 1)
|
||||
if '/' in name:
|
||||
name, subdir = name.split('/', 1)
|
||||
|
||||
return (name, ref, number, subdir)
|
||||
|
||||
|
||||
def getsrclib(spec, srclib_dir, subdir=None, basepath=False,
|
||||
raw=False, prepare=True, preponly=False, refresh=True,
|
||||
build=None):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue