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

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

Issue 468543002: Revert refactoring of CSSProperty .in files (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 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') | no next file » | 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 4b55736219c62112653e430b9efbf13e470c1340..2ddfef7839ad06dc5b2f4da56be8d0bcb94d1fa6 100755
--- a/Source/devtools/scripts/generate_supported_css.py
+++ b/Source/devtools/scripts/generate_supported_css.py
@@ -34,22 +34,49 @@ except ImportError:
import sys
+cssProperties = {}
-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].partition(",")[0]
- 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))
+
+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:
+ # Format for shorthands is:
+ # <property-name>[ longhands=<longhand 1>;<longhand 2>;<longhand 3>]
+ shorthand = line.partition(" ")[0]
+ longhands = line.partition("longhands=")[2].partition(",")[0]
+ if longhands:
+ cssProperties[shorthand] = longhands.split(";")
+
+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))
« no previous file with comments | « Source/devtools/devtools.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698