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

Unified Diff: tools/grit/grit/node/mapping.py

Issue 1410853008: Move grit from DEPS into src. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: webview licenses Created 5 years, 1 month 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 | « tools/grit/grit/node/io_unittest.py ('k') | tools/grit/grit/node/message.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/grit/grit/node/mapping.py
diff --git a/tools/grit/grit/node/mapping.py b/tools/grit/grit/node/mapping.py
new file mode 100755
index 0000000000000000000000000000000000000000..259be97c6b28d6eb403156512831f86254510e0e
--- /dev/null
+++ b/tools/grit/grit/node/mapping.py
@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+'''Maps each node type to an implementation class.
+When adding a new node type, you add to this mapping.
+'''
+
+
+from grit import exception
+
+from grit.node import empty
+from grit.node import message
+from grit.node import misc
+from grit.node import variant
+from grit.node import structure
+from grit.node import include
+from grit.node import io
+
+
+_ELEMENT_TO_CLASS = {
+ 'identifiers' : empty.IdentifiersNode,
+ 'includes' : empty.IncludesNode,
+ 'messages' : empty.MessagesNode,
+ 'outputs' : empty.OutputsNode,
+ 'structures' : empty.StructuresNode,
+ 'translations' : empty.TranslationsNode,
+ 'include' : include.IncludeNode,
+ 'emit' : io.EmitNode,
+ 'file' : io.FileNode,
+ 'output' : io.OutputNode,
+ 'ex' : message.ExNode,
+ 'message' : message.MessageNode,
+ 'ph' : message.PhNode,
+ 'else' : misc.ElseNode,
+ 'grit' : misc.GritNode,
+ 'identifier' : misc.IdentifierNode,
+ 'if' : misc.IfNode,
+ 'part' : misc.PartNode,
+ 'release' : misc.ReleaseNode,
+ 'then' : misc.ThenNode,
+ 'structure' : structure.StructureNode,
+ 'skeleton' : variant.SkeletonNode,
+}
+
+
+def ElementToClass(name, typeattr):
+ '''Maps an element to a class that handles the element.
+
+ Args:
+ name: 'element' (the name of the element)
+ typeattr: 'type' (the value of the type attribute, if present, else None)
+
+ Return:
+ type
+ '''
+ if name not in _ELEMENT_TO_CLASS:
+ raise exception.UnknownElement()
+ return _ELEMENT_TO_CLASS[name]
+
« no previous file with comments | « tools/grit/grit/node/io_unittest.py ('k') | tools/grit/grit/node/message.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698