def _parse_from_stream(self, stream, directory, file_path, address):
        level_dom = self._parse_dom(stream, file_path)

        # Check schema
        schema_checker      = SchemaChecker.SchemaChecker()
        schema_checker.check_schema(file_path, self.XSD_FILE_PATH)

        level_node      = LoaderUtilities.find_node(file_path, level_dom,  self.SUB_LEVEL + 's')

        # Load important nodes
        configuration_nodes = LoaderUtilities.find_nodes(file_path, level_node,  'configuration')
        user_nodes          = LoaderUtilities.find_nodes(file_path, level_node,  'user')
        runner_nodes        = LoaderUtilities.find_nodes(file_path, level_node,  'runner')
        sub_level_nodes     = LoaderUtilities.find_nodes(file_path, level_node, self.SUB_LEVEL)

        # Parse nodes
        configurations      = self._parse_configurations(directory, configuration_nodes)
        runner              = self._parse_runner(directory, runner_nodes)
        sub_levels          = self._parse_level(address, directory, sub_level_nodes)

        # Return structure
        level_configuration = self.CONFIG_CLASS(
                    None,
                    configurations,
                    sub_levels,
                    runner = runner,
                )

        # We know there can be 0 or 1 node...
        if len(user_nodes) > 0:
            level_configuration.user = LoaderUtilities.obtain_text_safe(user_nodes[0])

        return level_configuration
    def _parse_restrictions(self, directory, restriction_nodes):
        restrictions = []
        for restrictions_node in restriction_nodes:
            restriction = LoaderUtilities.obtain_text_safe(restrictions_node)
            restrictions.append(
                restriction
            )

        return restrictions
    def _parse_server_type_module(self, server_type_node):
        text_value = LoaderUtilities.obtain_text_safe(server_type_node)
        if text_value.count('::') != 1:
            raise LoaderErrors.InvalidConfigurationError(
                        'Unknown format: %s. module::variable expected' % text_value
                    )

        module_name, _ = text_value.split('::')
        module_inst = LoaderUtilities.obtain_from_python_path(module_name)
        return module_inst
    def _retrieve_variable(self, format_node):
        text_value = LoaderUtilities.obtain_text_safe(format_node)
        if text_value.count('::') != 1:
            raise LoaderErrors.InvalidConfigurationError(
                        'Unknown format: %s. module::variable expected' % text_value
                    )

        module_name, variable = text_value.split('::')
        module_inst = LoaderUtilities.obtain_from_python_path(module_name)
        try:
            return getattr(module_inst, variable)
        except AttributeError:
            raise LoaderErrors.InvalidConfigurationError(
                    'Unknown format: couldn\'t find %s in %s' % (variable, module_name)
                )
    def _parse_level(self, address, directory, sub_level_nodes):
        sub_level_names = [
                LoaderUtilities.obtain_text_safe(sub_level_node)
                for sub_level_node in sub_level_nodes
            ]

        sub_level_parser = self.PARSER()
        sub_levels_configurations = {}

        for sub_level_name in sub_level_names:
            sub_level_directory = os.sep.join((directory, sub_level_name))
            parsed_sub_level = sub_level_parser.parse(
                    sub_level_directory,
                    self._generate_address_of_sublevel(
                        address,
                        sub_level_name
                    )
                )
            sub_levels_configurations[sub_level_name] = parsed_sub_level

        return sub_levels_configurations
 def _parse_implementation(self, implementation_node):
     implementation_class_name = LoaderUtilities.obtain_text_safe(implementation_node)
     return LoaderUtilities.obtain_from_python_path(implementation_class_name)