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 '''Item formatters for RC headers. | 6 '''Item formatters for RC headers. |
7 ''' | 7 ''' |
8 | 8 |
9 from grit import exception | 9 from grit import exception |
10 from grit import util | 10 from grit import util |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 ''' | 46 ''' |
47 from grit.node import message | 47 from grit.node import message |
48 tids = GetIds(root) | 48 tids = GetIds(root) |
49 | 49 |
50 if output_all_resource_defines: | 50 if output_all_resource_defines: |
51 items = root.Preorder() | 51 items = root.Preorder() |
52 else: | 52 else: |
53 items = root.ActiveDescendants() | 53 items = root.ActiveDescendants() |
54 | 54 |
55 if not rc_header_format: | 55 if not rc_header_format: |
56 rc_header_format = "#define {textual_id} {numeric_id}\n" | 56 rc_header_format = "#define {textual_id} {numeric_id}" |
| 57 rc_header_format += "\n" |
57 seen = set() | 58 seen = set() |
58 for item in items: | 59 for item in items: |
59 if not isinstance(item, message.MessageNode): | 60 if not isinstance(item, message.MessageNode): |
60 with item: | 61 with item: |
61 for tid in item.GetTextualIds(): | 62 for tid in item.GetTextualIds(): |
62 if tid in tids and tid not in seen: | 63 if tid in tids and tid not in seen: |
63 seen.add(tid) | 64 seen.add(tid) |
64 yield rc_header_format.format(textual_id=tid,numeric_id=tids[tid]) | 65 yield rc_header_format.format(textual_id=tid,numeric_id=tids[tid]) |
65 | 66 |
66 # Temporarily mimic old behavior: MessageNodes were only output if active, | 67 # Temporarily mimic old behavior: MessageNodes were only output if active, |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 195 |
195 if id < 101: | 196 if id < 101: |
196 print ('WARNING: Numeric resource IDs should be greater than 100 to\n' | 197 print ('WARNING: Numeric resource IDs should be greater than 100 to\n' |
197 'avoid conflicts with system-defined resource IDs.') | 198 'avoid conflicts with system-defined resource IDs.') |
198 | 199 |
199 ids[id] = tid | 200 ids[id] = tid |
200 tids[tid] = id | 201 tids[tid] = id |
201 id_reasons[id] = reason | 202 id_reasons[id] = reason |
202 | 203 |
203 return tids | 204 return tids |
OLD | NEW |