<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def merge_versions(self, data):
 """Merges python versions specified in command lines options with extracted versions, checks if some of the versions is not > 2 if EPEL6 template will be used. attributes base_python_version and python_versions contain values specified by command line options or default values, data.python_versions contains extracted data. """

        if self.template == "epel6.spec":
            # if user requested version greater than 2, writes error message
            # and exits
            requested_versions = self.python_versions
            if self.base_python_version:
                requested_versions += [self.base_python_version]
            if any(int(ver[0]) > 2 for ver in requested_versions):
                sys.stderr.write(
                    "Invalid version, major number of python version for "
                    "EPEL6 spec file must not be greater than 2.\n")
                sys.exit(1)
            # if version greater than 2 were extracted it is removed
            data.python_versions = [
                ver for ver in data.python_versions if not int(ver[0]) > 2]

        # Set python versions from default values in settings.
        base_version, additional_versions = (
            self.template_base_py_ver, self.template_py_vers)

        # Sync default values with extracted versions from PyPI classifiers.
        if data.python_versions:
            if base_version not in data.python_versions:
                base_version = data.python_versions[0]

            additional_versions = [
                v for v in additional_versions if v in data.python_versions]

        # Override default values with those set from command line if any.
        if self.base_python_version:
            base_version = self.base_python_version
        if self.python_versions:
            additional_versions = [
                v for v in self.python_versions if v != base_version]

        data.base_python_version = base_version
        data.python_versions = additional_versions