150 lines
6.8 KiB
Diff
150 lines
6.8 KiB
Diff
From f90f49df8db04dcb72f7ce0c4d0b2fe329bab00c Mon Sep 17 00:00:00 2001
|
|
From: Dan Harrington <harringtond@chromium.org>
|
|
Date: Fri, 04 Jun 2021 16:46:25 +0000
|
|
Subject: [PATCH] Migrate presubmit to python3
|
|
|
|
Fixed a couple warnings I found when running the unit
|
|
tests in python3.
|
|
|
|
Bug: 1212110
|
|
Change-Id: I3d1b5859b5c517ad5eea30cb816fad0389715f73
|
|
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2934203
|
|
Reviewed-by: Jesse Doherty <jwd@chromium.org>
|
|
Commit-Queue: Dan H <harringtond@chromium.org>
|
|
Cr-Commit-Position: refs/heads/master@{#889331}
|
|
---
|
|
|
|
Index: qtwebengine-everywhere-src-5.15.13/src/3rdparty/chromium/tools/metrics/ukm/PRESUBMIT.py
|
|
===================================================================
|
|
--- qtwebengine-everywhere-src-5.15.13.orig/src/3rdparty/chromium/tools/metrics/ukm/PRESUBMIT.py
|
|
+++ qtwebengine-everywhere-src-5.15.13/src/3rdparty/chromium/tools/metrics/ukm/PRESUBMIT.py
|
|
@@ -8,6 +8,8 @@ See http://dev.chromium.org/developers/h
|
|
for more details on the presubmit API built into gcl.
|
|
"""
|
|
|
|
+USE_PYTHON3 = True
|
|
+
|
|
UKM_XML = 'ukm.xml'
|
|
|
|
|
|
Index: qtwebengine-everywhere-src-5.15.13/src/3rdparty/chromium/tools/metrics/ukm/gen_builders_test.py
|
|
===================================================================
|
|
--- qtwebengine-everywhere-src-5.15.13.orig/src/3rdparty/chromium/tools/metrics/ukm/gen_builders_test.py
|
|
+++ qtwebengine-everywhere-src-5.15.13/src/3rdparty/chromium/tools/metrics/ukm/gen_builders_test.py
|
|
@@ -25,8 +25,8 @@ class GenBuildersTest(unittest.TestCase)
|
|
|
|
def testGenerateCode(self):
|
|
relpath = '.'
|
|
- data = ukm_model.UKM_XML_TYPE.Parse(
|
|
- open('../../tools/metrics/ukm/ukm.xml').read())
|
|
+ with open('../../tools/metrics/ukm/ukm.xml') as f:
|
|
+ data = ukm_model.UKM_XML_TYPE.Parse(f.read())
|
|
event = data[ukm_model._EVENT_TYPE.tag][0]
|
|
metric = event[ukm_model._METRIC_TYPE.tag][0]
|
|
self.assertIsNotNone(event)
|
|
Index: qtwebengine-everywhere-src-5.15.13/src/3rdparty/chromium/tools/metrics/ukm/ukm_model.py
|
|
===================================================================
|
|
--- qtwebengine-everywhere-src-5.15.13.orig/src/3rdparty/chromium/tools/metrics/ukm/ukm_model.py
|
|
+++ qtwebengine-everywhere-src-5.15.13/src/3rdparty/chromium/tools/metrics/ukm/ukm_model.py
|
|
@@ -39,15 +39,16 @@ _INDEX_TYPE = models.ObjectNodeType(
|
|
],
|
|
single_line=True)
|
|
|
|
-_STATISTICS_TYPE = models.ObjectNodeType(
|
|
+_STATISTICS_TYPE = models.ObjectNodeType(
|
|
'statistics',
|
|
attributes=[
|
|
- ('export', str, r'^(?i)(|true|false)$'),
|
|
+ ('export', str, r'(?i)^(|true|false)$'),
|
|
],
|
|
children=[
|
|
models.ChildType(_QUANTILES_TYPE.tag, _QUANTILES_TYPE, multiple=False),
|
|
- models.ChildType(
|
|
- _ENUMERATION_TYPE.tag, _ENUMERATION_TYPE, multiple=False),
|
|
+ models.ChildType(_ENUMERATION_TYPE.tag,
|
|
+ _ENUMERATION_TYPE,
|
|
+ multiple=False),
|
|
])
|
|
|
|
_HISTORY_TYPE = models.ObjectNodeType(
|
|
@@ -90,25 +91,34 @@ _METRIC_TYPE = models.ObjectNodeType(
|
|
_AGGREGATION_TYPE.tag, _AGGREGATION_TYPE, multiple=True),
|
|
])
|
|
|
|
-_EVENT_TYPE = models.ObjectNodeType(
|
|
- 'event',
|
|
- attributes=[
|
|
- ('name', str, r'^[A-Za-z0-9.]+$'),
|
|
- ('singular', str, r'^(?i)(|true|false)$'),
|
|
- ],
|
|
- alphabetization=[
|
|
- (_OBSOLETE_TYPE.tag, _KEEP_ORDER),
|
|
- (_OWNER_TYPE.tag, _KEEP_ORDER),
|
|
- (_SUMMARY_TYPE.tag, _KEEP_ORDER),
|
|
- (_METRIC_TYPE.tag, _LOWERCASE_FN('name')),
|
|
- ],
|
|
- extra_newlines=(1, 1, 1),
|
|
- children=[
|
|
- models.ChildType(_OBSOLETE_TYPE.tag, _OBSOLETE_TYPE, multiple=False),
|
|
- models.ChildType(_OWNER_TYPE.tag, _OWNER_TYPE, multiple=True),
|
|
- models.ChildType(_SUMMARY_TYPE.tag, _SUMMARY_TYPE, multiple=False),
|
|
- models.ChildType(_METRIC_TYPE.tag, _METRIC_TYPE, multiple=True),
|
|
- ])
|
|
+_EVENT_TYPE = models.ObjectNodeType('event',
|
|
+ attributes=[
|
|
+ ('name', str, r'^[A-Za-z0-9.]+$'),
|
|
+ ('singular', str,
|
|
+ r'(?i)^(|true|false)$'),
|
|
+ ],
|
|
+ alphabetization=[
|
|
+ (_OBSOLETE_TYPE.tag, _KEEP_ORDER),
|
|
+ (_OWNER_TYPE.tag, _KEEP_ORDER),
|
|
+ (_SUMMARY_TYPE.tag, _KEEP_ORDER),
|
|
+ (_METRIC_TYPE.tag,
|
|
+ _LOWERCASE_FN('name')),
|
|
+ ],
|
|
+ extra_newlines=(1, 1, 1),
|
|
+ children=[
|
|
+ models.ChildType(_OBSOLETE_TYPE.tag,
|
|
+ _OBSOLETE_TYPE,
|
|
+ multiple=False),
|
|
+ models.ChildType(_OWNER_TYPE.tag,
|
|
+ _OWNER_TYPE,
|
|
+ multiple=True),
|
|
+ models.ChildType(_SUMMARY_TYPE.tag,
|
|
+ _SUMMARY_TYPE,
|
|
+ multiple=False),
|
|
+ models.ChildType(_METRIC_TYPE.tag,
|
|
+ _METRIC_TYPE,
|
|
+ multiple=True),
|
|
+ ])
|
|
|
|
_UKM_CONFIGURATION_TYPE = models.ObjectNodeType(
|
|
'ukm-configuration',
|
|
Index: qtwebengine-everywhere-src-5.15.13/src/3rdparty/chromium/PRESUBMIT_test_mocks.py
|
|
===================================================================
|
|
--- qtwebengine-everywhere-src-5.15.13.orig/src/3rdparty/chromium/PRESUBMIT_test_mocks.py
|
|
+++ qtwebengine-everywhere-src-5.15.13/src/3rdparty/chromium/PRESUBMIT_test_mocks.py
|
|
@@ -119,7 +119,7 @@ class MockInputApi(object):
|
|
def PresubmitLocalPath(self):
|
|
return self.presubmit_local_path
|
|
|
|
- def ReadFile(self, filename, mode='rU'):
|
|
+ def ReadFile(self, filename, mode='r'):
|
|
if hasattr(filename, 'AbsoluteLocalPath'):
|
|
filename = filename.AbsoluteLocalPath()
|
|
for file_ in self.files:
|
|
Index: qtwebengine-everywhere-src-5.15.13/src/3rdparty/chromium/tools/grit/grit/util.py
|
|
===================================================================
|
|
--- qtwebengine-everywhere-src-5.15.13.orig/src/3rdparty/chromium/tools/grit/grit/util.py
|
|
+++ qtwebengine-everywhere-src-5.15.13/src/3rdparty/chromium/tools/grit/grit/util.py
|
|
@@ -211,7 +211,7 @@ def ReadFile(filename, encoding):
|
|
mode = 'rb'
|
|
encoding = None
|
|
else:
|
|
- mode = 'rU'
|
|
+ mode = 'r'
|
|
|
|
with io.open(abs(filename), mode, encoding=encoding) as f:
|
|
return f.read()
|