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

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

Issue 11155024: If-then-else support for GRIT (Closed) Base URL: https://grit-i18n.googlecode.com/svn/trunk
Patch Set: Created 8 years, 2 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 '''Maps each node type to an implementation class. 6 '''Maps each node type to an implementation class.
7 When adding a new node type, you add to this mapping. 7 When adding a new node type, you add to this mapping.
8 ''' 8 '''
9 9
10 10
(...skipping 15 matching lines...) Expand all
26 'outputs' : empty.OutputsNode, 26 'outputs' : empty.OutputsNode,
27 'structures' : empty.StructuresNode, 27 'structures' : empty.StructuresNode,
28 'translations' : empty.TranslationsNode, 28 'translations' : empty.TranslationsNode,
29 'include' : include.IncludeNode, 29 'include' : include.IncludeNode,
30 'emit' : io.EmitNode, 30 'emit' : io.EmitNode,
31 'file' : io.FileNode, 31 'file' : io.FileNode,
32 'output' : io.OutputNode, 32 'output' : io.OutputNode,
33 'ex' : message.ExNode, 33 'ex' : message.ExNode,
34 'message' : message.MessageNode, 34 'message' : message.MessageNode,
35 'ph' : message.PhNode, 35 'ph' : message.PhNode,
36 'else' : misc.ElseNode,
36 'grit' : misc.GritNode, 37 'grit' : misc.GritNode,
37 'identifier' : misc.IdentifierNode, 38 'identifier' : misc.IdentifierNode,
38 'if' : misc.IfNode, 39 'if' : misc.IfNode,
39 'part' : misc.PartNode, 40 'part' : misc.PartNode,
40 'release' : misc.ReleaseNode, 41 'release' : misc.ReleaseNode,
42 'then' : misc.ThenNode,
41 'structure' : structure.StructureNode, 43 'structure' : structure.StructureNode,
42 'skeleton' : variant.SkeletonNode, 44 'skeleton' : variant.SkeletonNode,
43 } 45 }
44 46
45 47
46 def ElementToClass(name, typeattr): 48 def ElementToClass(name, typeattr):
47 '''Maps an element to a class that handles the element. 49 '''Maps an element to a class that handles the element.
48 50
49 Args: 51 Args:
50 name: 'element' (the name of the element) 52 name: 'element' (the name of the element)
51 typeattr: 'type' (the value of the type attribute, if present, else None) 53 typeattr: 'type' (the value of the type attribute, if present, else None)
52 54
53 Return: 55 Return:
54 type 56 type
55 ''' 57 '''
56 if name not in _ELEMENT_TO_CLASS: 58 if name not in _ELEMENT_TO_CLASS:
57 raise exception.UnknownElement() 59 raise exception.UnknownElement()
58 return _ELEMENT_TO_CLASS[name] 60 return _ELEMENT_TO_CLASS[name]
59 61
OLDNEW
« no previous file with comments | « grit/node/empty.py ('k') | grit/node/misc.py » ('j') | grit/node/misc.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698