File: copyright-helper

package info (click to toggle)
steamcmd 0~20180105-4
  • links: PTS, VCS
  • area: non-free
  • in suites: bullseye
  • size: 4,856 kB
  • sloc: sh: 75; python: 49; makefile: 32
file content (34 lines) | stat: -rw-r--r-- 1,081 bytes parent folder | download | duplicates (2)
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
#!/usr/bin/python3
# Copyright (C) 2013 Michael Gilbert <mgilbert@debian.org>
# License: MIT

import sys

if len( sys.argv ) < 3:
    sys.stderr.write(
            'usage: %s <minified copyright file> <debian copyright file>\n'
            % sys.argv[0] )
    sys.exit( 1 )

mincopyright = open( sys.argv[1] , 'r', encoding='utf-8' )
copyright = open( sys.argv[2] , 'w', encoding='utf-8' )
for cline in mincopyright:
    if cline.strip().startswith('License-File:'):
        info = cline.split()
        start = 0
        if len( info ) > 2:
            start = int( info[2] )
        license = open( info[1] , 'r', encoding='utf-8-sig')
        # utf-8-sig removes the U+FEFF byte order mark
        for line in license.readlines()[start:]:
            copyright.write( line.replace('\r', '') )
#            if line.strip() == '':
#                copyright.write( ' .\n' )
#            else:
#                copyright.write( ' ' )
#                copyright.write( line )
        license.close()
    else:
        copyright.write( cline )
mincopyright.close()
copyright.close()