def _coerce_datastream(self, d):
        if isinstance(d, dict):
            datapoints_data = d.pop('datapoints', None)
            unit_data = d.pop('unit', None)
            # Remove version, part of Feed not Datastream
            d.pop('version', None)
            # Strip out the readonly fields and manually set later.
            readonly = {f: d.pop(f) for f in self._readonly_fields if f in d}
            datastream = Datastream(**d)
            # Explicitely set the readonly fields we stripped out earlier.
            for name, value in readonly.items():
                setattr(datastream, name, value)
            if datapoints_data:
                datapoints = self._coerce_datapoints(
                    datastream.datapoints, datapoints_data)
                datastream.datapoints = datapoints
            if unit_data:
                unit = self._coerce_unit(unit_data)
                datastream.unit = unit
        elif isinstance(d, Datastream):
            datastream = d
        datastream._manager = self
        return datastream
Returns a Datastream object from a mapping object (dict).
dataset/ETHPy150Open xively/xively-python/xively/managers.py/DatastreamsManager._coerce_datastream