1 | """Track IP of data files included in this distribution. |
---|
2 | |
---|
3 | |
---|
4 | """ |
---|
5 | |
---|
6 | from os import remove, walk, sep |
---|
7 | from os.path import join |
---|
8 | |
---|
9 | def identify_data_files(distro_dir): |
---|
10 | """ Identify potential data files that might violate IP |
---|
11 | """ |
---|
12 | |
---|
13 | print '---------------------------------------------' |
---|
14 | print 'Files that need to be assessed for IP issues:' |
---|
15 | print '---------------------------------------------' |
---|
16 | |
---|
17 | # Print header |
---|
18 | dirwidth = 72 |
---|
19 | print '---------------------------------------------' |
---|
20 | print 'Directory'.ljust(dirwidth), 'File' |
---|
21 | print '---------------------------------------------' |
---|
22 | |
---|
23 | # Ignore source code files |
---|
24 | extensions_to_ignore = ['.py','.c','.h', '.f'] #,'gif'] |
---|
25 | |
---|
26 | # Ignore certain other files |
---|
27 | files_to_ignore = ['README.txt'] |
---|
28 | |
---|
29 | for dirpath, dirnames, filenames in walk(distro_dir): |
---|
30 | |
---|
31 | #print 'Searching dir', dirpath |
---|
32 | |
---|
33 | |
---|
34 | for filename in filenames: |
---|
35 | |
---|
36 | |
---|
37 | # Ignore extensions that need no IP check |
---|
38 | ignore = False |
---|
39 | for ext in extensions_to_ignore: |
---|
40 | if filename.endswith(ext): |
---|
41 | ignore = True |
---|
42 | |
---|
43 | if filename in files_to_ignore: |
---|
44 | ignore = True |
---|
45 | |
---|
46 | if ignore is False: |
---|
47 | subdirs = dirpath.split(sep) |
---|
48 | |
---|
49 | print join(subdirs[3:],sep).ljust(dirwidth), filename |
---|
50 | |
---|
51 | |
---|
52 | |
---|
53 | # FIXME (Ole): Here we could put in a check testing if |
---|
54 | # all the files above have a .license file associated with them |
---|
55 | # explaining their origins. |
---|
56 | |
---|