Kaydet (Commit) 02b666c4 authored tarafından Phillip Sz's avatar Phillip Sz Kaydeden (comit) Miklos Vajna

find-german-comments: enable scanning subdirs

This makes it possible to scan sub directories, when you give them
as arguments to the script.

Also update the directory_whitelist.

Change-Id: I0a8468348fffe0814905d6f5602fad3f8d6b69e3
Reviewed-on: https://gerrit.libreoffice.org/25523Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
üst 4aca087c
...@@ -224,12 +224,27 @@ class Parser: ...@@ -224,12 +224,27 @@ class Parser:
""" """
checks each _tracked_ file in a directory recursively checks each _tracked_ file in a directory recursively
""" """
sock = os.popen(r"git ls-files '%s' |egrep '\.(c|cc|cpp|cxx|h|hxx|mm)$'" % directory) globalscan = False
if re.match(r'.*/core$', os.getcwd()) and directory == '.':
globalscan = True
# Change into the given dir, so "git ls-tree" does work.
# If we want to scan the current dir, we must not do so as we are already there.
if not globalscan and directory != '.':
currentdir = os.getcwd()
os.chdir(currentdir.split("core",1)[0] + "core/")
os.chdir(directory)
sock = os.popen(r"git ls-tree -r HEAD --name-only |egrep '\.(c|cc|cpp|cxx|h|hxx|mm)$'")
lines = sock.readlines() lines = sock.readlines()
sock.close() sock.close()
# Helps to speedup a global scan # Helps to speedup a global scan
directory_whitelist = { directory_whitelist = {
"ure" : 1,
"ios" : 1,
"bean" : 1,
"apple_remote" : 1,
"UnoControls" : 1, "UnoControls" : 1,
"accessibility" : 1, "accessibility" : 1,
"android" : 1, "android" : 1,
...@@ -351,26 +366,31 @@ class Parser: ...@@ -351,26 +366,31 @@ class Parser:
"xmlscript" : 1, "xmlscript" : 1,
} }
if directory is '.': if globalscan:
sys.stderr.write("Overriding the white-list for the current directory - pass an absolute path to the top-level for faster global white-list searches.\n") print("Scanning all files globally:")
elif directory == '.':
print("Scanning all files in our current directory:")
else:
print("Scanning all files in", directory + ":")
num_checked = 0 num_checked = 0
for path in lines: for path in lines:
baseDir = self.first_elem(path) baseDir = self.first_elem(path)
# If we have an globalscan use the whitelist.
# Support searching within sub directories if globalscan:
if directory is '.': if not baseDir in directory_whitelist:
self.check_file(path.strip()) sys.stderr.write ("\n - Error: Missing path %s -\n\n" % baseDir)
elif not baseDir in directory_whitelist: sys.exit(1)
sys.stderr.write ("\n - Error: Missing path %s -\n\n" % baseDir) elif directory_whitelist[baseDir] is 0:
sys.exit(1) self.check_file(path.strip())
elif directory_whitelist[baseDir] is 0: num_checked = num_checked + 1
elif directory_whitelist[baseDir] is 1:
sys.stderr.write ("Skipping whitelisted directory %s\n" % baseDir)
directory_whitelist[baseDir] = 2
elif not globalscan:
self.check_file(path.strip()) self.check_file(path.strip())
num_checked = num_checked + 1 num_checked = num_checked + 1
elif directory_whitelist[baseDir] is 1:
sys.stderr.write ("Skipping whitelisted directory %s\n" % baseDir)
directory_whitelist[baseDir] = 2
sys.stderr.write ("Scanned %s files\n" % num_checked) sys.stderr.write ("Scanned %s files\n" % num_checked)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment