mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-10-05 18:50:09 +02:00
rename parse_srclib to parese_txt_srclib + test case
This commit is contained in:
parent
0d42338d4d
commit
c6a97939f1
@ -704,7 +704,7 @@ def description_html(s, linkres):
|
|||||||
return ps.text_html
|
return ps.text_html
|
||||||
|
|
||||||
|
|
||||||
def parse_srclib(metadatapath):
|
def parse_txt_srclib(metadatapath):
|
||||||
|
|
||||||
thisinfo = {}
|
thisinfo = {}
|
||||||
|
|
||||||
@ -746,7 +746,7 @@ def read_srclibs():
|
|||||||
|
|
||||||
The information read will be accessible as metadata.srclibs, which is a
|
The information read will be accessible as metadata.srclibs, which is a
|
||||||
dictionary, keyed on srclib name, with the values each being a dictionary
|
dictionary, keyed on srclib name, with the values each being a dictionary
|
||||||
in the same format as that returned by the parse_srclib function.
|
in the same format as that returned by the parse_txt_srclib function.
|
||||||
|
|
||||||
A MetaDataException is raised if there are any problems with the srclib
|
A MetaDataException is raised if there are any problems with the srclib
|
||||||
metadata.
|
metadata.
|
||||||
@ -765,7 +765,7 @@ def read_srclibs():
|
|||||||
|
|
||||||
for metadatapath in sorted(glob.glob(os.path.join(srcdir, '*.txt'))):
|
for metadatapath in sorted(glob.glob(os.path.join(srcdir, '*.txt'))):
|
||||||
srclibname = os.path.basename(metadatapath[:-4])
|
srclibname = os.path.basename(metadatapath[:-4])
|
||||||
srclibs[srclibname] = parse_srclib(metadatapath)
|
srclibs[srclibname] = parse_txt_srclib(metadatapath)
|
||||||
|
|
||||||
|
|
||||||
def read_metadata(xref=True, check_vcs=[], refresh=True, sort_by_time=False):
|
def read_metadata(xref=True, check_vcs=[], refresh=True, sort_by_time=False):
|
||||||
|
@ -23,6 +23,8 @@ print('localmodule: ' + localmodule)
|
|||||||
if localmodule not in sys.path:
|
if localmodule not in sys.path:
|
||||||
sys.path.insert(0, localmodule)
|
sys.path.insert(0, localmodule)
|
||||||
|
|
||||||
|
from testcommon import TmpCwd
|
||||||
|
|
||||||
import fdroidserver.common
|
import fdroidserver.common
|
||||||
import fdroidserver.metadata
|
import fdroidserver.metadata
|
||||||
from fdroidserver.exception import MetaDataException
|
from fdroidserver.exception import MetaDataException
|
||||||
@ -568,6 +570,29 @@ class MetadataTest(unittest.TestCase):
|
|||||||
UpdateCheckMode: None
|
UpdateCheckMode: None
|
||||||
"""))
|
"""))
|
||||||
|
|
||||||
|
def test_parse_txt_srclib(self):
|
||||||
|
with tempfile.TemporaryDirectory() as tmpdir, TmpCwd(tmpdir):
|
||||||
|
with open('JSoup.txt', 'w', encoding='utf-8') as f:
|
||||||
|
f.write(textwrap.dedent('''\
|
||||||
|
# Source details (the only mandatory fields)
|
||||||
|
Repo Type:git
|
||||||
|
Repo:https://github.com/jhy/jsoup.git
|
||||||
|
|
||||||
|
# Comma-separated list of subdirs to use. The first existing subdirectory
|
||||||
|
# found between those given will be used. If none is found or provided, the
|
||||||
|
# root of the repo directory will be used instead.
|
||||||
|
Subdir:
|
||||||
|
|
||||||
|
# Any extra commands to prepare the source library
|
||||||
|
Prepare:
|
||||||
|
'''))
|
||||||
|
srclib = fdroidserver.metadata.parse_txt_srclib('JSoup.txt')
|
||||||
|
self.assertDictEqual({'Repo': 'https://github.com/jhy/jsoup.git',
|
||||||
|
'Repo Type': 'git',
|
||||||
|
'Subdir': [''],
|
||||||
|
'Prepare': ''},
|
||||||
|
srclib)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
os.chdir(os.path.dirname(__file__))
|
os.chdir(os.path.dirname(__file__))
|
||||||
|
Loading…
Reference in New Issue
Block a user