Esempio n. 1
0
    def _parse_wiring_views(self, wiring_element):

        wiring_views = []

        for view in self._graph.objects(wiring_element, WIRE_M['hasWiringView']):
            element_view = {
                'label': self._get_field(RDFS, 'label', view),
                'iwidgets': {},
                'operators': {},
                'connections': []
            }

            for entity_view in self._graph.objects(view, WIRE_M['hasView']):

                type_ = self._get_field(WIRE, 'type', entity_view)
                id_ = self._get_field(WIRE, 'id', entity_view)
                position = self._get_field(WIRE_M, 'hasPosition', entity_view, id_=True)
                pos = {
                    'posX': self._get_field(WIRE_M, 'x', position),
                    'posY': self._get_field(WIRE_M, 'y', position)
                }
                endPointOut = {}
                sorted_sources = sorted(self._graph.objects(entity_view, WIRE_M['hasSource']), key=lambda source: possible_int(self._get_field(WIRE, 'index', source, required=False)))
                source = []
                for sourc in sorted_sources:
                    source.append(self._get_field(RDFS, 'label', sourc))

                endPointOut['sources'] = source

                sorted_targets = sorted(self._graph.objects(entity_view, WIRE_M['hasTarget']), key=lambda target: possible_int(self._get_field(WIRE, 'index', target, required=False)))
                target = []
                for targ in sorted_targets:
                    target.append(self._get_field(RDFS, 'label', targ))

                endPointOut['targets'] = target

                if type_ == 'widget':
                    element_view['iwidgets'][id_] = {
                        'position': pos,
                        'endPointsInOuts': endPointOut
                    }
                elif type_ == 'operator':
                    element_view['operators'][id_] = {
                        'position': pos,
                        'endPointsInOuts': endPointOut
                    }

            wiring_views.append(element_view)
        self._info['wiring']['views'] = wiring_views

        # TODO: update to the new wiring format
        inputs = self._info['wiring']['inputs']
        outputs = self._info['wiring']['outputs']
        self._info['wiring'] = parse_wiring_old_version(self._info['wiring'])
        self._info['wiring']['inputs'] = inputs
        self._info['wiring']['outputs'] = outputs
    def forwards(self, orm):
        for workspace in orm.Workspace.objects.all():
            wiring_status = json.loads(workspace.wiringStatus)

            # check if this wiring status is old version (1.0) or is empty
            if not self._need_to_upgrade(wiring_status):
                continue

            new_version = parse_wiring_old_version(wiring_status)

            workspace.wiringStatus = json.dumps(new_version)
            workspace.save()
Esempio n. 3
0
    def forwards(self, orm):
        for workspace in orm.Workspace.objects.all():

            # check if this wiring status is empty string
            if not workspace.wiringStatus:
                wiring_status = {}
            else:
                wiring_status = json.loads(workspace.wiringStatus)

            # check if this wiring status is empty object
            if not wiring_status:
                workspace.wiringStatus = json.dumps(get_wiring_skeleton())
                workspace.save()
                continue

            # check if this wiring status is old version (1.0)
            if not self._need_to_upgrade(wiring_status):
                continue

            new_version = parse_wiring_old_version(wiring_status)

            workspace.wiringStatus = json.dumps(new_version)
            workspace.save()
def build_json_template_from_workspace(options, workspace, user):
    options['type'] = 'mashup'
    options['params'] = []
    options['embedmacs'] = options.get('embedmacs', False) is True
    options['embedded'] = set()
    options['translations'] = {}
    options['translation_index_usage'] = {}

    description = options.get('description', '').strip()
    if description == '':
        options['description'] = get_workspace_description(workspace)

    if 'authors' not in options:
        options['authors'] = ({'name': six.text_type(user)}, )
    elif isinstance(options['authors'], six.text_type):
        options['authors'] = parse_contacts_info(options['authors'])

    if 'contributors' not in options:
        options['contributors'] = ()
    elif isinstance(options['contributors'], six.text_type):
        options['contributors'] = parse_contacts_info(options['contributors'])

    options['requirements'] = []

    readOnlyWidgets = options.get('readOnlyWidgets', False)
    parametrization = options.get('parametrization')
    if not parametrization:
        parametrization = {}
    if 'iwidgets' not in parametrization:
        parametrization['iwidgets'] = {}
    if 'ioperators' not in parametrization:
        parametrization['ioperators'] = {}

    # Workspace preferences
    options['preferences'] = {}
    for preference in workspace.workspacepreference_set.all():
        if not preference.inherit:
            options['preferences'][preference.name] = preference.value

    # Tabs and their preferences
    options['tabs'] = []
    options['wiring'] = {
        'inputs': [],
        'outputs': [],
    }
    for tab in workspace.tab_set.order_by('position'):
        preferences = {}
        for preference in tab.tabpreference_set.all():
            if not preference.inherit:
                preferences[preference.name] = preference.value

        resources = []
        for iwidget in tab.iwidget_set.select_related(
                'widget__resource').all():
            resource_info = process_iwidget(workspace, iwidget,
                                            options['wiring'],
                                            parametrization['iwidgets'],
                                            readOnlyWidgets)
            resources.append(resource_info)
            if options['embedmacs']:
                options['embedded'].add('/'.join(
                    (resource_info['vendor'], resource_info['name'],
                     resource_info['version'])))

        options['tabs'].append({
            'name': tab.name,
            'resources': resources,
            'preferences': preferences,
        })

    # wiring conections and operators
    readOnlyConnectables = options.get('readOnlyConnectables', False)
    wiring_status = workspace.wiringStatus
    if len(wiring_status) == 0:
        wiring_status = get_wiring_skeleton()

    # Set the wiring status' version
    if wiring_status.get('version', '1.0') == '1.0':
        wiring_status = parse_wiring_old_version(wiring_status)

    options['wiring']['version'] = '2.0'
    options['wiring']['operators'] = {}
    for id_, operator in six.iteritems(wiring_status['operators']):
        operator_data = {
            'name': operator['name'],
            'preferences': {},
        }

        vendor, name, version = operator['name'].split('/')
        resource = CatalogueResource.objects.get(vendor=vendor,
                                                 short_name=name,
                                                 version=version)
        operator_info = json.loads(resource.json_description)
        operator_params = parametrization['ioperators'].get(id_, {})
        for pref_index, preference in enumerate(operator_info['preferences']):

            status = 'normal'
            if preference['name'] in operator_params:
                ioperator_param_desc = operator_params[preference['name']]
                status = ioperator_param_desc.get('status', 'normal')
                source = ioperator_param_desc.get('source', 'current')
                if source == 'default':
                    if status == 'normal':
                        # Do not issue a Preference element for this preference
                        continue
                    value = None
                elif source == 'current':
                    value = get_current_operator_pref_value(
                        operator, preference)
                elif source == 'custom':
                    value = ioperator_param_desc['value']
                else:
                    raise Exception('Invalid preference value source: %s' %
                                    source)

            else:
                value = get_current_operator_pref_value(operator, preference)

            operator_data['preferences'][preference['name']] = {
                'readonly': status != 'normal',
                'hidden': status == 'hidden',
            }
            if value is not None:
                operator_data['preferences'][
                    preference['name']]['value'] = value

        options['wiring']['operators'][id_] = operator_data
        if options['embedmacs']:
            options['embedded'].add(operator['name'])

    options['wiring']['connections'] = []
    for connection in wiring_status['connections']:
        options['wiring']['connections'].append({
            'source':
            connection['source'],
            'target':
            connection['target'],
            'readonly':
            readOnlyConnectables,
        })

    options['wiring']['visualdescription'] = wiring_status['visualdescription']

    embedded = options['embedded']
    options['embedded'] = []
    for resource in embedded:
        (vendor, name, version) = resource.split('/')
        options['embedded'].append({
            'vendor':
            vendor,
            'name':
            name,
            'version':
            version,
            'src':
            'macs/%s_%s_%s.wgt' % (vendor, name, version)
        })
    del options['embedmacs']

    return options
Esempio n. 5
0
    def _parse_wiring_info(self):

        if self._info['type'] == 'mashup':
            self._info['wiring'] = get_wiring_skeleton()
        else:
            self._info['wiring'] = {}

        self._info['wiring']['inputs'] = []
        self._info['wiring']['outputs'] = []

        wiring_elements = self._xpath(WIRING_XPATH, self._doc)
        if len(wiring_elements) != 0:
            wiring_element = wiring_elements[0]

            for slot in self._xpath(INPUT_ENDPOINT_XPATH, wiring_element):
                self._add_translation_index(text_type(slot.get('label')), type='inputendpoint', variable=slot.get('name'))
                self._add_translation_index(text_type(slot.get('actionlabel', '')), type='inputendpoint', variable=slot.get('name'))
                self._add_translation_index(text_type(slot.get('description', '')), type='inputendpoint', variable=slot.get('name'))
                self._info['wiring']['inputs'].append({
                    'name': text_type(slot.get('name')),
                    'type': text_type(slot.get('type')),
                    'label': text_type(slot.get('label', '')),
                    'description': text_type(slot.get('description', '')),
                    'actionlabel': text_type(slot.get('actionlabel', '')),
                    'friendcode': text_type(slot.get('friendcode', '')),
                })

            for event in self._xpath(OUTPUT_ENDPOINT_XPATH, wiring_element):
                self._add_translation_index(text_type(event.get('label')), type='outputendpoint', variable=event.get('name'))
                self._add_translation_index(text_type(event.get('description', '')), type='outputendpoint', variable=event.get('name'))
                self._info['wiring']['outputs'].append({
                    'name': text_type(event.get('name')),
                    'type': text_type(event.get('type')),
                    'label': text_type(event.get('label', '')),
                    'description': text_type(event.get('description', '')),
                    'friendcode': text_type(event.get('friendcode', '')),
                })

        if self._info['type'] == "mashup":

            mashup_wiring_element = self.get_xpath(MASHUP_WIRING_XPATH, self._doc, required=False)
            if mashup_wiring_element is None:
                return

            self._info['wiring']['version'] = text_type(mashup_wiring_element.get('version', "1.0"))

            self._parse_wiring_connection_info(mashup_wiring_element)
            self._parse_wiring_operator_info(mashup_wiring_element)

            if self._info['wiring']['version'] == '1.0':
                # TODO: update to the new wiring format
                inputs = self._info['wiring']['inputs']
                outputs = self._info['wiring']['outputs']
                self._info['wiring'] = parse_wiring_old_version(self._info['wiring'])
                self._info['wiring']['inputs'] = inputs
                self._info['wiring']['outputs'] = outputs
                # END TODO
            elif self._info['wiring']['version'] == '2.0':
                visualdescription_element = self.get_xpath(VISUALDESCRIPTION_XPATH, mashup_wiring_element, required=False)
                if visualdescription_element is not None:
                    self._parse_visualdescription_info(visualdescription_element)
            else:
                # TODO raise unsupported version exception
                pass
Esempio n. 6
0
    def _init(self):

        self._check_string_fields(
            ('title', 'description', 'longdescription', 'email', 'homepage',
             'doc', 'changelog', 'image', 'smartphoneimage', 'license',
             'licenseurl', 'issuetracker'))
        self._check_contacts_fields(('authors', 'contributors'))

        # Normalize/check preferences and properties (only for widgets and operators)
        if self._info['type'] != 'mashup':

            self._check_array_fields(('preferences', 'properties'))
            for preference in self._info['preferences']:
                self._check_string_fields(('name', 'type'),
                                          place=preference,
                                          required=True)
                self._check_string_fields(('label', 'description', 'default'),
                                          place=preference)
                self._check_boolean_fields(('readonly', 'secure'),
                                           place=preference,
                                           default=False)
                self._check_string_fields(('value', ),
                                          place=preference,
                                          null=True,
                                          default=None)

            for prop in self._info['properties']:
                self._check_string_fields(('name', 'type'),
                                          place=prop,
                                          required=True)
                self._check_string_fields(('label', 'description', 'default'),
                                          place=prop)
                self._check_boolean_fields(('secure', ),
                                           place=prop,
                                           default=False)

        if self._info['type'] == 'widget':

            self._check_array_fields(('altcontents', ))
            if self._info.get('contents', None) is None:
                raise TemplateParseException('Missing widget content info')
            if not isinstance(self._info['contents'], dict):
                raise TemplateParseException('Content info must be an object')

            self._check_contents_field(self._info['contents'],
                                       alternative=False)
            for altcontent in self._info['altcontents']:
                self._check_contents_field(altcontent)

        elif self._info['type'] == 'mashup':

            self._check_array_fields(('params', 'embedded'))
            for resource in self._info['embedded']:
                if isinstance(resource, dict):
                    self._check_string_fields(
                        ('vendor', 'name', 'version', 'src'),
                        place=resource,
                        required=True)
                else:
                    raise TemplateParseException(
                        'embedded resource info must be an object')

            if 'wiring' not in self._info:
                self._info['wiring'] = get_wiring_skeleton()

            self._check_string_fields(('version', ),
                                      place=self._info['wiring'],
                                      default='1.0')

            if self._info['wiring']['version'] == '1.0':

                # TODO: update to the new wiring format
                inputs = self._info['wiring']['inputs']
                outputs = self._info['wiring']['outputs']
                self._info['wiring'] = parse_wiring_old_version(
                    self._info['wiring'])
                self._info['wiring']['inputs'] = inputs
                self._info['wiring']['outputs'] = outputs
                # END TODO

            elif self._info['wiring']['version'] == '2.0':

                if 'visualdescription' not in self._info['wiring']:
                    self._info['wiring']['visualdescription'] = {}

                self._check_array_fields(
                    'behaviours',
                    place=self._info['wiring']['visualdescription'],
                    required=False)
                self._check_behaviour_view_fields(
                    self._info['wiring']['visualdescription'])
                for behaviour in self._info['wiring']['visualdescription'][
                        'behaviours']:
                    self._check_behaviour_view_fields(behaviour)

        if not 'wiring' in self._info:
            self._info['wiring'] = {}

        self._check_array_fields(('inputs', 'outputs'),
                                 place=self._info['wiring'],
                                 required=False)

        # Translations
        self._check_string_fields(('default_lang', ), default='en')
        self._info['translation_index_usage'] = {}
        if 'translations' not in self._info:
            self._info['translations'] = {}

        self._add_translation_index(self._info['title'],
                                    type='resource',
                                    field='title')
        self._add_translation_index(self._info['description'],
                                    type='resource',
                                    field='description')

        if self._info['type'] != 'mashup':
            for preference in self._info['preferences']:
                self._add_translation_index(preference['label'],
                                            type='vdef',
                                            variable=preference['name'],
                                            field='label')
                self._add_translation_index(preference['description'],
                                            type='vdef',
                                            variable=preference['name'],
                                            field='description')

                if preference['type'] == 'list':
                    for option_index, option in enumerate(
                            preference['options']):
                        self._add_translation_index(
                            option['label'],
                            type='upo',
                            variable=preference['name'],
                            option=option_index)

            for prop in self._info['properties']:
                self._add_translation_index(prop['label'],
                                            type='vdef',
                                            variable=prop['name'],
                                            field='label')
                self._add_translation_index(prop['description'],
                                            type='vdef',
                                            variable=prop['name'],
                                            field='description')

            for input_endpoint in self._info['wiring']['inputs']:
                self._check_string_fields(('name', 'type'),
                                          required=True,
                                          place=input_endpoint)
                self._check_string_fields(
                    ('label', 'description', 'actionlabel', 'friendcode'),
                    place=input_endpoint)
                self._add_translation_index(input_endpoint['label'],
                                            type='inputendpoint',
                                            variable=input_endpoint['name'],
                                            field='label')
                self._add_translation_index(input_endpoint['description'],
                                            type='inputendpoint',
                                            variable=input_endpoint['name'],
                                            field='description')
                self._add_translation_index(input_endpoint['actionlabel'],
                                            type='inputendpoint',
                                            variable=input_endpoint['name'],
                                            field='actionlabel')

            for output_endpoint in self._info['wiring']['outputs']:
                self._check_string_fields(('name', 'type'),
                                          required=True,
                                          place=output_endpoint)
                self._check_string_fields(
                    ('label', 'description', 'friendcode'),
                    place=output_endpoint)
                self._add_translation_index(output_endpoint['label'],
                                            type='outputendpoint',
                                            variable=output_endpoint['name'],
                                            field='label')
                self._add_translation_index(output_endpoint['description'],
                                            type='outputendpoint',
                                            variable=output_endpoint['name'],
                                            field='description')

        # Requirements
        self._check_array_fields(('requirements', ))
Esempio n. 7
0
    def _init(self):

        self._check_string_fields(('title', 'description', 'longdescription', 'email',  'homepage','doc', 'changelog', 'image', 'smartphoneimage', 'license', 'licenseurl', 'issuetracker'))
        self._check_contacts_fields(('authors', 'contributors'))

        # Normalize/check preferences and properties (only for widgets and operators)
        if self._info['type'] != 'mashup':

            self._check_array_fields(('preferences', 'properties'))
            for preference in self._info['preferences']:
                self._check_string_fields(('name', 'type'), place=preference, required=True)
                self._check_string_fields(('label', 'description', 'default'), place=preference)
                self._check_boolean_fields(('readonly', 'secure'), place=preference, default=False)
                self._check_string_fields(('value',), place=preference, null=True, default=None)

            for prop in self._info['properties']:
                self._check_string_fields(('name', 'type'), place=prop, required=True)
                self._check_string_fields(('label', 'description', 'default'), place=prop)
                self._check_boolean_fields(('secure',), place=prop, default=False)

        if self._info['type'] == 'widget':

            self._check_array_fields(('altcontents',))
            if self._info.get('contents', None) is None:
                raise TemplateParseException('Missing widget content info')
            if not isinstance(self._info['contents'], dict):
                raise TemplateParseException('Content info must be an object')

            self._check_contents_field(self._info['contents'], alternative=False)
            for altcontent in self._info['altcontents']:
                self._check_contents_field(altcontent)

        elif self._info['type'] == 'mashup':

            self._check_array_fields(('params', 'embedded'))
            for resource in self._info['embedded']:
                if isinstance(resource, dict):
                    self._check_string_fields(('vendor', 'name', 'version', 'src'), place=resource, required=True)
                else:
                    raise TemplateParseException('embedded resource info must be an object')

            if 'wiring' not in self._info:
                self._info['wiring'] = get_wiring_skeleton()

            self._check_string_fields(('version',), place=self._info['wiring'], default='1.0')

            if self._info['wiring']['version'] == '1.0':

                # TODO: update to the new wiring format
                inputs = self._info['wiring']['inputs']
                outputs = self._info['wiring']['outputs']
                self._info['wiring'] = parse_wiring_old_version(self._info['wiring'])
                self._info['wiring']['inputs'] = inputs
                self._info['wiring']['outputs'] = outputs
                # END TODO

            elif self._info['wiring']['version'] == '2.0':

                if 'visualdescription' not in self._info['wiring']:
                    self._info['wiring']['visualdescription'] = {}

                self._check_array_fields('behaviours', place=self._info['wiring']['visualdescription'], required=False)
                self._check_behaviour_view_fields(self._info['wiring']['visualdescription'])
                for behaviour in self._info['wiring']['visualdescription']['behaviours']:
                    self._check_behaviour_view_fields(behaviour)

        if not 'wiring' in self._info:
            self._info['wiring'] = {}

        self._check_array_fields(('inputs', 'outputs'), place=self._info['wiring'], required=False)

        # Translations
        self._check_string_fields(('default_lang',), default='en')
        self._info['translation_index_usage'] = {}
        if 'translations' not in self._info:
            self._info['translations'] = {}

        self._add_translation_index(self._info['title'], type='resource', field='title')
        self._add_translation_index(self._info['description'], type='resource', field='description')

        if self._info['type'] != 'mashup':
            for preference in self._info['preferences']:
                self._add_translation_index(preference['label'], type='vdef', variable=preference['name'], field='label')
                self._add_translation_index(preference['description'], type='vdef', variable=preference['name'], field='description')

                if preference['type'] == 'list':
                    for option_index, option in enumerate(preference['options']):
                        self._add_translation_index(option['label'], type='upo', variable=preference['name'], option=option_index)

            for prop in self._info['properties']:
                self._add_translation_index(prop['label'], type='vdef', variable=prop['name'], field='label')
                self._add_translation_index(prop['description'], type='vdef', variable=prop['name'], field='description')

            for input_endpoint in self._info['wiring']['inputs']:
                self._check_string_fields(('name', 'type'), required=True, place=input_endpoint)
                self._check_string_fields(('label', 'description', 'actionlabel', 'friendcode'), place=input_endpoint)
                self._add_translation_index(input_endpoint['label'], type='inputendpoint', variable=input_endpoint['name'], field='label')
                self._add_translation_index(input_endpoint['description'], type='inputendpoint', variable=input_endpoint['name'], field='description')
                self._add_translation_index(input_endpoint['actionlabel'], type='inputendpoint', variable=input_endpoint['name'], field='actionlabel')

            for output_endpoint in self._info['wiring']['outputs']:
                self._check_string_fields(('name', 'type'), required=True, place=output_endpoint)
                self._check_string_fields(('label', 'description', 'friendcode'), place=output_endpoint)
                self._add_translation_index(output_endpoint['label'], type='outputendpoint', variable=output_endpoint['name'], field='label')
                self._add_translation_index(output_endpoint['description'], type='outputendpoint', variable=output_endpoint['name'], field='description')

        # Requirements
        self._check_array_fields(('requirements',))
def build_json_template_from_workspace(options, workspace, user):
    options['type'] = 'mashup'
    options['params'] = []
    options['embedmacs'] = options.get('embedmacs', False) is True
    options['embedded'] = set()
    options['translations'] = {}
    options['translation_index_usage'] = {}

    description = options.get('description', '').strip()
    if description == '':
        options['description'] = get_workspace_description(workspace)

    if 'authors' not in options:
        options['authors'] = ({'name': six.text_type(user)},)
    elif isinstance(options['authors'], six.text_type):
        options['authors'] = parse_contacts_info(options['authors'])

    if 'contributors' not in options:
        options['contributors'] = ()
    elif isinstance(options['contributors'], six.text_type):
        options['contributors'] = parse_contacts_info(options['contributors'])

    options['requirements'] = []

    readOnlyWidgets = options.get('readOnlyWidgets', False)
    parametrization = options.get('parametrization')
    if not parametrization:
        parametrization = {}
    if 'iwidgets' not in parametrization:
        parametrization['iwidgets'] = {}
    if 'ioperators' not in parametrization:
        parametrization['ioperators'] = {}

    # Workspace preferences
    options['preferences'] = {}
    for preference in workspace.workspacepreference_set.all():
        if not preference.inherit:
            options['preferences'][preference.name] = preference.value

    # Tabs and their preferences
    options['tabs'] = []
    options['wiring'] = {
        'inputs': [],
        'outputs': [],
    }
    for tab in workspace.tab_set.order_by('position'):
        preferences = {}
        for preference in tab.tabpreference_set.all():
            if not preference.inherit:
                preferences[preference.name] = preference.value

        resources = []
        for iwidget in tab.iwidget_set.select_related('widget__resource').all():
            resource_info = process_iwidget(workspace, iwidget, options['wiring'], parametrization['iwidgets'], readOnlyWidgets)
            resources.append(resource_info)
            if options['embedmacs']:
                options['embedded'].add('/'.join((resource_info['vendor'], resource_info['name'], resource_info['version'])))

        options['tabs'].append({
            'name': tab.name,
            'resources': resources,
            'preferences': preferences,
        })

    # wiring conections and operators
    readOnlyConnectables = options.get('readOnlyConnectables', False)
    wiring_status = workspace.wiringStatus
    if len(wiring_status) == 0:
        wiring_status = get_wiring_skeleton()

    # Set the wiring status' version
    if wiring_status.get('version', '1.0') == '1.0':
        wiring_status = parse_wiring_old_version(wiring_status)

    options['wiring']['version'] = '2.0'
    options['wiring']['operators'] = {}
    for id_, operator in six.iteritems(wiring_status['operators']):
        operator_data = {
            'name': operator['name'],
            'preferences': {},
        }

        vendor, name, version = operator['name'].split('/')
        resource = CatalogueResource.objects.get(vendor=vendor, short_name=name, version=version)
        operator_info = json.loads(resource.json_description)
        operator_params = parametrization['ioperators'].get(id_, {})
        for pref_index, preference in enumerate(operator_info['preferences']):

            status = 'normal'
            if preference['name'] in operator_params:
                ioperator_param_desc = operator_params[preference['name']]
                status = ioperator_param_desc.get('status', 'normal')
                source = ioperator_param_desc.get('source', 'current')
                if source == 'default':
                    if status == 'normal':
                        # Do not issue a Preference element for this preference
                        continue
                    value = None
                elif source == 'current':
                    value = get_current_operator_pref_value(operator, preference)
                elif source == 'custom':
                    value = ioperator_param_desc['value']
                else:
                    raise Exception('Invalid preference value source: %s' % source)

            else:
                value = get_current_operator_pref_value(operator, preference)

            operator_data['preferences'][preference['name']] = {
                'readonly': status != 'normal',
                'hidden': status == 'hidden',
            }
            if value is not None:
                operator_data['preferences'][preference['name']]['value'] = value

        options['wiring']['operators'][id_] = operator_data
        if options['embedmacs']:
            options['embedded'].add(operator['name'])

    options['wiring']['connections'] = []
    for connection in wiring_status['connections']:
        options['wiring']['connections'].append({
            'source': connection['source'],
            'target': connection['target'],
            'readonly': readOnlyConnectables,
        })

    options['wiring']['visualdescription'] = wiring_status['visualdescription']

    embedded = options['embedded']
    options['embedded'] = []
    for resource in embedded:
        (vendor, name, version) = resource.split('/')
        options['embedded'].append({
            'vendor': vendor,
            'name': name,
            'version': version,
            'src': 'macs/%s_%s_%s.wgt' % (vendor, name, version)
        })
    del options['embedmacs']

    return options