def __init__(self, id_, value, tags=list(), minValue=None, maxValue=None, unit=None, at=None, datapoints=None): """ Create a new Data :param id_: the identifier of this data :type id_: `int` :param value: the value of the data :type value: `float` :param tags: the tags on this data :type tags: `list` :param maxValue: the maximum value of this data :type maxValue: `float` :param minValue: the minimum value of this data :type minValue: `float` :param unit: a `Unit` for this data :type unit: `Unit` :param datapoints: additional datapoints beyond current_value :type datapoints: `DataPoint` """ _assertPosInt(id_, "id", True) self._id = id_ self._value = value self._tags = tags self._minValue = minValue self._maxValue = maxValue if unit is not None and not isinstance(unit, Unit): raise ValueError("unit must be an instance of Unit, got {}".format(type(unit))) self._unit = unit if at is not None and not isinstance(at, datetime): raise ValueError("at must be an instance of datetime.datetime, " "got {}".format(type(at))) self._at = at self._datapoints = datapoints
def __init__( self, title=None, feed=None, status=None, description=None, icon=None, website=None, email=None, updated=None, creator=None, id_=None, private=None, ): """ Create a new `Environment`. :raise Exception: if sg is wrong :param title: the title :type title: `str` :param feed: the url to this `Environment`'s feed :type feed: `str` :param status: the status, valid values: ``frozen``, ``live`` :type status: `str` :param description: a descriptive text :type description: `str` :param icon: an url to an icon :type icon: `str` :param website: the url to a website :type website: `str` :param email: an email address :type email: `str` :param updated: the time of update :type updated: `datetime.date` :param creator: the name of the creator :type creator: `str` :param id_: an identifier :type id_: `int` """ self._title = title self._feed = feed if status and status not in ["frozen", "live"]: raise ValueError("status must be either 'frozen' or 'live', " "got {}".format(status)) self._status = status self._description = description self._icon = icon self._website = website self._email = email self._updated = updated self._creator = creator _assertPosInt(id_, "id", False) self._id = id_ self._location = None self._data = [] self._private = None if isinstance(private, bool): self._private = private elif private is not None: raise ValueError("private is expected to be bool, got {}".format(type(private)))
def data(self, data): unit = data._unit at = data._at id_ = data._id _assertPosInt(id_, 'id', True) if unit is not None and not isinstance(unit, Unit): raise ValueError("unit must be an instance of Unit, got {}".format( type(unit))) if at is not None and not isinstance(at, datetime): raise ValueError("at must be an instance of datetime.datetime, " "got {}".format(type(at)))
def environment(self, env): status = env._status id_ = env._id private = env._private if status is not None and status not in ['frozen', 'live']: raise ValueError("status must be either 'frozen' or 'live', " "got {}".format(status)) _assertPosInt(id_, 'id', False) if private is not None and not isinstance(private, bool): raise ValueError("private is expected to be bool, got {}".format( type(private)))
def data(self, data): unit = data._unit at = data._at id_ = data._id _assertPosInt(id_, 'id', True) if unit is not None and not isinstance(unit, Unit): raise ValueError("unit must be an instance of Unit, got {}" .format(type(unit))) if at is not None and not isinstance(at, datetime): raise ValueError("at must be an instance of datetime.datetime, " "got {}".format(type(at)))
def environment(self, env): status = env._status id_ = env._id private = env._private if status is not None and status not in ['frozen', 'live']: raise ValueError("status must be either 'frozen' or 'live', " "got {}".format(status)) _assertPosInt(id_, 'id', False) if private is not None and not isinstance(private, bool): raise ValueError("private is expected to be bool, got {}" .format(type(private)))
def __init__(self, id_, values=list()): """ Create a new DataPoints. We want to be able to simply add a DataPoints object to the Environment via updateData, so we have to specify the id of the Data object that will include this DataPoints. :param id_: This is the id of the Data object that this DataPoints will belong to :type id: positive `int` :param values: the value of the data points, pairs of (value, date), where date is optional :type values: `float` """ _assertPosInt(id_, "id", True) self._id = id_ self._values = values
def datapoints(self, datapoints): id_ = datapoints._id _assertPosInt(id_, 'id', True)