mirror of
https://github.com/GAM-team/GAM.git
synced 2026-07-03 12:21:35 +00:00
Merge branch 'main' of https://github.com/jay0lee/GAM into main
This commit is contained in:
@@ -43,11 +43,11 @@ CHROME_VERSIONHISTORY_ORDERBY_CHOICE_MAP = {
|
|||||||
CHROME_VERSIONHISTORY_TITLES = {
|
CHROME_VERSIONHISTORY_TITLES = {
|
||||||
'platforms': ['platform'],
|
'platforms': ['platform'],
|
||||||
'channels': ['channel', 'platform'],
|
'channels': ['channel', 'platform'],
|
||||||
'versions': ['version', 'platform', 'channel',
|
'versions': ['version', 'channel', 'platform',
|
||||||
'major_version', 'minor_version', 'build', 'patch'],
|
'major_version', 'minor_version', 'build', 'patch'],
|
||||||
'releases': ['version', 'fraction', 'serving.startTime',
|
'releases': ['version', 'channel', 'platform',
|
||||||
'serving.endTime', 'platform', 'channel',
|
'major_version', 'minor_version', 'build', 'patch',
|
||||||
'major_version', 'minor_version', 'build', 'patch']
|
'fraction', 'serving.startTime','serving.endTime']
|
||||||
}
|
}
|
||||||
|
|
||||||
def get_relative_milestone(channel='stable', minus=0):
|
def get_relative_milestone(channel='stable', minus=0):
|
||||||
@@ -76,22 +76,26 @@ def get_relative_milestone(channel='stable', minus=0):
|
|||||||
except IndexError:
|
except IndexError:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
def _get_platform_map(cv):
|
def get_platform_map(cv=None):
|
||||||
'''returns dict mapping of platform choices'''
|
'''returns dict mapping of platform choices'''
|
||||||
|
if cv is None:
|
||||||
|
cv = build()
|
||||||
result = gapi.get_all_pages(cv.platforms(),
|
result = gapi.get_all_pages(cv.platforms(),
|
||||||
'list',
|
'list',
|
||||||
'platforms',
|
'platforms',
|
||||||
parent='chrome')
|
parent='chrome')
|
||||||
platforms = [p.get('platformType', '').lower() for p in result]
|
platforms = [p.get('platformType', '').lower() for p in result]
|
||||||
platform_map = {'all': 'all'}
|
platform_map = {'all': 'all'}
|
||||||
for platform in platforms:
|
for cplatform in platforms:
|
||||||
key = platform.replace('_', '')
|
key = cplatform.replace('_', '')
|
||||||
platform_map[key] = platform
|
platform_map[key] = cplatform
|
||||||
return platform_map
|
return platform_map
|
||||||
|
|
||||||
|
|
||||||
def _get_channel_map(cv):
|
def get_channel_map(cv=None):
|
||||||
'''returns dict mapping of channel choices'''
|
'''returns dict mapping of channel choices'''
|
||||||
|
if cv is None:
|
||||||
|
cv = build()
|
||||||
result = gapi.get_all_pages(cv.platforms().channels(),
|
result = gapi.get_all_pages(cv.platforms().channels(),
|
||||||
'list',
|
'list',
|
||||||
'channels',
|
'channels',
|
||||||
@@ -125,7 +129,7 @@ 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('_', '')
|
||||||
platform_map = _get_platform_map(cv)
|
platform_map = get_platform_map(cv)
|
||||||
if cplatform not in platform_map:
|
if cplatform not in platform_map:
|
||||||
controlflow.expected_argument_exit('platform',
|
controlflow.expected_argument_exit('platform',
|
||||||
', '.join(platform_map),
|
', '.join(platform_map),
|
||||||
@@ -134,7 +138,7 @@ def printHistory():
|
|||||||
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('_', '')
|
||||||
channel_map = _get_channel_map(cv)
|
channel_map = get_channel_map(cv)
|
||||||
if channel not in channel_map:
|
if channel not in channel_map:
|
||||||
controlflow.expected_argument_exit('channel',
|
controlflow.expected_argument_exit('channel',
|
||||||
', '.join(channel_map),
|
', '.join(channel_map),
|
||||||
|
|||||||
@@ -306,13 +306,14 @@ def update_policy():
|
|||||||
if mg:
|
if mg:
|
||||||
channel = mg.group(1).lower().replace('_', '')
|
channel = mg.group(1).lower().replace('_', '')
|
||||||
minus = mg.group(2)
|
minus = mg.group(2)
|
||||||
if channel not in gapi_chromehistory.CHROME_CHANNEL_CHOICE_MAP:
|
channel_map = gapi_chromehistory.get_channel_map(None)
|
||||||
expected_channels = ', '.join(gapi_chromehistory.CHROME_CHANNEL_CHOICE_MAP)
|
if channel not in channel_map:
|
||||||
|
expected_channels = ', '.join(channel_map)
|
||||||
msg = f'Expected {myarg} {cased_field} channel to be one of ' \
|
msg = f'Expected {myarg} {cased_field} channel to be one of ' \
|
||||||
f'{expected_channels}, got {channel}'
|
f'{expected_channels}, got {channel}'
|
||||||
controlflow.system_error_exit(8, msg)
|
controlflow.system_error_exit(8, msg)
|
||||||
milestone = gapi_chromehistory.get_relative_milestone(
|
milestone = gapi_chromehistory.get_relative_milestone(
|
||||||
gapi_chromehistory.CHROME_CHANNEL_CHOICE_MAP[channel], int(minus))
|
channel_map[channel], int(minus))
|
||||||
if not milestone:
|
if not milestone:
|
||||||
msg = f'{myarg} {cased_field} channel {channel} offset {minus} does not exist'
|
msg = f'{myarg} {cased_field} channel {channel} offset {minus} does not exist'
|
||||||
controlflow.system_error_exit(8, msg)
|
controlflow.system_error_exit(8, msg)
|
||||||
|
|||||||
Reference in New Issue
Block a user