#!/usr/bin/python3
# Copyright (C) 2013-2018 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] , 'rt', encoding='utf-8' )
copyright = open( sys.argv[2] , 'wt', encoding='utf-8' )
for cline in mincopyright.readlines():
    if cline.strip().startswith( 'License-File:' ):
        info = cline.split()
        license = open( info[1] , 'rt', encoding='utf-8' )
        for line in license.readlines():
            copyright.write( line )
        license.close()
    else:
        copyright.write( cline )
mincopyright.close()
copyright.close()
