/[ddp]/manuals/trunk/release-notes/transcount
ViewVC logotype

Contents of /manuals/trunk/release-notes/transcount

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6283 - (show annotations) (download)
Sat Feb 7 17:08:32 2009 UTC (4 years, 3 months ago) by debacle
File size: 1697 byte(s)
Count old DocBook translation now as 50%.
1 #!/usr/bin/env python
2
3 import glob
4 import os.path
5 import re
6 import sys
7
8 if __name__ == "__main__":
9 if len(sys.argv) < 3:
10 print >>sys.stderr, \
11 "call with original language directory and one or more"
12 print >>sys.stderr, \
13 "translation directories, e.g. %s en ca cs pt_BR" % sys.argv[0]
14 sys.exit(-1)
15 origlang = sys.argv[1]
16 targetlangs = sys.argv[2:]
17 filenames = map(os.path.basename, glob.glob("%s/*.dbk" % origlang))
18 sizes = {}
19 for fn in filenames:
20 sizes[fn] = len(open("%s/%s" % (origlang, fn), "r").readlines())
21 total = sum(sizes.values())
22 revisions = {}
23 for fn in filenames:
24 for attr in os.popen("svn info %s/%s" % (origlang, fn)).readlines():
25 if attr.startswith("Last Changed Rev:"):
26 _, revision = attr.split(":", 1)
27 revisions[fn] = int(revision)
28 # looking for marker: "^<!-- English version: 1234 -->$"
29 rev_re = re.compile("^\s*<!--\s+English version:\s+([0-9]+)\s+-->\s*$")
30 for lng in targetlangs:
31 stats = 0
32 for fn in filenames:
33 for line in open("%s/%s" % (lng, fn), "r").readlines(10):
34 match = rev_re.match(line)
35 if match:
36 revision = int(rev_re.match(line).group(1))
37 if revision >= revisions[fn]:
38 # Current! Count 100%.
39 stats += sizes[fn]
40 else:
41 # SVN revision not current. Count 50%.
42 stats += sizes[fn]/2.
43 value = float(stats)/(total/100.)
44 print "%s: ~%d%% (~%.2f%%)." % (lng, int(round(value)), value)

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.5