comparison Documentations/setGPLHeader.py @ 35:6237372f76a4

... more GPL License and general cleanups
author jDG@sauge
date Wed, 07 Mar 2018 18:56:48 +0100
parents 3a98f9e7ca58
children
comparison
equal deleted inserted replaced
34:01cc5959f199 35:6237372f76a4
21 for sub in ['.', 'Inc', 'Src']: 21 for sub in ['.', 'Inc', 'Src']:
22 path = os.path.join(OSTC4, dir, sub) 22 path = os.path.join(OSTC4, dir, sub)
23 if not os.path.exists(path): 23 if not os.path.exists(path):
24 continue 24 continue
25 print(path + ':') 25 print(path + ':')
26 for file in glob.iglob( os.path.join(path, '*.[chs]') ): 26 for file in sorted( glob.iglob( os.path.join(path, '*.[chs]') ) ):
27 try: 27 try:
28 work(file) 28 work(file)
29 except Exception as e: 29 except Exception as e:
30 raise RuntimeError('Cannot process ' + file + ':\n\t' + str(e)) 30 raise RuntimeError('Cannot process ' + file + ':\n\t' + str(e))
31 31
42 42
43 # Set defaults 43 # Set defaults
44 kw = {} 44 kw = {}
45 kw['file'] = file.replace(OSTC4+'/', '') 45 kw['file'] = file.replace(OSTC4+'/', '')
46 kw['brief'] = '' 46 kw['brief'] = ''
47 kw['author'] = 'Heinrichs Weikamp'
48 kw['date'] = '2018' 47 kw['date'] = '2018'
49 48
50 # Try to gather info from existing header, if any: 49 # Try to gather info from existing header, if any:
51 for line in lines: 50 for line in lines:
52 # Skip files that already have a GNU license: 51 # Skip files that already have a GNU license:
53 if 'GNU General Public License' in line: 52 if 'GNU General Public License' in line:
54 print('(done)\t' + file) 53 print('(done)\t' + file)
55 return 54 return
56 55
57 get(line, 'brief', kw) 56 get(line, 'brief', kw)
58 get(line, 'author', kw)
59 get(line, 'date', kw) 57 get(line, 'date', kw)
60 58
61 # Replace kw in header 59 # Replace kw in header
62 header = template 60 header = template
63 for k,v in kw.items(): 61 for k,v in kw.items():