summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorPhilipp Riemer <ruderphilipp@gmail.com>2013-08-09 23:02:16 +0200
committerPhilipp Riemer <ruderphilipp@gmail.com>2013-08-09 23:10:17 +0200
commit299e6381ef8895ac8d0c762b603ab50b9cfc4441 (patch)
tree52e7b1b36ee34c83601e189373ab8a3eacd456fa /bin
parentcbcec9930cd6f601b1d4ebfd7ee0351d7d0a097e (diff)
Add a new option to bin/find-german-comments
The new option "-L" allows to print out potential candidates for translation combined with the number of lines found like "-l" - but only if there was a positive result (i.e., a file that needs checking). This leads to a much more compact representation helping people to find the few files that still need translations. Change-Id: Iad554eb6ce5b062e96774d9488c54105679b7c4b
Diffstat (limited to 'bin')
-rwxr-xr-xbin/find-german-comments19
1 files changed, 13 insertions, 6 deletions
diff --git a/bin/find-german-comments b/bin/find-german-comments
index 1cc9d511edc9..59e4c88d0b82 100755
--- a/bin/find-german-comments
+++ b/bin/find-german-comments
@@ -43,9 +43,11 @@ class Parser:
op.add_option("-f", "--filenames-only", action="store_true", dest="filenames_only", default=False,
help="Only print the filenames of files containing German comments")
op.add_option("-v", "--verbose", action="store_true", dest="verbose", default=False,
- help="Turn on verbose mode (print progress to stderr)")
+ help="Turn on verbose mode (print only positives progress to stderr)")
op.add_option("-l", "--line-numbers", action="store_true", dest="line_numbers", default=False,
help="Prints the filenames and line numbers only.")
+ op.add_option("-L", "--line-numbers-pos", action="store_true", dest="line_numbers_pos", default=False,
+ help="Prints the filenames and line numbers only (if positive).")
op.add_option("-t", "--threshold", action="store", dest="THRESHOLD", default=0,
help="When used with '--line-numbers', only bothers outputting comment info if there are more than X number of flagged comments. Useful for weeding out false positives.")
self.options, args = op.parse_args()
@@ -156,15 +158,19 @@ class Parser:
padding = 0
return (diff/4)+padding
- if self.options.line_numbers:
+ if self.options.line_numbers or self.options.line_numbers_pos:
TABS = "\t"*10
path_linenums = []
for linenum, s in self.get_comments(path):
if self.is_german(s):
path_linenums.append(linenum)
valid = len(path_linenums) > int(self.options.THRESHOLD)
- sys.stderr.write("%s ... %s positives -- %s\n" % (path, str(len(path_linenums)), str(valid)))
+ if self.options.line_numbers:
+ sys.stderr.write("%s ... %s positives -- %s\n" % (path, str(len(path_linenums)), str(valid)))
if valid:
+ if self.options.line_numbers_pos:
+ sys.stderr.write("%s ... %s positives\n" % (path, str(len(path_linenums))))
+ return
if len(path) + (len(path_linenums)*4) > 75:
print "%s:\n" % path
while(path_linenums):
@@ -180,12 +186,13 @@ class Parser:
numline = [str(i) for i in numline]
print "%s%s" %(TABS, ",".join(numline))
else:
- path_linenums = [str(i) for i in path_linenums]
- print "%s:%s%s" % (path,"\t"*tab_calc(path),",".join(path_linenums))
+ if self.options.line_numbers:
+ path_linenums = [str(i) for i in path_linenums]
+ print "%s:%s%s" % (path,"\t"*tab_calc(path),",".join(path_linenums))
elif not self.options.filenames_only:
for linenum, s in self.get_comments(path):
- if self.is_german(s):
+ if self.is_german(s) and self.options.line_numbers:
print "%s:%s: %s" % (path, linenum, s)
else:
fnames = set([])