def licensecheck()

in tools/check-license.py [0:0]


def licensecheck(GITHUB_REPOSITORY, TOKEN, pr, commentcheck):   

    # If commentcheck = 'false' i.e. License check has not run on the PR before.
    if(commentcheck == 'false'):
    # if(checkmindiff(pr['created_at']) and commentcheck == 'false'):

        print('PR # ' + str(pr) + ' : Run Licence check...')
        
        # Get all pr files
        prfiles = pr_files(GITHUB_REPOSITORY,pr)

        # Download all prf files locally into ./tools/temp/ folder in the same directory structure
        downloadprfiles(prfiles)

        # print(os.getcwd()+'/temp')
        # print(glob.glob(os.getcwd()+'/temp/*'))
        # print(glob.glob(os.getcwd()+'/temp/*/*'))
        # print(glob.glob(os.getcwd()+'/temp/*/*/*'))

        # Run lisence check on the downloaded files in temp directory
        pr_no_license_files = boilerplate(os.getcwd()+'/temp')

        # Delete temp directory and its contents
        shutil.rmtree(os.getcwd()+'/temp')

        if pr_no_license_files:
            comment = '<!-- Boilerplate Check -->\nApache 2.0 License check failed!\n\nThe following files are missing the license boilerplate:\n'
            for x in range(len(pr_no_license_files)):
                # print (files[x])
                comment = comment + '\n' + pr_no_license_files[x]
        else:
            comment = '<!-- Boilerplate Check -->\nApache 2.0 License check successful!'

        # comment PR
        commentpr(GITHUB_REPOSITORY, pr, comment, TOKEN)

    else:
        print('PR # ' + str(pr) + ' : Skip Licence check...')