From c3a6ef0f72a33c2672f1f5675106f5de7590f72d Mon Sep 17 00:00:00 2001
From: Philipp Weissenbacher
Date: Tue, 6 Mar 2012 21:48:52 +0100
Subject: [PATCH] Add option to only list filenames
This adds the argument -f (--filenames-only), which only prints the
filenames of files containing German comments.
I personally scan the whole file for German strings anyway, as we do
not find German strings with less than 4 chars. So there's not so
much use in printing the found strings.
---
bin/find-german-comments | 18 +++++++++++++++---
1 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/bin/find-german-comments b/bin/find-german-comments
index 1538c6d..e0ce382 100755
--- a/bin/find-german-comments
+++ b/bin/find-german-comments
@@ -40,6 +40,8 @@ class Parser:
op.set_usage("%prog [options] \n\n" +
"Searches for german comments in cxx/hxx source files inside a given root\n" +
"directory recursively.")
+ 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)")
self.options, args = op.parse_args()
@@ -139,9 +141,19 @@ class Parser:
"""
checks each comment in a file
"""
- for linenum, s in self.get_comments(path):
- if self.is_german(s):
- print "%s:%s: %s" % (path, linenum, s)
+ if not self.options.filenames_only:
+ for linenum, s in self.get_comments(path):
+ if self.is_german(s):
+ print "%s:%s: %s" % (path, linenum, s)
+ else:
+ fnames = set([])
+ for linenum, s in self.get_comments(path):
+ if self.is_german(s):
+ # Make sure we print each filename only once
+ fnames.add(path)
+ # Print the filenames
+ for f in fnames:
+ print f
def check_source_files(self, dir):
"""
--
1.7.7.6