Chromium Code Reviews| Index: Source/devtools/scripts/generate_supported_css.py |
| diff --git a/Source/devtools/scripts/generate_supported_css.py b/Source/devtools/scripts/generate_supported_css.py |
| index 2883c943332d2495aa4524c54279cd215a7ae724..4fcce2e6f054a44d69fa96c3f8e857276e79b88a 100755 |
| --- a/Source/devtools/scripts/generate_supported_css.py |
| +++ b/Source/devtools/scripts/generate_supported_css.py |
| @@ -34,7 +34,7 @@ except ImportError: |
| import sys |
| -cssProperties = {} |
| +properties = [] |
| def filterCommentsAndEmptyLines(lines): |
| @@ -50,35 +50,17 @@ def fillPropertiesFromFile(fileName): |
| lines = f.readlines() |
| lines = filterCommentsAndEmptyLines(lines) |
| for line in lines: |
| - if not "alias_for" in line: |
| - cssProperties[line] = [] |
| - |
| - |
| -def fillCSSShorthandsFromFile(fileName): |
| - with open(fileName, "r") as f: |
| - lines = f.readlines() |
| - lines = filterCommentsAndEmptyLines(lines) |
| - for line in lines: |
| - # Every line is: |
| - # <property-name>[ longhands=<longhand 1>;<longhand 2>;<longhand 3>,runtimeEnabledShorthand=<runtime flag name>] |
| - # There might be a runtime flag declaration at the end of the list followed by a comma. |
| - if "," in line: |
| - line = line[:line.index(",")] |
| - shorthand = line[:line.index(" ")] |
| - longhands = line[line.index("=") + 1:].split(";") |
| - cssProperties[shorthand] = longhands |
| + if "alias_for" in line: |
| + continue |
| + name = line.split(" ")[0] |
|
Nils Barth (inactive)
2014/07/07 16:43:28
str.partition is a bit better:
name = line.partiti
|
| + entry = {"name": name} |
| + if "longhands=" in line: |
|
Nils Barth (inactive)
2014/07/07 16:43:28
longhands_value = line.partition("longhands=")[2]
|
| + longhands = line.split("longhands=")[1] |
| + longhands = longhands.split(",")[0] |
| + entry["longhands"] = longhands.split(";") |
| + properties.append(entry) |
| fillPropertiesFromFile(sys.argv[1]) |
| -fillPropertiesFromFile(sys.argv[2]) |
| -fillCSSShorthandsFromFile(sys.argv[3]) |
| - |
| -# Reformat from map into list. |
| -reformat = [] |
| -for name, longhands in cssProperties.items(): |
| - entry = {"name": name} |
| - if len(longhands) > 0: |
| - entry["longhands"] = longhands |
| - reformat.append(entry) |
| -with open(sys.argv[4], "w") as f: |
| - f.write("WebInspector.CSSMetadata.initializeWithSupportedProperties(%s);" % json.dumps(reformat)) |
| +with open(sys.argv[2], "w") as f: |
| + f.write("WebInspector.CSSMetadata.initializeWithSupportedProperties(%s);" % json.dumps(properties)) |