def from_dict(cls, data):
        """Create a new Measurement subclass instance using the given dict.

        If Measurement.name_from_class was previously called with this data's
        associated Measurement sub-class in Python, the returned object will be
        an instance of that sub-class. If the measurement name in ``data`` is
        unrecognized, the returned object will be of the generic ``Measurement``
        type.

        Args:
            data (dict): the data for the new measurement, including at least a
                name and value.
        """

        args = []

        if 'id' in data and 'data' in data:
            measurement_class = CanMessage
            args.append("Bus %s: 0x%x" % (data.get('bus', '?'), data['id']))
            args.append(data['data'])
            # TODO grab bus
        else:
            measurement_class = cls._class_from_name(data['name'])
            if measurement_class == Measurement:
                args.append(data['name'])
            args.append(data['value'])

        return measurement_class(*args, event=data.get('event', None),
                override_unit=True)
def from_dict ( cls , data ) : args = [ ] if 'id' in data and 'data' in data : measurement_class = CanMessage args . append ( "Bus %s: 0x%x" % ( data . get ( 'bus' , '?' ) , data [ 'id' ] ) ) args . append ( data [ 'data' ] ) else : measurement_class = cls . _class_from_name ( data [ 'name' ] ) if measurement_class == Measurement : args . append ( data [ 'name' ] ) args . append ( data [ 'value' ] ) return measurement_class ( * args , event = data . get ( 'event' , None ) , override_unit = True )
Create a new Measurement subclass instance using the given dict.

        If Measurement.name_from_class was previously called with this data's
        associated Measurement sub-class in Python, the returned object will be
        an instance of that sub-class. If the measurement name in ``data`` is
        unrecognized, the returned object will be of the generic ``Measurement``
        type.

        Args:
            data (dict): the data for the new measurement, including at least a
                name and value.