no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD CLOSED TREE
[gecko.git] / layout / style / GenerateCSSPropertyID.py
blobd9bdc22ec59b53247ceacc08966e13d82cf8f1c5
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 import runpy
6 import string
9 def generate(output, template, dataFile):
10 with open(template, "r") as f:
11 template = string.Template(f.read())
12 data = runpy.run_path(dataFile)["data"]
14 longhand_count = 0
15 shorthand_count = 0
16 alias_count = 0
17 property_ids = []
18 for prop in data.values():
19 if prop.type() != "alias":
20 if prop.type() == "longhand":
21 assert shorthand_count == 0
22 longhand_count += 1
23 else:
24 assert alias_count == 0
25 shorthand_count += 1
26 property_ids.append("eCSSProperty_{}".format(prop.id))
27 else:
28 alias_count += 1
29 property_ids.append("eCSSPropertyAlias_{}".format(prop.alias_id))
31 output.write("/* THIS IS AN AUTOGENERATED FILE. DO NOT EDIT */\n\n")
32 output.write(
33 template.substitute(
35 "property_ids": "\n".join(" {},".format(p) for p in property_ids),
36 "longhand_count": property_ids[longhand_count],
37 "shorthand_count": property_ids[longhand_count + shorthand_count],