mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-23 18:32:55 +00:00
41 lines
1.3 KiB
Python
41 lines
1.3 KiB
Python
![]() |
#!/usr/bin/python
|
||
|
|
||
|
import os
|
||
|
|
||
|
licenses = ['BSD', 'FDL', 'LGPL', 'LGPL3', 'LGPL21']
|
||
|
|
||
|
lfiles = []
|
||
|
for root, subdirs, files in os.walk(os.curdir):
|
||
|
for sfile in files:
|
||
|
if sfile.endswith(('.cpp', '.h', '.js', '.qs', '.qml', '.ui')):
|
||
|
lfiles.append('%s/%s' % (root, sfile))
|
||
|
|
||
|
def readlicense(sfile):
|
||
|
sheader = ''
|
||
|
with open(sfile, 'r') as f:
|
||
|
shouldappend = False
|
||
|
for sline in f.readlines():
|
||
|
if 'QT_BEGIN_LICENSE' in sline:
|
||
|
shouldappend = True
|
||
|
elif 'QT_END_LICENSE' in sline:
|
||
|
sheader = '%s%s' % (sheader, sline)
|
||
|
shouldappend = False
|
||
|
if shouldappend:
|
||
|
sheader = '%s%s' % (sheader, sline)
|
||
|
return sheader
|
||
|
|
||
|
for sfile in lfiles:
|
||
|
with open(sfile, 'r') as f:
|
||
|
scontent = f.read()
|
||
|
for license in licenses:
|
||
|
if ('$QT_BEGIN_LICENSE:%s$' % license) in scontent:
|
||
|
snewheader = readlicense('%s/header.%s' % (os.curdir, license))
|
||
|
soldheader = readlicense(sfile)
|
||
|
snewcontent = scontent.replace(soldheader, snewheader)
|
||
|
snewcontent = snewcontent.replace("2016-2019", "2016-2020")
|
||
|
if not snewcontent == scontent:
|
||
|
with open(sfile, 'w') as f:
|
||
|
f.write(snewcontent)
|
||
|
|
||
|
|