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

Side by Side Diff: grit/tool/count.py

Issue 7994004: Initial source commit to grit-i18n project. (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk/
Patch Set: Created 9 years, 3 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
« no previous file with comments | « grit/tool/build.py ('k') | grit/tool/diff_structures.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(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
OLDNEW
« no previous file with comments | « grit/tool/build.py ('k') | grit/tool/diff_structures.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698