mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-03 20:31:35 +00:00
build channel and platform maps dynamically to reduce future maintenance
This commit is contained in:
@@ -22,28 +22,6 @@ CHROME_HISTORY_ENTITY_CHOICES = {
|
|||||||
'releases',
|
'releases',
|
||||||
}
|
}
|
||||||
|
|
||||||
CHROME_PLATFORM_CHOICE_MAP = {
|
|
||||||
'all': 'all',
|
|
||||||
'android': 'android',
|
|
||||||
'ios': 'ios',
|
|
||||||
'lacros': 'lacros',
|
|
||||||
'linux': 'linux',
|
|
||||||
'mac': 'mac',
|
|
||||||
'macarm64': 'mac_arm64',
|
|
||||||
'webview': 'webview',
|
|
||||||
'win': 'win',
|
|
||||||
'win64': 'win64',
|
|
||||||
}
|
|
||||||
|
|
||||||
CHROME_CHANNEL_CHOICE_MAP = {
|
|
||||||
'beta': 'beta',
|
|
||||||
'canary': 'canary',
|
|
||||||
'canaryasan': 'canary_asan',
|
|
||||||
'dev': 'dev',
|
|
||||||
'extended': 'extended',
|
|
||||||
'stable': 'stable',
|
|
||||||
}
|
|
||||||
|
|
||||||
CHROME_VERSIONHISTORY_ORDERBY_CHOICE_MAP = {
|
CHROME_VERSIONHISTORY_ORDERBY_CHOICE_MAP = {
|
||||||
'versions': {
|
'versions': {
|
||||||
'channel': 'channel',
|
'channel': 'channel',
|
||||||
@@ -98,6 +76,34 @@ def get_relative_milestone(channel='stable', minus=0):
|
|||||||
except IndexError:
|
except IndexError:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
def _get_platform_map(cv):
|
||||||
|
'''returns dict mapping of platform choices'''
|
||||||
|
result = gapi.get_all_pages(cv.platforms(),
|
||||||
|
'list',
|
||||||
|
'platforms',
|
||||||
|
parent='chrome')
|
||||||
|
platforms = [p.get('platformType', '').lower() for p in result]
|
||||||
|
platform_map = {'all': 'all'}
|
||||||
|
for platform in platforms:
|
||||||
|
key = platform.replace('_', '')
|
||||||
|
platform_map[key] = platform
|
||||||
|
return platform_map
|
||||||
|
|
||||||
|
|
||||||
|
def _get_channel_map(cv):
|
||||||
|
'''returns dict mapping of channel choices'''
|
||||||
|
result = gapi.get_all_pages(cv.platforms().channels(),
|
||||||
|
'list',
|
||||||
|
'channels',
|
||||||
|
parent='chrome/platforms/all')
|
||||||
|
channels = [c.get('channelType', '').lower() for c in result]
|
||||||
|
channels = list(set(channels))
|
||||||
|
channel_map = {'all': 'all'}
|
||||||
|
for channel in channels:
|
||||||
|
key = channel.replace('_', '')
|
||||||
|
channel_map[key] = channel
|
||||||
|
return channel_map
|
||||||
|
|
||||||
def printHistory():
|
def printHistory():
|
||||||
cv = build()
|
cv = build()
|
||||||
entityType = sys.argv[3].lower().replace('_', '')
|
entityType = sys.argv[3].lower().replace('_', '')
|
||||||
@@ -119,19 +125,21 @@ def printHistory():
|
|||||||
i += 1
|
i += 1
|
||||||
elif entityType != 'platforms' and myarg == 'platform':
|
elif entityType != 'platforms' and myarg == 'platform':
|
||||||
cplatform = sys.argv[i + 1].lower().replace('_', '')
|
cplatform = sys.argv[i + 1].lower().replace('_', '')
|
||||||
if cplatform not in CHROME_PLATFORM_CHOICE_MAP:
|
platform_map = _get_platform_map(cv)
|
||||||
|
if cplatform not in platform_map:
|
||||||
controlflow.expected_argument_exit('platform',
|
controlflow.expected_argument_exit('platform',
|
||||||
', '.join(CHROME_PLATFORM_CHOICE_MAP),
|
', '.join(platform_map),
|
||||||
cplatform)
|
cplatform)
|
||||||
cplatform = CHROME_PLATFORM_CHOICE_MAP[cplatform]
|
cplatform = platform_map[cplatform]
|
||||||
i += 2
|
i += 2
|
||||||
elif entityType in {'versions', 'releases'} and myarg == 'channel':
|
elif entityType in {'versions', 'releases'} and myarg == 'channel':
|
||||||
channel = sys.argv[i + 1].lower().replace('_', '')
|
channel = sys.argv[i + 1].lower().replace('_', '')
|
||||||
if channel not in CHROME_CHANNEL_CHOICE_MAP:
|
channel_map = _get_channel_map(cv)
|
||||||
|
if channel not in channel_map:
|
||||||
controlflow.expected_argument_exit('channel',
|
controlflow.expected_argument_exit('channel',
|
||||||
', '.join(CHROME_CHANNEL_CHOICE_MAP),
|
', '.join(channel_map),
|
||||||
channel)
|
channel)
|
||||||
channel = CHROME_CHANNEL_CHOICE_MAP[channel]
|
channel = channel_map[channel]
|
||||||
i += 2
|
i += 2
|
||||||
elif entityType == 'releases' and myarg == 'version':
|
elif entityType == 'releases' and myarg == 'version':
|
||||||
version = sys.argv[i + 1]
|
version = sys.argv[i + 1]
|
||||||
|
|||||||
Reference in New Issue
Block a user