mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-13 14:32:28 +03:00
common: add calculate_gradle_flavor_combination
This commit is contained in:
parent
6c054f62ca
commit
e957583337
2 changed files with 20 additions and 0 deletions
|
@ -58,6 +58,7 @@ from typing import List
|
|||
import git
|
||||
import glob
|
||||
import io
|
||||
import itertools
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
|
@ -4823,6 +4824,20 @@ def calculate_archive_policy(app, default):
|
|||
return archive_policy
|
||||
|
||||
|
||||
def calculate_gradle_flavor_combination(flavors):
|
||||
"""Calculate all combinations of gradle flavors."""
|
||||
combination_lists = itertools.product(*[[flavor, ''] for flavor in flavors])
|
||||
combinations = [
|
||||
re.sub(
|
||||
r' +\w',
|
||||
lambda pat: pat.group(0)[-1].upper(),
|
||||
' '.join(combination_list).strip(),
|
||||
)
|
||||
for combination_list in combination_lists
|
||||
]
|
||||
return combinations
|
||||
|
||||
|
||||
FDROIDORG_MIRRORS = [
|
||||
{
|
||||
'isPrimary': True,
|
||||
|
|
|
@ -3040,6 +3040,11 @@ class CommonTest(SetUpTearDownMixin, unittest.TestCase):
|
|||
p = fdroidserver.common.FDroidPopen(['printenv', 'SOURCE_DATE_EPOCH'])
|
||||
self.assertEqual(int(p.output), int(now.timestamp()))
|
||||
|
||||
def test_calculate_gradle_flavor_combination(self):
|
||||
flavors = ['aa', 'BB', 'δδ']
|
||||
combinations = ['aaBBΔδ', 'aaBB', 'aaΔδ', 'aa', 'BBΔδ', 'BB', 'δδ', '']
|
||||
self.assertEqual(fdroidserver.common.calculate_gradle_flavor_combination(flavors), combinations)
|
||||
|
||||
|
||||
APKS_WITH_JAR_SIGNATURES = (
|
||||
(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue