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

Unified Diff: Source/devtools/scripts/generate_supported_css.py

Issue 371443003: Merge .in files for css/svg properties into a single file (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@cascade
Patch Set: up-to-date version of entire patch Created 6 years, 5 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 | « Source/devtools/devtools.gyp ('k') | Tools/Scripts/webkitpy/w3c/test_converter.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..a99e3140132dbd14ef7099e741e4464f78276e73 100755
--- a/Source/devtools/scripts/generate_supported_css.py
+++ b/Source/devtools/scripts/generate_supported_css.py
@@ -34,51 +34,22 @@ except ImportError:
import sys
-cssProperties = {}
-
-def filterCommentsAndEmptyLines(lines):
- result = []
- for line in lines:
- if len(line.strip()) > 0 and line[:2] != "//":
- result.append(line.strip())
- return result
-
-
-def fillPropertiesFromFile(fileName):
- with open(fileName, "r") as f:
- 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
-
-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))
+def properties_from_file(file_name):
+ properties = []
+ with open(file_name, "r") as f:
+ for line in f:
+ line = line.strip()
+ if not line or line.startswith("//") or "alias_for" in line:
+ continue
+ name = line.partition(" ")[0]
+ entry = {"name": name}
+ longhands = line.partition("longhands=")[2]
+ if longhands:
+ entry["longhands"] = longhands.split(";")
+ properties.append(entry)
+ return properties
+
+properties = properties_from_file(sys.argv[1])
+with open(sys.argv[2], "w") as f:
+ f.write("WebInspector.CSSMetadata.initializeWithSupportedProperties(%s);" % json.dumps(properties))
« no previous file with comments | « Source/devtools/devtools.gyp ('k') | Tools/Scripts/webkitpy/w3c/test_converter.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698