For better insights. Directories accounted: 4646 Directories complete: 2565 55%
Showing the changes to scripts (1 of 1 file). Show all
Unified · Split
| @@ -28,6 +28,15 @@ class SPDXdata(object): · 27 unmodified lines | |||
| 28 | self.licenses = [ ] | 28 | self.licenses = [ ] |
| 29 | self.exceptions = { } | 29 | self.exceptions = { } |
| 30 | 30 | ||
| 31 | class dirinfo(object): | ||
| 32 | def __init__(self): | ||
| 33 | self.missing = 0 | ||
| 34 | self.total = 0 | ||
| 35 | |||
| 36 | def update(self, miss): | ||
| 37 | self.total += 1 | ||
| 38 | self.missing += miss | ||
| 39 | |||
| 31 | # Read the spdx data from the LICENSES directory | 40 | # Read the spdx data from the LICENSES directory |
| 32 | def read_spdxdata(repo): | 41 | def read_spdxdata(repo): |
| 33 | 42 | ||
| @@ -93,6 +102,7 @@ class id_parser(object): · 59 unmodified lines | |||
| 93 | self.checked = 0 | 102 | self.checked = 0 |
| 94 | self.spdx_valid = 0 | 103 | self.spdx_valid = 0 |
| 95 | self.spdx_errors = 0 | 104 | self.spdx_errors = 0 |
| 105 | self.spdx_dirs = {} | ||
| 96 | self.curline = 0 | 106 | self.curline = 0 |
| 97 | self.deepest = 0 | 107 | self.deepest = 0 |
| 98 | 108 | ||
| @@ -167,6 +177,7 @@ class id_parser(object): · 68 unmodified lines | |||
| 167 | def parse_lines(self, fd, maxlines, fname): | 177 | def parse_lines(self, fd, maxlines, fname): |
| 168 | self.checked += 1 | 178 | self.checked += 1 |
| 169 | self.curline = 0 | 179 | self.curline = 0 |
| 180 | fail = 1 | ||
| 170 | try: | 181 | try: |
| 171 | for line in fd: | 182 | for line in fd: |
| 172 | line = line.decode(locale.getpreferredencoding(False), errors='ignore') | 183 | line = line.decode(locale.getpreferredencoding(False), errors='ignore') |
| @@ -192,6 +203,7 @@ class id_parser(object): · 19 unmodified lines | |||
| 192 | # Should we check for more SPDX ids in the same file and | 203 | # Should we check for more SPDX ids in the same file and |
| 193 | # complain if there are any? | 204 | # complain if there are any? |
| 194 | # | 205 | # |
| 206 | fail = 0 | ||
| 195 | break | 207 | break |
| 196 | 208 | ||
| 197 | except ParserException as pe: | 209 | except ParserException as pe: |
| @@ -203,6 +215,11 @@ class id_parser(object): · 5 unmodified lines | |||
| 203 | sys.stdout.write('%s: %d:0 %s\n' %(fname, self.curline, pe.txt)) | 215 | sys.stdout.write('%s: %d:0 %s\n' %(fname, self.curline, pe.txt)) |
| 204 | self.spdx_errors += 1 | 216 | self.spdx_errors += 1 |
| 205 | 217 | ||
| 218 | base = os.path.dirname(fname) | ||
| 219 | di = self.spdx_dirs.get(base, dirinfo()) | ||
| 220 | di.update(fail) | ||
| 221 | self.spdx_dirs[base] = di | ||
| 222 | |||
| 206 | def scan_git_tree(tree): | 223 | def scan_git_tree(tree): |
| 207 | for el in tree.traverse(): | 224 | for el in tree.traverse(): |
| 208 | # Exclude stuff which would make pointless noise | 225 | # Exclude stuff which would make pointless noise |
| @@ -289,6 +306,16 @@ if __name__ == '__main__': · 80 unmodified lines | |||
| 289 | pc = int(100 * parser.spdx_valid / parser.checked) | 306 | pc = int(100 * parser.spdx_valid / parser.checked) |
| 290 | sys.stderr.write('Files with SPDX: %12d %3d%%\n' %(parser.spdx_valid, pc)) | 307 | sys.stderr.write('Files with SPDX: %12d %3d%%\n' %(parser.spdx_valid, pc)) |
| 291 | sys.stderr.write('Files with errors: %12d\n' %parser.spdx_errors) | 308 | sys.stderr.write('Files with errors: %12d\n' %parser.spdx_errors) |
| 309 | ndirs = len(parser.spdx_dirs) | ||
| 310 | dirsok = 0 | ||
| 311 | if ndirs: | ||
| 312 | sys.stderr.write('\n') | ||
| 313 | sys.stderr.write('Directories accounted: %8d\n' %ndirs) | ||
| 314 | for di in parser.spdx_dirs.values(): | ||
| 315 | if not di.missing: | ||
| 316 | dirsok += 1 | ||
| 317 | pc = int(100 * dirsok / ndirs) | ||
| 318 | sys.stderr.write('Directories complete: %8d %3d%%\n' %(dirsok, pc)) | ||
| 292 | 319 | ||
| 293 | sys.exit(0) | 320 | sys.exit(0) |
| 294 | 321 | ||