1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
|
#!/usr/bin/python3
# encoding=utf-8
#
# Copyright © 2015 Simon McVittie <smcv@debian.org>
# SPDX-License-Identifier: GPL-2.0-or-later
import textwrap
if __name__ == '__main__':
cin = open('debian/copyright.in', encoding='utf-8')
copy = open('debian/copyright', 'w', encoding='utf-8')
copy.write(cin.__next__())
copy.write('# This file was generated by debian/copyright.py ')
copy.write('from debian/copyright.in\n')
copy.write('# Please edit one of those files instead\n')
for line in cin:
if line.lower().startswith('include-license:'):
license = line.split(':', 1)[1].strip()
with open(license, encoding='utf-8') as lic:
for line in lic:
if line.strip():
copy.write(' ' + line)
else:
copy.write(' .\n')
elif line.lower().startswith('include-license-wrap:'):
license = line.split(':', 1)[1].strip()
with open(license, encoding='utf-8') as lic:
for line in lic:
if line.strip():
for outline in textwrap.wrap(
line,
break_long_words=False,
initial_indent=' ',
subsequent_indent=' ',
tabsize=2,
):
copy.write(outline + '\n')
else:
copy.write(' .\n')
else:
copy.write(line)
cin.close()
copy.close()
|