| OLD | NEW |
| 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 '''Handling of the <message> element. | 6 '''Handling of the <message> element. |
| 7 ''' | 7 ''' |
| 8 | 8 |
| 9 import re | 9 import re |
| 10 import types | 10 import types |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 102 |
| 103 def ItemFormatter(self, t): | 103 def ItemFormatter(self, t): |
| 104 # Only generate an output if the if condition is satisfied. | 104 # Only generate an output if the if condition is satisfied. |
| 105 if not self.SatisfiesOutputCondition(): | 105 if not self.SatisfiesOutputCondition(): |
| 106 return super(type(self), self).ItemFormatter(t) | 106 return super(type(self), self).ItemFormatter(t) |
| 107 | 107 |
| 108 if t == 'rc_header': | 108 if t == 'rc_header': |
| 109 return grit.format.rc_header.Item() | 109 return grit.format.rc_header.Item() |
| 110 elif t in ('rc_all', 'rc_translateable', 'rc_nontranslateable'): | 110 elif t in ('rc_all', 'rc_translateable', 'rc_nontranslateable'): |
| 111 return grit.format.rc.Message() | 111 return grit.format.rc.Message() |
| 112 elif t == 'c_format' and self.SatisfiesOutputCondition(): |
| 113 return grit.format.c_format.Message() |
| 112 elif t == 'js_map_format': | 114 elif t == 'js_map_format': |
| 113 return grit.format.js_map_format.Message() | 115 return grit.format.js_map_format.Message() |
| 114 else: | 116 else: |
| 115 return super(type(self), self).ItemFormatter(t) | 117 return super(type(self), self).ItemFormatter(t) |
| 116 | 118 |
| 117 def EndParsing(self): | 119 def EndParsing(self): |
| 118 super(type(self), self).EndParsing() | 120 super(type(self), self).EndParsing() |
| 119 | 121 |
| 120 # Make the text (including placeholder references) and list of placeholders, | 122 # Make the text (including placeholder references) and list of placeholders, |
| 121 # then strip and store leading and trailing whitespace and create the | 123 # then strip and store leading and trailing whitespace and create the |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 def EndParsing(self): | 273 def EndParsing(self): |
| 272 super(type(self), self).EndParsing() | 274 super(type(self), self).EndParsing() |
| 273 # We only allow a single example for each placeholder | 275 # We only allow a single example for each placeholder |
| 274 if len(self.children) > 1: | 276 if len(self.children) > 1: |
| 275 raise exception.TooManyExamples() | 277 raise exception.TooManyExamples() |
| 276 | 278 |
| 277 | 279 |
| 278 class ExNode(base.ContentNode): | 280 class ExNode(base.ContentNode): |
| 279 '''An <ex> element.''' | 281 '''An <ex> element.''' |
| 280 pass | 282 pass |
| OLD | NEW |