diff options
author | Philipp Weissenbacher <p.weissenbacher@gmail.com> | 2012-03-06 21:48:52 +0100 |
---|---|---|
committer | Josh Heidenreich <josh.sickmate@gmail.com> | 2012-03-07 11:20:27 +1030 |
commit | aedb86399dca3be9c636267104d0893ffc17aca3 (patch) | |
tree | 3520d2d0206a7737e6b9561f133c443546563787 | |
parent | 37b6a37a2634cbb7bbe6602c3cc45b9ffccc05a7 (diff) |
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.
-rwxr-xr-x | 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 1538c6d57c72..e0ce3826e210 100755 --- a/bin/find-german-comments +++ b/bin/find-german-comments @@ -40,6 +40,8 @@ class Parser: op.set_usage("%prog [options] <rootdir>\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): """ |