File: copyright.py

package info (click to toggle)
game-data-packager 73
  • links: PTS, VCS
  • area: contrib
  • in suites: bookworm
  • size: 23,420 kB
  • sloc: python: 11,086; sh: 609; makefile: 59
file content (40 lines) | stat: -rwxr-xr-x 1,432 bytes parent folder | download
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
#!/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 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()
            for line in open(license, encoding='utf-8'):
                if line.strip():
                    copy.write('  ' + line)
                else:
                    copy.write(' .\n')
        elif line.lower().startswith('include-license-wrap:'):
            license = line.split(':', 1)[1].strip()
            for line in open(license, encoding='utf-8'):
                if line.strip():
                    for l in textwrap.wrap(
                        line,
                        break_long_words=False,
                        initial_indent=' ',
                        subsequent_indent=' ',
                        tabsize=2,
                    ):
                        copy.write(l + '\n')
                else:
                    copy.write(' .\n')
        else:
            copy.write(line)