repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
nugget/python-insteonplm | insteonplm/states/onOff.py | OnOffSwitch.on | def on(self):
"""Send ON command to device."""
on_command = StandardSend(self._address,
COMMAND_LIGHT_ON_0X11_NONE, 0xff)
self._send_method(on_command,
self._on_message_received) | python | def on(self):
"""Send ON command to device."""
on_command = StandardSend(self._address,
COMMAND_LIGHT_ON_0X11_NONE, 0xff)
self._send_method(on_command,
self._on_message_received) | [
"def",
"on",
"(",
"self",
")",
":",
"on_command",
"=",
"StandardSend",
"(",
"self",
".",
"_address",
",",
"COMMAND_LIGHT_ON_0X11_NONE",
",",
"0xff",
")",
"self",
".",
"_send_method",
"(",
"on_command",
",",
"self",
".",
"_on_message_received",
")"
] | Send ON command to device. | [
"Send",
"ON",
"command",
"to",
"device",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L196-L201 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L241-L245 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L247-L251 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L253-L267 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L295-L302 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L304-L310 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L312-L316 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L318-L332 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L365-L369 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L526-L532 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L671-L678 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L703-L732 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L734-L739 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L751-L778 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L792-L828 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L852-L855 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L857-L860 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L877-L883 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/onOff.py#L916-L919 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/thermostat.py#L363-L371 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/thermostat.py#L419-L427 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/linkedDevices.py#L93-L96 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/linkedDevices.py#L98-L104 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/linkedDevices.py#L106-L120 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/linkedDevices.py#L122-L127 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/linkedDevices.py#L129-L134 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/linkedDevices.py#L136-L168 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/linkedDevices.py#L171-L198 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/linkedDevices.py#L200-L204 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/linkedDevices.py#L206-L223 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/messages/x10received.py#L40-L53 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/messages/x10received.py#L56-L65 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/__init__.py#L21-L27 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/__init__.py#L113-L170 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/__init__.py#L187-L193 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/__init__.py#L196-L205 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/__init__.py#L220-L223 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/x10.py#L30-L39 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/x10.py#L41-L50 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/x10.py#L107-L134 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/address.py#L57-L65 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/address.py#L67-L96 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/address.py#L132-L140 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/address.py#L169-L174 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/address.py#L177-L182 | train |
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",
"."
] | 65548041f1b0729ae1ae904443dd81b0c6cbf1bf | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/address.py#L185-L210 | train |
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",
")",
":",
"return",
"'%04d%02d%02d%02d%02d%02d'",
"%",
"(",
"dt",
".",
"year",
",",
"dt",
".",
"month",
",",
"d... | 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",
"."
] | 2247b23d3cb6322ce477d45f84d52da47a940348 | https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1588-L1622 | train |
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",
"."
] | 2247b23d3cb6322ce477d45f84d52da47a940348 | https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1633-L1659 | train |
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",
"."
] | 2247b23d3cb6322ce477d45f84d52da47a940348 | https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L505-L517 | train |
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",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"path",
")",
":",
"shutil",
".",
"rmtree",
"(",
"self",
".",
... | 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",
"."
] | 2247b23d3cb6322ce477d45f84d52da47a940348 | https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L519-L544 | train |
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",
"."
] | 2247b23d3cb6322ce477d45f84d52da47a940348 | https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L552-L564 | train |
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",
"."
] | 2247b23d3cb6322ce477d45f84d52da47a940348 | https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L566-L576 | train |
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",
",",
"**",
"kwar... | 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",
"."
] | 2247b23d3cb6322ce477d45f84d52da47a940348 | https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L719-L815 | train |
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",
"(",
"''",
")",
"elif",
"query_string",
"==",
"''",
":",
"return",
"xapian",
".",
"Query",
"(",
")",
"qp",
"=",
... | 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"
] | 2247b23d3cb6322ce477d45f84d52da47a940348 | https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L817-L852 | train |
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",
"."
] | 2247b23d3cb6322ce477d45f84d52da47a940348 | https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L854-L924 | train |
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",
"."
] | 2247b23d3cb6322ce477d45f84d52da47a940348 | https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L927-L945 | train |
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",
"."
] | 2247b23d3cb6322ce477d45f84d52da47a940348 | https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L947-L959 | train |
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",
"."
] | 2247b23d3cb6322ce477d45f84d52da47a940348 | https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L985-L1006 | train |
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"
] | 2247b23d3cb6322ce477d45f84d52da47a940348 | https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1009-L1101 | train |
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"
] | 2247b23d3cb6322ce477d45f84d52da47a940348 | https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1103-L1122 | train |
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",
"."
] | 2247b23d3cb6322ce477d45f84d52da47a940348 | https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1125-L1148 | train |
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",
"."
] | 2247b23d3cb6322ce477d45f84d52da47a940348 | https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1150-L1171 | train |
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"
] | 2247b23d3cb6322ce477d45f84d52da47a940348 | https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1194-L1209 | train |
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",
"."
] | 2247b23d3cb6322ce477d45f84d52da47a940348 | https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1211-L1222 | train |
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",
"."
] | 2247b23d3cb6322ce477d45f84d52da47a940348 | https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1224-L1237 | train |
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",
"."
] | 2247b23d3cb6322ce477d45f84d52da47a940348 | https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1307-L1386 | train |
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",
"."
] | 2247b23d3cb6322ce477d45f84d52da47a940348 | https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1394-L1410 | train |
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",
"."
] | 2247b23d3cb6322ce477d45f84d52da47a940348 | https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1412-L1430 | train |
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",
"."
] | 2247b23d3cb6322ce477d45f84d52da47a940348 | https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1432-L1448 | train |
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",
"."
] | 2247b23d3cb6322ce477d45f84d52da47a940348 | https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1450-L1469 | train |
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",
"."
] | 2247b23d3cb6322ce477d45f84d52da47a940348 | https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1471-L1476 | train |
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}'",
"prefix",
"=",
"''",
"if",
"field_name",
":",
"prefix",
"=",
"TERM_PREFIXES",
"[",
"'field'",... | 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",
"."
] | 2247b23d3cb6322ce477d45f84d52da47a940348 | https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1492-L1536 | train |
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",
"."
] | 2247b23d3cb6322ce477d45f84d52da47a940348 | https://github.com/notanumber/xapian-haystack/blob/2247b23d3cb6322ce477d45f84d52da47a940348/xapian_backend.py#L1544-L1556 | train |
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"
] | 953bac53d499eca439ecd812892605d1906cb055 | https://github.com/hackerlist/glassdoor/blob/953bac53d499eca439ecd812892605d1906cb055/glassdoor/gd.py#L21-L37 | train |
hackerlist/glassdoor | glassdoor/gd.py | parse | def parse(soup):
"""Parses the results for a company search and return the results
if is_direct_match. If no company is found, a list of suggestions
are returned as dict. If one such recommendation is found to be an
exact match, re-perform request for this exact match
"""
if is_direct_match(sou... | python | def parse(soup):
"""Parses the results for a company search and return the results
if is_direct_match. If no company is found, a list of suggestions
are returned as dict. If one such recommendation is found to be an
exact match, re-perform request for this exact match
"""
if is_direct_match(sou... | [
"def",
"parse",
"(",
"soup",
")",
":",
"if",
"is_direct_match",
"(",
"soup",
")",
":",
"return",
"{",
"'satisfaction'",
":",
"parse_satisfaction",
"(",
"soup",
")",
",",
"'ceo'",
":",
"parse_ceo",
"(",
"soup",
")",
",",
"'meta'",
":",
"parse_meta",
"(",
... | Parses the results for a company search and return the results
if is_direct_match. If no company is found, a list of suggestions
are returned as dict. If one such recommendation is found to be an
exact match, re-perform request for this exact match | [
"Parses",
"the",
"results",
"for",
"a",
"company",
"search",
"and",
"return",
"the",
"results",
"if",
"is_direct_match",
".",
"If",
"no",
"company",
"is",
"found",
"a",
"list",
"of",
"suggestions",
"are",
"returned",
"as",
"dict",
".",
"If",
"one",
"such",... | 953bac53d499eca439ecd812892605d1906cb055 | https://github.com/hackerlist/glassdoor/blob/953bac53d499eca439ecd812892605d1906cb055/glassdoor/gd.py#L291-L309 | train |
callsign-viper/Flask-GraphQL-Auth | flask_graphql_auth/decorators.py | get_jwt_data | def get_jwt_data(token, token_type):
"""
Decodes encoded JWT token by using extension setting and validates token type
:param token: The encoded JWT string to decode
:param token_type: JWT type for type validation (access or refresh)
:return: Dictionary containing contents of the JWT
"""
jw... | python | def get_jwt_data(token, token_type):
"""
Decodes encoded JWT token by using extension setting and validates token type
:param token: The encoded JWT string to decode
:param token_type: JWT type for type validation (access or refresh)
:return: Dictionary containing contents of the JWT
"""
jw... | [
"def",
"get_jwt_data",
"(",
"token",
",",
"token_type",
")",
":",
"jwt_data",
"=",
"decode_jwt",
"(",
"encoded_token",
"=",
"token",
",",
"secret",
"=",
"current_app",
".",
"config",
"[",
"'JWT_SECRET_KEY'",
"]",
",",
"algorithm",
"=",
"'HS256'",
",",
"ident... | Decodes encoded JWT token by using extension setting and validates token type
:param token: The encoded JWT string to decode
:param token_type: JWT type for type validation (access or refresh)
:return: Dictionary containing contents of the JWT | [
"Decodes",
"encoded",
"JWT",
"token",
"by",
"using",
"extension",
"setting",
"and",
"validates",
"token",
"type"
] | 27897a6ef81e12f87e9695fbaf6659ff025ae782 | https://github.com/callsign-viper/Flask-GraphQL-Auth/blob/27897a6ef81e12f87e9695fbaf6659ff025ae782/flask_graphql_auth/decorators.py#L37-L57 | train |
callsign-viper/Flask-GraphQL-Auth | flask_graphql_auth/decorators.py | query_jwt_required | def query_jwt_required(fn):
"""
A decorator to protect a query resolver.
If you decorate an resolver with this, it will ensure that the requester
has a valid access token before allowing the resolver to be called. This
does not check the freshness of the access token.
"""
@wraps(fn)
def... | python | def query_jwt_required(fn):
"""
A decorator to protect a query resolver.
If you decorate an resolver with this, it will ensure that the requester
has a valid access token before allowing the resolver to be called. This
does not check the freshness of the access token.
"""
@wraps(fn)
def... | [
"def",
"query_jwt_required",
"(",
"fn",
")",
":",
"@",
"wraps",
"(",
"fn",
")",
"def",
"wrapper",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"print",
"(",
"args",
"[",
"0",
"]",
")",
"token",
"=",
"kwargs",
".",
"pop",
"(",
"current_app",
"... | A decorator to protect a query resolver.
If you decorate an resolver with this, it will ensure that the requester
has a valid access token before allowing the resolver to be called. This
does not check the freshness of the access token. | [
"A",
"decorator",
"to",
"protect",
"a",
"query",
"resolver",
"."
] | 27897a6ef81e12f87e9695fbaf6659ff025ae782 | https://github.com/callsign-viper/Flask-GraphQL-Auth/blob/27897a6ef81e12f87e9695fbaf6659ff025ae782/flask_graphql_auth/decorators.py#L82-L100 | train |
ahtn/python-easyhid | easyhid/easyhid.py | HIDDevice.open | def open(self):
"""
Open the HID device for reading and writing.
"""
if self._is_open:
raise HIDException("Failed to open device: HIDDevice already open")
path = self.path.encode('utf-8')
dev = hidapi.hid_open_path(path)
if dev:
self._is_... | python | def open(self):
"""
Open the HID device for reading and writing.
"""
if self._is_open:
raise HIDException("Failed to open device: HIDDevice already open")
path = self.path.encode('utf-8')
dev = hidapi.hid_open_path(path)
if dev:
self._is_... | [
"def",
"open",
"(",
"self",
")",
":",
"if",
"self",
".",
"_is_open",
":",
"raise",
"HIDException",
"(",
"\"Failed to open device: HIDDevice already open\"",
")",
"path",
"=",
"self",
".",
"path",
".",
"encode",
"(",
"'utf-8'",
")",
"dev",
"=",
"hidapi",
".",... | Open the HID device for reading and writing. | [
"Open",
"the",
"HID",
"device",
"for",
"reading",
"and",
"writing",
"."
] | b89a60e5b378495b34c51ef11c5260bb43885780 | https://github.com/ahtn/python-easyhid/blob/b89a60e5b378495b34c51ef11c5260bb43885780/easyhid/easyhid.py#L112-L126 | train |
ahtn/python-easyhid | easyhid/easyhid.py | HIDDevice.close | def close(self):
"""
Closes the hid device
"""
if self._is_open:
self._is_open = False
hidapi.hid_close(self._device) | python | def close(self):
"""
Closes the hid device
"""
if self._is_open:
self._is_open = False
hidapi.hid_close(self._device) | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"self",
".",
"_is_open",
":",
"self",
".",
"_is_open",
"=",
"False",
"hidapi",
".",
"hid_close",
"(",
"self",
".",
"_device",
")"
] | Closes the hid device | [
"Closes",
"the",
"hid",
"device"
] | b89a60e5b378495b34c51ef11c5260bb43885780 | https://github.com/ahtn/python-easyhid/blob/b89a60e5b378495b34c51ef11c5260bb43885780/easyhid/easyhid.py#L129-L135 | train |
ahtn/python-easyhid | easyhid/easyhid.py | HIDDevice.write | def write(self, data, report_id=0):
"""
Writes data to the HID device on its endpoint.
Parameters:
data: data to send on the HID endpoint
report_id: the report ID to use.
Returns:
The number of bytes written including the report ID.
"""
... | python | def write(self, data, report_id=0):
"""
Writes data to the HID device on its endpoint.
Parameters:
data: data to send on the HID endpoint
report_id: the report ID to use.
Returns:
The number of bytes written including the report ID.
"""
... | [
"def",
"write",
"(",
"self",
",",
"data",
",",
"report_id",
"=",
"0",
")",
":",
"if",
"not",
"self",
".",
"_is_open",
":",
"raise",
"HIDException",
"(",
"\"HIDDevice not open\"",
")",
"write_data",
"=",
"bytearray",
"(",
"[",
"report_id",
"]",
")",
"+",
... | Writes data to the HID device on its endpoint.
Parameters:
data: data to send on the HID endpoint
report_id: the report ID to use.
Returns:
The number of bytes written including the report ID. | [
"Writes",
"data",
"to",
"the",
"HID",
"device",
"on",
"its",
"endpoint",
"."
] | b89a60e5b378495b34c51ef11c5260bb43885780 | https://github.com/ahtn/python-easyhid/blob/b89a60e5b378495b34c51ef11c5260bb43885780/easyhid/easyhid.py#L137-L158 | train |
ahtn/python-easyhid | easyhid/easyhid.py | HIDDevice.read | def read(self, size=64, timeout=None):
"""
Read from the hid device on its endpoint.
Parameters:
size: number of bytes to read
timeout: length to wait in milliseconds
Returns:
The HID report read from the device. The first byte in the result
... | python | def read(self, size=64, timeout=None):
"""
Read from the hid device on its endpoint.
Parameters:
size: number of bytes to read
timeout: length to wait in milliseconds
Returns:
The HID report read from the device. The first byte in the result
... | [
"def",
"read",
"(",
"self",
",",
"size",
"=",
"64",
",",
"timeout",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"_is_open",
":",
"raise",
"HIDException",
"(",
"\"HIDDevice not open\"",
")",
"data",
"=",
"[",
"0",
"]",
"*",
"size",
"cdata",
"=",
... | Read from the hid device on its endpoint.
Parameters:
size: number of bytes to read
timeout: length to wait in milliseconds
Returns:
The HID report read from the device. The first byte in the result
will be the report ID if used. | [
"Read",
"from",
"the",
"hid",
"device",
"on",
"its",
"endpoint",
"."
] | b89a60e5b378495b34c51ef11c5260bb43885780 | https://github.com/ahtn/python-easyhid/blob/b89a60e5b378495b34c51ef11c5260bb43885780/easyhid/easyhid.py#L160-L192 | train |
ahtn/python-easyhid | easyhid/easyhid.py | HIDDevice.is_connected | def is_connected(self):
"""
Checks if the USB device is still connected
"""
if self._is_open:
err = hidapi.hid_read_timeout(self._device, ffi.NULL, 0, 0)
if err == -1:
return False
else:
return True
else:
... | python | def is_connected(self):
"""
Checks if the USB device is still connected
"""
if self._is_open:
err = hidapi.hid_read_timeout(self._device, ffi.NULL, 0, 0)
if err == -1:
return False
else:
return True
else:
... | [
"def",
"is_connected",
"(",
"self",
")",
":",
"if",
"self",
".",
"_is_open",
":",
"err",
"=",
"hidapi",
".",
"hid_read_timeout",
"(",
"self",
".",
"_device",
",",
"ffi",
".",
"NULL",
",",
"0",
",",
"0",
")",
"if",
"err",
"==",
"-",
"1",
":",
"ret... | Checks if the USB device is still connected | [
"Checks",
"if",
"the",
"USB",
"device",
"is",
"still",
"connected"
] | b89a60e5b378495b34c51ef11c5260bb43885780 | https://github.com/ahtn/python-easyhid/blob/b89a60e5b378495b34c51ef11c5260bb43885780/easyhid/easyhid.py#L206-L221 | train |
ahtn/python-easyhid | easyhid/easyhid.py | HIDDevice.send_feature_report | def send_feature_report(self, data, report_id=0x00):
"""
Send a Feature report to a HID device.
Feature reports are sent over the Control endpoint as a Set_Report
transfer.
Parameters:
data The data to send
Returns:
This function returns the ... | python | def send_feature_report(self, data, report_id=0x00):
"""
Send a Feature report to a HID device.
Feature reports are sent over the Control endpoint as a Set_Report
transfer.
Parameters:
data The data to send
Returns:
This function returns the ... | [
"def",
"send_feature_report",
"(",
"self",
",",
"data",
",",
"report_id",
"=",
"0x00",
")",
":",
"if",
"not",
"self",
".",
"_is_open",
":",
"raise",
"HIDException",
"(",
"\"HIDDevice not open\"",
")",
"report",
"=",
"bytearray",
"(",
"[",
"report_id",
"]",
... | Send a Feature report to a HID device.
Feature reports are sent over the Control endpoint as a Set_Report
transfer.
Parameters:
data The data to send
Returns:
This function returns the actual number of bytes written | [
"Send",
"a",
"Feature",
"report",
"to",
"a",
"HID",
"device",
"."
] | b89a60e5b378495b34c51ef11c5260bb43885780 | https://github.com/ahtn/python-easyhid/blob/b89a60e5b378495b34c51ef11c5260bb43885780/easyhid/easyhid.py#L223-L246 | train |
ahtn/python-easyhid | easyhid/easyhid.py | HIDDevice.get_feature_report | def get_feature_report(self, size, report_id=0x00):
"""
Get a feature report from a HID device.
Feature reports are sent over the Control endpoint as a Get_Report
transfer.
Parameters:
size The number of bytes to read.
report_id The report id to... | python | def get_feature_report(self, size, report_id=0x00):
"""
Get a feature report from a HID device.
Feature reports are sent over the Control endpoint as a Get_Report
transfer.
Parameters:
size The number of bytes to read.
report_id The report id to... | [
"def",
"get_feature_report",
"(",
"self",
",",
"size",
",",
"report_id",
"=",
"0x00",
")",
":",
"data",
"=",
"[",
"0",
"]",
"*",
"(",
"size",
"+",
"1",
")",
"cdata",
"=",
"ffi",
".",
"new",
"(",
"\"unsigned char[]\"",
",",
"bytes",
"(",
"data",
")"... | Get a feature report from a HID device.
Feature reports are sent over the Control endpoint as a Get_Report
transfer.
Parameters:
size The number of bytes to read.
report_id The report id to read
Returns:
They bytes read from the HID report | [
"Get",
"a",
"feature",
"report",
"from",
"a",
"HID",
"device",
"."
] | b89a60e5b378495b34c51ef11c5260bb43885780 | https://github.com/ahtn/python-easyhid/blob/b89a60e5b378495b34c51ef11c5260bb43885780/easyhid/easyhid.py#L248-L271 | train |
ahtn/python-easyhid | easyhid/easyhid.py | HIDDevice.get_error | def get_error(self):
"""
Get an error string from the device
"""
err_str = hidapi.hid_error(self._device)
if err_str == ffi.NULL:
return None
else:
return ffi.string(err_str) | python | def get_error(self):
"""
Get an error string from the device
"""
err_str = hidapi.hid_error(self._device)
if err_str == ffi.NULL:
return None
else:
return ffi.string(err_str) | [
"def",
"get_error",
"(",
"self",
")",
":",
"err_str",
"=",
"hidapi",
".",
"hid_error",
"(",
"self",
".",
"_device",
")",
"if",
"err_str",
"==",
"ffi",
".",
"NULL",
":",
"return",
"None",
"else",
":",
"return",
"ffi",
".",
"string",
"(",
"err_str",
")... | Get an error string from the device | [
"Get",
"an",
"error",
"string",
"from",
"the",
"device"
] | b89a60e5b378495b34c51ef11c5260bb43885780 | https://github.com/ahtn/python-easyhid/blob/b89a60e5b378495b34c51ef11c5260bb43885780/easyhid/easyhid.py#L273-L281 | train |
ahtn/python-easyhid | easyhid/easyhid.py | HIDDevice.get_indexed_string | def get_indexed_string(self, index):
"""
Get the string with the given index from the device
"""
max_len = 128
str_buf = ffi.new("wchar_t[]", str(bytearray(max_len)))
ret = hidapi.hid_get_indexed_string(self._device, index, str_buf, max_len)
if ret < 0:
... | python | def get_indexed_string(self, index):
"""
Get the string with the given index from the device
"""
max_len = 128
str_buf = ffi.new("wchar_t[]", str(bytearray(max_len)))
ret = hidapi.hid_get_indexed_string(self._device, index, str_buf, max_len)
if ret < 0:
... | [
"def",
"get_indexed_string",
"(",
"self",
",",
"index",
")",
":",
"max_len",
"=",
"128",
"str_buf",
"=",
"ffi",
".",
"new",
"(",
"\"wchar_t[]\"",
",",
"str",
"(",
"bytearray",
"(",
"max_len",
")",
")",
")",
"ret",
"=",
"hidapi",
".",
"hid_get_indexed_str... | Get the string with the given index from the device | [
"Get",
"the",
"string",
"with",
"the",
"given",
"index",
"from",
"the",
"device"
] | b89a60e5b378495b34c51ef11c5260bb43885780 | https://github.com/ahtn/python-easyhid/blob/b89a60e5b378495b34c51ef11c5260bb43885780/easyhid/easyhid.py#L313-L326 | train |
ahtn/python-easyhid | easyhid/easyhid.py | Enumeration.find | def find(self, vid=None, pid=None, serial=None, interface=None, \
path=None, release_number=None, manufacturer=None,
product=None, usage=None, usage_page=None):
"""
Attempts to open a device in this `Enumeration` object. Optional
arguments can be provided to filter the re... | python | def find(self, vid=None, pid=None, serial=None, interface=None, \
path=None, release_number=None, manufacturer=None,
product=None, usage=None, usage_page=None):
"""
Attempts to open a device in this `Enumeration` object. Optional
arguments can be provided to filter the re... | [
"def",
"find",
"(",
"self",
",",
"vid",
"=",
"None",
",",
"pid",
"=",
"None",
",",
"serial",
"=",
"None",
",",
"interface",
"=",
"None",
",",
"path",
"=",
"None",
",",
"release_number",
"=",
"None",
",",
"manufacturer",
"=",
"None",
",",
"product",
... | Attempts to open a device in this `Enumeration` object. Optional
arguments can be provided to filter the resulting list based on various
parameters of the HID devices.
Args:
vid: filters by USB Vendor ID
pid: filters by USB Product ID
serial: filters by USB s... | [
"Attempts",
"to",
"open",
"a",
"device",
"in",
"this",
"Enumeration",
"object",
".",
"Optional",
"arguments",
"can",
"be",
"provided",
"to",
"filter",
"the",
"resulting",
"list",
"based",
"on",
"various",
"parameters",
"of",
"the",
"HID",
"devices",
"."
] | b89a60e5b378495b34c51ef11c5260bb43885780 | https://github.com/ahtn/python-easyhid/blob/b89a60e5b378495b34c51ef11c5260bb43885780/easyhid/easyhid.py#L367-L411 | train |
ladybug-tools/uwg | uwg/utilities.py | str2fl | def str2fl(x):
"""Recurses through lists and converts lists of string to float
Args:
x: string or list of strings
"""
def helper_to_fl(s_):
""" deals with odd string imports converts to float"""
if s_ == "":
return "null"
elif "," in s_:
s_ = s_.r... | python | def str2fl(x):
"""Recurses through lists and converts lists of string to float
Args:
x: string or list of strings
"""
def helper_to_fl(s_):
""" deals with odd string imports converts to float"""
if s_ == "":
return "null"
elif "," in s_:
s_ = s_.r... | [
"def",
"str2fl",
"(",
"x",
")",
":",
"def",
"helper_to_fl",
"(",
"s_",
")",
":",
"if",
"s_",
"==",
"\"\"",
":",
"return",
"\"null\"",
"elif",
"\",\"",
"in",
"s_",
":",
"s_",
"=",
"s_",
".",
"replace",
"(",
"\",\"",
",",
"\"\"",
")",
"try",
":",
... | Recurses through lists and converts lists of string to float
Args:
x: string or list of strings | [
"Recurses",
"through",
"lists",
"and",
"converts",
"lists",
"of",
"string",
"to",
"float"
] | fb71f656b3cb69e7ccf1d851dff862e14fa210fc | https://github.com/ladybug-tools/uwg/blob/fb71f656b3cb69e7ccf1d851dff862e14fa210fc/uwg/utilities.py#L42-L70 | train |
ladybug-tools/uwg | uwg/uwg.py | procMat | def procMat(materials, max_thickness, min_thickness):
""" Processes material layer so that a material with single
layer thickness is divided into two and material layer that is too
thick is subdivided
"""
newmat = []
newthickness = []
k = materials.layerThermalCond
Vhc = material... | python | def procMat(materials, max_thickness, min_thickness):
""" Processes material layer so that a material with single
layer thickness is divided into two and material layer that is too
thick is subdivided
"""
newmat = []
newthickness = []
k = materials.layerThermalCond
Vhc = material... | [
"def",
"procMat",
"(",
"materials",
",",
"max_thickness",
",",
"min_thickness",
")",
":",
"newmat",
"=",
"[",
"]",
"newthickness",
"=",
"[",
"]",
"k",
"=",
"materials",
".",
"layerThermalCond",
"Vhc",
"=",
"materials",
".",
"layerVolHeat",
"if",
"len",
"("... | Processes material layer so that a material with single
layer thickness is divided into two and material layer that is too
thick is subdivided | [
"Processes",
"material",
"layer",
"so",
"that",
"a",
"material",
"with",
"single",
"layer",
"thickness",
"is",
"divided",
"into",
"two",
"and",
"material",
"layer",
"that",
"is",
"too",
"thick",
"is",
"subdivided"
] | fb71f656b3cb69e7ccf1d851dff862e14fa210fc | https://github.com/ladybug-tools/uwg/blob/fb71f656b3cb69e7ccf1d851dff862e14fa210fc/uwg/uwg.py#L977-L1024 | train |
ladybug-tools/uwg | uwg/uwg.py | uwg.set_input | def set_input(self):
""" Set inputs from .uwg input file if not already defined, the check if all
the required input parameters are there.
"""
# If a uwgParamFileName is set, then read inputs from .uwg file.
# User-defined class properties will override the inputs from the... | python | def set_input(self):
""" Set inputs from .uwg input file if not already defined, the check if all
the required input parameters are there.
"""
# If a uwgParamFileName is set, then read inputs from .uwg file.
# User-defined class properties will override the inputs from the... | [
"def",
"set_input",
"(",
"self",
")",
":",
"if",
"self",
".",
"uwgParamFileName",
"is",
"not",
"None",
":",
"print",
"(",
"\"\\nReading uwg file input.\"",
")",
"self",
".",
"read_input",
"(",
")",
"else",
":",
"print",
"(",
"\"\\nNo .uwg file input.\"",
")",
... | Set inputs from .uwg input file if not already defined, the check if all
the required input parameters are there. | [
"Set",
"inputs",
"from",
".",
"uwg",
"input",
"file",
"if",
"not",
"already",
"defined",
"the",
"check",
"if",
"all",
"the",
"required",
"input",
"parameters",
"are",
"there",
"."
] | fb71f656b3cb69e7ccf1d851dff862e14fa210fc | https://github.com/ladybug-tools/uwg/blob/fb71f656b3cb69e7ccf1d851dff862e14fa210fc/uwg/uwg.py#L532-L548 | train |
ladybug-tools/uwg | uwg/uwg.py | uwg.write_epw | def write_epw(self):
""" Section 8 - Writing new EPW file
"""
epw_prec = self.epw_precision # precision of epw file input
for iJ in range(len(self.UCMData)):
# [iJ+self.simTime.timeInitial-8] = increments along every weather timestep in epw
# [6 to 21] ... | python | def write_epw(self):
""" Section 8 - Writing new EPW file
"""
epw_prec = self.epw_precision # precision of epw file input
for iJ in range(len(self.UCMData)):
# [iJ+self.simTime.timeInitial-8] = increments along every weather timestep in epw
# [6 to 21] ... | [
"def",
"write_epw",
"(",
"self",
")",
":",
"epw_prec",
"=",
"self",
".",
"epw_precision",
"for",
"iJ",
"in",
"range",
"(",
"len",
"(",
"self",
".",
"UCMData",
")",
")",
":",
"self",
".",
"epwinput",
"[",
"iJ",
"+",
"self",
".",
"simTime",
".",
"tim... | Section 8 - Writing new EPW file | [
"Section",
"8",
"-",
"Writing",
"new",
"EPW",
"file"
] | fb71f656b3cb69e7ccf1d851dff862e14fa210fc | https://github.com/ladybug-tools/uwg/blob/fb71f656b3cb69e7ccf1d851dff862e14fa210fc/uwg/uwg.py#L926-L963 | train |
ladybug-tools/uwg | uwg/element.py | Element.SurfFlux | def SurfFlux(self,forc,parameter,simTime,humRef,tempRef,windRef,boundCond,intFlux):
""" Calculate net heat flux, and update element layer temperatures
"""
# Calculated per unit area (m^2)
dens = forc.pres/(1000*0.287042*tempRef*(1.+1.607858*humRef)) # air density (kgd m-3)
self.... | python | def SurfFlux(self,forc,parameter,simTime,humRef,tempRef,windRef,boundCond,intFlux):
""" Calculate net heat flux, and update element layer temperatures
"""
# Calculated per unit area (m^2)
dens = forc.pres/(1000*0.287042*tempRef*(1.+1.607858*humRef)) # air density (kgd m-3)
self.... | [
"def",
"SurfFlux",
"(",
"self",
",",
"forc",
",",
"parameter",
",",
"simTime",
",",
"humRef",
",",
"tempRef",
",",
"windRef",
",",
"boundCond",
",",
"intFlux",
")",
":",
"dens",
"=",
"forc",
".",
"pres",
"/",
"(",
"1000",
"*",
"0.287042",
"*",
"tempR... | Calculate net heat flux, and update element layer temperatures | [
"Calculate",
"net",
"heat",
"flux",
"and",
"update",
"element",
"layer",
"temperatures"
] | fb71f656b3cb69e7ccf1d851dff862e14fa210fc | https://github.com/ladybug-tools/uwg/blob/fb71f656b3cb69e7ccf1d851dff862e14fa210fc/uwg/element.py#L97-L145 | train |
wooster/biplist | biplist/__init__.py | readPlist | def readPlist(pathOrFile):
"""Raises NotBinaryPlistException, InvalidPlistException"""
didOpen = False
result = None
if isinstance(pathOrFile, (bytes, unicode)):
pathOrFile = open(pathOrFile, 'rb')
didOpen = True
try:
reader = PlistReader(pathOrFile)
result = reader.p... | python | def readPlist(pathOrFile):
"""Raises NotBinaryPlistException, InvalidPlistException"""
didOpen = False
result = None
if isinstance(pathOrFile, (bytes, unicode)):
pathOrFile = open(pathOrFile, 'rb')
didOpen = True
try:
reader = PlistReader(pathOrFile)
result = reader.p... | [
"def",
"readPlist",
"(",
"pathOrFile",
")",
":",
"didOpen",
"=",
"False",
"result",
"=",
"None",
"if",
"isinstance",
"(",
"pathOrFile",
",",
"(",
"bytes",
",",
"unicode",
")",
")",
":",
"pathOrFile",
"=",
"open",
"(",
"pathOrFile",
",",
"'rb'",
")",
"d... | Raises NotBinaryPlistException, InvalidPlistException | [
"Raises",
"NotBinaryPlistException",
"InvalidPlistException"
] | 4c3d0c94132621188ca4c1fa9bda3b2d4d52ab82 | https://github.com/wooster/biplist/blob/4c3d0c94132621188ca4c1fa9bda3b2d4d52ab82/biplist/__init__.py#L117-L147 | train |
wooster/biplist | biplist/__init__.py | PlistReader.getSizedInteger | def getSizedInteger(self, data, byteSize, as_number=False):
"""Numbers of 8 bytes are signed integers when they refer to numbers, but unsigned otherwise."""
result = 0
if byteSize == 0:
raise InvalidPlistException("Encountered integer with byte size of 0.")
# 1, 2, and 4 byte... | python | def getSizedInteger(self, data, byteSize, as_number=False):
"""Numbers of 8 bytes are signed integers when they refer to numbers, but unsigned otherwise."""
result = 0
if byteSize == 0:
raise InvalidPlistException("Encountered integer with byte size of 0.")
# 1, 2, and 4 byte... | [
"def",
"getSizedInteger",
"(",
"self",
",",
"data",
",",
"byteSize",
",",
"as_number",
"=",
"False",
")",
":",
"result",
"=",
"0",
"if",
"byteSize",
"==",
"0",
":",
"raise",
"InvalidPlistException",
"(",
"\"Encountered integer with byte size of 0.\"",
")",
"elif... | Numbers of 8 bytes are signed integers when they refer to numbers, but unsigned otherwise. | [
"Numbers",
"of",
"8",
"bytes",
"are",
"signed",
"integers",
"when",
"they",
"refer",
"to",
"numbers",
"but",
"unsigned",
"otherwise",
"."
] | 4c3d0c94132621188ca4c1fa9bda3b2d4d52ab82 | https://github.com/wooster/biplist/blob/4c3d0c94132621188ca4c1fa9bda3b2d4d52ab82/biplist/__init__.py#L499-L529 | train |
wooster/biplist | biplist/__init__.py | PlistWriter.writeOffsetTable | def writeOffsetTable(self, output):
"""Writes all of the object reference offsets."""
all_positions = []
writtenReferences = list(self.writtenReferences.items())
writtenReferences.sort(key=lambda x: x[1])
for obj,order in writtenReferences:
# Porting note: Elsewhere w... | python | def writeOffsetTable(self, output):
"""Writes all of the object reference offsets."""
all_positions = []
writtenReferences = list(self.writtenReferences.items())
writtenReferences.sort(key=lambda x: x[1])
for obj,order in writtenReferences:
# Porting note: Elsewhere w... | [
"def",
"writeOffsetTable",
"(",
"self",
",",
"output",
")",
":",
"all_positions",
"=",
"[",
"]",
"writtenReferences",
"=",
"list",
"(",
"self",
".",
"writtenReferences",
".",
"items",
"(",
")",
")",
"writtenReferences",
".",
"sort",
"(",
"key",
"=",
"lambd... | Writes all of the object reference offsets. | [
"Writes",
"all",
"of",
"the",
"object",
"reference",
"offsets",
"."
] | 4c3d0c94132621188ca4c1fa9bda3b2d4d52ab82 | https://github.com/wooster/biplist/blob/4c3d0c94132621188ca4c1fa9bda3b2d4d52ab82/biplist/__init__.py#L906-L924 | train |
wooster/biplist | biplist/__init__.py | PlistWriter.intSize | def intSize(self, obj):
"""Returns the number of bytes necessary to store the given integer."""
# SIGNED
if obj < 0: # Signed integer, always 8 bytes
return 8
# UNSIGNED
elif obj <= 0xFF: # 1 byte
return 1
elif obj <= 0xFFFF: # 2 bytes
... | python | def intSize(self, obj):
"""Returns the number of bytes necessary to store the given integer."""
# SIGNED
if obj < 0: # Signed integer, always 8 bytes
return 8
# UNSIGNED
elif obj <= 0xFF: # 1 byte
return 1
elif obj <= 0xFFFF: # 2 bytes
... | [
"def",
"intSize",
"(",
"self",
",",
"obj",
")",
":",
"if",
"obj",
"<",
"0",
":",
"return",
"8",
"elif",
"obj",
"<=",
"0xFF",
":",
"return",
"1",
"elif",
"obj",
"<=",
"0xFFFF",
":",
"return",
"2",
"elif",
"obj",
"<=",
"0xFFFFFFFF",
":",
"return",
... | Returns the number of bytes necessary to store the given integer. | [
"Returns",
"the",
"number",
"of",
"bytes",
"necessary",
"to",
"store",
"the",
"given",
"integer",
"."
] | 4c3d0c94132621188ca4c1fa9bda3b2d4d52ab82 | https://github.com/wooster/biplist/blob/4c3d0c94132621188ca4c1fa9bda3b2d4d52ab82/biplist/__init__.py#L955-L974 | train |
ladybug-tools/uwg | uwg/RSMDef.py | RSMDef.load_z_meso | def load_z_meso(self,z_meso_path):
""" Open the z_meso.txt file and return heights as list """
self.z_meso = []
z_meso_file_path = os.path.join(z_meso_path, self.Z_MESO_FILE_NAME)
# Check if exists
if not os.path.exists(z_meso_file_path):
raise Exception("z_meso.txt... | python | def load_z_meso(self,z_meso_path):
""" Open the z_meso.txt file and return heights as list """
self.z_meso = []
z_meso_file_path = os.path.join(z_meso_path, self.Z_MESO_FILE_NAME)
# Check if exists
if not os.path.exists(z_meso_file_path):
raise Exception("z_meso.txt... | [
"def",
"load_z_meso",
"(",
"self",
",",
"z_meso_path",
")",
":",
"self",
".",
"z_meso",
"=",
"[",
"]",
"z_meso_file_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"z_meso_path",
",",
"self",
".",
"Z_MESO_FILE_NAME",
")",
"if",
"not",
"os",
".",
"path... | Open the z_meso.txt file and return heights as list | [
"Open",
"the",
"z_meso",
".",
"txt",
"file",
"and",
"return",
"heights",
"as",
"list"
] | fb71f656b3cb69e7ccf1d851dff862e14fa210fc | https://github.com/ladybug-tools/uwg/blob/fb71f656b3cb69e7ccf1d851dff862e14fa210fc/uwg/RSMDef.py#L140-L154 | train |
dcos/shakedown | shakedown/dcos/task.py | get_task | def get_task(task_id, completed=True):
""" Get a task by task id where a task_id is required.
:param task_id: task ID
:type task_id: str
:param completed: include completed tasks?
:type completed: bool
:return: a task
:rtype: obj
"""
tasks = get_tasks(task_i... | python | def get_task(task_id, completed=True):
""" Get a task by task id where a task_id is required.
:param task_id: task ID
:type task_id: str
:param completed: include completed tasks?
:type completed: bool
:return: a task
:rtype: obj
"""
tasks = get_tasks(task_i... | [
"def",
"get_task",
"(",
"task_id",
",",
"completed",
"=",
"True",
")",
":",
"tasks",
"=",
"get_tasks",
"(",
"task_id",
"=",
"task_id",
",",
"completed",
"=",
"completed",
")",
"if",
"len",
"(",
"tasks",
")",
"==",
"0",
":",
"return",
"None",
"assert",
... | Get a task by task id where a task_id is required.
:param task_id: task ID
:type task_id: str
:param completed: include completed tasks?
:type completed: bool
:return: a task
:rtype: obj | [
"Get",
"a",
"task",
"by",
"task",
"id",
"where",
"a",
"task_id",
"is",
"required",
"."
] | e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e | https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/task.py#L32-L49 | train |
dcos/shakedown | shakedown/dcos/task.py | task_completed | def task_completed(task_id):
""" Check whether a task has completed.
:param task_id: task ID
:type task_id: str
:return: True if completed, False otherwise
:rtype: bool
"""
tasks = get_tasks(task_id=task_id)
completed_states = ('TASK_FINISHED',
... | python | def task_completed(task_id):
""" Check whether a task has completed.
:param task_id: task ID
:type task_id: str
:return: True if completed, False otherwise
:rtype: bool
"""
tasks = get_tasks(task_id=task_id)
completed_states = ('TASK_FINISHED',
... | [
"def",
"task_completed",
"(",
"task_id",
")",
":",
"tasks",
"=",
"get_tasks",
"(",
"task_id",
"=",
"task_id",
")",
"completed_states",
"=",
"(",
"'TASK_FINISHED'",
",",
"'TASK_FAILED'",
",",
"'TASK_KILLED'",
",",
"'TASK_LOST'",
",",
"'TASK_ERROR'",
")",
"for",
... | Check whether a task has completed.
:param task_id: task ID
:type task_id: str
:return: True if completed, False otherwise
:rtype: bool | [
"Check",
"whether",
"a",
"task",
"has",
"completed",
"."
] | e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e | https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/task.py#L59-L80 | train |
dcos/shakedown | shakedown/dcos/task.py | task_property_present_predicate | def task_property_present_predicate(service, task, prop):
""" True if the json_element passed is present for the task specified.
"""
try:
response = get_service_task(service, task)
except Exception as e:
pass
return (response is not None) and (prop in response) | python | def task_property_present_predicate(service, task, prop):
""" True if the json_element passed is present for the task specified.
"""
try:
response = get_service_task(service, task)
except Exception as e:
pass
return (response is not None) and (prop in response) | [
"def",
"task_property_present_predicate",
"(",
"service",
",",
"task",
",",
"prop",
")",
":",
"try",
":",
"response",
"=",
"get_service_task",
"(",
"service",
",",
"task",
")",
"except",
"Exception",
"as",
"e",
":",
"pass",
"return",
"(",
"response",
"is",
... | True if the json_element passed is present for the task specified. | [
"True",
"if",
"the",
"json_element",
"passed",
"is",
"present",
"for",
"the",
"task",
"specified",
"."
] | e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e | https://github.com/dcos/shakedown/blob/e2f9e2382788dbcd29bd18aa058b76e7c3b83b3e/shakedown/dcos/task.py#L107-L115 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.