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 | 28 | self.licenses = [ ] |
| 29 | 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 | 40 | # Read the spdx data from the LICENSES directory |
| 32 | 41 | def read_spdxdata(repo): |
| 33 | 42 | |
| @@ -93,6 +102,7 @@ class id_parser(object): · 59 unmodified lines | ||
| 93 | 102 | self.checked = 0 |
| 94 | 103 | self.spdx_valid = 0 |
| 95 | 104 | self.spdx_errors = 0 |
| 105 | + self.spdx_dirs = {} | |
| 96 | 106 | self.curline = 0 |
| 97 | 107 | self.deepest = 0 |
| 98 | 108 | |
| @@ -167,6 +177,7 @@ class id_parser(object): · 68 unmodified lines | ||
| 167 | 177 | def parse_lines(self, fd, maxlines, fname): |
| 168 | 178 | self.checked += 1 |
| 169 | 179 | self.curline = 0 |
| 180 | + fail = 1 | |
| 170 | 181 | try: |
| 171 | 182 | for line in fd: |
| 172 | 183 | line = line.decode(locale.getpreferredencoding(False), errors='ignore') |
| @@ -192,6 +203,7 @@ class id_parser(object): · 19 unmodified lines | ||
| 192 | 203 | # Should we check for more SPDX ids in the same file and |
| 193 | 204 | # complain if there are any? |
| 194 | 205 | # |
| 206 | + fail = 0 | |
| 195 | 207 | break |
| 196 | 208 | |
| 197 | 209 | except ParserException as pe: |
| @@ -203,6 +215,11 @@ class id_parser(object): · 5 unmodified lines | ||
| 203 | 215 | sys.stdout.write('%s: %d:0 %s\n' %(fname, self.curline, pe.txt)) |
| 204 | 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 | 223 | def scan_git_tree(tree): |
| 207 | 224 | for el in tree.traverse(): |
| 208 | 225 | # Exclude stuff which would make pointless noise |
| @@ -289,6 +306,16 @@ if __name__ == '__main__': · 80 unmodified lines | ||
| 289 | 306 | pc = int(100 * parser.spdx_valid / parser.checked) |
| 290 | 307 | sys.stderr.write('Files with SPDX: %12d %3d%%\n' %(parser.spdx_valid, pc)) |
| 291 | 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 | 320 | sys.exit(0) |
| 294 | 321 | |