def add_module_from_settings(self, module, settings):
        """Adds a module to the registry, with an explicit `ModuleSettings`.

        See :class:`~vistrails.core.modules.config.ModuleSettings`.

        :returns: The new
            :class:`~vistrails.core.modules.module_descriptor.ModuleDescriptor`
        """

        def get_setting(attr, default_val):
            val = getattr(settings, attr)
            if val is None:
                return default_val
            return val

        name = get_setting('name', module.__name__)

        default_identifier = None
        default_version = ""
        if self._current_package is not None:
            default_identifier = self._current_package.identifier
            default_version = self._current_package.version
        identifier = get_setting('package', default_identifier)
        package_version = get_setting('package_version', default_version)
        namespace = settings.namespace
        version = settings.version

        if identifier is None:
            raise VistrailsInternalError("No package is currently being "
                                         "loaded and argument 'package' is "
                                         "not specified.")

        package = self.package_versions[(identifier, package_version)]
        desc_key = (name, namespace, version)
        if desc_key in package.descriptor_versions:
            raise ModuleAlreadyExists(identifier, name)

        # We allow multiple inheritance as long as only one of the superclasses
        # is a subclass of Module.
        if settings.is_root:
            base_descriptor = None
        else:
            candidates = self.get_subclass_candidates(module)
            if len(candidates) != 1:
                raise InvalidModuleClass(module)
            base_class = candidates[0]
            if base_class not in self._module_key_map:
                raise MissingBaseClass(base_class)
            base_descriptor = self.get_descriptor(base_class)

        if module in self._module_key_map:
            # This is really obsolete as having two descriptors
            # pointing to the same module isn't a big deal except to
            # get_descriptor which shouldn't be used often
            if identifier != 'local.abstractions':
                raise DuplicateModule(self.get_descriptor(module), identifier,
                                      name, namespace)
        elif self.has_descriptor_with_name(identifier, name, namespace,
                                           package_version, version):
            raise DuplicateIdentifier(identifier, name, namespace,
                                      package_version, version)
        descriptor = self.update_registry(base_descriptor, module, identifier,
                                          name, namespace, package_version,
                                          version)
        if settings.is_root:
            self.root_descriptor = descriptor

        descriptor.set_module_abstract(settings.abstract)
        descriptor.set_configuration_widget(settings.configure_widget)
        # descriptor.set_configuration_widget(configureWidget)
        descriptor.is_hidden = settings.hide_descriptor
        descriptor.namespace_hidden = settings.hide_namespace

        if settings.signature:
            descriptor.set_hasher_callable(settings.signature)

        if settings.constant_signature:
            if not self.is_constant_module(module):
                raise TypeError("To set constant_signature, module "
                                "must be a subclass of Constant")

            # FIXME, currently only allow one per hash, no versioning
            hash_key = (identifier, name, namespace)
            self._constant_hasher_map[hash_key] = settings.constant_signature

        constant_widgets = []
        if settings.constant_widget:
            constant_widgets += [settings.constant_widget]
        if settings.constant_widgets is not None:
            constant_widgets += settings.constant_widgets
        if len(constant_widgets) > 0:
            if not self.is_constant_module(module):
                raise TypeError("To set constant widgets, module " +
                                "must be a subclass of Constant")
            for widget_t in constant_widgets:
                if isinstance(widget_t, tuple):
                    widget_t = ConstantWidgetConfig(*widget_t)
                else:
                    widget_t = ConstantWidgetConfig(widget_t)
                if widget_t.widget is not None:
                    self.set_constant_config_widget(descriptor,
                                                    widget_t.widget,
                                                    widget_t.widget_type,
                                                    widget_t.widget_use)

        descriptor.set_module_color(settings.color)

        if settings.fringe:
            _check_fringe(settings.fringe)
            left_fringe = list(reversed([(-x, 1.0-y) for (x, y) in \
                                    settings.fringe]))
            descriptor.set_module_fringe(left_fringe, settings.fringe)
        elif settings.left_fringe and settings.right_fringe:
            _check_fringe(settings.left_fringe)
            _check_fringe(settings.right_fringe)
            descriptor.set_module_fringe(settings.left_fringe,
                                         settings.right_fringe)

        if settings.ghost_package:
            descriptor.ghost_identifier = settings.ghost_package
        if settings.ghost_package_version:
            descriptor.ghost_package_version = settings.ghost_package_version
        if settings.ghost_namespace:
            descriptor.ghost_namespace = settings.ghost_namespace

        self.signals.emit_new_module(descriptor)
        if self.is_abstraction(descriptor):
            self.signals.emit_new_abstraction(descriptor)
        return descriptor
dataset/ETHPy150Open VisTrails/VisTrails/vistrails/core/modules/module_registry.py/ModuleRegistry.add_module_from_settings/original