From 7265682a4d57d88956cb54f98f7a470465bbf417 Mon Sep 17 00:00:00 2001 From: Robin Gloster Date: Mon, 18 Aug 2014 00:52:24 +0200 Subject: cleanup semicolons, whitespace and mutable default arguments --- sleekxmpp/plugins/xep_0325/device.py | 46 ++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'sleekxmpp/plugins/xep_0325/device.py') diff --git a/sleekxmpp/plugins/xep_0325/device.py b/sleekxmpp/plugins/xep_0325/device.py index a60d5f9a..f1ed0733 100644 --- a/sleekxmpp/plugins/xep_0325/device.py +++ b/sleekxmpp/plugins/xep_0325/device.py @@ -13,16 +13,16 @@ import datetime class Device(object): """ Example implementation of a device control object. - - The device object may by any custom implementation to support + + The device object may by any custom implementation to support specific devices, but it must implement the functions: has_control_field set_control_fields """ def __init__(self, nodeId): - self.nodeId = nodeId; - self.control_fields = {}; + self.nodeId = nodeId + self.control_fields = {} def has_control_field(self, field, typename): """ @@ -30,12 +30,12 @@ class Device(object): and the type matches for control in this device. Arguments: - field -- The field name + field -- The field name typename -- The expected type """ if field in self.control_fields and self.control_fields[field]["type"] == typename: - return True; - return False; + return True + return False def set_control_fields(self, fields, session, callback): """ @@ -43,22 +43,22 @@ class Device(object): sets the data and (if needed) and calls the callback. Arguments: - fields -- List of control fields in tuple format: + fields -- List of control fields in tuple format: (name, typename, value) session -- Session id, only used in the callback as identifier callback -- Callback function to call when control set is complete. The callback function must support the following arguments: - session -- Session id, as supplied in the + session -- Session id, as supplied in the request_fields call nodeId -- Identifier for this device - result -- The current result status of the readout. + result -- The current result status of the readout. Valid values are: "error" - Set fields failed. "ok" - All fields were set. - error_field -- [optional] Only applies when result == "error" - The field name that failed + error_field -- [optional] Only applies when result == "error" + The field name that failed (usually means it is missing) error_msg -- [optional] Only applies when result == "error". Error details when a request failed. @@ -69,12 +69,12 @@ class Device(object): for name, typename, value in fields: if not self.has_control_field(name, typename): self._send_control_reject(session, name, "NotFound", callback) - return False; + return False for name, typename, value in fields: self._set_field_value(name, value) - callback(session, result="ok", nodeId=self.nodeId); + callback(session, result="ok", nodeId=self.nodeId) return True def _send_control_reject(self, session, field, message, callback): @@ -82,12 +82,12 @@ class Device(object): Sends a reject to the caller Arguments: - session -- Session id, see definition in + session -- Session id, see definition in set_control_fields function - callback -- Callback function, see definition in + callback -- Callback function, see definition in set_control_fields function """ - callback(session, result="error", nodeId=self.nodeId, error_field=field, error_msg=message); + callback(session, result="error", nodeId=self.nodeId, error_field=field, error_msg=message) def _add_control_field(self, name, typename, value): """ @@ -95,12 +95,12 @@ class Device(object): Arguments: name -- Name of the field - typename -- Type of the field, one of: - (boolean, color, string, date, dateTime, + typename -- Type of the field, one of: + (boolean, color, string, date, dateTime, double, duration, int, long, time) value -- Field value """ - self.control_fields[name] = {"type": typename, "value": value}; + self.control_fields[name] = {"type": typename, "value": value} def _set_field_value(self, name, value): """ @@ -111,7 +111,7 @@ class Device(object): value -- New value for the field """ if name in self.control_fields: - self.control_fields[name]["value"] = value; + self.control_fields[name]["value"] = value def _get_field_value(self, name): """ @@ -121,5 +121,5 @@ class Device(object): name -- Name of the field """ if name in self.control_fields: - return self.control_fields[name]["value"]; - return None; + return self.control_fields[name]["value"] + return None -- cgit v1.2.3 From 3dd379cdf12d885e26f8ec26c54879a95d5f0b84 Mon Sep 17 00:00:00 2001 From: Robin Gloster Date: Mon, 18 Aug 2014 15:15:14 +0200 Subject: Revert "cleanup semicolons, whitespace and mutable default arguments" This reverts commit 7265682a4d57d88956cb54f98f7a470465bbf417. --- sleekxmpp/plugins/xep_0325/device.py | 46 ++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'sleekxmpp/plugins/xep_0325/device.py') diff --git a/sleekxmpp/plugins/xep_0325/device.py b/sleekxmpp/plugins/xep_0325/device.py index f1ed0733..a60d5f9a 100644 --- a/sleekxmpp/plugins/xep_0325/device.py +++ b/sleekxmpp/plugins/xep_0325/device.py @@ -13,16 +13,16 @@ import datetime class Device(object): """ Example implementation of a device control object. - - The device object may by any custom implementation to support + + The device object may by any custom implementation to support specific devices, but it must implement the functions: has_control_field set_control_fields """ def __init__(self, nodeId): - self.nodeId = nodeId - self.control_fields = {} + self.nodeId = nodeId; + self.control_fields = {}; def has_control_field(self, field, typename): """ @@ -30,12 +30,12 @@ class Device(object): and the type matches for control in this device. Arguments: - field -- The field name + field -- The field name typename -- The expected type """ if field in self.control_fields and self.control_fields[field]["type"] == typename: - return True - return False + return True; + return False; def set_control_fields(self, fields, session, callback): """ @@ -43,22 +43,22 @@ class Device(object): sets the data and (if needed) and calls the callback. Arguments: - fields -- List of control fields in tuple format: + fields -- List of control fields in tuple format: (name, typename, value) session -- Session id, only used in the callback as identifier callback -- Callback function to call when control set is complete. The callback function must support the following arguments: - session -- Session id, as supplied in the + session -- Session id, as supplied in the request_fields call nodeId -- Identifier for this device - result -- The current result status of the readout. + result -- The current result status of the readout. Valid values are: "error" - Set fields failed. "ok" - All fields were set. - error_field -- [optional] Only applies when result == "error" - The field name that failed + error_field -- [optional] Only applies when result == "error" + The field name that failed (usually means it is missing) error_msg -- [optional] Only applies when result == "error". Error details when a request failed. @@ -69,12 +69,12 @@ class Device(object): for name, typename, value in fields: if not self.has_control_field(name, typename): self._send_control_reject(session, name, "NotFound", callback) - return False + return False; for name, typename, value in fields: self._set_field_value(name, value) - callback(session, result="ok", nodeId=self.nodeId) + callback(session, result="ok", nodeId=self.nodeId); return True def _send_control_reject(self, session, field, message, callback): @@ -82,12 +82,12 @@ class Device(object): Sends a reject to the caller Arguments: - session -- Session id, see definition in + session -- Session id, see definition in set_control_fields function - callback -- Callback function, see definition in + callback -- Callback function, see definition in set_control_fields function """ - callback(session, result="error", nodeId=self.nodeId, error_field=field, error_msg=message) + callback(session, result="error", nodeId=self.nodeId, error_field=field, error_msg=message); def _add_control_field(self, name, typename, value): """ @@ -95,12 +95,12 @@ class Device(object): Arguments: name -- Name of the field - typename -- Type of the field, one of: - (boolean, color, string, date, dateTime, + typename -- Type of the field, one of: + (boolean, color, string, date, dateTime, double, duration, int, long, time) value -- Field value """ - self.control_fields[name] = {"type": typename, "value": value} + self.control_fields[name] = {"type": typename, "value": value}; def _set_field_value(self, name, value): """ @@ -111,7 +111,7 @@ class Device(object): value -- New value for the field """ if name in self.control_fields: - self.control_fields[name]["value"] = value + self.control_fields[name]["value"] = value; def _get_field_value(self, name): """ @@ -121,5 +121,5 @@ class Device(object): name -- Name of the field """ if name in self.control_fields: - return self.control_fields[name]["value"] - return None + return self.control_fields[name]["value"]; + return None; -- cgit v1.2.3 From afc939708ff71e168f9204f1eab8823b7dc9f875 Mon Sep 17 00:00:00 2001 From: Robin Gloster Date: Mon, 18 Aug 2014 00:52:24 +0200 Subject: cleanup semicolons, whitespace and mutable default arguments --- sleekxmpp/plugins/xep_0325/device.py | 46 ++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'sleekxmpp/plugins/xep_0325/device.py') diff --git a/sleekxmpp/plugins/xep_0325/device.py b/sleekxmpp/plugins/xep_0325/device.py index a60d5f9a..f1ed0733 100644 --- a/sleekxmpp/plugins/xep_0325/device.py +++ b/sleekxmpp/plugins/xep_0325/device.py @@ -13,16 +13,16 @@ import datetime class Device(object): """ Example implementation of a device control object. - - The device object may by any custom implementation to support + + The device object may by any custom implementation to support specific devices, but it must implement the functions: has_control_field set_control_fields """ def __init__(self, nodeId): - self.nodeId = nodeId; - self.control_fields = {}; + self.nodeId = nodeId + self.control_fields = {} def has_control_field(self, field, typename): """ @@ -30,12 +30,12 @@ class Device(object): and the type matches for control in this device. Arguments: - field -- The field name + field -- The field name typename -- The expected type """ if field in self.control_fields and self.control_fields[field]["type"] == typename: - return True; - return False; + return True + return False def set_control_fields(self, fields, session, callback): """ @@ -43,22 +43,22 @@ class Device(object): sets the data and (if needed) and calls the callback. Arguments: - fields -- List of control fields in tuple format: + fields -- List of control fields in tuple format: (name, typename, value) session -- Session id, only used in the callback as identifier callback -- Callback function to call when control set is complete. The callback function must support the following arguments: - session -- Session id, as supplied in the + session -- Session id, as supplied in the request_fields call nodeId -- Identifier for this device - result -- The current result status of the readout. + result -- The current result status of the readout. Valid values are: "error" - Set fields failed. "ok" - All fields were set. - error_field -- [optional] Only applies when result == "error" - The field name that failed + error_field -- [optional] Only applies when result == "error" + The field name that failed (usually means it is missing) error_msg -- [optional] Only applies when result == "error". Error details when a request failed. @@ -69,12 +69,12 @@ class Device(object): for name, typename, value in fields: if not self.has_control_field(name, typename): self._send_control_reject(session, name, "NotFound", callback) - return False; + return False for name, typename, value in fields: self._set_field_value(name, value) - callback(session, result="ok", nodeId=self.nodeId); + callback(session, result="ok", nodeId=self.nodeId) return True def _send_control_reject(self, session, field, message, callback): @@ -82,12 +82,12 @@ class Device(object): Sends a reject to the caller Arguments: - session -- Session id, see definition in + session -- Session id, see definition in set_control_fields function - callback -- Callback function, see definition in + callback -- Callback function, see definition in set_control_fields function """ - callback(session, result="error", nodeId=self.nodeId, error_field=field, error_msg=message); + callback(session, result="error", nodeId=self.nodeId, error_field=field, error_msg=message) def _add_control_field(self, name, typename, value): """ @@ -95,12 +95,12 @@ class Device(object): Arguments: name -- Name of the field - typename -- Type of the field, one of: - (boolean, color, string, date, dateTime, + typename -- Type of the field, one of: + (boolean, color, string, date, dateTime, double, duration, int, long, time) value -- Field value """ - self.control_fields[name] = {"type": typename, "value": value}; + self.control_fields[name] = {"type": typename, "value": value} def _set_field_value(self, name, value): """ @@ -111,7 +111,7 @@ class Device(object): value -- New value for the field """ if name in self.control_fields: - self.control_fields[name]["value"] = value; + self.control_fields[name]["value"] = value def _get_field_value(self, name): """ @@ -121,5 +121,5 @@ class Device(object): name -- Name of the field """ if name in self.control_fields: - return self.control_fields[name]["value"]; - return None; + return self.control_fields[name]["value"] + return None -- cgit v1.2.3