yml srclibs: support multiline Prepare

This commit is contained in:
Michael Pöhn 2020-02-29 13:42:12 +01:00
parent 58776da694
commit 1ac7d612b1
2 changed files with 39 additions and 0 deletions

View File

@ -779,6 +779,8 @@ def parse_yml_srclib(metadatapath):
else:
if key == 'Subdir':
thisinfo[key] = str(data[key] or '').split(',')
elif key == 'Prepare' and isinstance(data[key], list):
thisinfo[key] = ' && '.join(data[key])
else:
thisinfo[key] = str(data[key] or '')

View File

@ -733,6 +733,43 @@ class MetadataTest(unittest.TestCase):
"ant.properties && echo -e "
"'android.library=true\\ntarget=android-19' > project.properties"})
def test_read_srclibs_yml_prepare_list(self):
fdroidserver.metadata.warnings_action = 'error'
fdroidserver.metadata.srclibs = None
with tempfile.TemporaryDirectory() as tmpdir, TmpCwd(tmpdir):
os.mkdir('srclibs')
with open('srclibs/with-list.yml', 'w', encoding='utf-8') as f:
f.write(textwrap.dedent('''\
# this should be simple
RepoType: git
Repo: https://git.host/repo.git
Subdir:
Prepare:
- The Matrix is a system, Neo.
- That system is our enemy.
- But when you're inside, you look around, what do you see?
- Businessmen, teachers, lawyers, carpenters.
- The very minds of the people we are trying to save.
- But until we do, these people are still a part of that system and that makes them our enemy.
- You have to understand, most of these people are not ready to be unplugged.
- And many of them are so inert, so hopelessly dependent on the system that they will fight to protect it.
'''))
fdroidserver.metadata.read_srclibs()
self.maxDiff = None
self.assertDictEqual(fdroidserver.metadata.srclibs,
{'with-list': {'RepoType': 'git',
'Repo': 'https://git.host/repo.git',
'Subdir': [''],
'Prepare': 'The Matrix is a system, Neo. && '
'That system is our enemy. && '
'But when you\'re inside, you look around, what do you see? && '
'Businessmen, teachers, lawyers, carpenters. && '
'The very minds of the people we are trying to save. && '
'But until we do, these people are still a part of that system and that makes them our enemy. && '
'You have to understand, most of these people are not ready to be unplugged. && '
'And many of them are so inert, so hopelessly dependent on the system that they will fight to protect it.'}})
def test_read_srclibs(self):
fdroidserver.metadata.warnings_action = 'error'
fdroidserver.metadata.srclibs = None