mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
scripts/spdxcheck: Add directory statistics
For better insights. Directories accounted: 4646 Directories complete: 2565 55% Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
149d623fbe
commit
a377ce75e4
1 changed files with 27 additions and 0 deletions
|
@ -28,6 +28,15 @@ class SPDXdata(object):
|
||||||
self.licenses = [ ]
|
self.licenses = [ ]
|
||||||
self.exceptions = { }
|
self.exceptions = { }
|
||||||
|
|
||||||
|
class dirinfo(object):
|
||||||
|
def __init__(self):
|
||||||
|
self.missing = 0
|
||||||
|
self.total = 0
|
||||||
|
|
||||||
|
def update(self, miss):
|
||||||
|
self.total += 1
|
||||||
|
self.missing += miss
|
||||||
|
|
||||||
# Read the spdx data from the LICENSES directory
|
# Read the spdx data from the LICENSES directory
|
||||||
def read_spdxdata(repo):
|
def read_spdxdata(repo):
|
||||||
|
|
||||||
|
@ -93,6 +102,7 @@ class id_parser(object):
|
||||||
self.checked = 0
|
self.checked = 0
|
||||||
self.spdx_valid = 0
|
self.spdx_valid = 0
|
||||||
self.spdx_errors = 0
|
self.spdx_errors = 0
|
||||||
|
self.spdx_dirs = {}
|
||||||
self.curline = 0
|
self.curline = 0
|
||||||
self.deepest = 0
|
self.deepest = 0
|
||||||
|
|
||||||
|
@ -167,6 +177,7 @@ class id_parser(object):
|
||||||
def parse_lines(self, fd, maxlines, fname):
|
def parse_lines(self, fd, maxlines, fname):
|
||||||
self.checked += 1
|
self.checked += 1
|
||||||
self.curline = 0
|
self.curline = 0
|
||||||
|
fail = 1
|
||||||
try:
|
try:
|
||||||
for line in fd:
|
for line in fd:
|
||||||
line = line.decode(locale.getpreferredencoding(False), errors='ignore')
|
line = line.decode(locale.getpreferredencoding(False), errors='ignore')
|
||||||
|
@ -192,6 +203,7 @@ class id_parser(object):
|
||||||
# Should we check for more SPDX ids in the same file and
|
# Should we check for more SPDX ids in the same file and
|
||||||
# complain if there are any?
|
# complain if there are any?
|
||||||
#
|
#
|
||||||
|
fail = 0
|
||||||
break
|
break
|
||||||
|
|
||||||
except ParserException as pe:
|
except ParserException as pe:
|
||||||
|
@ -203,6 +215,11 @@ class id_parser(object):
|
||||||
sys.stdout.write('%s: %d:0 %s\n' %(fname, self.curline, pe.txt))
|
sys.stdout.write('%s: %d:0 %s\n' %(fname, self.curline, pe.txt))
|
||||||
self.spdx_errors += 1
|
self.spdx_errors += 1
|
||||||
|
|
||||||
|
base = os.path.dirname(fname)
|
||||||
|
di = self.spdx_dirs.get(base, dirinfo())
|
||||||
|
di.update(fail)
|
||||||
|
self.spdx_dirs[base] = di
|
||||||
|
|
||||||
def scan_git_tree(tree):
|
def scan_git_tree(tree):
|
||||||
for el in tree.traverse():
|
for el in tree.traverse():
|
||||||
# Exclude stuff which would make pointless noise
|
# Exclude stuff which would make pointless noise
|
||||||
|
@ -289,6 +306,16 @@ if __name__ == '__main__':
|
||||||
pc = int(100 * parser.spdx_valid / parser.checked)
|
pc = int(100 * parser.spdx_valid / parser.checked)
|
||||||
sys.stderr.write('Files with SPDX: %12d %3d%%\n' %(parser.spdx_valid, pc))
|
sys.stderr.write('Files with SPDX: %12d %3d%%\n' %(parser.spdx_valid, pc))
|
||||||
sys.stderr.write('Files with errors: %12d\n' %parser.spdx_errors)
|
sys.stderr.write('Files with errors: %12d\n' %parser.spdx_errors)
|
||||||
|
ndirs = len(parser.spdx_dirs)
|
||||||
|
dirsok = 0
|
||||||
|
if ndirs:
|
||||||
|
sys.stderr.write('\n')
|
||||||
|
sys.stderr.write('Directories accounted: %8d\n' %ndirs)
|
||||||
|
for di in parser.spdx_dirs.values():
|
||||||
|
if not di.missing:
|
||||||
|
dirsok += 1
|
||||||
|
pc = int(100 * dirsok / ndirs)
|
||||||
|
sys.stderr.write('Directories complete: %8d %3d%%\n' %(dirsok, pc))
|
||||||
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue