webthing/thing.py
def as_thing_description(self):
        """
        Return the thing state as a Thing Description.

        Returns the state as a dictionary.
        """
        thing = {
            'name': self.name,
            'href': self.href_prefix if self.href_prefix else '/',
            '@context': self.context,
            '@type': self.type,
            'properties': self.get_property_descriptions(),
            'actions': {},
            'events': {},
            'links': [
                {
                    'rel': 'properties',
                    'href': '{}/properties'.format(self.href_prefix),
                },
                {
                    'rel': 'actions',
                    'href': '{}/actions'.format(self.href_prefix),
                },
                {
                    'rel': 'events',
                    'href': '{}/events'.format(self.href_prefix),
                },
            ],
        }

        for name, action in self.available_actions.items():
            thing['actions'][name] = action['metadata']
            thing['actions'][name]['links'] = [
                {
                    'rel': 'action',
                    'href': '{}/actions/{}'.format(self.href_prefix, name),
                },
            ]

        for name, event in self.available_events.items():
            thing['events'][name] = event['metadata']
            thing['events'][name]['links'] = [
                {
                    'rel': 'event',
                    'href': '{}/events/{}'.format(self.href_prefix, name),
                },
            ]

        if self.ui_href is not None:
            thing['links'].append({
                'rel': 'alternate',
                'mediaType': 'text/html',
                'href': self.ui_href,
            })

        if self.description:
            thing['description'] = self.description

        return thing
def as_thing_description(self):
        thing = {
            'name': self.name,
            'href': self.href_prefix if self.href_prefix else '/',
            '@context': self.context,
            '@type': self.type,
            'properties': self.get_property_descriptions(),
            'actions': {},
            'events': {},
            'links': [
                {
                    'rel': 'properties',
                    'href': '{}/properties'.format(self.href_prefix),
                },
                {
                    'rel': 'actions',
                    'href': '{}/actions'.format(self.href_prefix),
                },
                {
                    'rel': 'events',
                    'href': '{}/events'.format(self.href_prefix),
                },
            ],
        }

        for name, action in self.available_actions.items():
            thing['actions'][name] = action['metadata']
            thing['actions'][name]['links'] = [
                {
                    'rel': 'action',
                    'href': '{}/actions/{}'.format(self.href_prefix, name),
                },
            ]

        for name, event in self.available_events.items():
            thing['events'][name] = event['metadata']
            thing['events'][name]['links'] = [
                {
                    'rel': 'event',
                    'href': '{}/events/{}'.format(self.href_prefix, name),
                },
            ]

        if self.ui_href is not None:
            thing['links'].append({
                'rel': 'alternate',
                'mediaType': 'text/html',
                'href': self.ui_href,
            })

        if self.description:
            thing['description'] = self.description

        return thing
def as_thing_description ( self ) : thing = { 'name' : self . name , 'href' : self . href_prefix if self . href_prefix else '/' , '@context' : self . context , '@type' : self . type , 'properties' : self . get_property_descriptions ( ) , 'actions' : { } , 'events' : { } , 'links' : [ { 'rel' : 'properties' , 'href' : '{}/properties' . format ( self . href_prefix ) , } , { 'rel' : 'actions' , 'href' : '{}/actions' . format ( self . href_prefix ) , } , { 'rel' : 'events' , 'href' : '{}/events' . format ( self . href_prefix ) , } , ] , } for name , action in self . available_actions . items ( ) : thing [ 'actions' ] [ name ] = action [ 'metadata' ] thing [ 'actions' ] [ name ] [ 'links' ] = [ { 'rel' : 'action' , 'href' : '{}/actions/{}' . format ( self . href_prefix , name ) , } , ] for name , event in self . available_events . items ( ) : thing [ 'events' ] [ name ] = event [ 'metadata' ] thing [ 'events' ] [ name ] [ 'links' ] = [ { 'rel' : 'event' , 'href' : '{}/events/{}' . format ( self . href_prefix , name ) , } , ] if self . ui_href is not None : thing [ 'links' ] . append ( { 'rel' : 'alternate' , 'mediaType' : 'text/html' , 'href' : self . ui_href , } ) if self . description : thing [ 'description' ] = self . description return thing
Return the thing state as a Thing Description.

        Returns the state as a dictionary.
Return the thing state as a Thing Description .