summaryrefslogtreecommitdiff
path: root/slixmpp/plugins/xep_0323/device.py
diff options
context:
space:
mode:
Diffstat (limited to 'slixmpp/plugins/xep_0323/device.py')
-rw-r--r--slixmpp/plugins/xep_0323/device.py64
1 files changed, 32 insertions, 32 deletions
diff --git a/slixmpp/plugins/xep_0323/device.py b/slixmpp/plugins/xep_0323/device.py
index 592cac75..b4142003 100644
--- a/slixmpp/plugins/xep_0323/device.py
+++ b/slixmpp/plugins/xep_0323/device.py
@@ -27,7 +27,7 @@ class Device(object):
# {'type':'numeric',
# 'name':'myname',
# 'value': 42,
- # 'unit':'Z'}];
+ # 'unit':'Z'}]
self.timestamp_data = {}
self.momentary_data = {}
self.momentary_timestamp = ""
@@ -41,8 +41,8 @@ class Device(object):
field -- The field name
"""
if field in self.fields.keys():
- return True;
- return False;
+ return True
+ return False
def refresh(self, fields):
"""
@@ -101,10 +101,10 @@ class Device(object):
for f in fields:
if f not in self.fields.keys():
self._send_reject(session, callback)
- return False;
+ return False
else:
# Request all fields
- fields = self.fields.keys();
+ fields = self.fields.keys()
# Refresh data from device
@@ -114,15 +114,15 @@ class Device(object):
if "momentary" in flags and flags['momentary'] == "true" or \
"all" in flags and flags['all'] == "true":
- ts_block = {};
- timestamp = "";
+ ts_block = {}
+ timestamp = ""
if len(self.momentary_timestamp) > 0:
- timestamp = self.momentary_timestamp;
+ timestamp = self.momentary_timestamp
else:
- timestamp = self._get_timestamp();
+ timestamp = self._get_timestamp()
- field_block = [];
+ field_block = []
for f in self.momentary_data:
if f in fields:
field_block.append({"name": f,
@@ -130,11 +130,11 @@ class Device(object):
"unit": self.fields[f]["unit"],
"dataType": self.fields[f]["dataType"],
"value": self.momentary_data[f]["value"],
- "flags": self.momentary_data[f]["flags"]});
- ts_block["timestamp"] = timestamp;
- ts_block["fields"] = field_block;
+ "flags": self.momentary_data[f]["flags"]})
+ ts_block["timestamp"] = timestamp
+ ts_block["fields"] = field_block
- callback(session, result="done", nodeId=self.nodeId, timestamp_block=ts_block);
+ callback(session, result="done", nodeId=self.nodeId, timestamp_block=ts_block)
return
from_flag = self._datetime_flag_parser(flags, 'from')
@@ -151,8 +151,8 @@ class Device(object):
#print (str(tsdt) + " > " + str(to_flag))
continue
- ts_block = {};
- field_block = [];
+ ts_block = {}
+ field_block = []
for f in self.timestamp_data[ts]:
if f in fields:
@@ -161,12 +161,12 @@ class Device(object):
"unit": self.fields[f]["unit"],
"dataType": self.fields[f]["dataType"],
"value": self.timestamp_data[ts][f]["value"],
- "flags": self.timestamp_data[ts][f]["flags"]});
+ "flags": self.timestamp_data[ts][f]["flags"]})
- ts_block["timestamp"] = ts;
- ts_block["fields"] = field_block;
- callback(session, result="fields", nodeId=self.nodeId, timestamp_block=ts_block);
- callback(session, result="done", nodeId=self.nodeId, timestamp_block=None);
+ ts_block["timestamp"] = ts
+ ts_block["fields"] = field_block
+ callback(session, result="fields", nodeId=self.nodeId, timestamp_block=ts_block)
+ callback(session, result="done", nodeId=self.nodeId, timestamp_block=None)
def _datetime_flag_parser(self, flags, flagname):
if not flagname in flags:
@@ -195,7 +195,7 @@ class Device(object):
session -- Session id, see definition in request_fields function
callback -- Callback function, see definition in request_fields function
"""
- callback(session, result="error", nodeId=self.nodeId, timestamp_block=None, error_msg="Reject");
+ callback(session, result="error", nodeId=self.nodeId, timestamp_block=None, error_msg="Reject")
def _add_field(self, name, typename, unit=None, dataType=None):
"""
@@ -207,7 +207,7 @@ class Device(object):
unit -- [optional] only applies to "numeric". Unit for the field.
dataType -- [optional] only applies to "enum". Datatype for the field.
"""
- self.fields[name] = {"type": typename, "unit": unit, "dataType": dataType};
+ self.fields[name] = {"type": typename, "unit": unit, "dataType": dataType}
def _add_field_timestamp_data(self, name, timestamp, value, flags=None):
"""
@@ -221,12 +221,12 @@ class Device(object):
Formatted as a dictionary like { "flag name": "flag value" ... }
"""
if not name in self.fields.keys():
- return False;
+ return False
if not timestamp in self.timestamp_data:
- self.timestamp_data[timestamp] = {};
+ self.timestamp_data[timestamp] = {}
- self.timestamp_data[timestamp][name] = {"value": value, "flags": flags};
- return True;
+ self.timestamp_data[timestamp][name] = {"value": value, "flags": flags}
+ return True
def _add_field_momentary_data(self, name, value, flags=None):
"""
@@ -239,17 +239,17 @@ class Device(object):
Formatted as a dictionary like { "flag name": "flag value" ... }
"""
if name not in self.fields:
- return False;
+ return False
if flags is None:
- flags = {};
+ flags = {}
flags["momentary"] = "true"
- self.momentary_data[name] = {"value": value, "flags": flags};
- return True;
+ self.momentary_data[name] = {"value": value, "flags": flags}
+ return True
def _set_momentary_timestamp(self, timestamp):
"""
This function is only for unit testing to produce predictable results.
"""
- self.momentary_timestamp = timestamp;
+ self.momentary_timestamp = timestamp