summaryrefslogtreecommitdiff
path: root/sleekxmpp/plugins/xep_0323/stanza/sensordata.py
diff options
context:
space:
mode:
authorRobin Gloster <robin@loc-com.de>2014-08-18 00:52:24 +0200
committerRobin Gloster <robin@loc-com.de>2014-08-18 00:52:24 +0200
commit7265682a4d57d88956cb54f98f7a470465bbf417 (patch)
treed32011f02f648de9ba2d5ea99d5af1daefecbaf9 /sleekxmpp/plugins/xep_0323/stanza/sensordata.py
parent08c62a6bf1fe19ddf1f0c8fa441750f41f5d9436 (diff)
downloadslixmpp-7265682a4d57d88956cb54f98f7a470465bbf417.tar.gz
slixmpp-7265682a4d57d88956cb54f98f7a470465bbf417.tar.bz2
slixmpp-7265682a4d57d88956cb54f98f7a470465bbf417.tar.xz
slixmpp-7265682a4d57d88956cb54f98f7a470465bbf417.zip
cleanup semicolons, whitespace and mutable default arguments
Diffstat (limited to 'sleekxmpp/plugins/xep_0323/stanza/sensordata.py')
-rw-r--r--sleekxmpp/plugins/xep_0323/stanza/sensordata.py178
1 files changed, 89 insertions, 89 deletions
diff --git a/sleekxmpp/plugins/xep_0323/stanza/sensordata.py b/sleekxmpp/plugins/xep_0323/stanza/sensordata.py
index a11c3e94..e8718161 100644
--- a/sleekxmpp/plugins/xep_0323/stanza/sensordata.py
+++ b/sleekxmpp/plugins/xep_0323/stanza/sensordata.py
@@ -20,14 +20,14 @@ class Sensordata(ElementBase):
interfaces = set(tuple())
class FieldTypes():
- """
+ """
All field types are optional booleans that default to False
"""
field_types = set([ 'momentary','peak','status','computed','identity','historicalSecond','historicalMinute','historicalHour', \
'historicalDay','historicalWeek','historicalMonth','historicalQuarter','historicalYear','historicalOther'])
class FieldStatus():
- """
+ """
All field statuses are optional booleans that default to False
"""
field_status = set([ 'missing','automaticEstimate','manualEstimate','manualReadout','automaticReadout','timeOffset','warning','error', \
@@ -38,12 +38,12 @@ class Request(ElementBase):
name = 'req'
plugin_attrib = name
interfaces = set(['seqnr','nodes','fields','serviceToken','deviceToken','userToken','from','to','when','historical','all'])
- interfaces.update(FieldTypes.field_types);
- _flags = set(['serviceToken','deviceToken','userToken','from','to','when','historical','all']);
- _flags.update(FieldTypes.field_types);
-
+ interfaces.update(FieldTypes.field_types)
+ _flags = set(['serviceToken','deviceToken','userToken','from','to','when','historical','all'])
+ _flags.update(FieldTypes.field_types)
+
def __init__(self, xml=None, parent=None):
- ElementBase.__init__(self, xml, parent);
+ ElementBase.__init__(self, xml, parent)
self._nodes = set()
self._fields = set()
@@ -64,27 +64,27 @@ class Request(ElementBase):
def _get_flags(self):
"""
- Helper function for getting of flags. Returns all flags in
- dictionary format: { "flag name": "flag value" ... }
+ Helper function for getting of flags. Returns all flags in
+ dictionary format: { "flag name": "flag value" ... }
"""
- flags = {};
+ flags = {}
for f in self._flags:
if not self[f] == "":
- flags[f] = self[f];
- return flags;
+ flags[f] = self[f]
+ return flags
def _set_flags(self, flags):
"""
- Helper function for setting of flags.
+ Helper function for setting of flags.
Arguments:
- flags -- Flags in dictionary format: { "flag name": "flag value" ... }
+ flags -- Flags in dictionary format: { "flag name": "flag value" ... }
"""
for f in self._flags:
if flags is not None and f in flags:
- self[f] = flags[f];
+ self[f] = flags[f]
else:
- self[f] = None;
+ self[f] = None
def add_node(self, nodeId, sourceId=None, cacheType=None):
"""
@@ -94,7 +94,7 @@ class Request(ElementBase):
Arguments:
nodeId -- The ID for the node.
sourceId -- [optional] identifying the data source controlling the device
- cacheType -- [optional] narrowing down the search to a specific kind of node
+ cacheType -- [optional] narrowing down the search to a specific kind of node
"""
if nodeId not in self._nodes:
self._nodes.add((nodeId))
@@ -269,7 +269,7 @@ class Error(ElementBase):
:param value: string
"""
- self.xml.text = value;
+ self.xml.text = value
return self
def del_text(self):
@@ -292,7 +292,7 @@ class Fields(ElementBase):
interfaces = set(['seqnr','done','nodes'])
def __init__(self, xml=None, parent=None):
- ElementBase.__init__(self, xml, parent);
+ ElementBase.__init__(self, xml, parent)
self._nodes = set()
def setup(self, xml=None):
@@ -318,7 +318,7 @@ class Fields(ElementBase):
Arguments:
nodeId -- The ID for the node.
sourceId -- [optional] identifying the data source controlling the device
- cacheType -- [optional] narrowing down the search to a specific kind of node
+ cacheType -- [optional] narrowing down the search to a specific kind of node
"""
if nodeId not in self._nodes:
self._nodes.add((nodeId))
@@ -392,7 +392,7 @@ class FieldsNode(ElementBase):
interfaces = set(['nodeId','sourceId','cacheType','timestamps'])
def __init__(self, xml=None, parent=None):
- ElementBase.__init__(self, xml, parent);
+ ElementBase.__init__(self, xml, parent)
self._timestamps = set()
def setup(self, xml=None):
@@ -411,7 +411,7 @@ class FieldsNode(ElementBase):
def add_timestamp(self, timestamp, substanzas=None):
"""
- Add a new timestamp element.
+ Add a new timestamp element.
Arguments:
timestamp -- The timestamp in ISO format.
@@ -423,7 +423,7 @@ class FieldsNode(ElementBase):
ts = Timestamp(parent=self)
ts['value'] = timestamp
if not substanzas is None:
- ts.set_datas(substanzas);
+ ts.set_datas(substanzas)
#print("add_timestamp with substanzas: " + str(substanzas))
self.iterables.append(ts)
#print(str(id(self)) + " added_timestamp: " + str(id(ts)))
@@ -485,7 +485,7 @@ class FieldsNode(ElementBase):
self.iterables.remove(timestamp)
class Field(ElementBase):
- """
+ """
Field element in response Timestamp. This is a base class,
all instances of fields added to Timestamp must be of types:
DataNumeric
@@ -494,17 +494,17 @@ class Field(ElementBase):
DataDateTime
DataTimeSpan
DataEnum
- """
+ """
namespace = 'urn:xmpp:iot:sensordata'
name = 'field'
plugin_attrib = name
- interfaces = set(['name','module','stringIds']);
- interfaces.update(FieldTypes.field_types);
- interfaces.update(FieldStatus.field_status);
+ interfaces = set(['name','module','stringIds'])
+ interfaces.update(FieldTypes.field_types)
+ interfaces.update(FieldStatus.field_status)
- _flags = set();
- _flags.update(FieldTypes.field_types);
- _flags.update(FieldStatus.field_status);
+ _flags = set()
+ _flags.update(FieldTypes.field_types)
+ _flags.update(FieldStatus.field_status)
def set_stringIds(self, value):
"""Verifies stringIds according to regexp from specification XMPP-0323.
@@ -514,7 +514,7 @@ class Field(ElementBase):
pattern = re.compile("^\d+([|]\w+([.]\w+)*([|][^,]*)?)?(,\d+([|]\w+([.]\w+)*([|][^,]*)?)?)*$")
if pattern.match(value) is not None:
- self.xml.stringIds = value;
+ self.xml.stringIds = value
else:
# Bad content, add nothing
pass
@@ -523,30 +523,30 @@ class Field(ElementBase):
def _get_flags(self):
"""
- Helper function for getting of flags. Returns all flags in
- dictionary format: { "flag name": "flag value" ... }
+ Helper function for getting of flags. Returns all flags in
+ dictionary format: { "flag name": "flag value" ... }
"""
- flags = {};
+ flags = {}
for f in self._flags:
if not self[f] == "":
- flags[f] = self[f];
- return flags;
+ flags[f] = self[f]
+ return flags
def _set_flags(self, flags):
"""
- Helper function for setting of flags.
+ Helper function for setting of flags.
Arguments:
- flags -- Flags in dictionary format: { "flag name": "flag value" ... }
+ flags -- Flags in dictionary format: { "flag name": "flag value" ... }
"""
for f in self._flags:
if flags is not None and f in flags:
- self[f] = flags[f];
+ self[f] = flags[f]
else:
- self[f] = None;
+ self[f] = None
def _get_typename(self):
- return "invalid type, use subclasses!";
+ return "invalid type, use subclasses!"
class Timestamp(ElementBase):
@@ -557,7 +557,7 @@ class Timestamp(ElementBase):
interfaces = set(['value','datas'])
def __init__(self, xml=None, parent=None):
- ElementBase.__init__(self, xml, parent);
+ ElementBase.__init__(self, xml, parent)
self._datas = set()
def setup(self, xml=None):
@@ -576,7 +576,7 @@ class Timestamp(ElementBase):
def add_data(self, typename, name, value, module=None, stringIds=None, unit=None, dataType=None, flags=None):
"""
- Add a new data element.
+ Add a new data element.
Arguments:
typename -- The type of data element (numeric, string, boolean, dateTime, timeSpan or enum)
@@ -587,29 +587,29 @@ class Timestamp(ElementBase):
dataType -- [optional] The dataType. Only applicable for type enum
"""
if name not in self._datas:
- dataObj = None;
+ dataObj = None
if typename == "numeric":
- dataObj = DataNumeric(parent=self);
- dataObj['unit'] = unit;
+ dataObj = DataNumeric(parent=self)
+ dataObj['unit'] = unit
elif typename == "string":
- dataObj = DataString(parent=self);
+ dataObj = DataString(parent=self)
elif typename == "boolean":
- dataObj = DataBoolean(parent=self);
+ dataObj = DataBoolean(parent=self)
elif typename == "dateTime":
- dataObj = DataDateTime(parent=self);
+ dataObj = DataDateTime(parent=self)
elif typename == "timeSpan":
- dataObj = DataTimeSpan(parent=self);
+ dataObj = DataTimeSpan(parent=self)
elif typename == "enum":
- dataObj = DataEnum(parent=self);
- dataObj['dataType'] = dataType;
+ dataObj = DataEnum(parent=self)
+ dataObj['dataType'] = dataType
- dataObj['name'] = name;
- dataObj['value'] = value;
- dataObj['module'] = module;
- dataObj['stringIds'] = stringIds;
+ dataObj['name'] = name
+ dataObj['value'] = value
+ dataObj['module'] = module
+ dataObj['stringIds'] = stringIds
if flags is not None:
- dataObj._set_flags(flags);
+ dataObj._set_flags(flags)
self._datas.add(name)
self.iterables.append(dataObj)
@@ -661,87 +661,87 @@ class Timestamp(ElementBase):
self.iterables.remove(data)
class DataNumeric(Field):
- """
- Field data of type numeric.
- Note that the value is expressed as a string.
+ """
+ Field data of type numeric.
+ Note that the value is expressed as a string.
"""
namespace = 'urn:xmpp:iot:sensordata'
name = 'numeric'
plugin_attrib = name
- interfaces = set(['value', 'unit']);
- interfaces.update(Field.interfaces);
+ interfaces = set(['value', 'unit'])
+ interfaces.update(Field.interfaces)
def _get_typename(self):
- return "numeric"
+ return "numeric"
class DataString(Field):
- """
- Field data of type string
+ """
+ Field data of type string
"""
namespace = 'urn:xmpp:iot:sensordata'
name = 'string'
plugin_attrib = name
- interfaces = set(['value']);
- interfaces.update(Field.interfaces);
+ interfaces = set(['value'])
+ interfaces.update(Field.interfaces)
def _get_typename(self):
- return "string"
+ return "string"
class DataBoolean(Field):
- """
+ """
Field data of type boolean.
- Note that the value is expressed as a string.
+ Note that the value is expressed as a string.
"""
namespace = 'urn:xmpp:iot:sensordata'
name = 'boolean'
plugin_attrib = name
- interfaces = set(['value']);
- interfaces.update(Field.interfaces);
+ interfaces = set(['value'])
+ interfaces.update(Field.interfaces)
def _get_typename(self):
- return "boolean"
+ return "boolean"
class DataDateTime(Field):
- """
+ """
Field data of type dateTime.
- Note that the value is expressed as a string.
+ Note that the value is expressed as a string.
"""
namespace = 'urn:xmpp:iot:sensordata'
name = 'dateTime'
plugin_attrib = name
- interfaces = set(['value']);
- interfaces.update(Field.interfaces);
+ interfaces = set(['value'])
+ interfaces.update(Field.interfaces)
def _get_typename(self):
- return "dateTime"
+ return "dateTime"
class DataTimeSpan(Field):
- """
+ """
Field data of type timeSpan.
- Note that the value is expressed as a string.
+ Note that the value is expressed as a string.
"""
namespace = 'urn:xmpp:iot:sensordata'
name = 'timeSpan'
plugin_attrib = name
- interfaces = set(['value']);
- interfaces.update(Field.interfaces);
+ interfaces = set(['value'])
+ interfaces.update(Field.interfaces)
def _get_typename(self):
- return "timeSpan"
+ return "timeSpan"
class DataEnum(Field):
- """
+ """
Field data of type enum.
- Note that the value is expressed as a string.
+ Note that the value is expressed as a string.
"""
namespace = 'urn:xmpp:iot:sensordata'
name = 'enum'
plugin_attrib = name
- interfaces = set(['value', 'dataType']);
- interfaces.update(Field.interfaces);
+ interfaces = set(['value', 'dataType'])
+ interfaces.update(Field.interfaces)
def _get_typename(self):
- return "enum"
+ return "enum"
class Done(ElementBase):
""" Done element used to signal that all data has been transferred """