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

Unified Diff: third_party/WebKit/Source/build/scripts/json5_generator.py

Issue 2666173002: Add support to validate list of items in json5 config. (Closed)
Patch Set: Created 3 years, 11 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: third_party/WebKit/Source/build/scripts/json5_generator.py
diff --git a/third_party/WebKit/Source/build/scripts/json5_generator.py b/third_party/WebKit/Source/build/scripts/json5_generator.py
index 00f4e9ad937ce91117d6005bf843b78ce5a2a332..4c7a63d7f2fd7d677095f69ab9a0e5fa36f33897 100644
--- a/third_party/WebKit/Source/build/scripts/json5_generator.py
+++ b/third_party/WebKit/Source/build/scripts/json5_generator.py
@@ -164,14 +164,23 @@ class Json5File(object):
return entry
def _validate_parameter(self, parameter, value):
- valid_values = parameter.get("valid_values")
- if valid_values and value not in valid_values:
- raise Exception("Unknown value: '%s'\nKnown values: %s" %
- (value, valid_values))
valid_type = parameter.get("valid_type")
if valid_type and type(value).__name__ != valid_type:
raise Exception("Incorrect type: '%s'\nExpected type: %s" %
(type(value).__name__, valid_type))
+ valid_values = parameter.get("valid_values")
+ if not valid_values:
+ return
+ # If valid_values is a list of simple items and not list of list, then
+ # validate each item in the value list against valid_values.
+ if valid_type == "list" and type(valid_values[0]) is not list:
+ for item in value:
+ if item not in valid_values:
+ raise Exception("Unknown value: '%s'\nKnown values: %s" %
+ (item, valid_values))
+ elif value not in valid_values:
+ raise Exception("Unknown value: '%s'\nKnown values: %s" %
+ (value, valid_values))
class Writer(object):
« 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