Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Unified Diff: components/variations/service/generate_ui_string_overrider.py

Issue 1969243002: Fix regex to parse Variations UI override strings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed rkaplow and alexei comments Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/variations/service/generate_ui_string_overrider.py
diff --git a/components/variations/service/generate_ui_string_overrider.py b/components/variations/service/generate_ui_string_overrider.py
index 6e43559d60f99cf65f57439ef6ab8ce20c8e5431..b39a03e27c8a9a3e00c7ae4ad2e61eff083a2b0b 100755
--- a/components/variations/service/generate_ui_string_overrider.py
+++ b/components/variations/service/generate_ui_string_overrider.py
@@ -12,7 +12,25 @@ import re
import sys
SCRIPT_NAME = "generate_ui_string_overrider.py"
+
+
+# Regular expressions for parsing the #define macro format. Separate regular
+# expressions are used for parsing lines with pragma (for builds with
+# enable_resource_whitelist_generation flag) in windows and non-windows, and for
+# lines without pragma, For example,
+# Without generate whitelist flag:
+# #define IDS_FOO_MESSAGE 1234
+# With generate whitelist flag in non-windows:
+# #define IDS_FOO_MESSAGE _Pragma("whitelisted_resource_1234") 1234
+# With generate whitelist flag in windows:
+# #define IDS_FOO_MESSAGE __pragma(message("whitelisted_resource_1234")) 1234
RESOURCE_EXTRACT_REGEX = re.compile('^#define (\S*) (\d*)$', re.MULTILINE)
+RESOURCE_EXTRACT_REGEX_PRAGMA = re.compile(
+ '^#define (\S*) _Pragma\("whitelisted_resource_\d*"\) (\d*)$',
+ re.MULTILINE)
+RESOURCE_EXTRACT_REGEX_PRAGMA_WINDOWS = re.compile(
+ '^#define (\S*) __pragma\(message\("whitelisted_resource_\d*"\)\) (\d*)$',
+ re.MULTILINE)
class Error(Exception):
"""Base error class for all exceptions in generated_resources_map."""
@@ -53,6 +71,10 @@ def _GetNameIndexPairsIter(string_to_scan):
"""
for match in RESOURCE_EXTRACT_REGEX.finditer(string_to_scan):
yield match.group(1, 2)
+ for match in RESOURCE_EXTRACT_REGEX_PRAGMA.finditer(string_to_scan):
+ yield match.group(1, 2)
+ for match in RESOURCE_EXTRACT_REGEX_PRAGMA_WINDOWS.finditer(string_to_scan):
+ yield match.group(1, 2)
def _GetResourceListFromString(resources_content):
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698