repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
nugget/python-insteonplm
insteonplm/states/onOff.py
OnOffSwitch_OutletTop.off
def off(self): """Send OFF command to device.""" self._send_method(StandardSend(self._address, COMMAND_LIGHT_OFF_0X13_0X00), self._off_message_received)
python
def off(self): """Send OFF command to device.""" self._send_method(StandardSend(self._address, COMMAND_LIGHT_OFF_0X13_0X00), self._off_message_received)
[ "def", "off", "(", "self", ")", ":", "self", ".", "_send_method", "(", "StandardSend", "(", "self", ".", "_address", ",", "COMMAND_LIGHT_OFF_0X13_0X00", ")", ",", "self", ".", "_off_message_received", ")" ]
Send OFF command to device.
[ "Send", "OFF", "command", "to", "device", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L241-L245
nugget/python-insteonplm
insteonplm/states/onOff.py
OnOffSwitch_OutletTop._send_status_0x01_request
def _send_status_0x01_request(self): """Sent status request to device.""" status_command = StandardSend(self._address, COMMAND_LIGHT_STATUS_REQUEST_0X19_0X01) self._send_method(status_command, self._status_message_0x01_received)
python
def _send_status_0x01_request(self): """Sent status request to device.""" status_command = StandardSend(self._address, COMMAND_LIGHT_STATUS_REQUEST_0X19_0X01) self._send_method(status_command, self._status_message_0x01_received)
[ "def", "_send_status_0x01_request", "(", "self", ")", ":", "status_command", "=", "StandardSend", "(", "self", ".", "_address", ",", "COMMAND_LIGHT_STATUS_REQUEST_0X19_0X01", ")", "self", ".", "_send_method", "(", "status_command", ",", "self", ".", "_status_message_0...
Sent status request to device.
[ "Sent", "status", "request", "to", "device", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L247-L251
nugget/python-insteonplm
insteonplm/states/onOff.py
OnOffSwitch_OutletTop._status_message_0x01_received
def _status_message_0x01_received(self, msg): """Handle status received messages. The following status values can be received: 0x00 = Both Outlets Off 0x01 = Only Top Outlet On 0x02 = Only Bottom Outlet On 0x03 = Both Outlets On """ if msg...
python
def _status_message_0x01_received(self, msg): """Handle status received messages. The following status values can be received: 0x00 = Both Outlets Off 0x01 = Only Top Outlet On 0x02 = Only Bottom Outlet On 0x03 = Both Outlets On """ if msg...
[ "def", "_status_message_0x01_received", "(", "self", ",", "msg", ")", ":", "if", "msg", ".", "cmd2", "==", "0x00", "or", "msg", ".", "cmd2", "==", "0x02", ":", "self", ".", "_update_subscribers", "(", "0x00", ")", "elif", "msg", ".", "cmd2", "==", "0x0...
Handle status received messages. The following status values can be received: 0x00 = Both Outlets Off 0x01 = Only Top Outlet On 0x02 = Only Bottom Outlet On 0x03 = Both Outlets On
[ "Handle", "status", "received", "messages", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L253-L267
nugget/python-insteonplm
insteonplm/states/onOff.py
OnOffSwitch_OutletBottom.on
def on(self): """Send an ON message to device group.""" on_command = ExtendedSend(self._address, COMMAND_LIGHT_ON_0X11_NONE, self._udata, cmd2=0xff) on_command.set_checksum() self._send_...
python
def on(self): """Send an ON message to device group.""" on_command = ExtendedSend(self._address, COMMAND_LIGHT_ON_0X11_NONE, self._udata, cmd2=0xff) on_command.set_checksum() self._send_...
[ "def", "on", "(", "self", ")", ":", "on_command", "=", "ExtendedSend", "(", "self", ".", "_address", ",", "COMMAND_LIGHT_ON_0X11_NONE", ",", "self", ".", "_udata", ",", "cmd2", "=", "0xff", ")", "on_command", ".", "set_checksum", "(", ")", "self", ".", "...
Send an ON message to device group.
[ "Send", "an", "ON", "message", "to", "device", "group", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L295-L302
nugget/python-insteonplm
insteonplm/states/onOff.py
OnOffSwitch_OutletBottom.off
def off(self): """Send an OFF message to device group.""" off_command = ExtendedSend(self._address, COMMAND_LIGHT_OFF_0X13_0X00, self._udata) off_command.set_checksum() self._send_method(off_command, self._off_message_...
python
def off(self): """Send an OFF message to device group.""" off_command = ExtendedSend(self._address, COMMAND_LIGHT_OFF_0X13_0X00, self._udata) off_command.set_checksum() self._send_method(off_command, self._off_message_...
[ "def", "off", "(", "self", ")", ":", "off_command", "=", "ExtendedSend", "(", "self", ".", "_address", ",", "COMMAND_LIGHT_OFF_0X13_0X00", ",", "self", ".", "_udata", ")", "off_command", ".", "set_checksum", "(", ")", "self", ".", "_send_method", "(", "off_c...
Send an OFF message to device group.
[ "Send", "an", "OFF", "message", "to", "device", "group", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L304-L310
nugget/python-insteonplm
insteonplm/states/onOff.py
OnOffSwitch_OutletBottom._send_status_0x01_request
def _send_status_0x01_request(self): """Send a status request.""" status_command = StandardSend(self._address, COMMAND_LIGHT_STATUS_REQUEST_0X19_0X01) self._send_method(status_command, self._status_message_received)
python
def _send_status_0x01_request(self): """Send a status request.""" status_command = StandardSend(self._address, COMMAND_LIGHT_STATUS_REQUEST_0X19_0X01) self._send_method(status_command, self._status_message_received)
[ "def", "_send_status_0x01_request", "(", "self", ")", ":", "status_command", "=", "StandardSend", "(", "self", ".", "_address", ",", "COMMAND_LIGHT_STATUS_REQUEST_0X19_0X01", ")", "self", ".", "_send_method", "(", "status_command", ",", "self", ".", "_status_message_r...
Send a status request.
[ "Send", "a", "status", "request", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L312-L316
nugget/python-insteonplm
insteonplm/states/onOff.py
OnOffSwitch_OutletBottom._status_message_received
def _status_message_received(self, msg): """Receive a status message. The following status values can be received: 0x00 = Both Outlets Off 0x01 = Only Top Outlet On 0x02 = Only Bottom Outlet On 0x03 = Both Outlets On """ if msg.cmd2 == 0x0...
python
def _status_message_received(self, msg): """Receive a status message. The following status values can be received: 0x00 = Both Outlets Off 0x01 = Only Top Outlet On 0x02 = Only Bottom Outlet On 0x03 = Both Outlets On """ if msg.cmd2 == 0x0...
[ "def", "_status_message_received", "(", "self", ",", "msg", ")", ":", "if", "msg", ".", "cmd2", "==", "0x00", "or", "msg", ".", "cmd2", "==", "0x01", ":", "self", ".", "_update_subscribers", "(", "0x00", ")", "elif", "msg", ".", "cmd2", "==", "0x02", ...
Receive a status message. The following status values can be received: 0x00 = Both Outlets Off 0x01 = Only Top Outlet On 0x02 = Only Bottom Outlet On 0x03 = Both Outlets On
[ "Receive", "a", "status", "message", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L318-L332
nugget/python-insteonplm
insteonplm/states/onOff.py
OpenClosedRelay.close
def close(self): """Send CLOSE command to device.""" close_command = StandardSend(self._address, COMMAND_LIGHT_OFF_0X13_0X00) self._send_method(close_command, self._close_message_received)
python
def close(self): """Send CLOSE command to device.""" close_command = StandardSend(self._address, COMMAND_LIGHT_OFF_0X13_0X00) self._send_method(close_command, self._close_message_received)
[ "def", "close", "(", "self", ")", ":", "close_command", "=", "StandardSend", "(", "self", ".", "_address", ",", "COMMAND_LIGHT_OFF_0X13_0X00", ")", "self", ".", "_send_method", "(", "close_command", ",", "self", ".", "_close_message_received", ")" ]
Send CLOSE command to device.
[ "Send", "CLOSE", "command", "to", "device", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L365-L369
nugget/python-insteonplm
insteonplm/states/onOff.py
OnOffKeypad.led_changed
def led_changed(self, addr, group, val): """Capture a change to the LED for this button.""" _LOGGER.debug("Button %d LED changed from %d to %d", self._group, self._value, val) led_on = bool(val) if led_on != bool(self._value): self._update_subscribers(in...
python
def led_changed(self, addr, group, val): """Capture a change to the LED for this button.""" _LOGGER.debug("Button %d LED changed from %d to %d", self._group, self._value, val) led_on = bool(val) if led_on != bool(self._value): self._update_subscribers(in...
[ "def", "led_changed", "(", "self", ",", "addr", ",", "group", ",", "val", ")", ":", "_LOGGER", ".", "debug", "(", "\"Button %d LED changed from %d to %d\"", ",", "self", ".", "_group", ",", "self", ".", "_value", ",", "val", ")", "led_on", "=", "bool", "...
Capture a change to the LED for this button.
[ "Capture", "a", "change", "to", "the", "LED", "for", "this", "button", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L526-L532
nugget/python-insteonplm
insteonplm/states/onOff.py
OnOffKeypad.set_on_mask
def set_on_mask(self, mask): """Set the on mask for the current group/button.""" set_cmd = self._create_set_property_msg('_on_mask', 0x02, mask) self._send_method(set_cmd, self._property_set)
python
def set_on_mask(self, mask): """Set the on mask for the current group/button.""" set_cmd = self._create_set_property_msg('_on_mask', 0x02, mask) self._send_method(set_cmd, self._property_set)
[ "def", "set_on_mask", "(", "self", ",", "mask", ")", ":", "set_cmd", "=", "self", ".", "_create_set_property_msg", "(", "'_on_mask'", ",", "0x02", ",", "mask", ")", "self", ".", "_send_method", "(", "set_cmd", ",", "self", ".", "_property_set", ")" ]
Set the on mask for the current group/button.
[ "Set", "the", "on", "mask", "for", "the", "current", "group", "/", "button", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L534-L537
nugget/python-insteonplm
insteonplm/states/onOff.py
OnOffKeypad.set_off_mask
def set_off_mask(self, mask): """Set the off mask for the current group/button.""" set_cmd = self._create_set_property_msg('_off_mask', 0x03, mask) self._send_method(set_cmd, self._property_set)
python
def set_off_mask(self, mask): """Set the off mask for the current group/button.""" set_cmd = self._create_set_property_msg('_off_mask', 0x03, mask) self._send_method(set_cmd, self._property_set)
[ "def", "set_off_mask", "(", "self", ",", "mask", ")", ":", "set_cmd", "=", "self", ".", "_create_set_property_msg", "(", "'_off_mask'", ",", "0x03", ",", "mask", ")", "self", ".", "_send_method", "(", "set_cmd", ",", "self", ".", "_property_set", ")" ]
Set the off mask for the current group/button.
[ "Set", "the", "off", "mask", "for", "the", "current", "group", "/", "button", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L539-L542
nugget/python-insteonplm
insteonplm/states/onOff.py
OnOffKeypad.set_x10_address
def set_x10_address(self, x10address): """Set the X10 address for the current group/button.""" set_cmd = self._create_set_property_msg('_x10_house_code', 0x04, x10address) self._send_method(set_cmd, self._property_set)
python
def set_x10_address(self, x10address): """Set the X10 address for the current group/button.""" set_cmd = self._create_set_property_msg('_x10_house_code', 0x04, x10address) self._send_method(set_cmd, self._property_set)
[ "def", "set_x10_address", "(", "self", ",", "x10address", ")", ":", "set_cmd", "=", "self", ".", "_create_set_property_msg", "(", "'_x10_house_code'", ",", "0x04", ",", "x10address", ")", "self", ".", "_send_method", "(", "set_cmd", ",", "self", ".", "_propert...
Set the X10 address for the current group/button.
[ "Set", "the", "X10", "address", "for", "the", "current", "group", "/", "button", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L544-L548
nugget/python-insteonplm
insteonplm/states/onOff.py
OnOffKeypad.set_ramp_rate
def set_ramp_rate(self, ramp_rate): """Set the X10 address for the current group/button.""" set_cmd = self._create_set_property_msg('_ramp_rate', 0x05, ramp_rate) self._send_method(set_cmd, self._property_set)
python
def set_ramp_rate(self, ramp_rate): """Set the X10 address for the current group/button.""" set_cmd = self._create_set_property_msg('_ramp_rate', 0x05, ramp_rate) self._send_method(set_cmd, self._property_set)
[ "def", "set_ramp_rate", "(", "self", ",", "ramp_rate", ")", ":", "set_cmd", "=", "self", ".", "_create_set_property_msg", "(", "'_ramp_rate'", ",", "0x05", ",", "ramp_rate", ")", "self", ".", "_send_method", "(", "set_cmd", ",", "self", ".", "_property_set", ...
Set the X10 address for the current group/button.
[ "Set", "the", "X10", "address", "for", "the", "current", "group", "/", "button", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L550-L554
nugget/python-insteonplm
insteonplm/states/onOff.py
OnOffKeypad.set_on_level
def set_on_level(self, val): """Set on level for the button/group.""" on_cmd = self._create_set_property_msg("_on_level", 0x06, val) self._send_method(on_cmd, self._property_set) self._send_method(on_cmd, self._on_message_received)
python
def set_on_level(self, val): """Set on level for the button/group.""" on_cmd = self._create_set_property_msg("_on_level", 0x06, val) self._send_method(on_cmd, self._property_set) self._send_method(on_cmd, self._on_message_received)
[ "def", "set_on_level", "(", "self", ",", "val", ")", ":", "on_cmd", "=", "self", ".", "_create_set_property_msg", "(", "\"_on_level\"", ",", "0x06", ",", "val", ")", "self", ".", "_send_method", "(", "on_cmd", ",", "self", ".", "_property_set", ")", "self"...
Set on level for the button/group.
[ "Set", "on", "level", "for", "the", "button", "/", "group", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L556-L561
nugget/python-insteonplm
insteonplm/states/onOff.py
OnOffKeypad.set_led_brightness
def set_led_brightness(self, brightness): """Set the LED brightness for the current group/button.""" set_cmd = self._create_set_property_msg("_led_brightness", 0x07, brightness) self._send_method(set_cmd, self._property_set)
python
def set_led_brightness(self, brightness): """Set the LED brightness for the current group/button.""" set_cmd = self._create_set_property_msg("_led_brightness", 0x07, brightness) self._send_method(set_cmd, self._property_set)
[ "def", "set_led_brightness", "(", "self", ",", "brightness", ")", ":", "set_cmd", "=", "self", ".", "_create_set_property_msg", "(", "\"_led_brightness\"", ",", "0x07", ",", "brightness", ")", "self", ".", "_send_method", "(", "set_cmd", ",", "self", ".", "_pr...
Set the LED brightness for the current group/button.
[ "Set", "the", "LED", "brightness", "for", "the", "current", "group", "/", "button", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L563-L567
nugget/python-insteonplm
insteonplm/states/onOff.py
OnOffKeypad.set_non_toggle_mask
def set_non_toggle_mask(self, non_toggle_mask): """Set the non_toggle_mask for the current group/button.""" set_cmd = self._create_set_property_msg("_non_toggle_mask", 0x08, non_toggle_mask) self._send_method(set_cmd, self._property_set)
python
def set_non_toggle_mask(self, non_toggle_mask): """Set the non_toggle_mask for the current group/button.""" set_cmd = self._create_set_property_msg("_non_toggle_mask", 0x08, non_toggle_mask) self._send_method(set_cmd, self._property_set)
[ "def", "set_non_toggle_mask", "(", "self", ",", "non_toggle_mask", ")", ":", "set_cmd", "=", "self", ".", "_create_set_property_msg", "(", "\"_non_toggle_mask\"", ",", "0x08", ",", "non_toggle_mask", ")", "self", ".", "_send_method", "(", "set_cmd", ",", "self", ...
Set the non_toggle_mask for the current group/button.
[ "Set", "the", "non_toggle_mask", "for", "the", "current", "group", "/", "button", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L569-L573
nugget/python-insteonplm
insteonplm/states/onOff.py
OnOffKeypad.set_x10_all_bit_mask
def set_x10_all_bit_mask(self, x10_all_bit_mask): """Set the x10_all_bit_mask for the current group/button.""" set_cmd = self._create_set_property_msg("_x10_all_bit_mask", 0x0a, x10_all_bit_mask) self._send_method(set_cmd, self._property_set)
python
def set_x10_all_bit_mask(self, x10_all_bit_mask): """Set the x10_all_bit_mask for the current group/button.""" set_cmd = self._create_set_property_msg("_x10_all_bit_mask", 0x0a, x10_all_bit_mask) self._send_method(set_cmd, self._property_set)
[ "def", "set_x10_all_bit_mask", "(", "self", ",", "x10_all_bit_mask", ")", ":", "set_cmd", "=", "self", ".", "_create_set_property_msg", "(", "\"_x10_all_bit_mask\"", ",", "0x0a", ",", "x10_all_bit_mask", ")", "self", ".", "_send_method", "(", "set_cmd", ",", "self...
Set the x10_all_bit_mask for the current group/button.
[ "Set", "the", "x10_all_bit_mask", "for", "the", "current", "group", "/", "button", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L575-L579
nugget/python-insteonplm
insteonplm/states/onOff.py
OnOffKeypad.set_trigger_group_bit_mask
def set_trigger_group_bit_mask(self, trigger_group_bit_mask): """Set the trigger_group_bit_mask for the current group/button.""" set_cmd = self._create_set_property_msg("_trigger_group_bit_mask", 0x0c, trigger_group_bit_mask) self._send_method(set_...
python
def set_trigger_group_bit_mask(self, trigger_group_bit_mask): """Set the trigger_group_bit_mask for the current group/button.""" set_cmd = self._create_set_property_msg("_trigger_group_bit_mask", 0x0c, trigger_group_bit_mask) self._send_method(set_...
[ "def", "set_trigger_group_bit_mask", "(", "self", ",", "trigger_group_bit_mask", ")", ":", "set_cmd", "=", "self", ".", "_create_set_property_msg", "(", "\"_trigger_group_bit_mask\"", ",", "0x0c", ",", "trigger_group_bit_mask", ")", "self", ".", "_send_method", "(", "...
Set the trigger_group_bit_mask for the current group/button.
[ "Set", "the", "trigger_group_bit_mask", "for", "the", "current", "group", "/", "button", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L581-L585
nugget/python-insteonplm
insteonplm/states/onOff.py
OnOffKeypad.scene_on
def scene_on(self): """Trigger group/scene to ON level.""" user_data = Userdata({'d1': self._group, 'd2': 0x00, 'd3': 0x00, 'd4': 0x11, 'd5': 0xff, 'd6': ...
python
def scene_on(self): """Trigger group/scene to ON level.""" user_data = Userdata({'d1': self._group, 'd2': 0x00, 'd3': 0x00, 'd4': 0x11, 'd5': 0xff, 'd6': ...
[ "def", "scene_on", "(", "self", ")", ":", "user_data", "=", "Userdata", "(", "{", "'d1'", ":", "self", ".", "_group", ",", "'d2'", ":", "0x00", ",", "'d3'", ":", "0x00", ",", "'d4'", ":", "0x11", ",", "'d5'", ":", "0xff", ",", "'d6'", ":", "0x00"...
Trigger group/scene to ON level.
[ "Trigger", "group", "/", "scene", "to", "ON", "level", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L587-L602
nugget/python-insteonplm
insteonplm/states/onOff.py
OnOffKeypad.scene_off
def scene_off(self): """Trigger group/scene to OFF level.""" user_data = Userdata({'d1': self._group, 'd2': 0x00, 'd3': 0x00, 'd4': 0x13, 'd5': 0x00, 'd6'...
python
def scene_off(self): """Trigger group/scene to OFF level.""" user_data = Userdata({'d1': self._group, 'd2': 0x00, 'd3': 0x00, 'd4': 0x13, 'd5': 0x00, 'd6'...
[ "def", "scene_off", "(", "self", ")", ":", "user_data", "=", "Userdata", "(", "{", "'d1'", ":", "self", ".", "_group", ",", "'d2'", ":", "0x00", ",", "'d3'", ":", "0x00", ",", "'d4'", ":", "0x13", ",", "'d5'", ":", "0x00", ",", "'d6'", ":", "0x00...
Trigger group/scene to OFF level.
[ "Trigger", "group", "/", "scene", "to", "OFF", "level", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L604-L617
nugget/python-insteonplm
insteonplm/states/onOff.py
OnOffKeypad.extended_status_request
def extended_status_request(self): """Send status request for group/button.""" self._status_received = False user_data = Userdata({'d1': self.group, 'd2': 0x00}) cmd = ExtendedSend(self._address, COMMAND_EXTENDED_GET_SET_0X2E_0X00,...
python
def extended_status_request(self): """Send status request for group/button.""" self._status_received = False user_data = Userdata({'d1': self.group, 'd2': 0x00}) cmd = ExtendedSend(self._address, COMMAND_EXTENDED_GET_SET_0X2E_0X00,...
[ "def", "extended_status_request", "(", "self", ")", ":", "self", ".", "_status_received", "=", "False", "user_data", "=", "Userdata", "(", "{", "'d1'", ":", "self", ".", "group", ",", "'d2'", ":", "0x00", "}", ")", "cmd", "=", "ExtendedSend", "(", "self"...
Send status request for group/button.
[ "Send", "status", "request", "for", "group", "/", "button", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L637-L646
nugget/python-insteonplm
insteonplm/states/onOff.py
OnOffKeypad._status_message_received
def _status_message_received(self, msg): """Receive confirmation that the status message is coming. The real status message is the extended direct message. """ if not self._status_received: asyncio.ensure_future(self._confirm_status_received(), ...
python
def _status_message_received(self, msg): """Receive confirmation that the status message is coming. The real status message is the extended direct message. """ if not self._status_received: asyncio.ensure_future(self._confirm_status_received(), ...
[ "def", "_status_message_received", "(", "self", ",", "msg", ")", ":", "if", "not", "self", ".", "_status_received", ":", "asyncio", ".", "ensure_future", "(", "self", ".", "_confirm_status_received", "(", ")", ",", "loop", "=", "self", ".", "_loop", ")" ]
Receive confirmation that the status message is coming. The real status message is the extended direct message.
[ "Receive", "confirmation", "that", "the", "status", "message", "is", "coming", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L671-L678
nugget/python-insteonplm
insteonplm/states/onOff.py
OnOffKeypad._status_extended_message_received
def _status_extended_message_received(self, msg): """Receeive an extended status message. Status message received: cmd1: 0x2e cmd2: 0x00 flags: Direct Extended d1: group d2: 0x01 d3: On Mask d4: Off Mask ...
python
def _status_extended_message_received(self, msg): """Receeive an extended status message. Status message received: cmd1: 0x2e cmd2: 0x00 flags: Direct Extended d1: group d2: 0x01 d3: On Mask d4: Off Mask ...
[ "def", "_status_extended_message_received", "(", "self", ",", "msg", ")", ":", "self", ".", "_status_received", "=", "True", "self", ".", "_status_retries", "=", "0", "_LOGGER", ".", "debug", "(", "\"Extended status message received\"", ")", "if", "self", ".", "...
Receeive an extended status message. Status message received: cmd1: 0x2e cmd2: 0x00 flags: Direct Extended d1: group d2: 0x01 d3: On Mask d4: Off Mask d5: X10 House Code d6: X10 Unit ...
[ "Receeive", "an", "extended", "status", "message", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L703-L732
nugget/python-insteonplm
insteonplm/states/onOff.py
OnOffKeypad._property_set
def _property_set(self, msg): """Set command received and acknowledged.""" prop = self._sent_property.get('prop') if prop and hasattr(self, prop): setattr(self, prop, self._sent_property.get('val')) self._sent_property = {}
python
def _property_set(self, msg): """Set command received and acknowledged.""" prop = self._sent_property.get('prop') if prop and hasattr(self, prop): setattr(self, prop, self._sent_property.get('val')) self._sent_property = {}
[ "def", "_property_set", "(", "self", ",", "msg", ")", ":", "prop", "=", "self", ".", "_sent_property", ".", "get", "(", "'prop'", ")", "if", "prop", "and", "hasattr", "(", "self", ",", "prop", ")", ":", "setattr", "(", "self", ",", "prop", ",", "se...
Set command received and acknowledged.
[ "Set", "command", "received", "and", "acknowledged", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L734-L739
nugget/python-insteonplm
insteonplm/states/onOff.py
OnOffKeypad._set_status_data
def _set_status_data(self, userdata): """Set status properties from userdata response. Response values: d3: On Mask d4: Off Mask d5: X10 House Code d6: X10 Unit d7: Ramp Rate d8: On-Level d9: LED Brightness ...
python
def _set_status_data(self, userdata): """Set status properties from userdata response. Response values: d3: On Mask d4: Off Mask d5: X10 House Code d6: X10 Unit d7: Ramp Rate d8: On-Level d9: LED Brightness ...
[ "def", "_set_status_data", "(", "self", ",", "userdata", ")", ":", "self", ".", "_on_mask", "=", "userdata", "[", "'d3'", "]", "self", ".", "_off_mask", "=", "userdata", "[", "'d4'", "]", "self", ".", "_x10_house_code", "=", "userdata", "[", "'d5'", "]",...
Set status properties from userdata response. Response values: d3: On Mask d4: Off Mask d5: X10 House Code d6: X10 Unit d7: Ramp Rate d8: On-Level d9: LED Brightness d10: Non-Toggle Mask d11: LED ...
[ "Set", "status", "properties", "from", "userdata", "response", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L751-L778
nugget/python-insteonplm
insteonplm/states/onOff.py
OnOffKeypad._create_set_property_msg
def _create_set_property_msg(self, prop, cmd, val): """Create an extended message to set a property. Create an extended message with: cmd1: 0x2e cmd2: 0x00 flags: Direct Extended d1: group d2: cmd d3: val d4 - d14: 0x00...
python
def _create_set_property_msg(self, prop, cmd, val): """Create an extended message to set a property. Create an extended message with: cmd1: 0x2e cmd2: 0x00 flags: Direct Extended d1: group d2: cmd d3: val d4 - d14: 0x00...
[ "def", "_create_set_property_msg", "(", "self", ",", "prop", ",", "cmd", ",", "val", ")", ":", "user_data", "=", "Userdata", "(", "{", "'d1'", ":", "self", ".", "group", ",", "'d2'", ":", "cmd", ",", "'d3'", ":", "val", "}", ")", "msg", "=", "Exten...
Create an extended message to set a property. Create an extended message with: cmd1: 0x2e cmd2: 0x00 flags: Direct Extended d1: group d2: cmd d3: val d4 - d14: 0x00 Parameters: prop: Property name to update...
[ "Create", "an", "extended", "message", "to", "set", "a", "property", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L792-L828
nugget/python-insteonplm
insteonplm/states/onOff.py
OnOffKeypadLed.on
def on(self, group): """Turn the LED on for a group.""" asyncio.ensure_future(self._send_led_on_off_request(group, 1), loop=self._loop)
python
def on(self, group): """Turn the LED on for a group.""" asyncio.ensure_future(self._send_led_on_off_request(group, 1), loop=self._loop)
[ "def", "on", "(", "self", ",", "group", ")", ":", "asyncio", ".", "ensure_future", "(", "self", ".", "_send_led_on_off_request", "(", "group", ",", "1", ")", ",", "loop", "=", "self", ".", "_loop", ")" ]
Turn the LED on for a group.
[ "Turn", "the", "LED", "on", "for", "a", "group", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L852-L855
nugget/python-insteonplm
insteonplm/states/onOff.py
OnOffKeypadLed.off
def off(self, group): """Turn the LED off for a group.""" asyncio.ensure_future(self._send_led_on_off_request(group, 0), loop=self._loop)
python
def off(self, group): """Turn the LED off for a group.""" asyncio.ensure_future(self._send_led_on_off_request(group, 0), loop=self._loop)
[ "def", "off", "(", "self", ",", "group", ")", ":", "asyncio", ".", "ensure_future", "(", "self", ".", "_send_led_on_off_request", "(", "group", ",", "0", ")", ",", "loop", "=", "self", ".", "_loop", ")" ]
Turn the LED off for a group.
[ "Turn", "the", "LED", "off", "for", "a", "group", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L857-L860
nugget/python-insteonplm
insteonplm/states/onOff.py
OnOffKeypadLed.register_led_updates
def register_led_updates(self, callback, button): """Register a callback when a specific button LED changes.""" button_callbacks = self._button_observer_callbacks.get(button) if not button_callbacks: self._button_observer_callbacks[button] = [] _LOGGER.debug('New callback for...
python
def register_led_updates(self, callback, button): """Register a callback when a specific button LED changes.""" button_callbacks = self._button_observer_callbacks.get(button) if not button_callbacks: self._button_observer_callbacks[button] = [] _LOGGER.debug('New callback for...
[ "def", "register_led_updates", "(", "self", ",", "callback", ",", "button", ")", ":", "button_callbacks", "=", "self", ".", "_button_observer_callbacks", ".", "get", "(", "button", ")", "if", "not", "button_callbacks", ":", "self", ".", "_button_observer_callbacks...
Register a callback when a specific button LED changes.
[ "Register", "a", "callback", "when", "a", "specific", "button", "LED", "changes", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L877-L883
nugget/python-insteonplm
insteonplm/states/onOff.py
OnOffKeypadLed._set_led_value
def _set_led_value(self, group, val): """Set the LED value and confirm with a status check.""" new_bitmask = set_bit(self._value, group, bool(val)) self._set_led_bitmask(new_bitmask)
python
def _set_led_value(self, group, val): """Set the LED value and confirm with a status check.""" new_bitmask = set_bit(self._value, group, bool(val)) self._set_led_bitmask(new_bitmask)
[ "def", "_set_led_value", "(", "self", ",", "group", ",", "val", ")", ":", "new_bitmask", "=", "set_bit", "(", "self", ".", "_value", ",", "group", ",", "bool", "(", "val", ")", ")", "self", ".", "_set_led_bitmask", "(", "new_bitmask", ")" ]
Set the LED value and confirm with a status check.
[ "Set", "the", "LED", "value", "and", "confirm", "with", "a", "status", "check", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L916-L919
nugget/python-insteonplm
insteonplm/states/onOff.py
OnOffKeypadLed._bit_value
def _bit_value(self, group, val): """Set the LED on/off value from the LED bitmap.""" bitshift = group - 1 if val: new_value = self._value | (1 << bitshift) else: new_value = self._value & (0xff & ~(1 << bitshift)) return new_value
python
def _bit_value(self, group, val): """Set the LED on/off value from the LED bitmap.""" bitshift = group - 1 if val: new_value = self._value | (1 << bitshift) else: new_value = self._value & (0xff & ~(1 << bitshift)) return new_value
[ "def", "_bit_value", "(", "self", ",", "group", ",", "val", ")", ":", "bitshift", "=", "group", "-", "1", "if", "val", ":", "new_value", "=", "self", ".", "_value", "|", "(", "1", "<<", "bitshift", ")", "else", ":", "new_value", "=", "self", ".", ...
Set the LED on/off value from the LED bitmap.
[ "Set", "the", "LED", "on", "/", "off", "value", "from", "the", "LED", "bitmap", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L924-L931
nugget/python-insteonplm
insteonplm/states/thermostat.py
SystemMode.set
def set(self, mode): """Set the thermostat mode. Mode optons: OFF = 0x00, HEAT = 0x01, COOL = 0x02, AUTO = 0x03, FAN_AUTO = 0x04, FAN_ALWAYS_ON = 0x8 """ new_mode = None if mode == ThermostatMode.OFF: ...
python
def set(self, mode): """Set the thermostat mode. Mode optons: OFF = 0x00, HEAT = 0x01, COOL = 0x02, AUTO = 0x03, FAN_AUTO = 0x04, FAN_ALWAYS_ON = 0x8 """ new_mode = None if mode == ThermostatMode.OFF: ...
[ "def", "set", "(", "self", ",", "mode", ")", ":", "new_mode", "=", "None", "if", "mode", "==", "ThermostatMode", ".", "OFF", ":", "new_mode", "=", "COMMAND_THERMOSTAT_CONTROL_OFF_ALL_0X6B_0X09", "elif", "mode", "==", "ThermostatMode", ".", "HEAT", ":", "new_mo...
Set the thermostat mode. Mode optons: OFF = 0x00, HEAT = 0x01, COOL = 0x02, AUTO = 0x03, FAN_AUTO = 0x04, FAN_ALWAYS_ON = 0x8
[ "Set", "the", "thermostat", "mode", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/thermostat.py#L143-L168
nugget/python-insteonplm
insteonplm/states/thermostat.py
FanMode.set
def set(self, mode): """Set the thermostat mode. Mode optons: OFF = 0x00, HEAT = 0x01, COOL = 0x02, AUTO = 0x03, FAN_AUTO = 0x04, FAN_ALWAYS_ON = 0x8 """ if mode == ThermostatMode.FAN_AUTO: new_mode = CO...
python
def set(self, mode): """Set the thermostat mode. Mode optons: OFF = 0x00, HEAT = 0x01, COOL = 0x02, AUTO = 0x03, FAN_AUTO = 0x04, FAN_ALWAYS_ON = 0x8 """ if mode == ThermostatMode.FAN_AUTO: new_mode = CO...
[ "def", "set", "(", "self", ",", "mode", ")", ":", "if", "mode", "==", "ThermostatMode", ".", "FAN_AUTO", ":", "new_mode", "=", "COMMAND_THERMOSTAT_CONTROL_OFF_FAN_0X6B_0X08", "elif", "mode", "==", "ThermostatMode", ".", "FAN_ALWAYS_ON", ":", "new_mode", "=", "CO...
Set the thermostat mode. Mode optons: OFF = 0x00, HEAT = 0x01, COOL = 0x02, AUTO = 0x03, FAN_AUTO = 0x04, FAN_ALWAYS_ON = 0x8
[ "Set", "the", "thermostat", "mode", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/thermostat.py#L260-L280
nugget/python-insteonplm
insteonplm/states/thermostat.py
CoolSetPoint.set
def set(self, val): """Set the cool set point.""" msg = ExtendedSend( address=self._address, commandtuple=COMMAND_THERMOSTAT_SET_COOL_SETPOINT_0X6C_NONE, cmd2=int(val * 2), userdata=Userdata()) msg.set_checksum() self._send_method(msg, self...
python
def set(self, val): """Set the cool set point.""" msg = ExtendedSend( address=self._address, commandtuple=COMMAND_THERMOSTAT_SET_COOL_SETPOINT_0X6C_NONE, cmd2=int(val * 2), userdata=Userdata()) msg.set_checksum() self._send_method(msg, self...
[ "def", "set", "(", "self", ",", "val", ")", ":", "msg", "=", "ExtendedSend", "(", "address", "=", "self", ".", "_address", ",", "commandtuple", "=", "COMMAND_THERMOSTAT_SET_COOL_SETPOINT_0X6C_NONE", ",", "cmd2", "=", "int", "(", "val", "*", "2", ")", ",", ...
Set the cool set point.
[ "Set", "the", "cool", "set", "point", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/thermostat.py#L363-L371
nugget/python-insteonplm
insteonplm/states/thermostat.py
HeatSetPoint.set
def set(self, val): """Set the heat set point.""" msg = ExtendedSend( address=self._address, commandtuple=COMMAND_THERMOSTAT_SET_HEAT_SETPOINT_0X6D_NONE, cmd2=int(val * 2), userdata=Userdata()) msg.set_checksum() self._send_method(msg, self...
python
def set(self, val): """Set the heat set point.""" msg = ExtendedSend( address=self._address, commandtuple=COMMAND_THERMOSTAT_SET_HEAT_SETPOINT_0X6D_NONE, cmd2=int(val * 2), userdata=Userdata()) msg.set_checksum() self._send_method(msg, self...
[ "def", "set", "(", "self", ",", "val", ")", ":", "msg", "=", "ExtendedSend", "(", "address", "=", "self", ".", "_address", ",", "commandtuple", "=", "COMMAND_THERMOSTAT_SET_HEAT_SETPOINT_0X6D_NONE", ",", "cmd2", "=", "int", "(", "val", "*", "2", ")", ",", ...
Set the heat set point.
[ "Set", "the", "heat", "set", "point", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/thermostat.py#L419-L427
nugget/python-insteonplm
insteonplm/linkedDevices.py
LinkedDevices.add_device_callback
def add_device_callback(self, callback): """Register a callback to be invoked when a new device appears.""" _LOGGER.debug('Added new callback %s ', callback) self._cb_new_device.append(callback)
python
def add_device_callback(self, callback): """Register a callback to be invoked when a new device appears.""" _LOGGER.debug('Added new callback %s ', callback) self._cb_new_device.append(callback)
[ "def", "add_device_callback", "(", "self", ",", "callback", ")", ":", "_LOGGER", ".", "debug", "(", "'Added new callback %s '", ",", "callback", ")", "self", ".", "_cb_new_device", ".", "append", "(", "callback", ")" ]
Register a callback to be invoked when a new device appears.
[ "Register", "a", "callback", "to", "be", "invoked", "when", "a", "new", "device", "appears", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/linkedDevices.py#L93-L96
nugget/python-insteonplm
insteonplm/linkedDevices.py
LinkedDevices.add_override
def add_override(self, addr, key, value): """Register an attribute override for a device.""" address = Address(str(addr)).id _LOGGER.debug('New override for %s %s is %s', address, key, value) device_override = self._overrides.get(address, {}) device_override[key] = value ...
python
def add_override(self, addr, key, value): """Register an attribute override for a device.""" address = Address(str(addr)).id _LOGGER.debug('New override for %s %s is %s', address, key, value) device_override = self._overrides.get(address, {}) device_override[key] = value ...
[ "def", "add_override", "(", "self", ",", "addr", ",", "key", ",", "value", ")", ":", "address", "=", "Address", "(", "str", "(", "addr", ")", ")", ".", "id", "_LOGGER", ".", "debug", "(", "'New override for %s %s is %s'", ",", "address", ",", "key", ",...
Register an attribute override for a device.
[ "Register", "an", "attribute", "override", "for", "a", "device", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/linkedDevices.py#L98-L104
nugget/python-insteonplm
insteonplm/linkedDevices.py
LinkedDevices.create_device_from_category
def create_device_from_category(self, plm, addr, cat, subcat, product_key=0x00): """Create a new device from the cat, subcat and product_key data.""" saved_device = self._saved_devices.get(Address(addr).id, {}) cat = saved_device.get('cat', cat) subcat...
python
def create_device_from_category(self, plm, addr, cat, subcat, product_key=0x00): """Create a new device from the cat, subcat and product_key data.""" saved_device = self._saved_devices.get(Address(addr).id, {}) cat = saved_device.get('cat', cat) subcat...
[ "def", "create_device_from_category", "(", "self", ",", "plm", ",", "addr", ",", "cat", ",", "subcat", ",", "product_key", "=", "0x00", ")", ":", "saved_device", "=", "self", ".", "_saved_devices", ".", "get", "(", "Address", "(", "addr", ")", ".", "id",...
Create a new device from the cat, subcat and product_key data.
[ "Create", "a", "new", "device", "from", "the", "cat", "subcat", "and", "product_key", "data", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/linkedDevices.py#L106-L120
nugget/python-insteonplm
insteonplm/linkedDevices.py
LinkedDevices.has_saved
def has_saved(self, addr): """Test if device has data from the saved data file.""" saved = False if self._saved_devices.get(addr, None) is not None: saved = True return saved
python
def has_saved(self, addr): """Test if device has data from the saved data file.""" saved = False if self._saved_devices.get(addr, None) is not None: saved = True return saved
[ "def", "has_saved", "(", "self", ",", "addr", ")", ":", "saved", "=", "False", "if", "self", ".", "_saved_devices", ".", "get", "(", "addr", ",", "None", ")", "is", "not", "None", ":", "saved", "=", "True", "return", "saved" ]
Test if device has data from the saved data file.
[ "Test", "if", "device", "has", "data", "from", "the", "saved", "data", "file", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/linkedDevices.py#L122-L127
nugget/python-insteonplm
insteonplm/linkedDevices.py
LinkedDevices.has_override
def has_override(self, addr): """Test if device has data from a device override setting.""" override = False if self._overrides.get(addr, None) is not None: override = True return override
python
def has_override(self, addr): """Test if device has data from a device override setting.""" override = False if self._overrides.get(addr, None) is not None: override = True return override
[ "def", "has_override", "(", "self", ",", "addr", ")", ":", "override", "=", "False", "if", "self", ".", "_overrides", ".", "get", "(", "addr", ",", "None", ")", "is", "not", "None", ":", "override", "=", "True", "return", "override" ]
Test if device has data from a device override setting.
[ "Test", "if", "device", "has", "data", "from", "a", "device", "override", "setting", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/linkedDevices.py#L129-L134
nugget/python-insteonplm
insteonplm/linkedDevices.py
LinkedDevices.add_known_devices
def add_known_devices(self, plm): """Add devices from the saved devices or from the device overrides.""" from insteonplm.devices import ALDBStatus for addr in self._saved_devices: if not self._devices.get(addr): saved_device = self._saved_devices.get(Address(addr).id,...
python
def add_known_devices(self, plm): """Add devices from the saved devices or from the device overrides.""" from insteonplm.devices import ALDBStatus for addr in self._saved_devices: if not self._devices.get(addr): saved_device = self._saved_devices.get(Address(addr).id,...
[ "def", "add_known_devices", "(", "self", ",", "plm", ")", ":", "from", "insteonplm", ".", "devices", "import", "ALDBStatus", "for", "addr", "in", "self", ".", "_saved_devices", ":", "if", "not", "self", ".", "_devices", ".", "get", "(", "addr", ")", ":",...
Add devices from the saved devices or from the device overrides.
[ "Add", "devices", "from", "the", "saved", "devices", "or", "from", "the", "device", "overrides", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/linkedDevices.py#L136-L168
nugget/python-insteonplm
insteonplm/linkedDevices.py
LinkedDevices.save_device_info
def save_device_info(self): """Save all device information to the device info file.""" if self._workdir is not None: devices = [] for addr in self._devices: device = self._devices.get(addr) if not device.address.is_x10: aldb = {...
python
def save_device_info(self): """Save all device information to the device info file.""" if self._workdir is not None: devices = [] for addr in self._devices: device = self._devices.get(addr) if not device.address.is_x10: aldb = {...
[ "def", "save_device_info", "(", "self", ")", ":", "if", "self", ".", "_workdir", "is", "not", "None", ":", "devices", "=", "[", "]", "for", "addr", "in", "self", ".", "_devices", ":", "device", "=", "self", ".", "_devices", ".", "get", "(", "addr", ...
Save all device information to the device info file.
[ "Save", "all", "device", "information", "to", "the", "device", "info", "file", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/linkedDevices.py#L171-L198
nugget/python-insteonplm
insteonplm/linkedDevices.py
LinkedDevices._add_saved_device_info
def _add_saved_device_info(self, **kwarg): """Register device info from the saved data file.""" addr = kwarg.get('address') _LOGGER.debug('Found saved device with address %s', addr) self._saved_devices[addr] = kwarg
python
def _add_saved_device_info(self, **kwarg): """Register device info from the saved data file.""" addr = kwarg.get('address') _LOGGER.debug('Found saved device with address %s', addr) self._saved_devices[addr] = kwarg
[ "def", "_add_saved_device_info", "(", "self", ",", "*", "*", "kwarg", ")", ":", "addr", "=", "kwarg", ".", "get", "(", "'address'", ")", "_LOGGER", ".", "debug", "(", "'Found saved device with address %s'", ",", "addr", ")", "self", ".", "_saved_devices", "[...
Register device info from the saved data file.
[ "Register", "device", "info", "from", "the", "saved", "data", "file", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/linkedDevices.py#L200-L204
nugget/python-insteonplm
insteonplm/linkedDevices.py
LinkedDevices.load_saved_device_info
async def load_saved_device_info(self): """Load device information from the device info file.""" _LOGGER.debug("Loading saved device info.") deviceinfo = [] if self._workdir: _LOGGER.debug("Really Loading saved device info.") try: device_file = '{}...
python
async def load_saved_device_info(self): """Load device information from the device info file.""" _LOGGER.debug("Loading saved device info.") deviceinfo = [] if self._workdir: _LOGGER.debug("Really Loading saved device info.") try: device_file = '{}...
[ "async", "def", "load_saved_device_info", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "\"Loading saved device info.\"", ")", "deviceinfo", "=", "[", "]", "if", "self", ".", "_workdir", ":", "_LOGGER", ".", "debug", "(", "\"Really Loading saved device info...
Load device information from the device info file.
[ "Load", "device", "information", "from", "the", "device", "info", "file", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/linkedDevices.py#L206-L223
nugget/python-insteonplm
insteonplm/messages/x10received.py
X10Received.unit_code_msg
def unit_code_msg(housecode, unitcode): """Create an X10 message to send the house code and unit code.""" house_byte = 0 unit_byte = 0 if isinstance(housecode, str): house_byte = insteonplm.utils.housecode_to_byte(housecode) << 4 unit_byte = insteonplm.utils.unitc...
python
def unit_code_msg(housecode, unitcode): """Create an X10 message to send the house code and unit code.""" house_byte = 0 unit_byte = 0 if isinstance(housecode, str): house_byte = insteonplm.utils.housecode_to_byte(housecode) << 4 unit_byte = insteonplm.utils.unitc...
[ "def", "unit_code_msg", "(", "housecode", ",", "unitcode", ")", ":", "house_byte", "=", "0", "unit_byte", "=", "0", "if", "isinstance", "(", "housecode", ",", "str", ")", ":", "house_byte", "=", "insteonplm", ".", "utils", ".", "housecode_to_byte", "(", "h...
Create an X10 message to send the house code and unit code.
[ "Create", "an", "X10", "message", "to", "send", "the", "house", "code", "and", "unit", "code", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/messages/x10received.py#L40-L53
nugget/python-insteonplm
insteonplm/messages/x10received.py
X10Received.command_msg
def command_msg(housecode, command): """Create an X10 message to send the house code and a command code.""" house_byte = 0 if isinstance(housecode, str): house_byte = insteonplm.utils.housecode_to_byte(housecode) << 4 elif isinstance(housecode, int) and housecode < 16: ...
python
def command_msg(housecode, command): """Create an X10 message to send the house code and a command code.""" house_byte = 0 if isinstance(housecode, str): house_byte = insteonplm.utils.housecode_to_byte(housecode) << 4 elif isinstance(housecode, int) and housecode < 16: ...
[ "def", "command_msg", "(", "housecode", ",", "command", ")", ":", "house_byte", "=", "0", "if", "isinstance", "(", "housecode", ",", "str", ")", ":", "house_byte", "=", "insteonplm", ".", "utils", ".", "housecode_to_byte", "(", "housecode", ")", "<<", "4",...
Create an X10 message to send the house code and a command code.
[ "Create", "an", "X10", "message", "to", "send", "the", "house", "code", "and", "a", "command", "code", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/messages/x10received.py#L56-L65
nugget/python-insteonplm
insteonplm/__init__.py
create_http_connection
async def create_http_connection(loop, protocol_factory, host, port=25105, auth=None): """Create an HTTP session used to connect to the Insteon Hub.""" protocol = protocol_factory() transport = HttpTransport(loop, protocol, host, port, auth) _LOGGER.debug("create_http_co...
python
async def create_http_connection(loop, protocol_factory, host, port=25105, auth=None): """Create an HTTP session used to connect to the Insteon Hub.""" protocol = protocol_factory() transport = HttpTransport(loop, protocol, host, port, auth) _LOGGER.debug("create_http_co...
[ "async", "def", "create_http_connection", "(", "loop", ",", "protocol_factory", ",", "host", ",", "port", "=", "25105", ",", "auth", "=", "None", ")", ":", "protocol", "=", "protocol_factory", "(", ")", "transport", "=", "HttpTransport", "(", "loop", ",", ...
Create an HTTP session used to connect to the Insteon Hub.
[ "Create", "an", "HTTP", "session", "used", "to", "connect", "to", "the", "Insteon", "Hub", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/__init__.py#L21-L27
nugget/python-insteonplm
insteonplm/__init__.py
Connection.create
async def create(cls, device='/dev/ttyUSB0', host=None, username=None, password=None, port=25010, hub_version=2, auto_reconnect=True, loop=None, workdir=None, poll_devices=True, load_aldb=True): """Create a connection to a specific device. ...
python
async def create(cls, device='/dev/ttyUSB0', host=None, username=None, password=None, port=25010, hub_version=2, auto_reconnect=True, loop=None, workdir=None, poll_devices=True, load_aldb=True): """Create a connection to a specific device. ...
[ "async", "def", "create", "(", "cls", ",", "device", "=", "'/dev/ttyUSB0'", ",", "host", "=", "None", ",", "username", "=", "None", ",", "password", "=", "None", ",", "port", "=", "25010", ",", "hub_version", "=", "2", ",", "auto_reconnect", "=", "True...
Create a connection to a specific device. Here is where we supply the device and callback callables we expect for this PLM class object. :param device: Unix device where the PLM is attached :param address: IP Address of the Hub :param username: ...
[ "Create", "a", "connection", "to", "a", "specific", "device", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/__init__.py#L113-L170
nugget/python-insteonplm
insteonplm/__init__.py
Connection.reconnect
async def reconnect(self): """Reconnect to the modem.""" _LOGGER.debug('starting Connection.reconnect') await self._connect() while self._closed: await self._retry_connection() _LOGGER.debug('ending Connection.reconnect')
python
async def reconnect(self): """Reconnect to the modem.""" _LOGGER.debug('starting Connection.reconnect') await self._connect() while self._closed: await self._retry_connection() _LOGGER.debug('ending Connection.reconnect')
[ "async", "def", "reconnect", "(", "self", ")", ":", "_LOGGER", ".", "debug", "(", "'starting Connection.reconnect'", ")", "await", "self", ".", "_connect", "(", ")", "while", "self", ".", "_closed", ":", "await", "self", ".", "_retry_connection", "(", ")", ...
Reconnect to the modem.
[ "Reconnect", "to", "the", "modem", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/__init__.py#L187-L193
nugget/python-insteonplm
insteonplm/__init__.py
Connection.close
async def close(self, event): """Close the PLM device connection and don't try to reconnect.""" _LOGGER.info('Closing connection to Insteon Modem') self._closing = True self._auto_reconnect = False await self.protocol.close() if self.protocol.transport: self.p...
python
async def close(self, event): """Close the PLM device connection and don't try to reconnect.""" _LOGGER.info('Closing connection to Insteon Modem') self._closing = True self._auto_reconnect = False await self.protocol.close() if self.protocol.transport: self.p...
[ "async", "def", "close", "(", "self", ",", "event", ")", ":", "_LOGGER", ".", "info", "(", "'Closing connection to Insteon Modem'", ")", "self", ".", "_closing", "=", "True", "self", ".", "_auto_reconnect", "=", "False", "await", "self", ".", "protocol", "."...
Close the PLM device connection and don't try to reconnect.
[ "Close", "the", "PLM", "device", "connection", "and", "don", "t", "try", "to", "reconnect", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/__init__.py#L196-L205
nugget/python-insteonplm
insteonplm/__init__.py
Connection.dump_conndata
def dump_conndata(self): """Developer tool for debugging forensics.""" attrs = vars(self) return ', '.join("%s: %s" % item for item in attrs.items())
python
def dump_conndata(self): """Developer tool for debugging forensics.""" attrs = vars(self) return ', '.join("%s: %s" % item for item in attrs.items())
[ "def", "dump_conndata", "(", "self", ")", ":", "attrs", "=", "vars", "(", "self", ")", "return", "', '", ".", "join", "(", "\"%s: %s\"", "%", "item", "for", "item", "in", "attrs", ".", "items", "(", ")", ")" ]
Developer tool for debugging forensics.
[ "Developer", "tool", "for", "debugging", "forensics", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/__init__.py#L220-L223
nugget/python-insteonplm
insteonplm/states/x10.py
X10OnOffSwitch.on
def on(self): """Send the On command to an X10 device.""" msg = X10Send.unit_code_msg(self.address.x10_housecode, self.address.x10_unitcode) self._send_method(msg) msg = X10Send.command_msg(self.address.x10_housecode, ...
python
def on(self): """Send the On command to an X10 device.""" msg = X10Send.unit_code_msg(self.address.x10_housecode, self.address.x10_unitcode) self._send_method(msg) msg = X10Send.command_msg(self.address.x10_housecode, ...
[ "def", "on", "(", "self", ")", ":", "msg", "=", "X10Send", ".", "unit_code_msg", "(", "self", ".", "address", ".", "x10_housecode", ",", "self", ".", "address", ".", "x10_unitcode", ")", "self", ".", "_send_method", "(", "msg", ")", "msg", "=", "X10Sen...
Send the On command to an X10 device.
[ "Send", "the", "On", "command", "to", "an", "X10", "device", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/x10.py#L30-L39
nugget/python-insteonplm
insteonplm/states/x10.py
X10OnOffSwitch.off
def off(self): """Send the Off command to an X10 device.""" msg = X10Send.unit_code_msg(self.address.x10_housecode, self.address.x10_unitcode) self._send_method(msg) msg = X10Send.command_msg(self.address.x10_housecode, ...
python
def off(self): """Send the Off command to an X10 device.""" msg = X10Send.unit_code_msg(self.address.x10_housecode, self.address.x10_unitcode) self._send_method(msg) msg = X10Send.command_msg(self.address.x10_housecode, ...
[ "def", "off", "(", "self", ")", ":", "msg", "=", "X10Send", ".", "unit_code_msg", "(", "self", ".", "address", ".", "x10_housecode", ",", "self", ".", "address", ".", "x10_unitcode", ")", "self", ".", "_send_method", "(", "msg", ")", "msg", "=", "X10Se...
Send the Off command to an X10 device.
[ "Send", "the", "Off", "command", "to", "an", "X10", "device", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/x10.py#L41-L50
nugget/python-insteonplm
insteonplm/states/x10.py
X10DimmableSwitch.set_level
def set_level(self, val): """Set the device ON LEVEL.""" if val == 0: self.off() elif val == 255: self.on() else: setlevel = 255 if val < 1: setlevel = val * 255 elif val <= 0xff: setlevel = val ...
python
def set_level(self, val): """Set the device ON LEVEL.""" if val == 0: self.off() elif val == 255: self.on() else: setlevel = 255 if val < 1: setlevel = val * 255 elif val <= 0xff: setlevel = val ...
[ "def", "set_level", "(", "self", ",", "val", ")", ":", "if", "val", "==", "0", ":", "self", ".", "off", "(", ")", "elif", "val", "==", "255", ":", "self", ".", "on", "(", ")", "else", ":", "setlevel", "=", "255", "if", "val", "<", "1", ":", ...
Set the device ON LEVEL.
[ "Set", "the", "device", "ON", "LEVEL", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/x10.py#L107-L134
nugget/python-insteonplm
insteonplm/states/x10.py
X10DimmableSwitch.brighten
def brighten(self, defer_update=False): """Brighten the device one step.""" msg = X10Send.unit_code_msg(self.address.x10_housecode, self.address.x10_unitcode) self._send_method(msg) msg = X10Send.command_msg(self.address.x10_housecode, ...
python
def brighten(self, defer_update=False): """Brighten the device one step.""" msg = X10Send.unit_code_msg(self.address.x10_housecode, self.address.x10_unitcode) self._send_method(msg) msg = X10Send.command_msg(self.address.x10_housecode, ...
[ "def", "brighten", "(", "self", ",", "defer_update", "=", "False", ")", ":", "msg", "=", "X10Send", ".", "unit_code_msg", "(", "self", ".", "address", ".", "x10_housecode", ",", "self", ".", "address", ".", "x10_unitcode", ")", "self", ".", "_send_method",...
Brighten the device one step.
[ "Brighten", "the", "device", "one", "step", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/x10.py#L136-L146
nugget/python-insteonplm
insteonplm/states/x10.py
X10DimmableSwitch.dim
def dim(self, defer_update=False): """Dim the device one step.""" msg = X10Send.unit_code_msg(self.address.x10_housecode, self.address.x10_unitcode) self._send_method(msg) msg = X10Send.command_msg(self.address.x10_housecode, ...
python
def dim(self, defer_update=False): """Dim the device one step.""" msg = X10Send.unit_code_msg(self.address.x10_housecode, self.address.x10_unitcode) self._send_method(msg) msg = X10Send.command_msg(self.address.x10_housecode, ...
[ "def", "dim", "(", "self", ",", "defer_update", "=", "False", ")", ":", "msg", "=", "X10Send", ".", "unit_code_msg", "(", "self", ".", "address", ".", "x10_housecode", ",", "self", ".", "address", ".", "x10_unitcode", ")", "self", ".", "_send_method", "(...
Dim the device one step.
[ "Dim", "the", "device", "one", "step", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/x10.py#L148-L158
nugget/python-insteonplm
insteonplm/address.py
Address.matches_pattern
def matches_pattern(self, other): """Test Address object matches the pattern of another object.""" matches = False if hasattr(other, 'addr'): if self.addr is None or other.addr is None: matches = True else: matches = self.addr == other.add...
python
def matches_pattern(self, other): """Test Address object matches the pattern of another object.""" matches = False if hasattr(other, 'addr'): if self.addr is None or other.addr is None: matches = True else: matches = self.addr == other.add...
[ "def", "matches_pattern", "(", "self", ",", "other", ")", ":", "matches", "=", "False", "if", "hasattr", "(", "other", ",", "'addr'", ")", ":", "if", "self", ".", "addr", "is", "None", "or", "other", ".", "addr", "is", "None", ":", "matches", "=", ...
Test Address object matches the pattern of another object.
[ "Test", "Address", "object", "matches", "the", "pattern", "of", "another", "object", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/address.py#L57-L65
nugget/python-insteonplm
insteonplm/address.py
Address._normalize
def _normalize(self, addr): """Take any format of address and turn it into a hex string.""" normalize = None if isinstance(addr, Address): normalize = addr.addr self._is_x10 = addr.is_x10 elif isinstance(addr, bytearray): normalize = binascii.unhexlif...
python
def _normalize(self, addr): """Take any format of address and turn it into a hex string.""" normalize = None if isinstance(addr, Address): normalize = addr.addr self._is_x10 = addr.is_x10 elif isinstance(addr, bytearray): normalize = binascii.unhexlif...
[ "def", "_normalize", "(", "self", ",", "addr", ")", ":", "normalize", "=", "None", "if", "isinstance", "(", "addr", ",", "Address", ")", ":", "normalize", "=", "addr", ".", "addr", "self", ".", "_is_x10", "=", "addr", ".", "is_x10", "elif", "isinstance...
Take any format of address and turn it into a hex string.
[ "Take", "any", "format", "of", "address", "and", "turn", "it", "into", "a", "hex", "string", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/address.py#L67-L96
nugget/python-insteonplm
insteonplm/address.py
Address.human
def human(self): """Emit the address in human-readible format (AA.BB.CC).""" addrstr = '00.00.00' if self.addr: if self._is_x10: housecode_byte = self.addr[1] housecode = insteonplm.utils.byte_to_housecode(housecode_byte) unitcode_byte ...
python
def human(self): """Emit the address in human-readible format (AA.BB.CC).""" addrstr = '00.00.00' if self.addr: if self._is_x10: housecode_byte = self.addr[1] housecode = insteonplm.utils.byte_to_housecode(housecode_byte) unitcode_byte ...
[ "def", "human", "(", "self", ")", ":", "addrstr", "=", "'00.00.00'", "if", "self", ".", "addr", ":", "if", "self", ".", "_is_x10", ":", "housecode_byte", "=", "self", ".", "addr", "[", "1", "]", "housecode", "=", "insteonplm", ".", "utils", ".", "byt...
Emit the address in human-readible format (AA.BB.CC).
[ "Emit", "the", "address", "in", "human", "-", "readible", "format", "(", "AA", ".", "BB", ".", "CC", ")", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/address.py#L99-L113
nugget/python-insteonplm
insteonplm/address.py
Address.hex
def hex(self): """Emit the address in bare hex format (aabbcc).""" addrstr = '000000' if self.addr is not None: addrstr = binascii.hexlify(self.addr).decode() return addrstr
python
def hex(self): """Emit the address in bare hex format (aabbcc).""" addrstr = '000000' if self.addr is not None: addrstr = binascii.hexlify(self.addr).decode() return addrstr
[ "def", "hex", "(", "self", ")", ":", "addrstr", "=", "'000000'", "if", "self", ".", "addr", "is", "not", "None", ":", "addrstr", "=", "binascii", ".", "hexlify", "(", "self", ".", "addr", ")", ".", "decode", "(", ")", "return", "addrstr" ]
Emit the address in bare hex format (aabbcc).
[ "Emit", "the", "address", "in", "bare", "hex", "format", "(", "aabbcc", ")", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/address.py#L116-L121
nugget/python-insteonplm
insteonplm/address.py
Address.bytes
def bytes(self): """Emit the address in bytes format.""" addrbyte = b'\x00\x00\x00' if self.addr is not None: addrbyte = self.addr return addrbyte
python
def bytes(self): """Emit the address in bytes format.""" addrbyte = b'\x00\x00\x00' if self.addr is not None: addrbyte = self.addr return addrbyte
[ "def", "bytes", "(", "self", ")", ":", "addrbyte", "=", "b'\\x00\\x00\\x00'", "if", "self", ".", "addr", "is", "not", "None", ":", "addrbyte", "=", "self", ".", "addr", "return", "addrbyte" ]
Emit the address in bytes format.
[ "Emit", "the", "address", "in", "bytes", "format", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/address.py#L124-L129
nugget/python-insteonplm
insteonplm/address.py
Address.id
def id(self): """Return the ID of the device address.""" dev_id = '' if self._is_x10: dev_id = 'x10{}{:02d}'.format(self.x10_housecode, self.x10_unitcode) else: dev_id = self.hex return dev_id
python
def id(self): """Return the ID of the device address.""" dev_id = '' if self._is_x10: dev_id = 'x10{}{:02d}'.format(self.x10_housecode, self.x10_unitcode) else: dev_id = self.hex return dev_id
[ "def", "id", "(", "self", ")", ":", "dev_id", "=", "''", "if", "self", ".", "_is_x10", ":", "dev_id", "=", "'x10{}{:02d}'", ".", "format", "(", "self", ".", "x10_housecode", ",", "self", ".", "x10_unitcode", ")", "else", ":", "dev_id", "=", "self", "...
Return the ID of the device address.
[ "Return", "the", "ID", "of", "the", "device", "address", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/address.py#L132-L140
nugget/python-insteonplm
insteonplm/address.py
Address.x10_housecode
def x10_housecode(self): """Emit the X10 house code.""" housecode = None if self.is_x10: housecode = insteonplm.utils.byte_to_housecode(self.addr[1]) return housecode
python
def x10_housecode(self): """Emit the X10 house code.""" housecode = None if self.is_x10: housecode = insteonplm.utils.byte_to_housecode(self.addr[1]) return housecode
[ "def", "x10_housecode", "(", "self", ")", ":", "housecode", "=", "None", "if", "self", ".", "is_x10", ":", "housecode", "=", "insteonplm", ".", "utils", ".", "byte_to_housecode", "(", "self", ".", "addr", "[", "1", "]", ")", "return", "housecode" ]
Emit the X10 house code.
[ "Emit", "the", "X10", "house", "code", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/address.py#L169-L174
nugget/python-insteonplm
insteonplm/address.py
Address.x10_unitcode
def x10_unitcode(self): """Emit the X10 unit code.""" unitcode = None if self.is_x10: unitcode = insteonplm.utils.byte_to_unitcode(self.addr[2]) return unitcode
python
def x10_unitcode(self): """Emit the X10 unit code.""" unitcode = None if self.is_x10: unitcode = insteonplm.utils.byte_to_unitcode(self.addr[2]) return unitcode
[ "def", "x10_unitcode", "(", "self", ")", ":", "unitcode", "=", "None", "if", "self", ".", "is_x10", ":", "unitcode", "=", "insteonplm", ".", "utils", ".", "byte_to_unitcode", "(", "self", ".", "addr", "[", "2", "]", ")", "return", "unitcode" ]
Emit the X10 unit code.
[ "Emit", "the", "X10", "unit", "code", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/address.py#L177-L182
nugget/python-insteonplm
insteonplm/address.py
Address.x10
def x10(cls, housecode, unitcode): """Create an X10 device address.""" if housecode.lower() in ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p']: byte_housecode = insteonplm.utils.housecode_to_byte(housecode) else: ...
python
def x10(cls, housecode, unitcode): """Create an X10 device address.""" if housecode.lower() in ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p']: byte_housecode = insteonplm.utils.housecode_to_byte(housecode) else: ...
[ "def", "x10", "(", "cls", ",", "housecode", ",", "unitcode", ")", ":", "if", "housecode", ".", "lower", "(", ")", "in", "[", "'a'", ",", "'b'", ",", "'c'", ",", "'d'", ",", "'e'", ",", "'f'", ",", "'g'", ",", "'h'", ",", "'i'", ",", "'j'", ",...
Create an X10 device address.
[ "Create", "an", "X10", "device", "address", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/address.py#L185-L210
nugget/python-insteonplm
insteonplm/messages/manageAllLinkRecord.py
ManageAllLinkRecord.from_raw_message
def from_raw_message(cls, rawmessage): """Create message from raw byte stream.""" return ManageAllLinkRecord(rawmessage[2:3], rawmessage[3:4], rawmessage[4:7], rawmessage[7:8], ...
python
def from_raw_message(cls, rawmessage): """Create message from raw byte stream.""" return ManageAllLinkRecord(rawmessage[2:3], rawmessage[3:4], rawmessage[4:7], rawmessage[7:8], ...
[ "def", "from_raw_message", "(", "cls", ",", "rawmessage", ")", ":", "return", "ManageAllLinkRecord", "(", "rawmessage", "[", "2", ":", "3", "]", ",", "rawmessage", "[", "3", ":", "4", "]", ",", "rawmessage", "[", "4", ":", "7", "]", ",", "rawmessage", ...
Create message from raw byte stream.
[ "Create", "message", "from", "raw", "byte", "stream", "." ]
train
https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/messages/manageAllLinkRecord.py#L37-L45
notanumber/xapian-haystack
xapian_backend.py
_term_to_xapian_value
def _term_to_xapian_value(term, field_type): """ Converts a term to a serialized Xapian value based on the field_type. """ assert field_type in FIELD_TYPES def strf(dt): """ Equivalent to datetime.datetime.strptime(dt, DATETIME_FORMAT) but accepts years below 1900 (see h...
python
def _term_to_xapian_value(term, field_type): """ Converts a term to a serialized Xapian value based on the field_type. """ assert field_type in FIELD_TYPES def strf(dt): """ Equivalent to datetime.datetime.strptime(dt, DATETIME_FORMAT) but accepts years below 1900 (see h...
[ "def", "_term_to_xapian_value", "(", "term", ",", "field_type", ")", ":", "assert", "field_type", "in", "FIELD_TYPES", "def", "strf", "(", "dt", ")", ":", "\"\"\"\n Equivalent to datetime.datetime.strptime(dt, DATETIME_FORMAT)\n but accepts years below 1900 (see htt...
Converts a term to a serialized Xapian value based on the field_type.
[ "Converts", "a", "term", "to", "a", "serialized", "Xapian", "value", "based", "on", "the", "field_type", "." ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1588-L1622
notanumber/xapian-haystack
xapian_backend.py
_from_xapian_value
def _from_xapian_value(value, field_type): """ Converts a serialized Xapian value to Python equivalent based on the field_type. Doesn't accept multivalued fields. """ assert field_type in FIELD_TYPES if field_type == 'boolean': if value == 't': return True elif v...
python
def _from_xapian_value(value, field_type): """ Converts a serialized Xapian value to Python equivalent based on the field_type. Doesn't accept multivalued fields. """ assert field_type in FIELD_TYPES if field_type == 'boolean': if value == 't': return True elif v...
[ "def", "_from_xapian_value", "(", "value", ",", "field_type", ")", ":", "assert", "field_type", "in", "FIELD_TYPES", "if", "field_type", "==", "'boolean'", ":", "if", "value", "==", "'t'", ":", "return", "True", "elif", "value", "==", "'f'", ":", "return", ...
Converts a serialized Xapian value to Python equivalent based on the field_type. Doesn't accept multivalued fields.
[ "Converts", "a", "serialized", "Xapian", "value", "to", "Python", "equivalent", "based", "on", "the", "field_type", "." ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1633-L1659
notanumber/xapian-haystack
xapian_backend.py
XapianSearchBackend._update_cache
def _update_cache(self): """ To avoid build_schema every time, we cache some values: they only change when a SearchIndex changes, which typically restarts the Python. """ fields = connections[self.connection_alias].get_unified_index().all_searchfields() if self._f...
python
def _update_cache(self): """ To avoid build_schema every time, we cache some values: they only change when a SearchIndex changes, which typically restarts the Python. """ fields = connections[self.connection_alias].get_unified_index().all_searchfields() if self._f...
[ "def", "_update_cache", "(", "self", ")", ":", "fields", "=", "connections", "[", "self", ".", "connection_alias", "]", ".", "get_unified_index", "(", ")", ".", "all_searchfields", "(", ")", "if", "self", ".", "_fields", "!=", "fields", ":", "self", ".", ...
To avoid build_schema every time, we cache some values: they only change when a SearchIndex changes, which typically restarts the Python.
[ "To", "avoid", "build_schema", "every", "time", "we", "cache", "some", "values", ":", "they", "only", "change", "when", "a", "SearchIndex", "changes", "which", "typically", "restarts", "the", "Python", "." ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L221-L230
notanumber/xapian-haystack
xapian_backend.py
XapianSearchBackend.update
def update(self, index, iterable, commit=True): """ Updates the `index` with any objects in `iterable` by adding/updating the database as needed. Required arguments: `index` -- The `SearchIndex` to process `iterable` -- An iterable of model instances to index ...
python
def update(self, index, iterable, commit=True): """ Updates the `index` with any objects in `iterable` by adding/updating the database as needed. Required arguments: `index` -- The `SearchIndex` to process `iterable` -- An iterable of model instances to index ...
[ "def", "update", "(", "self", ",", "index", ",", "iterable", ",", "commit", "=", "True", ")", ":", "database", "=", "self", ".", "_database", "(", "writable", "=", "True", ")", "try", ":", "term_generator", "=", "xapian", ".", "TermGenerator", "(", ")"...
Updates the `index` with any objects in `iterable` by adding/updating the database as needed. Required arguments: `index` -- The `SearchIndex` to process `iterable` -- An iterable of model instances to index Optional arguments: `commit` -- ignored Fo...
[ "Updates", "the", "index", "with", "any", "objects", "in", "iterable", "by", "adding", "/", "updating", "the", "database", "as", "needed", "." ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L250-L503
notanumber/xapian-haystack
xapian_backend.py
XapianSearchBackend.remove
def remove(self, obj, commit=True): """ Remove indexes for `obj` from the database. We delete all instances of `Q<app_name>.<model_name>.<pk>` which should be unique to this object. Optional arguments: `commit` -- ignored """ database = self._database...
python
def remove(self, obj, commit=True): """ Remove indexes for `obj` from the database. We delete all instances of `Q<app_name>.<model_name>.<pk>` which should be unique to this object. Optional arguments: `commit` -- ignored """ database = self._database...
[ "def", "remove", "(", "self", ",", "obj", ",", "commit", "=", "True", ")", ":", "database", "=", "self", ".", "_database", "(", "writable", "=", "True", ")", "database", ".", "delete_document", "(", "TERM_PREFIXES", "[", "ID", "]", "+", "get_identifier",...
Remove indexes for `obj` from the database. We delete all instances of `Q<app_name>.<model_name>.<pk>` which should be unique to this object. Optional arguments: `commit` -- ignored
[ "Remove", "indexes", "for", "obj", "from", "the", "database", "." ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L505-L517
notanumber/xapian-haystack
xapian_backend.py
XapianSearchBackend.clear
def clear(self, models=(), commit=True): """ Clear all instances of `models` from the database or all models, if not specified. Optional Arguments: `models` -- Models to clear from the database (default = []) If `models` is empty, an empty query is executed which ma...
python
def clear(self, models=(), commit=True): """ Clear all instances of `models` from the database or all models, if not specified. Optional Arguments: `models` -- Models to clear from the database (default = []) If `models` is empty, an empty query is executed which ma...
[ "def", "clear", "(", "self", ",", "models", "=", "(", ")", ",", "commit", "=", "True", ")", ":", "if", "not", "models", ":", "# Because there does not appear to be a \"clear all\" method,", "# it's much quicker to remove the contents of the `self.path`", "# folder than it i...
Clear all instances of `models` from the database or all models, if not specified. Optional Arguments: `models` -- Models to clear from the database (default = []) If `models` is empty, an empty query is executed which matches all documents in the database. Afterwards, eac...
[ "Clear", "all", "instances", "of", "models", "from", "the", "database", "or", "all", "models", "if", "not", "specified", "." ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L519-L544
notanumber/xapian-haystack
xapian_backend.py
XapianSearchBackend._build_models_query
def _build_models_query(self, query): """ Builds a query from `query` that filters to documents only from registered models. """ registered_models_ct = self.build_models_list() if registered_models_ct: restrictions = [xapian.Query('%s%s' % (TERM_PREFIXES[DJANGO_CT], m...
python
def _build_models_query(self, query): """ Builds a query from `query` that filters to documents only from registered models. """ registered_models_ct = self.build_models_list() if registered_models_ct: restrictions = [xapian.Query('%s%s' % (TERM_PREFIXES[DJANGO_CT], m...
[ "def", "_build_models_query", "(", "self", ",", "query", ")", ":", "registered_models_ct", "=", "self", ".", "build_models_list", "(", ")", "if", "registered_models_ct", ":", "restrictions", "=", "[", "xapian", ".", "Query", "(", "'%s%s'", "%", "(", "TERM_PREF...
Builds a query from `query` that filters to documents only from registered models.
[ "Builds", "a", "query", "from", "query", "that", "filters", "to", "documents", "only", "from", "registered", "models", "." ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L552-L564
notanumber/xapian-haystack
xapian_backend.py
XapianSearchBackend._check_field_names
def _check_field_names(self, field_names): """ Raises InvalidIndexError if any of a field_name in field_names is not indexed. """ if field_names: for field_name in field_names: try: self.column[field_name] except Key...
python
def _check_field_names(self, field_names): """ Raises InvalidIndexError if any of a field_name in field_names is not indexed. """ if field_names: for field_name in field_names: try: self.column[field_name] except Key...
[ "def", "_check_field_names", "(", "self", ",", "field_names", ")", ":", "if", "field_names", ":", "for", "field_name", "in", "field_names", ":", "try", ":", "self", ".", "column", "[", "field_name", "]", "except", "KeyError", ":", "raise", "InvalidIndexError",...
Raises InvalidIndexError if any of a field_name in field_names is not indexed.
[ "Raises", "InvalidIndexError", "if", "any", "of", "a", "field_name", "in", "field_names", "is", "not", "indexed", "." ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L566-L576
notanumber/xapian-haystack
xapian_backend.py
XapianSearchBackend.search
def search(self, query, sort_by=None, start_offset=0, end_offset=None, fields='', highlight=False, facets=None, date_facets=None, query_facets=None, narrow_queries=None, spelling_query=None, limit_to_registered_models=None, result_class=None, **kwargs): """ E...
python
def search(self, query, sort_by=None, start_offset=0, end_offset=None, fields='', highlight=False, facets=None, date_facets=None, query_facets=None, narrow_queries=None, spelling_query=None, limit_to_registered_models=None, result_class=None, **kwargs): """ E...
[ "def", "search", "(", "self", ",", "query", ",", "sort_by", "=", "None", ",", "start_offset", "=", "0", ",", "end_offset", "=", "None", ",", "fields", "=", "''", ",", "highlight", "=", "False", ",", "facets", "=", "None", ",", "date_facets", "=", "No...
Executes the Xapian::query as defined in `query`. Required arguments: `query` -- Search query to execute Optional arguments: `sort_by` -- Sort results by specified field (default = None) `start_offset` -- Slice results from `start_offset` (default = 0) `...
[ "Executes", "the", "Xapian", "::", "query", "as", "defined", "in", "query", "." ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L579-L717
notanumber/xapian-haystack
xapian_backend.py
XapianSearchBackend.more_like_this
def more_like_this(self, model_instance, additional_query=None, start_offset=0, end_offset=None, limit_to_registered_models=True, result_class=None, **kwargs): """ Given a model instance, returns a result set of similar documents. Required arguments...
python
def more_like_this(self, model_instance, additional_query=None, start_offset=0, end_offset=None, limit_to_registered_models=True, result_class=None, **kwargs): """ Given a model instance, returns a result set of similar documents. Required arguments...
[ "def", "more_like_this", "(", "self", ",", "model_instance", ",", "additional_query", "=", "None", ",", "start_offset", "=", "0", ",", "end_offset", "=", "None", ",", "limit_to_registered_models", "=", "True", ",", "result_class", "=", "None", ",", "*", "*", ...
Given a model instance, returns a result set of similar documents. Required arguments: `model_instance` -- The model instance to use as a basis for retrieving similar documents. Optional arguments: `additional_query` -- An additional query to nar...
[ "Given", "a", "model", "instance", "returns", "a", "result", "set", "of", "similar", "documents", "." ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L719-L815
notanumber/xapian-haystack
xapian_backend.py
XapianSearchBackend.parse_query
def parse_query(self, query_string): """ Given a `query_string`, will attempt to return a xapian.Query Required arguments: ``query_string`` -- A query string to parse Returns a xapian.Query """ if query_string == '*': return xapian.Query('') # M...
python
def parse_query(self, query_string): """ Given a `query_string`, will attempt to return a xapian.Query Required arguments: ``query_string`` -- A query string to parse Returns a xapian.Query """ if query_string == '*': return xapian.Query('') # M...
[ "def", "parse_query", "(", "self", ",", "query_string", ")", ":", "if", "query_string", "==", "'*'", ":", "return", "xapian", ".", "Query", "(", "''", ")", "# Match everything", "elif", "query_string", "==", "''", ":", "return", "xapian", ".", "Query", "("...
Given a `query_string`, will attempt to return a xapian.Query Required arguments: ``query_string`` -- A query string to parse Returns a xapian.Query
[ "Given", "a", "query_string", "will", "attempt", "to", "return", "a", "xapian", ".", "Query" ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L817-L852
notanumber/xapian-haystack
xapian_backend.py
XapianSearchBackend.build_schema
def build_schema(self, fields): """ Build the schema from fields. :param fields: A list of fields in the index :returns: list of dictionaries Each dictionary has the keys field_name: The name of the field index type: what type of value it is 'multi_va...
python
def build_schema(self, fields): """ Build the schema from fields. :param fields: A list of fields in the index :returns: list of dictionaries Each dictionary has the keys field_name: The name of the field index type: what type of value it is 'multi_va...
[ "def", "build_schema", "(", "self", ",", "fields", ")", ":", "content_field_name", "=", "''", "schema_fields", "=", "[", "{", "'field_name'", ":", "ID", ",", "'type'", ":", "'text'", ",", "'multi_valued'", ":", "'false'", ",", "'column'", ":", "0", "}", ...
Build the schema from fields. :param fields: A list of fields in the index :returns: list of dictionaries Each dictionary has the keys field_name: The name of the field index type: what type of value it is 'multi_valued': if it allows more than one value 'co...
[ "Build", "the", "schema", "from", "fields", "." ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L854-L924
notanumber/xapian-haystack
xapian_backend.py
XapianSearchBackend._do_highlight
def _do_highlight(content, query, tag='em'): """ Highlight `query` terms in `content` with html `tag`. This method assumes that the input text (`content`) does not contain any special formatting. That is, it does not contain any html tags or similar markup that could be screwed...
python
def _do_highlight(content, query, tag='em'): """ Highlight `query` terms in `content` with html `tag`. This method assumes that the input text (`content`) does not contain any special formatting. That is, it does not contain any html tags or similar markup that could be screwed...
[ "def", "_do_highlight", "(", "content", ",", "query", ",", "tag", "=", "'em'", ")", ":", "for", "term", "in", "query", ":", "term", "=", "term", ".", "decode", "(", "'utf-8'", ")", "for", "match", "in", "re", ".", "findall", "(", "'[^A-Z]+'", ",", ...
Highlight `query` terms in `content` with html `tag`. This method assumes that the input text (`content`) does not contain any special formatting. That is, it does not contain any html tags or similar markup that could be screwed up by the highlighting. Required arguments: ...
[ "Highlight", "query", "terms", "in", "content", "with", "html", "tag", "." ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L927-L945
notanumber/xapian-haystack
xapian_backend.py
XapianSearchBackend._prepare_facet_field_spies
def _prepare_facet_field_spies(self, facets): """ Returns a list of spies based on the facets used to count frequencies. """ spies = [] for facet in facets: slot = self.column[facet] spy = xapian.ValueCountMatchSpy(slot) # add attribute...
python
def _prepare_facet_field_spies(self, facets): """ Returns a list of spies based on the facets used to count frequencies. """ spies = [] for facet in facets: slot = self.column[facet] spy = xapian.ValueCountMatchSpy(slot) # add attribute...
[ "def", "_prepare_facet_field_spies", "(", "self", ",", "facets", ")", ":", "spies", "=", "[", "]", "for", "facet", "in", "facets", ":", "slot", "=", "self", ".", "column", "[", "facet", "]", "spy", "=", "xapian", ".", "ValueCountMatchSpy", "(", "slot", ...
Returns a list of spies based on the facets used to count frequencies.
[ "Returns", "a", "list", "of", "spies", "based", "on", "the", "facets", "used", "to", "count", "frequencies", "." ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L947-L959
notanumber/xapian-haystack
xapian_backend.py
XapianSearchBackend._process_facet_field_spies
def _process_facet_field_spies(self, spies): """ Returns a dict of facet names with lists of tuples of the form (term, term_frequency) from a list of spies that observed the enquire. """ facet_dict = {} for spy in spies: field = self.schema[spy.slot] ...
python
def _process_facet_field_spies(self, spies): """ Returns a dict of facet names with lists of tuples of the form (term, term_frequency) from a list of spies that observed the enquire. """ facet_dict = {} for spy in spies: field = self.schema[spy.slot] ...
[ "def", "_process_facet_field_spies", "(", "self", ",", "spies", ")", ":", "facet_dict", "=", "{", "}", "for", "spy", "in", "spies", ":", "field", "=", "self", ".", "schema", "[", "spy", ".", "slot", "]", "field_name", ",", "field_type", "=", "field", "...
Returns a dict of facet names with lists of tuples of the form (term, term_frequency) from a list of spies that observed the enquire.
[ "Returns", "a", "dict", "of", "facet", "names", "with", "lists", "of", "tuples", "of", "the", "form", "(", "term", "term_frequency", ")", "from", "a", "list", "of", "spies", "that", "observed", "the", "enquire", "." ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L961-L983
notanumber/xapian-haystack
xapian_backend.py
XapianSearchBackend._do_multivalued_field_facets
def _do_multivalued_field_facets(self, results, field_facets): """ Implements a multivalued field facet on the results. This is implemented using brute force - O(N^2) - because Xapian does not have it implemented yet (see http://trac.xapian.org/ticket/199) """ fa...
python
def _do_multivalued_field_facets(self, results, field_facets): """ Implements a multivalued field facet on the results. This is implemented using brute force - O(N^2) - because Xapian does not have it implemented yet (see http://trac.xapian.org/ticket/199) """ fa...
[ "def", "_do_multivalued_field_facets", "(", "self", ",", "results", ",", "field_facets", ")", ":", "facet_dict", "=", "{", "}", "for", "field", "in", "field_facets", ":", "facet_list", "=", "{", "}", "if", "not", "self", ".", "_multi_value_field", "(", "fiel...
Implements a multivalued field facet on the results. This is implemented using brute force - O(N^2) - because Xapian does not have it implemented yet (see http://trac.xapian.org/ticket/199)
[ "Implements", "a", "multivalued", "field", "facet", "on", "the", "results", "." ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L985-L1006
notanumber/xapian-haystack
xapian_backend.py
XapianSearchBackend._do_date_facets
def _do_date_facets(results, date_facets): """ Private method that facets a document by date ranges Required arguments: `results` -- A list SearchResults to facet `date_facets` -- A dictionary containing facet parameters: {'field': {'start_date': ..., 'en...
python
def _do_date_facets(results, date_facets): """ Private method that facets a document by date ranges Required arguments: `results` -- A list SearchResults to facet `date_facets` -- A dictionary containing facet parameters: {'field': {'start_date': ..., 'en...
[ "def", "_do_date_facets", "(", "results", ",", "date_facets", ")", ":", "def", "next_datetime", "(", "previous", ",", "gap_value", ",", "gap_type", ")", ":", "year", "=", "previous", ".", "year", "month", "=", "previous", ".", "month", "if", "gap_type", "=...
Private method that facets a document by date ranges Required arguments: `results` -- A list SearchResults to facet `date_facets` -- A dictionary containing facet parameters: {'field': {'start_date': ..., 'end_date': ...: 'gap_by': '...', 'gap_amount': n}} ...
[ "Private", "method", "that", "facets", "a", "document", "by", "date", "ranges" ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1009-L1101
notanumber/xapian-haystack
xapian_backend.py
XapianSearchBackend._do_query_facets
def _do_query_facets(self, results, query_facets): """ Private method that facets a document by query Required arguments: `results` -- A list SearchResults to facet `query_facets` -- A dictionary containing facet parameters: {'field': 'query', [...]} ...
python
def _do_query_facets(self, results, query_facets): """ Private method that facets a document by query Required arguments: `results` -- A list SearchResults to facet `query_facets` -- A dictionary containing facet parameters: {'field': 'query', [...]} ...
[ "def", "_do_query_facets", "(", "self", ",", "results", ",", "query_facets", ")", ":", "facet_dict", "=", "{", "}", "for", "field", ",", "query", "in", "list", "(", "dict", "(", "query_facets", ")", ".", "items", "(", ")", ")", ":", "facet_dict", "[", ...
Private method that facets a document by query Required arguments: `results` -- A list SearchResults to facet `query_facets` -- A dictionary containing facet parameters: {'field': 'query', [...]} For each query in `query_facets`, generates a dictionary entry wit...
[ "Private", "method", "that", "facets", "a", "document", "by", "query" ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1103-L1122
notanumber/xapian-haystack
xapian_backend.py
XapianSearchBackend._do_spelling_suggestion
def _do_spelling_suggestion(database, query, spelling_query): """ Private method that returns a single spelling suggestion based on `spelling_query` or `query`. Required arguments: `database` -- The database to check spelling against `query` -- The query to check...
python
def _do_spelling_suggestion(database, query, spelling_query): """ Private method that returns a single spelling suggestion based on `spelling_query` or `query`. Required arguments: `database` -- The database to check spelling against `query` -- The query to check...
[ "def", "_do_spelling_suggestion", "(", "database", ",", "query", ",", "spelling_query", ")", ":", "if", "spelling_query", ":", "if", "' '", "in", "spelling_query", ":", "return", "' '", ".", "join", "(", "[", "database", ".", "get_spelling_suggestion", "(", "t...
Private method that returns a single spelling suggestion based on `spelling_query` or `query`. Required arguments: `database` -- The database to check spelling against `query` -- The query to check `spelling_query` -- If not None, this will be checked instead of `que...
[ "Private", "method", "that", "returns", "a", "single", "spelling", "suggestion", "based", "on", "spelling_query", "or", "query", "." ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1125-L1148
notanumber/xapian-haystack
xapian_backend.py
XapianSearchBackend._database
def _database(self, writable=False): """ Private method that returns a xapian.Database for use. Optional arguments: ``writable`` -- Open the database in read/write mode (default=False) Returns an instance of a xapian.Database or xapian.WritableDatabase """ i...
python
def _database(self, writable=False): """ Private method that returns a xapian.Database for use. Optional arguments: ``writable`` -- Open the database in read/write mode (default=False) Returns an instance of a xapian.Database or xapian.WritableDatabase """ i...
[ "def", "_database", "(", "self", ",", "writable", "=", "False", ")", ":", "if", "self", ".", "path", "==", "MEMORY_DB_NAME", ":", "if", "not", "self", ".", "inmemory_db", ":", "self", ".", "inmemory_db", "=", "xapian", ".", "inmemory_open", "(", ")", "...
Private method that returns a xapian.Database for use. Optional arguments: ``writable`` -- Open the database in read/write mode (default=False) Returns an instance of a xapian.Database or xapian.WritableDatabase
[ "Private", "method", "that", "returns", "a", "xapian", ".", "Database", "for", "use", "." ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1150-L1171
notanumber/xapian-haystack
xapian_backend.py
XapianSearchBackend._get_enquire_mset
def _get_enquire_mset(database, enquire, start_offset, end_offset, checkatleast=DEFAULT_CHECK_AT_LEAST): """ A safer version of Xapian.enquire.get_mset Simply wraps the Xapian version and catches any `Xapian.DatabaseModifiedError`, attempting a `database.reopen` as needed. Requ...
python
def _get_enquire_mset(database, enquire, start_offset, end_offset, checkatleast=DEFAULT_CHECK_AT_LEAST): """ A safer version of Xapian.enquire.get_mset Simply wraps the Xapian version and catches any `Xapian.DatabaseModifiedError`, attempting a `database.reopen` as needed. Requ...
[ "def", "_get_enquire_mset", "(", "database", ",", "enquire", ",", "start_offset", ",", "end_offset", ",", "checkatleast", "=", "DEFAULT_CHECK_AT_LEAST", ")", ":", "try", ":", "return", "enquire", ".", "get_mset", "(", "start_offset", ",", "end_offset", ",", "che...
A safer version of Xapian.enquire.get_mset Simply wraps the Xapian version and catches any `Xapian.DatabaseModifiedError`, attempting a `database.reopen` as needed. Required arguments: `database` -- The database to be read `enquire` -- An instance of an Xapian.enquire o...
[ "A", "safer", "version", "of", "Xapian", ".", "enquire", ".", "get_mset" ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1174-L1191
notanumber/xapian-haystack
xapian_backend.py
XapianSearchBackend._get_document_data
def _get_document_data(database, document): """ A safer version of Xapian.document.get_data Simply wraps the Xapian version and catches any `Xapian.DatabaseModifiedError`, attempting a `database.reopen` as needed. Required arguments: `database` -- The database to be...
python
def _get_document_data(database, document): """ A safer version of Xapian.document.get_data Simply wraps the Xapian version and catches any `Xapian.DatabaseModifiedError`, attempting a `database.reopen` as needed. Required arguments: `database` -- The database to be...
[ "def", "_get_document_data", "(", "database", ",", "document", ")", ":", "try", ":", "return", "document", ".", "get_data", "(", ")", "except", "xapian", ".", "DatabaseModifiedError", ":", "database", ".", "reopen", "(", ")", "return", "document", ".", "get_...
A safer version of Xapian.document.get_data Simply wraps the Xapian version and catches any `Xapian.DatabaseModifiedError`, attempting a `database.reopen` as needed. Required arguments: `database` -- The database to be read `document` -- An instance of an Xapian.documen...
[ "A", "safer", "version", "of", "Xapian", ".", "document", ".", "get_data" ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1194-L1209
notanumber/xapian-haystack
xapian_backend.py
XapianSearchBackend._get_hit_count
def _get_hit_count(self, database, enquire): """ Given a database and enquire instance, returns the estimated number of matches. Required arguments: `database` -- The database to be queried `enquire` -- The enquire instance """ return self._get_en...
python
def _get_hit_count(self, database, enquire): """ Given a database and enquire instance, returns the estimated number of matches. Required arguments: `database` -- The database to be queried `enquire` -- The enquire instance """ return self._get_en...
[ "def", "_get_hit_count", "(", "self", ",", "database", ",", "enquire", ")", ":", "return", "self", ".", "_get_enquire_mset", "(", "database", ",", "enquire", ",", "0", ",", "database", ".", "get_doccount", "(", ")", ")", ".", "size", "(", ")" ]
Given a database and enquire instance, returns the estimated number of matches. Required arguments: `database` -- The database to be queried `enquire` -- The enquire instance
[ "Given", "a", "database", "and", "enquire", "instance", "returns", "the", "estimated", "number", "of", "matches", "." ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1211-L1222
notanumber/xapian-haystack
xapian_backend.py
XapianSearchBackend._multi_value_field
def _multi_value_field(self, field): """ Private method that returns `True` if a field is multi-valued, else `False`. Required arguemnts: `field` -- The field to lookup Returns a boolean value indicating whether the field is multi-valued. """ for fie...
python
def _multi_value_field(self, field): """ Private method that returns `True` if a field is multi-valued, else `False`. Required arguemnts: `field` -- The field to lookup Returns a boolean value indicating whether the field is multi-valued. """ for fie...
[ "def", "_multi_value_field", "(", "self", ",", "field", ")", ":", "for", "field_dict", "in", "self", ".", "schema", ":", "if", "field_dict", "[", "'field_name'", "]", "==", "field", ":", "return", "field_dict", "[", "'multi_valued'", "]", "==", "'true'", "...
Private method that returns `True` if a field is multi-valued, else `False`. Required arguemnts: `field` -- The field to lookup Returns a boolean value indicating whether the field is multi-valued.
[ "Private", "method", "that", "returns", "True", "if", "a", "field", "is", "multi", "-", "valued", "else", "False", "." ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1224-L1237
notanumber/xapian-haystack
xapian_backend.py
XapianSearchQuery._query_from_term
def _query_from_term(self, term, field_name, filter_type, is_not): """ Uses arguments to construct a list of xapian.Query's. """ if field_name != 'content' and field_name not in self.backend.column: raise InvalidIndexError('field "%s" not indexed' % field_name) # It ...
python
def _query_from_term(self, term, field_name, filter_type, is_not): """ Uses arguments to construct a list of xapian.Query's. """ if field_name != 'content' and field_name not in self.backend.column: raise InvalidIndexError('field "%s" not indexed' % field_name) # It ...
[ "def", "_query_from_term", "(", "self", ",", "term", ",", "field_name", ",", "filter_type", ",", "is_not", ")", ":", "if", "field_name", "!=", "'content'", "and", "field_name", "not", "in", "self", ".", "backend", ".", "column", ":", "raise", "InvalidIndexEr...
Uses arguments to construct a list of xapian.Query's.
[ "Uses", "arguments", "to", "construct", "a", "list", "of", "xapian", ".", "Query", "s", "." ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1307-L1386
notanumber/xapian-haystack
xapian_backend.py
XapianSearchQuery._filter_contains
def _filter_contains(self, term, field_name, field_type, is_not): """ Splits the sentence in terms and join them with OR, using stemmed and un-stemmed. Assumes term is not a list. """ if field_type == 'text': term_list = term.split() else: ...
python
def _filter_contains(self, term, field_name, field_type, is_not): """ Splits the sentence in terms and join them with OR, using stemmed and un-stemmed. Assumes term is not a list. """ if field_type == 'text': term_list = term.split() else: ...
[ "def", "_filter_contains", "(", "self", ",", "term", ",", "field_name", ",", "field_type", ",", "is_not", ")", ":", "if", "field_type", "==", "'text'", ":", "term_list", "=", "term", ".", "split", "(", ")", "else", ":", "term_list", "=", "[", "term", "...
Splits the sentence in terms and join them with OR, using stemmed and un-stemmed. Assumes term is not a list.
[ "Splits", "the", "sentence", "in", "terms", "and", "join", "them", "with", "OR", "using", "stemmed", "and", "un", "-", "stemmed", "." ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1394-L1410
notanumber/xapian-haystack
xapian_backend.py
XapianSearchQuery._filter_in
def _filter_in(self, term_list, field_name, field_type, is_not): """ Returns a query that matches exactly ANY term in term_list. Notice that: A in {B,C} <=> (A = B or A = C) ~(A in {B,C}) <=> ~(A = B or A = C) Because OP_AND_NOT(C, D) <=> (C and ~D), then D=(A in {B,C}...
python
def _filter_in(self, term_list, field_name, field_type, is_not): """ Returns a query that matches exactly ANY term in term_list. Notice that: A in {B,C} <=> (A = B or A = C) ~(A in {B,C}) <=> ~(A = B or A = C) Because OP_AND_NOT(C, D) <=> (C and ~D), then D=(A in {B,C}...
[ "def", "_filter_in", "(", "self", ",", "term_list", ",", "field_name", ",", "field_type", ",", "is_not", ")", ":", "query_list", "=", "[", "self", ".", "_filter_exact", "(", "term", ",", "field_name", ",", "field_type", ",", "is_not", "=", "False", ")", ...
Returns a query that matches exactly ANY term in term_list. Notice that: A in {B,C} <=> (A = B or A = C) ~(A in {B,C}) <=> ~(A = B or A = C) Because OP_AND_NOT(C, D) <=> (C and ~D), then D=(A in {B,C}) requires `is_not=False`. Assumes term is a list.
[ "Returns", "a", "query", "that", "matches", "exactly", "ANY", "term", "in", "term_list", "." ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1412-L1430
notanumber/xapian-haystack
xapian_backend.py
XapianSearchQuery._filter_exact
def _filter_exact(self, term, field_name, field_type, is_not): """ Returns a query that matches exactly the un-stemmed term with positional order. Assumes term is not a list. """ if field_type == 'text' and field_name not in (DJANGO_CT,): term = '^ %s $' % te...
python
def _filter_exact(self, term, field_name, field_type, is_not): """ Returns a query that matches exactly the un-stemmed term with positional order. Assumes term is not a list. """ if field_type == 'text' and field_name not in (DJANGO_CT,): term = '^ %s $' % te...
[ "def", "_filter_exact", "(", "self", ",", "term", ",", "field_name", ",", "field_type", ",", "is_not", ")", ":", "if", "field_type", "==", "'text'", "and", "field_name", "not", "in", "(", "DJANGO_CT", ",", ")", ":", "term", "=", "'^ %s $'", "%", "term", ...
Returns a query that matches exactly the un-stemmed term with positional order. Assumes term is not a list.
[ "Returns", "a", "query", "that", "matches", "exactly", "the", "un", "-", "stemmed", "term", "with", "positional", "order", "." ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1432-L1448
notanumber/xapian-haystack
xapian_backend.py
XapianSearchQuery._filter_startswith
def _filter_startswith(self, term, field_name, field_type, is_not): """ Returns a startswith query on the un-stemmed term. Assumes term is not a list. """ if field_type == 'text': if len(term.split()) == 1: term = '^ %s*' % term query ...
python
def _filter_startswith(self, term, field_name, field_type, is_not): """ Returns a startswith query on the un-stemmed term. Assumes term is not a list. """ if field_type == 'text': if len(term.split()) == 1: term = '^ %s*' % term query ...
[ "def", "_filter_startswith", "(", "self", ",", "term", ",", "field_name", ",", "field_type", ",", "is_not", ")", ":", "if", "field_type", "==", "'text'", ":", "if", "len", "(", "term", ".", "split", "(", ")", ")", "==", "1", ":", "term", "=", "'^ %s*...
Returns a startswith query on the un-stemmed term. Assumes term is not a list.
[ "Returns", "a", "startswith", "query", "on", "the", "un", "-", "stemmed", "term", "." ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1450-L1469
notanumber/xapian-haystack
xapian_backend.py
XapianSearchQuery._or_query
def _or_query(self, term_list, field, field_type): """ Joins each item of term_list decorated by _term_query with an OR. """ term_list = [self._term_query(term, field, field_type) for term in term_list] return xapian.Query(xapian.Query.OP_OR, term_list)
python
def _or_query(self, term_list, field, field_type): """ Joins each item of term_list decorated by _term_query with an OR. """ term_list = [self._term_query(term, field, field_type) for term in term_list] return xapian.Query(xapian.Query.OP_OR, term_list)
[ "def", "_or_query", "(", "self", ",", "term_list", ",", "field", ",", "field_type", ")", ":", "term_list", "=", "[", "self", ".", "_term_query", "(", "term", ",", "field", ",", "field_type", ")", "for", "term", "in", "term_list", "]", "return", "xapian",...
Joins each item of term_list decorated by _term_query with an OR.
[ "Joins", "each", "item", "of", "term_list", "decorated", "by", "_term_query", "with", "an", "OR", "." ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1471-L1476
notanumber/xapian-haystack
xapian_backend.py
XapianSearchQuery._phrase_query
def _phrase_query(self, term_list, field_name, field_type): """ Returns a query that matches exact terms with positional order (i.e. ["this", "thing"] != ["thing", "this"]) and no stem. If `field_name` is not `None`, restrict to the field. """ term_list = [self._...
python
def _phrase_query(self, term_list, field_name, field_type): """ Returns a query that matches exact terms with positional order (i.e. ["this", "thing"] != ["thing", "this"]) and no stem. If `field_name` is not `None`, restrict to the field. """ term_list = [self._...
[ "def", "_phrase_query", "(", "self", ",", "term_list", ",", "field_name", ",", "field_type", ")", ":", "term_list", "=", "[", "self", ".", "_term_query", "(", "term", ",", "field_name", ",", "field_type", ",", "stemmed", "=", "False", ")", "for", "term", ...
Returns a query that matches exact terms with positional order (i.e. ["this", "thing"] != ["thing", "this"]) and no stem. If `field_name` is not `None`, restrict to the field.
[ "Returns", "a", "query", "that", "matches", "exact", "terms", "with", "positional", "order", "(", "i", ".", "e", ".", "[", "this", "thing", "]", "!", "=", "[", "thing", "this", "]", ")", "and", "no", "stem", "." ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1478-L1490
notanumber/xapian-haystack
xapian_backend.py
XapianSearchQuery._term_query
def _term_query(self, term, field_name, field_type, stemmed=True): """ Constructs a query of a single term. If `field_name` is not `None`, the term is search on that field only. If exact is `True`, the search is restricted to boolean matches. """ constructor = '{prefix}{...
python
def _term_query(self, term, field_name, field_type, stemmed=True): """ Constructs a query of a single term. If `field_name` is not `None`, the term is search on that field only. If exact is `True`, the search is restricted to boolean matches. """ constructor = '{prefix}{...
[ "def", "_term_query", "(", "self", ",", "term", ",", "field_name", ",", "field_type", ",", "stemmed", "=", "True", ")", ":", "constructor", "=", "'{prefix}{term}'", "# construct the prefix to be used.", "prefix", "=", "''", "if", "field_name", ":", "prefix", "="...
Constructs a query of a single term. If `field_name` is not `None`, the term is search on that field only. If exact is `True`, the search is restricted to boolean matches.
[ "Constructs", "a", "query", "of", "a", "single", "term", "." ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1492-L1536
notanumber/xapian-haystack
xapian_backend.py
XapianSearchQuery._filter_gte
def _filter_gte(self, term, field_name, field_type, is_not): """ Private method that returns a xapian.Query that searches for any term that is greater than `term` in a specified `field`. """ vrp = XHValueRangeProcessor(self.backend) pos, begin, end = vrp('%s:%s' % (field_...
python
def _filter_gte(self, term, field_name, field_type, is_not): """ Private method that returns a xapian.Query that searches for any term that is greater than `term` in a specified `field`. """ vrp = XHValueRangeProcessor(self.backend) pos, begin, end = vrp('%s:%s' % (field_...
[ "def", "_filter_gte", "(", "self", ",", "term", ",", "field_name", ",", "field_type", ",", "is_not", ")", ":", "vrp", "=", "XHValueRangeProcessor", "(", "self", ".", "backend", ")", "pos", ",", "begin", ",", "end", "=", "vrp", "(", "'%s:%s'", "%", "(",...
Private method that returns a xapian.Query that searches for any term that is greater than `term` in a specified `field`.
[ "Private", "method", "that", "returns", "a", "xapian", ".", "Query", "that", "searches", "for", "any", "term", "that", "is", "greater", "than", "term", "in", "a", "specified", "field", "." ]
train
https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1544-L1556
hackerlist/glassdoor
glassdoor/gd.py
get
def get(company='', company_uri=''): """Performs a HTTP GET for a glassdoor page and returns json""" if not company and not company_uri: raise Exception("glassdoor.gd.get(company='', company_uri=''): "\ " company or company_uri required") payload = {} if not company_u...
python
def get(company='', company_uri=''): """Performs a HTTP GET for a glassdoor page and returns json""" if not company and not company_uri: raise Exception("glassdoor.gd.get(company='', company_uri=''): "\ " company or company_uri required") payload = {} if not company_u...
[ "def", "get", "(", "company", "=", "''", ",", "company_uri", "=", "''", ")", ":", "if", "not", "company", "and", "not", "company_uri", ":", "raise", "Exception", "(", "\"glassdoor.gd.get(company='', company_uri=''): \"", "\" company or company_uri required\"", ")", ...
Performs a HTTP GET for a glassdoor page and returns json
[ "Performs", "a", "HTTP", "GET", "for", "a", "glassdoor", "page", "and", "returns", "json" ]
train
https://github.com/hackerlist/glassdoor/blob/953bac53d499eca439ecd812892605d1906cb055/glassdoor/gd.py#L21-L37