OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/python2.4 |
| 2 # Copyright (c) 2006-2008 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 '''Count number of occurrences of a given message ID |
| 7 ''' |
| 8 |
| 9 import getopt |
| 10 import os |
| 11 import types |
| 12 |
| 13 from grit.tool import interface |
| 14 from grit import grd_reader |
| 15 from grit import util |
| 16 |
| 17 from grit.extern import tclib |
| 18 |
| 19 |
| 20 class CountMessage(interface.Tool): |
| 21 '''Count the number of times a given message ID is used. |
| 22 ''' |
| 23 |
| 24 def __init__(self): |
| 25 pass |
| 26 |
| 27 def ShortDescription(self): |
| 28 return 'Exports all translateable messages into an XMB file.' |
| 29 |
| 30 def Run(self, opts, args): |
| 31 self.SetOptions(opts) |
| 32 |
| 33 id = args[0] |
| 34 res_tree = grd_reader.Parse(opts.input, debug=opts.extra_verbose) |
| 35 res_tree.OnlyTheseTranslations([]) |
| 36 res_tree.RunGatherers(True) |
| 37 |
| 38 count = 0 |
| 39 for c in res_tree.UberClique().AllCliques(): |
| 40 if c.GetId() == id: |
| 41 count += 1 |
| 42 |
| 43 print "There are %d occurrences of message %s." % (count, id) |
| 44 |
OLD | NEW |