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

Side by Side Diff: grit/node/mapping.py

Issue 1442863002: Remove contents of grit's SVN repository. (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk/
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « grit/node/io_unittest.py ('k') | grit/node/message.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 '''Maps each node type to an implementation class.
7 When adding a new node type, you add to this mapping.
8 '''
9
10
11 from grit import exception
12
13 from grit.node import empty
14 from grit.node import message
15 from grit.node import misc
16 from grit.node import variant
17 from grit.node import structure
18 from grit.node import include
19 from grit.node import io
20
21
22 _ELEMENT_TO_CLASS = {
23 'identifiers' : empty.IdentifiersNode,
24 'includes' : empty.IncludesNode,
25 'messages' : empty.MessagesNode,
26 'outputs' : empty.OutputsNode,
27 'structures' : empty.StructuresNode,
28 'translations' : empty.TranslationsNode,
29 'include' : include.IncludeNode,
30 'emit' : io.EmitNode,
31 'file' : io.FileNode,
32 'output' : io.OutputNode,
33 'ex' : message.ExNode,
34 'message' : message.MessageNode,
35 'ph' : message.PhNode,
36 'else' : misc.ElseNode,
37 'grit' : misc.GritNode,
38 'identifier' : misc.IdentifierNode,
39 'if' : misc.IfNode,
40 'part' : misc.PartNode,
41 'release' : misc.ReleaseNode,
42 'then' : misc.ThenNode,
43 'structure' : structure.StructureNode,
44 'skeleton' : variant.SkeletonNode,
45 }
46
47
48 def ElementToClass(name, typeattr):
49 '''Maps an element to a class that handles the element.
50
51 Args:
52 name: 'element' (the name of the element)
53 typeattr: 'type' (the value of the type attribute, if present, else None)
54
55 Return:
56 type
57 '''
58 if name not in _ELEMENT_TO_CLASS:
59 raise exception.UnknownElement()
60 return _ELEMENT_TO_CLASS[name]
61
OLDNEW
« no previous file with comments | « grit/node/io_unittest.py ('k') | grit/node/message.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698