[Libreoffice-commits] .: bin/find-german-comments

Josh Heidenreich jheidenreich at kemper.freedesktop.org
Tue Mar 6 16:53:42 PST 2012


 bin/find-german-comments |   18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

New commits:
commit aedb86399dca3be9c636267104d0893ffc17aca3
Author: Philipp Weissenbacher <p.weissenbacher at gmail.com>
Date:   Tue Mar 6 21:48:52 2012 +0100

    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.

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] <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):
         """


More information about the Libreoffice-commits mailing list