# Path: lava_dispatcher/action.py
# class ConfigurationError(LAVAError):
#     error_help = "ConfigurationError: The LAVA instance is not configured " \
#                  "correctly. Please report this error to LAVA admins."
#     error_type = "Configuration"


import yaml
from lava_dispatcher.action import ConfigurationError
                if missing_ok:
                    return None
                raise ConfigurationError("Constant %s,%s does not exist in the device config 'constants' section." % (prefix, const))
            else:
                return self['constants'][prefix][const]
        if const not in self['constants']:
            if missing_ok:
                return None
            raise ConfigurationError("Constant %s does not exist in the device config 'constants' section." % const)
        return self['constants'][const]


class NewDevice(PipelineDevice):
    """
    YAML based PipelineDevice class with clearer support for the pipeline overrides
    and deployment types. Simple change of init whilst allowing the scheduler and
    the dispatcher to share the same functionality.
    """

    def __init__(self, target):
        super(NewDevice, self).__init__({})
        # Parse the yaml configuration
        try:
            if isinstance(target, str):
                with open(target) as f_in:
                    data = f_in.read()
            else:
                data = target.read()
            data = yaml.load(data)
            if data is None:

# Path: lava_dispatcher/action.py
# class ConfigurationError(LAVAError):
#     error_help = "ConfigurationError: The LAVA instance is not configured " \
#                  "correctly. Please report this error to LAVA admins."
#     error_type = "Configuration"


# Path: lava_dispatcher/device.py
import yaml
from lava_dispatcher.action import ConfigurationError

                if missing_ok:
                    return None
                raise ConfigurationError("Constant %s,%s does not exist in the device config 'constants' section." % (prefix, const))
            else:
                return self['constants'][prefix][const]
        if const not in self['constants']:
            if missing_ok:
                return None
            raise ConfigurationError("Constant %s does not exist in the device config 'constants' section." % const)
        return self['constants'][const]


class NewDevice(PipelineDevice):
    """
    YAML based PipelineDevice class with clearer support for the pipeline overrides
    and deployment types. Simple change of init whilst allowing the scheduler and
    the dispatcher to share the same functionality.
    """

    def __init__(self, target):
        super(NewDevice, self).__init__({})
        # Parse the yaml configuration
        try:
            if isinstance(target, str):
                with open(target) as f_in:
                    data = f_in.read()
            else:
                data = target.read()
            data = yaml.load(data)
            if data is None:

                raise ConfigurationError("Missing device configuration")