#-------------------------------------------------------------------------------------------------------
# Copyright (C) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
#-------------------------------------------------------------------------------------------------------

# Python 2.7 and 3.x compatibility for easier testing regardless of python installation
from __future__ import print_function

import sys
import os.path
import re

copyright_lines = [
    r'-------------------------------------------------------------------------------------------------------',
    r' Copyright \(C\) Microsoft\. All rights reserved\.',
    r' Licensed under the MIT license\. See LICENSE\.txt file in the project root for full license information\.'
]

regexes = []
for line in copyright_lines:
    pattern = '^.{1,5}%s$' % line
    regexes.append(re.compile(pattern))

if len(sys.argv) < 2:
    print("Requires passing a filename as an argument.")
    exit(1)

file_name = sys.argv[1]
if not os.path.isfile(file_name):
    print("File does not exist:", file_name, "(not necessarily an error)")
    exit(0)

with open(file_name, 'r') as sourcefile:
    for x in range(0,len(copyright_lines)):
        # TODO add a check for empty files (dummy.js etc), as they cause the script to crash here
        line = next(sourcefile)
        line = line.rstrip()
        matches = regexes[x].match(line)
        if not matches:
            print(file_name, "... does not contain a correct Microsoft copyright notice.")
            # found a problem so exit and report the problem to the caller
            exit(1)

#-------------------------------------------------------------------------------------------------------
# Copyright (C) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
#-------------------------------------------------------------------------------------------------------

# Python 2.7 and 3.x compatibility for easier testing regardless of python installation
from __future__ import print_function

import sys
import os.path
import re

copyright_lines = [
    r'-------------------------------------------------------------------------------------------------------',
    r' Copyright \(C\) Microsoft( Corporation and contributors)?\. All rights reserved\.',
    r' Licensed under the MIT license\. See LICENSE\.txt file in the project root for full license information\.'
]

regexes = []
for line in copyright_lines:
    pattern = '^.{1,5}%s$' % line
    regexes.append(re.compile(pattern))

if len(sys.argv) < 2:
    print("Requires passing a filename as an argument.")
    exit(1)

file_name = sys.argv[1]
if not os.path.isfile(file_name):
    print("File does not exist:", file_name, "(not necessarily an error)")
    exit(0)

with open(file_name, 'r') as sourcefile:
    for x in range(0,len(copyright_lines)):
        # TODO add a check for empty files (dummy.js etc), as they cause the script to crash here
        line = next(sourcefile)
        line = line.rstrip()
        matches = regexes[x].match(line)
        if not matches:
            print(file_name, "... does not contain a correct Microsoft copyright notice.")
            # found a problem so exit and report the problem to the caller
            exit(1)

Update copyright check to accept a new, more inclusive, copyright.
Update copyright check to accept a new, more inclusive, copyright.

In order to address concerns over community copyright of the source code they modify. All authors are still subject to the terms of the CLA they sign when contributing.

This new format was approved by Microsoft legal:

```
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft Corporation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
```

In addition to the original format:

```
//-------------------------------------------------------------------------------------------------------
// Copyright (C) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
//-------------------------------------------------------------------------------------------------------
```

The check now allows both so that we don't need to make a disruptive change to every file in the project. The notice can be updated at the author's discretion as they make changes.
