Exemplo n.º 1
0
import sys
import logging
import os

import LicenseUtils

logging.basicConfig(format="[CheckLicense]: %(message)s", level = logging.INFO)

exitStatus = 0
for filename in sys.stdin.readlines():
    filename = filename.strip()
    if LicenseUtils.isSourceFile(filename) and os.path.exists(filename):
        license = LicenseUtils.extractLicense(LicenseUtils.getAppropriateLicense(filename))
        sourceFile = open(filename)
        source = LicenseUtils.extractLicenseFromSource(sourceFile)
        if license != source:
            logging.info("Wrong license for file " + filename)
            exitStatus = -1
exit(exitStatus)
Exemplo n.º 2
0
import sys
import os
import logging
import LicenseUtils

logging.basicConfig(format="[UpdateLicense]: %(message)s", level = logging.INFO)
for filename in sys.stdin.readlines():
    filename = filename.strip()

    if LicenseUtils.isSourceFile(filename) and os.path.exists(filename):
        licenseFile = open(LicenseUtils.getAppropriateLicense(filename))
        sourceFile = open(filename)
        updatedSource = "/*\n"
        for line in licenseFile.readlines():
            updatedSource += "* " + line

        skipLicense = True
        for line in sourceFile.readlines():
            strippedLine = line.strip()
            if skipLicense and strippedLine.startswith("package"):
                updatedSource += "*/\n\n"
                skipLicense = False
            elif skipLicense and LicenseUtils.lineIsNotCommentedOut(strippedLine):
                logging.error(filename + " is missing package information")
                exit(2)

            if not skipLicense:
                updatedSource += line

        sourceFile.close()
        sourceFile = open(filename, "w")
Exemplo n.º 3
0
import sys
import logging
import os

import LicenseUtils

logging.basicConfig(format="[CheckLicense]: %(message)s", level=logging.INFO)

exitStatus = 0
for filename in sys.stdin.readlines():
    filename = filename.strip()
    if LicenseUtils.isSourceFile(filename) and os.path.exists(filename):
        license = LicenseUtils.extractLicense(
            LicenseUtils.getAppropriateLicense(filename))
        sourceFile = open(filename)
        source = LicenseUtils.extractLicenseFromSource(sourceFile)
        if license != source:
            logging.info("Wrong license for file " + filename)
            exitStatus = -1
exit(exitStatus)