From 00c302e545a180978b85b5a58b9056cd1fc9cd97 Mon Sep 17 00:00:00 2001 From: Jay Lee Date: Thu, 8 Apr 2021 08:12:15 -0400 Subject: [PATCH] further refine chromehistory output --- src/gam/gapi/chromehistory.py | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/gam/gapi/chromehistory.py b/src/gam/gapi/chromehistory.py index cf1a9a9e..2b04baba 100644 --- a/src/gam/gapi/chromehistory.py +++ b/src/gam/gapi/chromehistory.py @@ -63,12 +63,12 @@ CHROME_VERSIONHISTORY_ORDERBY_CHOICE_MAP = { } CHROME_VERSIONHISTORY_TITLES = { - 'platforms': ['name', 'platformType'], - 'channels': ['name', 'channelType', 'platformType'], - 'versions': ['name', 'version', 'platformType', 'channelType', + 'platforms': ['platform'], + 'channels': ['channel', 'platform'], + 'versions': ['version', 'platform', 'channel', 'major_version', 'minor_version', 'build', 'patch'], - 'releases': ['name', 'version', 'fraction', 'serving.startTime', - 'serving.endTime', 'platformType', 'channelType', + 'releases': ['version', 'fraction', 'serving.startTime', + 'serving.endTime', 'platform', 'channel', 'major_version', 'minor_version', 'build', 'patch'] } @@ -185,24 +185,34 @@ def printHistory(): fields=f'nextPageToken,{entityType}', **kwargs) for citem in citems: - if 'channelType' not in citem: + for key in list(citem): + if key.endswith('Type'): + newkey = key[:-4] + citem[newkey] = citem.pop(key) + if 'channel' in citem: + citem['channel'] = citem['channel'].lower() + else: channel_match = re.search(r"\/channels\/([^/]*)", citem['name']) if channel_match: try: - citem['channelType'] = channel_match.group(1) + citem['channel'] = channel_match.group(1) except IndexError: pass - if 'platformType' not in citem: + if 'platform' in citem: + citem['platform'] = citem['platform'].lower() + else: platform_match = re.search(r"\/platforms\/([^/]*)", citem['name']) if platform_match: try: - citem['platformType'] = platform_match.group(1) + citem['platform'] = platform_match.group(1) except IndexError: pass + if citem.get('version', '').count('.') == 3: citem['major_version'], \ citem['minor_version'], \ citem['build'], \ citem['patch'] = citem['version'].split('.') + citem.pop('name') csvRows.append(utils.flatten_json(citem)) display.write_csv_file(csvRows, CHROME_VERSIONHISTORY_TITLES[entityType], reportTitle, todrive)