Esempio n. 1
0
    def test_readme_gpl_disclamer(self):
        """WL8400: Check GPL Disclaimer in README.txt"""
        with open(os.path.join(self.root_path, "README.txt")) as fp:
            line = seek_needle(fp, "GPLv2 Disclaimer")
            self.assertTrue(line is not None, "Could not find start of GPL Disclaimer exception")

            nr_lines = 7
            lines = []
            while nr_lines > 0:
                lines.append(next(fp))
                nr_lines -= 1
            hash = sha1("".join(lines)).hexdigest()

            self.assertEqual("7ea8fbbe1fcdf8965a3ee310f14e6eb7cb1543d0", hash, "GPL Disclaimer in README.txt changed?")
Esempio n. 2
0
    def test_readme_license_foss(self):
        """WL8400: Check FOSS exception in README.txt"""
        with open(os.path.join(self.root_path, "README.txt")) as fp:
            line = seek_needle(fp, "MySQL FOSS License Exception")
            self.assertTrue(line is not None, "Could not find start of FOSS exception")

            nr_lines = 16
            lines = []
            while nr_lines > 0:
                lines.append(next(fp))
                nr_lines -= 1
            hash = sha1("".join(lines)).hexdigest()

            self.assertEqual("d319794f726e1d8dae88227114e30761bc98b11f", hash, "FOSS exception in README.txt changed?")
Esempio n. 3
0
    def test_readme_gpl_disclamer(self):
        """WL8400: Check GPL Disclaimer in README.txt"""
        with open(os.path.join(self.root_path, 'README.txt')) as fp:
            line = seek_needle(fp, 'GPLv2 Disclaimer')
            self.assertTrue(
                line is not None,
                "Could not find start of GPL Disclaimer exception")

            nr_lines = 7
            lines = []
            while nr_lines > 0:
                lines.append(next(fp))
                nr_lines -= 1
            hash = sha1(''.join(lines)).hexdigest()

            self.assertEqual(
                '7ea8fbbe1fcdf8965a3ee310f14e6eb7cb1543d0',
                hash,
                "GPL Disclaimer in README.txt changed?")
Esempio n. 4
0
    def test_readme_license_foss(self):
        """WL8400: Check FOSS exception in README.txt"""
        with open(os.path.join(self.root_path, 'README.txt')) as fp:
            line = seek_needle(fp, 'MySQL FOSS License Exception')
            self.assertTrue(
                line is not None,
                "Could not find start of FOSS exception")

            nr_lines = 16
            lines = []
            while nr_lines > 0:
                lines.append(next(fp))
                nr_lines -= 1
            hash = sha1(''.join(lines)).hexdigest()

            self.assertEqual(
                'd319794f726e1d8dae88227114e30761bc98b11f',
                hash,
                "FOSS exception in README.txt changed?")
Esempio n. 5
0
    def _check_license_presence(self, path):
        """Check if short license text is present

        Returns True if all is OK; False otherwise.
        """
        ext = os.path.splitext(path)[1]
        errmsg = "License problem in %s (license line: %%d)" % path

        with open(path, "rb") as fp:
            # Go to the line containing the copyright statement
            line = seek_needle(fp, "Copyright (c)")
            if not line:
                return path + " (Copyright notice not found)"

            # Always blank line after copyright
            try:
                line = next(fp)
            except StopIteration:
                return path + " (no blank line after copyright)"
            if line[0] == "#":
                line = line[1:]
            if line.strip():
                return path + " (no blank line after copyright)"

            # Now check license part
            curr_line = 1
            for line in fp:
                # Remove hash sign if present
                if line[0] == "#":
                    line = line[1:]
                if curr_line == len(EXP_SHORT_LICENSE_LINES) - 1:
                    # We are at the end; skip blank
                    break
                if not EXP_SHORT_LICENSE_LINES[curr_line].strip() == line.strip():
                    return path + " (error line %d in short license)" % curr_line
                curr_line += 1
            if not 13 == curr_line:
                return path + " (short license not 13 lines)"

        return None
Esempio n. 6
0
    def _check_license_presence(self, path):
        """Check if short license text is present

        Returns True if all is OK; False otherwise.
        """
        ext = os.path.splitext(path)[1]
        errmsg = "License problem in %s (license line: %%d)" % path

        with open(path, 'rb') as fp:
            # Go to the line containing the copyright statement
            line = seek_needle(fp, 'Copyright (c)')
            if not line:
                return path + " (Copyright notice not found)"

            # Always blank line after copyright
            try:
                line = next(fp)
            except StopIteration:
                return path + " (no blank line after copyright)"
            if line[0] == '#':
                line = line[1:]
            if line.strip():
                return path + " (no blank line after copyright)"

            # Now check license part
            curr_line = 1
            for line in fp:
                # Remove hash sign if present
                if line[0] == '#':
                    line = line[1:]
                if curr_line == len(EXP_SHORT_LICENSE_LINES) - 1:
                    # We are at the end; skip blank
                    break
                if not EXP_SHORT_LICENSE_LINES[curr_line].strip() == line.strip():
                    return path + " (error line %d in short license)" % curr_line
                curr_line += 1
            if not 13 == curr_line:
                return path + " (short license not 13 lines)"

        return None