def remove_apache_reference()

in remove-apache-license-identifier.py [0:0]


def remove_apache_reference(path, extension='backup'):
    apache_references = [
        '# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.',
        '# SPDX-License-Identifier: Apache-2.0'
    ]
    backup = path + '.' + extension
    shutil.move(path, backup)
    with open(backup) as infile, open(path, "w") as outfile:
        removed = False
        for line in infile:
            if strip_whitespace(line) in apache_references:
                removed = True
                logging.debug('Deleted Apache reference in %s: %s',
                             path, strip_whitespace(line))
                continue
            outfile.write(line)
        if removed:
            logging.info('Deleted Apache reference in %s', path)
            return True
        return False