# Path: muranoagent/exceptions.py
# class AgentException(Exception):
# class CustomException(AgentException):
# class IncorrectFormat(AgentException):
#     def __init__(self, code, message=None, additional_data=None):
#     def error_code(self):
#     def additional_data(self):
#     def __init__(self, code, message=None, additional_data=None):


import semantic_version
from muranoagent import exceptions as exc

def _validate_script(name, script, plan_format_version, plan):
    for attr in ('Type', 'EntryPoint'):
        if attr not in script or not isinstance(script[attr], str):
            raise exc.IncorrectFormat(
                2, 'Incorrect {0} entry in script {1}'.format(
                    attr, name))

    if plan_format_version in semantic_version.Spec('>=2.0.0,<2.1.0'):
        if script['Type'] != 'Application':
            raise exc.IncorrectFormat(
                2, 'Type {0} is not valid for format {1}'.format(
                    script['Type'], plan_format_version))
        if script['EntryPoint'] not in plan.get('Files', {}):
            raise exc.IncorrectFormat(
                2, 'Script {0} misses entry point {1}'.format(
                    name, script['EntryPoint']))

    if plan_format_version in semantic_version.Spec('>=2.1.0'):
        if script['Type'] not in ('Application', 'Chef', 'Puppet'):
            raise exc.IncorrectFormat(
                2, 'Script has not a valid type {0}'.format(
                    script['Type']))
        if (script['Type'] == 'Application' and script['EntryPoint']
                not in plan.get('Files', {})):
            raise exc.IncorrectFormat(
                2, 'Script {0} misses entry point {1}'.format(
                    name, script['EntryPoint']))
        elif (script['Type'] != 'Application' and
              "::" not in script['EntryPoint']):

# Path: muranoagent/exceptions.py
# class AgentException(Exception):
# class CustomException(AgentException):
# class IncorrectFormat(AgentException):
#     def __init__(self, code, message=None, additional_data=None):
#     def error_code(self):
#     def additional_data(self):
#     def __init__(self, code, message=None, additional_data=None):


# Path: muranoagent/validation.py
import semantic_version
from muranoagent import exceptions as exc


def _validate_script(name, script, plan_format_version, plan):
    for attr in ('Type', 'EntryPoint'):
        if attr not in script or not isinstance(script[attr], str):
            raise exc.IncorrectFormat(
                2, 'Incorrect {0} entry in script {1}'.format(
                    attr, name))

    if plan_format_version in semantic_version.Spec('>=2.0.0,<2.1.0'):
        if script['Type'] != 'Application':
            raise exc.IncorrectFormat(
                2, 'Type {0} is not valid for format {1}'.format(
                    script['Type'], plan_format_version))
        if script['EntryPoint'] not in plan.get('Files', {}):
            raise exc.IncorrectFormat(
                2, 'Script {0} misses entry point {1}'.format(
                    name, script['EntryPoint']))

    if plan_format_version in semantic_version.Spec('>=2.1.0'):
        if script['Type'] not in ('Application', 'Chef', 'Puppet'):
            raise exc.IncorrectFormat(
                2, 'Script has not a valid type {0}'.format(
                    script['Type']))
        if (script['Type'] == 'Application' and script['EntryPoint']
                not in plan.get('Files', {})):
            raise exc.IncorrectFormat(
                2, 'Script {0} misses entry point {1}'.format(
                    name, script['EntryPoint']))
        elif (script['Type'] != 'Application' and
              "::" not in script['EntryPoint']):

            raise exc.IncorrectFormat(