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 listlengths 20 707 | docstring stringlengths 3 17.3k | docstring_tokens listlengths 3 222 | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value | idx int64 0 252k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
cloudnull/turbolift | turbolift/clouderator/actions.py | CloudActions.put_object | def put_object(self, url, container, container_object, local_object,
object_headers, meta=None):
"""This is the Sync method which uploads files to the swift repository
if they are not already found. If a file "name" is found locally and
in the swift repository an MD5 comparis... | python | def put_object(self, url, container, container_object, local_object,
object_headers, meta=None):
"""This is the Sync method which uploads files to the swift repository
if they are not already found. If a file "name" is found locally and
in the swift repository an MD5 comparis... | [
"def",
"put_object",
"(",
"self",
",",
"url",
",",
"container",
",",
"container_object",
",",
"local_object",
",",
"object_headers",
",",
"meta",
"=",
"None",
")",
":",
"headers",
",",
"container_uri",
"=",
"self",
".",
"_return_base_data",
"(",
"url",
"=",
... | This is the Sync method which uploads files to the swift repository
if they are not already found. If a file "name" is found locally and
in the swift repository an MD5 comparison is done between the two
files. If the MD5 is miss-matched the local file is uploaded to the
repository. If c... | [
"This",
"is",
"the",
"Sync",
"method",
"which",
"uploads",
"files",
"to",
"the",
"swift",
"repository"
] | da33034e88959226529ce762e2895e6f6356c448 | https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/clouderator/actions.py#L579-L606 | train | 61,900 |
cloudnull/turbolift | turbolift/clouderator/actions.py | CloudActions.get_items | def get_items(self, url, container, container_object, local_object):
"""Get an objects from a container.
:param url:
:param container:
"""
headers, container_uri = self._return_base_data(
url=url,
container=container,
container_object=contain... | python | def get_items(self, url, container, container_object, local_object):
"""Get an objects from a container.
:param url:
:param container:
"""
headers, container_uri = self._return_base_data(
url=url,
container=container,
container_object=contain... | [
"def",
"get_items",
"(",
"self",
",",
"url",
",",
"container",
",",
"container_object",
",",
"local_object",
")",
":",
"headers",
",",
"container_uri",
"=",
"self",
".",
"_return_base_data",
"(",
"url",
"=",
"url",
",",
"container",
"=",
"container",
",",
... | Get an objects from a container.
:param url:
:param container: | [
"Get",
"an",
"objects",
"from",
"a",
"container",
"."
] | da33034e88959226529ce762e2895e6f6356c448 | https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/clouderator/actions.py#L609-L626 | train | 61,901 |
cloudnull/turbolift | turbolift/clouderator/actions.py | CloudActions.delete_items | def delete_items(self, url, container, container_object=None):
"""Deletes an objects in a container.
:param url:
:param container:
"""
headers, container_uri = self._return_base_data(
url=url,
container=container,
container_object=container_o... | python | def delete_items(self, url, container, container_object=None):
"""Deletes an objects in a container.
:param url:
:param container:
"""
headers, container_uri = self._return_base_data(
url=url,
container=container,
container_object=container_o... | [
"def",
"delete_items",
"(",
"self",
",",
"url",
",",
"container",
",",
"container_object",
"=",
"None",
")",
":",
"headers",
",",
"container_uri",
"=",
"self",
".",
"_return_base_data",
"(",
"url",
"=",
"url",
",",
"container",
"=",
"container",
",",
"cont... | Deletes an objects in a container.
:param url:
:param container: | [
"Deletes",
"an",
"objects",
"in",
"a",
"container",
"."
] | da33034e88959226529ce762e2895e6f6356c448 | https://github.com/cloudnull/turbolift/blob/da33034e88959226529ce762e2895e6f6356c448/turbolift/clouderator/actions.py#L642-L655 | train | 61,902 |
stephantul/somber | somber/ng.py | Ng._get_bmu | def _get_bmu(self, activations):
"""Get indices of bmus, sorted by their distance from input."""
# If the neural gas is a recursive neural gas, we need reverse argsort.
if self.argfunc == 'argmax':
activations = -activations
sort = np.argsort(activations, 1)
return so... | python | def _get_bmu(self, activations):
"""Get indices of bmus, sorted by their distance from input."""
# If the neural gas is a recursive neural gas, we need reverse argsort.
if self.argfunc == 'argmax':
activations = -activations
sort = np.argsort(activations, 1)
return so... | [
"def",
"_get_bmu",
"(",
"self",
",",
"activations",
")",
":",
"# If the neural gas is a recursive neural gas, we need reverse argsort.",
"if",
"self",
".",
"argfunc",
"==",
"'argmax'",
":",
"activations",
"=",
"-",
"activations",
"sort",
"=",
"np",
".",
"argsort",
"... | Get indices of bmus, sorted by their distance from input. | [
"Get",
"indices",
"of",
"bmus",
"sorted",
"by",
"their",
"distance",
"from",
"input",
"."
] | b7a13e646239500cc393668c01a7169c3e50b7b5 | https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/ng.py#L64-L70 | train | 61,903 |
stephantul/somber | somber/ng.py | Ng._calculate_influence | def _calculate_influence(self, influence_lambda):
"""Calculate the ranking influence."""
return np.exp(-np.arange(self.num_neurons) / influence_lambda)[:, None] | python | def _calculate_influence(self, influence_lambda):
"""Calculate the ranking influence."""
return np.exp(-np.arange(self.num_neurons) / influence_lambda)[:, None] | [
"def",
"_calculate_influence",
"(",
"self",
",",
"influence_lambda",
")",
":",
"return",
"np",
".",
"exp",
"(",
"-",
"np",
".",
"arange",
"(",
"self",
".",
"num_neurons",
")",
"/",
"influence_lambda",
")",
"[",
":",
",",
"None",
"]"
] | Calculate the ranking influence. | [
"Calculate",
"the",
"ranking",
"influence",
"."
] | b7a13e646239500cc393668c01a7169c3e50b7b5 | https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/ng.py#L72-L74 | train | 61,904 |
stephantul/somber | somber/plsom.py | PLSom._update_params | def _update_params(self, constants):
"""Update the params."""
constants = np.max(np.min(constants, 1))
self.params['r']['value'] = max([self.params['r']['value'],
constants])
epsilon = constants / self.params['r']['value']
influence = self... | python | def _update_params(self, constants):
"""Update the params."""
constants = np.max(np.min(constants, 1))
self.params['r']['value'] = max([self.params['r']['value'],
constants])
epsilon = constants / self.params['r']['value']
influence = self... | [
"def",
"_update_params",
"(",
"self",
",",
"constants",
")",
":",
"constants",
"=",
"np",
".",
"max",
"(",
"np",
".",
"min",
"(",
"constants",
",",
"1",
")",
")",
"self",
".",
"params",
"[",
"'r'",
"]",
"[",
"'value'",
"]",
"=",
"max",
"(",
"[",
... | Update the params. | [
"Update",
"the",
"params",
"."
] | b7a13e646239500cc393668c01a7169c3e50b7b5 | https://github.com/stephantul/somber/blob/b7a13e646239500cc393668c01a7169c3e50b7b5/somber/plsom.py#L139-L147 | train | 61,905 |
jbasko/pytest-random-order | random_order/shuffler.py | _shuffle_items | def _shuffle_items(items, bucket_key=None, disable=None, seed=None, session=None):
"""
Shuffles a list of `items` in place.
If `bucket_key` is None, items are shuffled across the entire list.
`bucket_key` is an optional function called for each item in `items` to
calculate the key of bucket in whi... | python | def _shuffle_items(items, bucket_key=None, disable=None, seed=None, session=None):
"""
Shuffles a list of `items` in place.
If `bucket_key` is None, items are shuffled across the entire list.
`bucket_key` is an optional function called for each item in `items` to
calculate the key of bucket in whi... | [
"def",
"_shuffle_items",
"(",
"items",
",",
"bucket_key",
"=",
"None",
",",
"disable",
"=",
"None",
",",
"seed",
"=",
"None",
",",
"session",
"=",
"None",
")",
":",
"if",
"seed",
"is",
"not",
"None",
":",
"random",
".",
"seed",
"(",
"seed",
")",
"#... | Shuffles a list of `items` in place.
If `bucket_key` is None, items are shuffled across the entire list.
`bucket_key` is an optional function called for each item in `items` to
calculate the key of bucket in which the item falls.
Bucket defines the boundaries across which items will not
be shuffl... | [
"Shuffles",
"a",
"list",
"of",
"items",
"in",
"place",
"."
] | e8ff95fcd097f9f330638cf58cc1b24983fdde15 | https://github.com/jbasko/pytest-random-order/blob/e8ff95fcd097f9f330638cf58cc1b24983fdde15/random_order/shuffler.py#L23-L92 | train | 61,906 |
jbasko/pytest-random-order | random_order/bucket_types.py | bucket_type_key | def bucket_type_key(bucket_type):
"""
Registers a function that calculates test item key for the specified bucket type.
"""
def decorator(f):
@functools.wraps(f)
def wrapped(item, session):
key = f(item)
if session is not None:
for handler in se... | python | def bucket_type_key(bucket_type):
"""
Registers a function that calculates test item key for the specified bucket type.
"""
def decorator(f):
@functools.wraps(f)
def wrapped(item, session):
key = f(item)
if session is not None:
for handler in se... | [
"def",
"bucket_type_key",
"(",
"bucket_type",
")",
":",
"def",
"decorator",
"(",
"f",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"f",
")",
"def",
"wrapped",
"(",
"item",
",",
"session",
")",
":",
"key",
"=",
"f",
"(",
"item",
")",
"if",
"sessio... | Registers a function that calculates test item key for the specified bucket type. | [
"Registers",
"a",
"function",
"that",
"calculates",
"test",
"item",
"key",
"for",
"the",
"specified",
"bucket",
"type",
"."
] | e8ff95fcd097f9f330638cf58cc1b24983fdde15 | https://github.com/jbasko/pytest-random-order/blob/e8ff95fcd097f9f330638cf58cc1b24983fdde15/random_order/bucket_types.py#L8-L28 | train | 61,907 |
bitpay/bitpay-python | bitpay/client.py | Client.unsigned_request | def unsigned_request(self, path, payload=None):
"""
generic bitpay usigned wrapper
passing a payload will do a POST, otherwise a GET
"""
headers = {"content-type": "application/json", "accept": "application/json", "X-accept-version": "2.0.0"}
try:
if payload:
response = requests.po... | python | def unsigned_request(self, path, payload=None):
"""
generic bitpay usigned wrapper
passing a payload will do a POST, otherwise a GET
"""
headers = {"content-type": "application/json", "accept": "application/json", "X-accept-version": "2.0.0"}
try:
if payload:
response = requests.po... | [
"def",
"unsigned_request",
"(",
"self",
",",
"path",
",",
"payload",
"=",
"None",
")",
":",
"headers",
"=",
"{",
"\"content-type\"",
":",
"\"application/json\"",
",",
"\"accept\"",
":",
"\"application/json\"",
",",
"\"X-accept-version\"",
":",
"\"2.0.0\"",
"}",
... | generic bitpay usigned wrapper
passing a payload will do a POST, otherwise a GET | [
"generic",
"bitpay",
"usigned",
"wrapper",
"passing",
"a",
"payload",
"will",
"do",
"a",
"POST",
"otherwise",
"a",
"GET"
] | 3f456118bef1c460adf5d4d5546f38dac1e2a5cc | https://github.com/bitpay/bitpay-python/blob/3f456118bef1c460adf5d4d5546f38dac1e2a5cc/bitpay/client.py#L98-L111 | train | 61,908 |
nutechsoftware/alarmdecoder | examples/rf_device.py | main | def main():
"""
Example application that watches for an event from a specific RF device.
This feature allows you to watch for events from RF devices if you have
an RF receiver. This is useful in the case of internal sensors, which
don't emit a FAULT if the sensor is tripped and the panel is armed ... | python | def main():
"""
Example application that watches for an event from a specific RF device.
This feature allows you to watch for events from RF devices if you have
an RF receiver. This is useful in the case of internal sensors, which
don't emit a FAULT if the sensor is tripped and the panel is armed ... | [
"def",
"main",
"(",
")",
":",
"try",
":",
"# Retrieve the first USB device",
"device",
"=",
"AlarmDecoder",
"(",
"SerialDevice",
"(",
"interface",
"=",
"SERIAL_DEVICE",
")",
")",
"# Set up an event handler and open the device",
"device",
".",
"on_rfx_message",
"+=",
"... | Example application that watches for an event from a specific RF device.
This feature allows you to watch for events from RF devices if you have
an RF receiver. This is useful in the case of internal sensors, which
don't emit a FAULT if the sensor is tripped and the panel is armed STAY.
It also will m... | [
"Example",
"application",
"that",
"watches",
"for",
"an",
"event",
"from",
"a",
"specific",
"RF",
"device",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/examples/rf_device.py#L10-L33 | train | 61,909 |
nutechsoftware/alarmdecoder | examples/rf_device.py | handle_rfx | def handle_rfx(sender, message):
"""
Handles RF message events from the AlarmDecoder.
"""
# Check for our target serial number and loop
if message.serial_number == RF_DEVICE_SERIAL_NUMBER and message.loop[0] == True:
print(message.serial_number, 'triggered loop #1') | python | def handle_rfx(sender, message):
"""
Handles RF message events from the AlarmDecoder.
"""
# Check for our target serial number and loop
if message.serial_number == RF_DEVICE_SERIAL_NUMBER and message.loop[0] == True:
print(message.serial_number, 'triggered loop #1') | [
"def",
"handle_rfx",
"(",
"sender",
",",
"message",
")",
":",
"# Check for our target serial number and loop",
"if",
"message",
".",
"serial_number",
"==",
"RF_DEVICE_SERIAL_NUMBER",
"and",
"message",
".",
"loop",
"[",
"0",
"]",
"==",
"True",
":",
"print",
"(",
... | Handles RF message events from the AlarmDecoder. | [
"Handles",
"RF",
"message",
"events",
"from",
"the",
"AlarmDecoder",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/examples/rf_device.py#L35-L41 | train | 61,910 |
nutechsoftware/alarmdecoder | alarmdecoder/event/event.py | EventHandler.fire | def fire(self, *args, **kwargs):
"""Fire event and call all handler functions
You can call EventHandler object itself like e(*args, **kwargs) instead of
e.fire(*args, **kwargs).
"""
for func in self._getfunctionlist():
if type(func) == EventHandler:
... | python | def fire(self, *args, **kwargs):
"""Fire event and call all handler functions
You can call EventHandler object itself like e(*args, **kwargs) instead of
e.fire(*args, **kwargs).
"""
for func in self._getfunctionlist():
if type(func) == EventHandler:
... | [
"def",
"fire",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"func",
"in",
"self",
".",
"_getfunctionlist",
"(",
")",
":",
"if",
"type",
"(",
"func",
")",
"==",
"EventHandler",
":",
"func",
".",
"fire",
"(",
"*",
"args"... | Fire event and call all handler functions
You can call EventHandler object itself like e(*args, **kwargs) instead of
e.fire(*args, **kwargs). | [
"Fire",
"event",
"and",
"call",
"all",
"handler",
"functions"
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/event/event.py#L72-L84 | train | 61,911 |
nutechsoftware/alarmdecoder | examples/serialport.py | main | def main():
"""
Example application that opens a serial device and prints messages to the terminal.
"""
try:
# Retrieve the specified serial device.
device = AlarmDecoder(SerialDevice(interface=SERIAL_DEVICE))
# Set up an event handler and open the device
device.on_messa... | python | def main():
"""
Example application that opens a serial device and prints messages to the terminal.
"""
try:
# Retrieve the specified serial device.
device = AlarmDecoder(SerialDevice(interface=SERIAL_DEVICE))
# Set up an event handler and open the device
device.on_messa... | [
"def",
"main",
"(",
")",
":",
"try",
":",
"# Retrieve the specified serial device.",
"device",
"=",
"AlarmDecoder",
"(",
"SerialDevice",
"(",
"interface",
"=",
"SERIAL_DEVICE",
")",
")",
"# Set up an event handler and open the device",
"device",
".",
"on_message",
"+=",... | Example application that opens a serial device and prints messages to the terminal. | [
"Example",
"application",
"that",
"opens",
"a",
"serial",
"device",
"and",
"prints",
"messages",
"to",
"the",
"terminal",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/examples/serialport.py#L9-L27 | train | 61,912 |
nutechsoftware/alarmdecoder | alarmdecoder/devices/socket_device.py | SocketDevice._init_ssl | def _init_ssl(self):
"""
Initializes our device as an SSL connection.
:raises: :py:class:`~alarmdecoder.util.CommError`
"""
if not have_openssl:
raise ImportError('SSL sockets have been disabled due to missing requirement: pyopenssl.')
try:
ctx ... | python | def _init_ssl(self):
"""
Initializes our device as an SSL connection.
:raises: :py:class:`~alarmdecoder.util.CommError`
"""
if not have_openssl:
raise ImportError('SSL sockets have been disabled due to missing requirement: pyopenssl.')
try:
ctx ... | [
"def",
"_init_ssl",
"(",
"self",
")",
":",
"if",
"not",
"have_openssl",
":",
"raise",
"ImportError",
"(",
"'SSL sockets have been disabled due to missing requirement: pyopenssl.'",
")",
"try",
":",
"ctx",
"=",
"SSL",
".",
"Context",
"(",
"SSL",
".",
"TLSv1_METHOD",
... | Initializes our device as an SSL connection.
:raises: :py:class:`~alarmdecoder.util.CommError` | [
"Initializes",
"our",
"device",
"as",
"an",
"SSL",
"connection",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/devices/socket_device.py#L379-L417 | train | 61,913 |
phuijse/P4J | P4J/periodogram.py | periodogram.get_best_frequencies | def get_best_frequencies(self):
"""
Returns the best n_local_max frequencies
"""
return self.freq[self.best_local_optima], self.per[self.best_local_optima] | python | def get_best_frequencies(self):
"""
Returns the best n_local_max frequencies
"""
return self.freq[self.best_local_optima], self.per[self.best_local_optima] | [
"def",
"get_best_frequencies",
"(",
"self",
")",
":",
"return",
"self",
".",
"freq",
"[",
"self",
".",
"best_local_optima",
"]",
",",
"self",
".",
"per",
"[",
"self",
".",
"best_local_optima",
"]"
] | Returns the best n_local_max frequencies | [
"Returns",
"the",
"best",
"n_local_max",
"frequencies"
] | 1ec6b2ac63674ca55aeb2966b9cf40c273d7c203 | https://github.com/phuijse/P4J/blob/1ec6b2ac63674ca55aeb2966b9cf40c273d7c203/P4J/periodogram.py#L127-L131 | train | 61,914 |
phuijse/P4J | P4J/periodogram.py | periodogram.finetune_best_frequencies | def finetune_best_frequencies(self, fresolution=1e-5, n_local_optima=10):
"""
Computes the selected criterion over a grid of frequencies
around a specified amount of local optima of the periodograms. This
function is intended for additional fine tuning of the results obtained
w... | python | def finetune_best_frequencies(self, fresolution=1e-5, n_local_optima=10):
"""
Computes the selected criterion over a grid of frequencies
around a specified amount of local optima of the periodograms. This
function is intended for additional fine tuning of the results obtained
w... | [
"def",
"finetune_best_frequencies",
"(",
"self",
",",
"fresolution",
"=",
"1e-5",
",",
"n_local_optima",
"=",
"10",
")",
":",
"# Find the local optima",
"local_optima_index",
"=",
"[",
"]",
"for",
"k",
"in",
"range",
"(",
"1",
",",
"len",
"(",
"self",
".",
... | Computes the selected criterion over a grid of frequencies
around a specified amount of local optima of the periodograms. This
function is intended for additional fine tuning of the results obtained
with grid_search | [
"Computes",
"the",
"selected",
"criterion",
"over",
"a",
"grid",
"of",
"frequencies",
"around",
"a",
"specified",
"amount",
"of",
"local",
"optima",
"of",
"the",
"periodograms",
".",
"This",
"function",
"is",
"intended",
"for",
"additional",
"fine",
"tuning",
... | 1ec6b2ac63674ca55aeb2966b9cf40c273d7c203 | https://github.com/phuijse/P4J/blob/1ec6b2ac63674ca55aeb2966b9cf40c273d7c203/P4J/periodogram.py#L137-L173 | train | 61,915 |
nutechsoftware/alarmdecoder | alarmdecoder/messages/lrr/system.py | LRRSystem.update | def update(self, message):
"""
Updates the states in the primary AlarmDecoder object based on
the LRR message provided.
:param message: LRR message object
:type message: :py:class:`~alarmdecoder.messages.LRRMessage`
"""
# Firmware version < 2.2a.8.6
if me... | python | def update(self, message):
"""
Updates the states in the primary AlarmDecoder object based on
the LRR message provided.
:param message: LRR message object
:type message: :py:class:`~alarmdecoder.messages.LRRMessage`
"""
# Firmware version < 2.2a.8.6
if me... | [
"def",
"update",
"(",
"self",
",",
"message",
")",
":",
"# Firmware version < 2.2a.8.6",
"if",
"message",
".",
"version",
"==",
"1",
":",
"if",
"message",
".",
"event_type",
"==",
"'ALARM_PANIC'",
":",
"self",
".",
"_alarmdecoder",
".",
"_update_panic_status",
... | Updates the states in the primary AlarmDecoder object based on
the LRR message provided.
:param message: LRR message object
:type message: :py:class:`~alarmdecoder.messages.LRRMessage` | [
"Updates",
"the",
"states",
"in",
"the",
"primary",
"AlarmDecoder",
"object",
"based",
"on",
"the",
"LRR",
"message",
"provided",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/messages/lrr/system.py#L26-L56 | train | 61,916 |
nutechsoftware/alarmdecoder | alarmdecoder/messages/lrr/system.py | LRRSystem._handle_cid_message | def _handle_cid_message(self, message):
"""
Handles ContactID LRR events.
:param message: LRR message object
:type message: :py:class:`~alarmdecoder.messages.LRRMessage`
"""
status = self._get_event_status(message)
if status is None:
return
i... | python | def _handle_cid_message(self, message):
"""
Handles ContactID LRR events.
:param message: LRR message object
:type message: :py:class:`~alarmdecoder.messages.LRRMessage`
"""
status = self._get_event_status(message)
if status is None:
return
i... | [
"def",
"_handle_cid_message",
"(",
"self",
",",
"message",
")",
":",
"status",
"=",
"self",
".",
"_get_event_status",
"(",
"message",
")",
"if",
"status",
"is",
"None",
":",
"return",
"if",
"message",
".",
"event_code",
"in",
"LRR_FIRE_EVENTS",
":",
"if",
... | Handles ContactID LRR events.
:param message: LRR message object
:type message: :py:class:`~alarmdecoder.messages.LRRMessage` | [
"Handles",
"ContactID",
"LRR",
"events",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/messages/lrr/system.py#L58-L109 | train | 61,917 |
nutechsoftware/alarmdecoder | alarmdecoder/messages/lrr/system.py | LRRSystem._get_event_status | def _get_event_status(self, message):
"""
Retrieves the boolean status of an LRR message.
:param message: LRR message object
:type message: :py:class:`~alarmdecoder.messages.LRRMessage`
:returns: Boolean indicating whether the event was triggered or restored.
"""
... | python | def _get_event_status(self, message):
"""
Retrieves the boolean status of an LRR message.
:param message: LRR message object
:type message: :py:class:`~alarmdecoder.messages.LRRMessage`
:returns: Boolean indicating whether the event was triggered or restored.
"""
... | [
"def",
"_get_event_status",
"(",
"self",
",",
"message",
")",
":",
"status",
"=",
"None",
"if",
"message",
".",
"event_status",
"==",
"LRR_EVENT_STATUS",
".",
"TRIGGER",
":",
"status",
"=",
"True",
"elif",
"message",
".",
"event_status",
"==",
"LRR_EVENT_STATU... | Retrieves the boolean status of an LRR message.
:param message: LRR message object
:type message: :py:class:`~alarmdecoder.messages.LRRMessage`
:returns: Boolean indicating whether the event was triggered or restored. | [
"Retrieves",
"the",
"boolean",
"status",
"of",
"an",
"LRR",
"message",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/messages/lrr/system.py#L148-L164 | train | 61,918 |
nutechsoftware/alarmdecoder | alarmdecoder/devices/serial_device.py | SerialDevice.find_all | def find_all(pattern=None):
"""
Returns all serial ports present.
:param pattern: pattern to search for when retrieving serial ports
:type pattern: string
:returns: list of devices
:raises: :py:class:`~alarmdecoder.util.CommError`
"""
devices = []
... | python | def find_all(pattern=None):
"""
Returns all serial ports present.
:param pattern: pattern to search for when retrieving serial ports
:type pattern: string
:returns: list of devices
:raises: :py:class:`~alarmdecoder.util.CommError`
"""
devices = []
... | [
"def",
"find_all",
"(",
"pattern",
"=",
"None",
")",
":",
"devices",
"=",
"[",
"]",
"try",
":",
"if",
"pattern",
":",
"devices",
"=",
"serial",
".",
"tools",
".",
"list_ports",
".",
"grep",
"(",
"pattern",
")",
"else",
":",
"devices",
"=",
"serial",
... | Returns all serial ports present.
:param pattern: pattern to search for when retrieving serial ports
:type pattern: string
:returns: list of devices
:raises: :py:class:`~alarmdecoder.util.CommError` | [
"Returns",
"all",
"serial",
"ports",
"present",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/devices/serial_device.py#L30-L51 | train | 61,919 |
nutechsoftware/alarmdecoder | alarmdecoder/messages/panel_message.py | Message._parse_message | def _parse_message(self, data):
"""
Parse the message from the device.
:param data: message data
:type data: string
:raises: :py:class:`~alarmdecoder.util.InvalidMessageError`
"""
match = self._regex.match(str(data))
if match is None:
raise ... | python | def _parse_message(self, data):
"""
Parse the message from the device.
:param data: message data
:type data: string
:raises: :py:class:`~alarmdecoder.util.InvalidMessageError`
"""
match = self._regex.match(str(data))
if match is None:
raise ... | [
"def",
"_parse_message",
"(",
"self",
",",
"data",
")",
":",
"match",
"=",
"self",
".",
"_regex",
".",
"match",
"(",
"str",
"(",
"data",
")",
")",
"if",
"match",
"is",
"None",
":",
"raise",
"InvalidMessageError",
"(",
"'Received invalid message: {0}'",
"."... | Parse the message from the device.
:param data: message data
:type data: string
:raises: :py:class:`~alarmdecoder.util.InvalidMessageError` | [
"Parse",
"the",
"message",
"from",
"the",
"device",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/messages/panel_message.py#L87-L131 | train | 61,920 |
nutechsoftware/alarmdecoder | alarmdecoder/messages/panel_message.py | Message.parse_numeric_code | def parse_numeric_code(self, force_hex=False):
"""
Parses and returns the numeric code as an integer.
The numeric code can be either base 10 or base 16, depending on
where the message came from.
:param force_hex: force the numeric code to be processed as base 16.
:type ... | python | def parse_numeric_code(self, force_hex=False):
"""
Parses and returns the numeric code as an integer.
The numeric code can be either base 10 or base 16, depending on
where the message came from.
:param force_hex: force the numeric code to be processed as base 16.
:type ... | [
"def",
"parse_numeric_code",
"(",
"self",
",",
"force_hex",
"=",
"False",
")",
":",
"code",
"=",
"None",
"got_error",
"=",
"False",
"if",
"not",
"force_hex",
":",
"try",
":",
"code",
"=",
"int",
"(",
"self",
".",
"numeric_code",
")",
"except",
"ValueErro... | Parses and returns the numeric code as an integer.
The numeric code can be either base 10 or base 16, depending on
where the message came from.
:param force_hex: force the numeric code to be processed as base 16.
:type force_hex: boolean
:raises: ValueError | [
"Parses",
"and",
"returns",
"the",
"numeric",
"code",
"as",
"an",
"integer",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/messages/panel_message.py#L133-L160 | train | 61,921 |
dottedmag/pychm | chm/chm.py | CHMFile.LoadCHM | def LoadCHM(self, archiveName):
'''Loads a CHM archive.
This function will also call GetArchiveInfo to obtain information
such as the index file name and the topics file. It returns 1 on
success, and 0 if it fails.
'''
if self.filename is not None:
self.CloseC... | python | def LoadCHM(self, archiveName):
'''Loads a CHM archive.
This function will also call GetArchiveInfo to obtain information
such as the index file name and the topics file. It returns 1 on
success, and 0 if it fails.
'''
if self.filename is not None:
self.CloseC... | [
"def",
"LoadCHM",
"(",
"self",
",",
"archiveName",
")",
":",
"if",
"self",
".",
"filename",
"is",
"not",
"None",
":",
"self",
".",
"CloseCHM",
"(",
")",
"self",
".",
"file",
"=",
"chmlib",
".",
"chm_open",
"(",
"archiveName",
")",
"if",
"self",
".",
... | Loads a CHM archive.
This function will also call GetArchiveInfo to obtain information
such as the index file name and the topics file. It returns 1 on
success, and 0 if it fails. | [
"Loads",
"a",
"CHM",
"archive",
".",
"This",
"function",
"will",
"also",
"call",
"GetArchiveInfo",
"to",
"obtain",
"information",
"such",
"as",
"the",
"index",
"file",
"name",
"and",
"the",
"topics",
"file",
".",
"It",
"returns",
"1",
"on",
"success",
"and... | fd87831a8c23498e65304fce341718bd2968211b | https://github.com/dottedmag/pychm/blob/fd87831a8c23498e65304fce341718bd2968211b/chm/chm.py#L205-L221 | train | 61,922 |
dottedmag/pychm | chm/chm.py | CHMFile.CloseCHM | def CloseCHM(self):
'''Closes the CHM archive.
This function will close the CHM file, if it is open. All variables
are also reset.
'''
if self.filename is not None:
chmlib.chm_close(self.file)
self.file = None
self.filename = ''
sel... | python | def CloseCHM(self):
'''Closes the CHM archive.
This function will close the CHM file, if it is open. All variables
are also reset.
'''
if self.filename is not None:
chmlib.chm_close(self.file)
self.file = None
self.filename = ''
sel... | [
"def",
"CloseCHM",
"(",
"self",
")",
":",
"if",
"self",
".",
"filename",
"is",
"not",
"None",
":",
"chmlib",
".",
"chm_close",
"(",
"self",
".",
"file",
")",
"self",
".",
"file",
"=",
"None",
"self",
".",
"filename",
"=",
"''",
"self",
".",
"title"... | Closes the CHM archive.
This function will close the CHM file, if it is open. All variables
are also reset. | [
"Closes",
"the",
"CHM",
"archive",
".",
"This",
"function",
"will",
"close",
"the",
"CHM",
"file",
"if",
"it",
"is",
"open",
".",
"All",
"variables",
"are",
"also",
"reset",
"."
] | fd87831a8c23498e65304fce341718bd2968211b | https://github.com/dottedmag/pychm/blob/fd87831a8c23498e65304fce341718bd2968211b/chm/chm.py#L223-L236 | train | 61,923 |
dottedmag/pychm | chm/chm.py | CHMFile.GetTopicsTree | def GetTopicsTree(self):
'''Reads and returns the topics tree.
This auxiliary function reads and returns the topics tree file
contents for the CHM archive.
'''
if self.topics is None:
return None
if self.topics:
res, ui = chmlib.chm_resolve_object... | python | def GetTopicsTree(self):
'''Reads and returns the topics tree.
This auxiliary function reads and returns the topics tree file
contents for the CHM archive.
'''
if self.topics is None:
return None
if self.topics:
res, ui = chmlib.chm_resolve_object... | [
"def",
"GetTopicsTree",
"(",
"self",
")",
":",
"if",
"self",
".",
"topics",
"is",
"None",
":",
"return",
"None",
"if",
"self",
".",
"topics",
":",
"res",
",",
"ui",
"=",
"chmlib",
".",
"chm_resolve_object",
"(",
"self",
".",
"file",
",",
"self",
".",... | Reads and returns the topics tree.
This auxiliary function reads and returns the topics tree file
contents for the CHM archive. | [
"Reads",
"and",
"returns",
"the",
"topics",
"tree",
".",
"This",
"auxiliary",
"function",
"reads",
"and",
"returns",
"the",
"topics",
"tree",
"file",
"contents",
"for",
"the",
"CHM",
"archive",
"."
] | fd87831a8c23498e65304fce341718bd2968211b | https://github.com/dottedmag/pychm/blob/fd87831a8c23498e65304fce341718bd2968211b/chm/chm.py#L321-L338 | train | 61,924 |
dottedmag/pychm | chm/chm.py | CHMFile.GetIndex | def GetIndex(self):
'''Reads and returns the index tree.
This auxiliary function reads and returns the index tree file
contents for the CHM archive.
'''
if self.index is None:
return None
if self.index:
res, ui = chmlib.chm_resolve_object(self.fil... | python | def GetIndex(self):
'''Reads and returns the index tree.
This auxiliary function reads and returns the index tree file
contents for the CHM archive.
'''
if self.index is None:
return None
if self.index:
res, ui = chmlib.chm_resolve_object(self.fil... | [
"def",
"GetIndex",
"(",
"self",
")",
":",
"if",
"self",
".",
"index",
"is",
"None",
":",
"return",
"None",
"if",
"self",
".",
"index",
":",
"res",
",",
"ui",
"=",
"chmlib",
".",
"chm_resolve_object",
"(",
"self",
".",
"file",
",",
"self",
".",
"ind... | Reads and returns the index tree.
This auxiliary function reads and returns the index tree file
contents for the CHM archive. | [
"Reads",
"and",
"returns",
"the",
"index",
"tree",
".",
"This",
"auxiliary",
"function",
"reads",
"and",
"returns",
"the",
"index",
"tree",
"file",
"contents",
"for",
"the",
"CHM",
"archive",
"."
] | fd87831a8c23498e65304fce341718bd2968211b | https://github.com/dottedmag/pychm/blob/fd87831a8c23498e65304fce341718bd2968211b/chm/chm.py#L340-L357 | train | 61,925 |
dottedmag/pychm | chm/chm.py | CHMFile.ResolveObject | def ResolveObject(self, document):
'''Tries to locate a document in the archive.
This function tries to locate the document inside the archive. It
returns a tuple where the first element is zero if the function
was successful, and the second is the UnitInfo for that document.
The... | python | def ResolveObject(self, document):
'''Tries to locate a document in the archive.
This function tries to locate the document inside the archive. It
returns a tuple where the first element is zero if the function
was successful, and the second is the UnitInfo for that document.
The... | [
"def",
"ResolveObject",
"(",
"self",
",",
"document",
")",
":",
"if",
"self",
".",
"file",
":",
"path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"document",
")",
"return",
"chmlib",
".",
"chm_resolve_object",
"(",
"self",
".",
"file",
",",
"path",
... | Tries to locate a document in the archive.
This function tries to locate the document inside the archive. It
returns a tuple where the first element is zero if the function
was successful, and the second is the UnitInfo for that document.
The UnitInfo is used to retrieve the document con... | [
"Tries",
"to",
"locate",
"a",
"document",
"in",
"the",
"archive",
".",
"This",
"function",
"tries",
"to",
"locate",
"the",
"document",
"inside",
"the",
"archive",
".",
"It",
"returns",
"a",
"tuple",
"where",
"the",
"first",
"element",
"is",
"zero",
"if",
... | fd87831a8c23498e65304fce341718bd2968211b | https://github.com/dottedmag/pychm/blob/fd87831a8c23498e65304fce341718bd2968211b/chm/chm.py#L359-L370 | train | 61,926 |
dottedmag/pychm | chm/chm.py | CHMFile.RetrieveObject | def RetrieveObject(self, ui, start=-1, length=-1):
'''Retrieves the contents of a document.
This function takes a UnitInfo and two optional arguments, the first
being the start address and the second is the length. These define
the amount of data to be read from the archive.
'''
... | python | def RetrieveObject(self, ui, start=-1, length=-1):
'''Retrieves the contents of a document.
This function takes a UnitInfo and two optional arguments, the first
being the start address and the second is the length. These define
the amount of data to be read from the archive.
'''
... | [
"def",
"RetrieveObject",
"(",
"self",
",",
"ui",
",",
"start",
"=",
"-",
"1",
",",
"length",
"=",
"-",
"1",
")",
":",
"if",
"self",
".",
"file",
"and",
"ui",
":",
"if",
"length",
"==",
"-",
"1",
":",
"len",
"=",
"ui",
".",
"length",
"else",
"... | Retrieves the contents of a document.
This function takes a UnitInfo and two optional arguments, the first
being the start address and the second is the length. These define
the amount of data to be read from the archive. | [
"Retrieves",
"the",
"contents",
"of",
"a",
"document",
".",
"This",
"function",
"takes",
"a",
"UnitInfo",
"and",
"two",
"optional",
"arguments",
"the",
"first",
"being",
"the",
"start",
"address",
"and",
"the",
"second",
"is",
"the",
"length",
".",
"These",
... | fd87831a8c23498e65304fce341718bd2968211b | https://github.com/dottedmag/pychm/blob/fd87831a8c23498e65304fce341718bd2968211b/chm/chm.py#L372-L389 | train | 61,927 |
dottedmag/pychm | chm/chm.py | CHMFile.Search | def Search(self, text, wholewords=0, titleonly=0):
'''Performs full-text search on the archive.
The first parameter is the word to look for, the second
indicates if the search should be for whole words only, and
the third parameter indicates if the search should be
restricted to ... | python | def Search(self, text, wholewords=0, titleonly=0):
'''Performs full-text search on the archive.
The first parameter is the word to look for, the second
indicates if the search should be for whole words only, and
the third parameter indicates if the search should be
restricted to ... | [
"def",
"Search",
"(",
"self",
",",
"text",
",",
"wholewords",
"=",
"0",
",",
"titleonly",
"=",
"0",
")",
":",
"if",
"text",
"and",
"text",
"!=",
"''",
"and",
"self",
".",
"file",
":",
"return",
"extra",
".",
"search",
"(",
"self",
".",
"file",
",... | Performs full-text search on the archive.
The first parameter is the word to look for, the second
indicates if the search should be for whole words only, and
the third parameter indicates if the search should be
restricted to page titles.
This method will return a tuple, the firs... | [
"Performs",
"full",
"-",
"text",
"search",
"on",
"the",
"archive",
".",
"The",
"first",
"parameter",
"is",
"the",
"word",
"to",
"look",
"for",
"the",
"second",
"indicates",
"if",
"the",
"search",
"should",
"be",
"for",
"whole",
"words",
"only",
"and",
"t... | fd87831a8c23498e65304fce341718bd2968211b | https://github.com/dottedmag/pychm/blob/fd87831a8c23498e65304fce341718bd2968211b/chm/chm.py#L391-L404 | train | 61,928 |
dottedmag/pychm | chm/chm.py | CHMFile.GetEncoding | def GetEncoding(self):
'''Returns a string that can be used with the codecs python package
to encode or decode the files in the chm archive. If an error is
found, or if it is not possible to find the encoding, None is
returned.'''
if self.encoding:
vals = string.split... | python | def GetEncoding(self):
'''Returns a string that can be used with the codecs python package
to encode or decode the files in the chm archive. If an error is
found, or if it is not possible to find the encoding, None is
returned.'''
if self.encoding:
vals = string.split... | [
"def",
"GetEncoding",
"(",
"self",
")",
":",
"if",
"self",
".",
"encoding",
":",
"vals",
"=",
"string",
".",
"split",
"(",
"self",
".",
"encoding",
",",
"','",
")",
"if",
"len",
"(",
"vals",
")",
">",
"2",
":",
"try",
":",
"return",
"charset_table"... | Returns a string that can be used with the codecs python package
to encode or decode the files in the chm archive. If an error is
found, or if it is not possible to find the encoding, None is
returned. | [
"Returns",
"a",
"string",
"that",
"can",
"be",
"used",
"with",
"the",
"codecs",
"python",
"package",
"to",
"encode",
"or",
"decode",
"the",
"files",
"in",
"the",
"chm",
"archive",
".",
"If",
"an",
"error",
"is",
"found",
"or",
"if",
"it",
"is",
"not",
... | fd87831a8c23498e65304fce341718bd2968211b | https://github.com/dottedmag/pychm/blob/fd87831a8c23498e65304fce341718bd2968211b/chm/chm.py#L411-L423 | train | 61,929 |
nutechsoftware/alarmdecoder | examples/socket_example.py | main | def main():
"""
Example application that opens a device that has been exposed to the network
with ser2sock or similar serial-to-IP software.
"""
try:
# Retrieve an AD2 device that has been exposed with ser2sock on localhost:10000.
device = AlarmDecoder(SocketDevice(interface=(HOSTNAM... | python | def main():
"""
Example application that opens a device that has been exposed to the network
with ser2sock or similar serial-to-IP software.
"""
try:
# Retrieve an AD2 device that has been exposed with ser2sock on localhost:10000.
device = AlarmDecoder(SocketDevice(interface=(HOSTNAM... | [
"def",
"main",
"(",
")",
":",
"try",
":",
"# Retrieve an AD2 device that has been exposed with ser2sock on localhost:10000.",
"device",
"=",
"AlarmDecoder",
"(",
"SocketDevice",
"(",
"interface",
"=",
"(",
"HOSTNAME",
",",
"PORT",
")",
")",
")",
"# Set up an event handl... | Example application that opens a device that has been exposed to the network
with ser2sock or similar serial-to-IP software. | [
"Example",
"application",
"that",
"opens",
"a",
"device",
"that",
"has",
"been",
"exposed",
"to",
"the",
"network",
"with",
"ser2sock",
"or",
"similar",
"serial",
"-",
"to",
"-",
"IP",
"software",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/examples/socket_example.py#L9-L25 | train | 61,930 |
nutechsoftware/alarmdecoder | alarmdecoder/messages/expander_message.py | ExpanderMessage._parse_message | def _parse_message(self, data):
"""
Parse the raw message from the device.
:param data: message data
:type data: string
:raises: :py:class:`~alarmdecoder.util.InvalidMessageError`
"""
try:
header, values = data.split(':')
address, channel... | python | def _parse_message(self, data):
"""
Parse the raw message from the device.
:param data: message data
:type data: string
:raises: :py:class:`~alarmdecoder.util.InvalidMessageError`
"""
try:
header, values = data.split(':')
address, channel... | [
"def",
"_parse_message",
"(",
"self",
",",
"data",
")",
":",
"try",
":",
"header",
",",
"values",
"=",
"data",
".",
"split",
"(",
"':'",
")",
"address",
",",
"channel",
",",
"value",
"=",
"values",
".",
"split",
"(",
"','",
")",
"self",
".",
"addre... | Parse the raw message from the device.
:param data: message data
:type data: string
:raises: :py:class:`~alarmdecoder.util.InvalidMessageError` | [
"Parse",
"the",
"raw",
"message",
"from",
"the",
"device",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/messages/expander_message.py#L46-L71 | train | 61,931 |
nutechsoftware/alarmdecoder | alarmdecoder/messages/lrr/events.py | get_event_description | def get_event_description(event_type, event_code):
"""
Retrieves the human-readable description of an LRR event.
:param event_type: Base LRR event type. Use LRR_EVENT_TYPE.*
:type event_type: int
:param event_code: LRR event code
:type event_code: int
:returns: string
"""
descript... | python | def get_event_description(event_type, event_code):
"""
Retrieves the human-readable description of an LRR event.
:param event_type: Base LRR event type. Use LRR_EVENT_TYPE.*
:type event_type: int
:param event_code: LRR event code
:type event_code: int
:returns: string
"""
descript... | [
"def",
"get_event_description",
"(",
"event_type",
",",
"event_code",
")",
":",
"description",
"=",
"'Unknown'",
"lookup_map",
"=",
"LRR_TYPE_MAP",
".",
"get",
"(",
"event_type",
",",
"None",
")",
"if",
"lookup_map",
"is",
"not",
"None",
":",
"description",
"=... | Retrieves the human-readable description of an LRR event.
:param event_type: Base LRR event type. Use LRR_EVENT_TYPE.*
:type event_type: int
:param event_code: LRR event code
:type event_code: int
:returns: string | [
"Retrieves",
"the",
"human",
"-",
"readable",
"description",
"of",
"an",
"LRR",
"event",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/messages/lrr/events.py#L7-L24 | train | 61,932 |
nutechsoftware/alarmdecoder | alarmdecoder/messages/lrr/events.py | get_event_source | def get_event_source(prefix):
"""
Retrieves the LRR_EVENT_TYPE corresponding to the prefix provided.abs
:param prefix: Prefix to convert to event type
:type prefix: string
:returns: int
"""
source = LRR_EVENT_TYPE.UNKNOWN
if prefix == 'CID':
source = LRR_EVENT_TYPE.CID
eli... | python | def get_event_source(prefix):
"""
Retrieves the LRR_EVENT_TYPE corresponding to the prefix provided.abs
:param prefix: Prefix to convert to event type
:type prefix: string
:returns: int
"""
source = LRR_EVENT_TYPE.UNKNOWN
if prefix == 'CID':
source = LRR_EVENT_TYPE.CID
eli... | [
"def",
"get_event_source",
"(",
"prefix",
")",
":",
"source",
"=",
"LRR_EVENT_TYPE",
".",
"UNKNOWN",
"if",
"prefix",
"==",
"'CID'",
":",
"source",
"=",
"LRR_EVENT_TYPE",
".",
"CID",
"elif",
"prefix",
"==",
"'DSC'",
":",
"source",
"=",
"LRR_EVENT_TYPE",
".",
... | Retrieves the LRR_EVENT_TYPE corresponding to the prefix provided.abs
:param prefix: Prefix to convert to event type
:type prefix: string
:returns: int | [
"Retrieves",
"the",
"LRR_EVENT_TYPE",
"corresponding",
"to",
"the",
"prefix",
"provided",
".",
"abs"
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/messages/lrr/events.py#L26-L46 | train | 61,933 |
nutechsoftware/alarmdecoder | alarmdecoder/decoder.py | AlarmDecoder.send | def send(self, data):
"""
Sends data to the `AlarmDecoder`_ device.
:param data: data to send
:type data: string
"""
if self._device:
if isinstance(data, str):
data = str.encode(data)
# Hack to support unicode under Python 2.x
... | python | def send(self, data):
"""
Sends data to the `AlarmDecoder`_ device.
:param data: data to send
:type data: string
"""
if self._device:
if isinstance(data, str):
data = str.encode(data)
# Hack to support unicode under Python 2.x
... | [
"def",
"send",
"(",
"self",
",",
"data",
")",
":",
"if",
"self",
".",
"_device",
":",
"if",
"isinstance",
"(",
"data",
",",
"str",
")",
":",
"data",
"=",
"str",
".",
"encode",
"(",
"data",
")",
"# Hack to support unicode under Python 2.x",
"if",
"sys",
... | Sends data to the `AlarmDecoder`_ device.
:param data: data to send
:type data: string | [
"Sends",
"data",
"to",
"the",
"AlarmDecoder",
"_",
"device",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/decoder.py#L287-L304 | train | 61,934 |
nutechsoftware/alarmdecoder | alarmdecoder/decoder.py | AlarmDecoder.get_config_string | def get_config_string(self):
"""
Build a configuration string that's compatible with the AlarmDecoder configuration
command from the current values in the object.
:returns: string
"""
config_entries = []
# HACK: This is ugly.. but I can't think of an elegant way... | python | def get_config_string(self):
"""
Build a configuration string that's compatible with the AlarmDecoder configuration
command from the current values in the object.
:returns: string
"""
config_entries = []
# HACK: This is ugly.. but I can't think of an elegant way... | [
"def",
"get_config_string",
"(",
"self",
")",
":",
"config_entries",
"=",
"[",
"]",
"# HACK: This is ugly.. but I can't think of an elegant way of doing it.",
"config_entries",
".",
"append",
"(",
"(",
"'ADDRESS'",
",",
"'{0}'",
".",
"format",
"(",
"self",
".",
"addre... | Build a configuration string that's compatible with the AlarmDecoder configuration
command from the current values in the object.
:returns: string | [
"Build",
"a",
"configuration",
"string",
"that",
"s",
"compatible",
"with",
"the",
"AlarmDecoder",
"configuration",
"command",
"from",
"the",
"current",
"values",
"in",
"the",
"object",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/decoder.py#L318-L342 | train | 61,935 |
nutechsoftware/alarmdecoder | alarmdecoder/decoder.py | AlarmDecoder.fault_zone | def fault_zone(self, zone, simulate_wire_problem=False):
"""
Faults a zone if we are emulating a zone expander.
:param zone: zone to fault
:type zone: int
:param simulate_wire_problem: Whether or not to simulate a wire fault
:type simulate_wire_problem: bool
"""
... | python | def fault_zone(self, zone, simulate_wire_problem=False):
"""
Faults a zone if we are emulating a zone expander.
:param zone: zone to fault
:type zone: int
:param simulate_wire_problem: Whether or not to simulate a wire fault
:type simulate_wire_problem: bool
"""
... | [
"def",
"fault_zone",
"(",
"self",
",",
"zone",
",",
"simulate_wire_problem",
"=",
"False",
")",
":",
"# Allow ourselves to also be passed an address/channel combination",
"# for zone expanders.",
"#",
"# Format (expander index, channel)",
"if",
"isinstance",
"(",
"zone",
",",... | Faults a zone if we are emulating a zone expander.
:param zone: zone to fault
:type zone: int
:param simulate_wire_problem: Whether or not to simulate a wire fault
:type simulate_wire_problem: bool | [
"Faults",
"a",
"zone",
"if",
"we",
"are",
"emulating",
"a",
"zone",
"expander",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/decoder.py#L356-L377 | train | 61,936 |
nutechsoftware/alarmdecoder | alarmdecoder/decoder.py | AlarmDecoder._wire_events | def _wire_events(self):
"""
Wires up the internal device events.
"""
self._device.on_open += self._on_open
self._device.on_close += self._on_close
self._device.on_read += self._on_read
self._device.on_write += self._on_write
self._zonetracker.on_fault += s... | python | def _wire_events(self):
"""
Wires up the internal device events.
"""
self._device.on_open += self._on_open
self._device.on_close += self._on_close
self._device.on_read += self._on_read
self._device.on_write += self._on_write
self._zonetracker.on_fault += s... | [
"def",
"_wire_events",
"(",
"self",
")",
":",
"self",
".",
"_device",
".",
"on_open",
"+=",
"self",
".",
"_on_open",
"self",
".",
"_device",
".",
"on_close",
"+=",
"self",
".",
"_on_close",
"self",
".",
"_device",
".",
"on_read",
"+=",
"self",
".",
"_o... | Wires up the internal device events. | [
"Wires",
"up",
"the",
"internal",
"device",
"events",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/decoder.py#L388-L397 | train | 61,937 |
nutechsoftware/alarmdecoder | alarmdecoder/decoder.py | AlarmDecoder._handle_message | def _handle_message(self, data):
"""
Parses keypad messages from the panel.
:param data: keypad data to parse
:type data: string
:returns: :py:class:`~alarmdecoder.messages.Message`
"""
try:
data = data.decode('utf-8')
except:
ra... | python | def _handle_message(self, data):
"""
Parses keypad messages from the panel.
:param data: keypad data to parse
:type data: string
:returns: :py:class:`~alarmdecoder.messages.Message`
"""
try:
data = data.decode('utf-8')
except:
ra... | [
"def",
"_handle_message",
"(",
"self",
",",
"data",
")",
":",
"try",
":",
"data",
"=",
"data",
".",
"decode",
"(",
"'utf-8'",
")",
"except",
":",
"raise",
"InvalidMessageError",
"(",
"'Decode failed for message: {0}'",
".",
"format",
"(",
"data",
")",
")",
... | Parses keypad messages from the panel.
:param data: keypad data to parse
:type data: string
:returns: :py:class:`~alarmdecoder.messages.Message` | [
"Parses",
"keypad",
"messages",
"from",
"the",
"panel",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/decoder.py#L410-L461 | train | 61,938 |
nutechsoftware/alarmdecoder | alarmdecoder/decoder.py | AlarmDecoder._handle_keypad_message | def _handle_keypad_message(self, data):
"""
Handle keypad messages.
:param data: keypad message to parse
:type data: string
:returns: :py:class:`~alarmdecoder.messages.Message`
"""
msg = Message(data)
if self._internal_address_mask & msg.mask > 0:
... | python | def _handle_keypad_message(self, data):
"""
Handle keypad messages.
:param data: keypad message to parse
:type data: string
:returns: :py:class:`~alarmdecoder.messages.Message`
"""
msg = Message(data)
if self._internal_address_mask & msg.mask > 0:
... | [
"def",
"_handle_keypad_message",
"(",
"self",
",",
"data",
")",
":",
"msg",
"=",
"Message",
"(",
"data",
")",
"if",
"self",
".",
"_internal_address_mask",
"&",
"msg",
".",
"mask",
">",
"0",
":",
"if",
"not",
"self",
".",
"_ignore_message_states",
":",
"s... | Handle keypad messages.
:param data: keypad message to parse
:type data: string
:returns: :py:class:`~alarmdecoder.messages.Message` | [
"Handle",
"keypad",
"messages",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/decoder.py#L463-L481 | train | 61,939 |
nutechsoftware/alarmdecoder | alarmdecoder/decoder.py | AlarmDecoder._handle_expander_message | def _handle_expander_message(self, data):
"""
Handle expander messages.
:param data: expander message to parse
:type data: string
:returns: :py:class:`~alarmdecoder.messages.ExpanderMessage`
"""
msg = ExpanderMessage(data)
self._update_internal_states(m... | python | def _handle_expander_message(self, data):
"""
Handle expander messages.
:param data: expander message to parse
:type data: string
:returns: :py:class:`~alarmdecoder.messages.ExpanderMessage`
"""
msg = ExpanderMessage(data)
self._update_internal_states(m... | [
"def",
"_handle_expander_message",
"(",
"self",
",",
"data",
")",
":",
"msg",
"=",
"ExpanderMessage",
"(",
"data",
")",
"self",
".",
"_update_internal_states",
"(",
"msg",
")",
"self",
".",
"on_expander_message",
"(",
"message",
"=",
"msg",
")",
"return",
"m... | Handle expander messages.
:param data: expander message to parse
:type data: string
:returns: :py:class:`~alarmdecoder.messages.ExpanderMessage` | [
"Handle",
"expander",
"messages",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/decoder.py#L483-L497 | train | 61,940 |
nutechsoftware/alarmdecoder | alarmdecoder/decoder.py | AlarmDecoder._handle_rfx | def _handle_rfx(self, data):
"""
Handle RF messages.
:param data: RF message to parse
:type data: string
:returns: :py:class:`~alarmdecoder.messages.RFMessage`
"""
msg = RFMessage(data)
self.on_rfx_message(message=msg)
return msg | python | def _handle_rfx(self, data):
"""
Handle RF messages.
:param data: RF message to parse
:type data: string
:returns: :py:class:`~alarmdecoder.messages.RFMessage`
"""
msg = RFMessage(data)
self.on_rfx_message(message=msg)
return msg | [
"def",
"_handle_rfx",
"(",
"self",
",",
"data",
")",
":",
"msg",
"=",
"RFMessage",
"(",
"data",
")",
"self",
".",
"on_rfx_message",
"(",
"message",
"=",
"msg",
")",
"return",
"msg"
] | Handle RF messages.
:param data: RF message to parse
:type data: string
:returns: :py:class:`~alarmdecoder.messages.RFMessage` | [
"Handle",
"RF",
"messages",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/decoder.py#L499-L512 | train | 61,941 |
nutechsoftware/alarmdecoder | alarmdecoder/decoder.py | AlarmDecoder._handle_lrr | def _handle_lrr(self, data):
"""
Handle Long Range Radio messages.
:param data: LRR message to parse
:type data: string
:returns: :py:class:`~alarmdecoder.messages.LRRMessage`
"""
msg = LRRMessage(data)
if not self._ignore_lrr_states:
self._... | python | def _handle_lrr(self, data):
"""
Handle Long Range Radio messages.
:param data: LRR message to parse
:type data: string
:returns: :py:class:`~alarmdecoder.messages.LRRMessage`
"""
msg = LRRMessage(data)
if not self._ignore_lrr_states:
self._... | [
"def",
"_handle_lrr",
"(",
"self",
",",
"data",
")",
":",
"msg",
"=",
"LRRMessage",
"(",
"data",
")",
"if",
"not",
"self",
".",
"_ignore_lrr_states",
":",
"self",
".",
"_lrr_system",
".",
"update",
"(",
"msg",
")",
"self",
".",
"on_lrr_message",
"(",
"... | Handle Long Range Radio messages.
:param data: LRR message to parse
:type data: string
:returns: :py:class:`~alarmdecoder.messages.LRRMessage` | [
"Handle",
"Long",
"Range",
"Radio",
"messages",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/decoder.py#L514-L529 | train | 61,942 |
nutechsoftware/alarmdecoder | alarmdecoder/decoder.py | AlarmDecoder._handle_aui | def _handle_aui(self, data):
"""
Handle AUI messages.
:param data: RF message to parse
:type data: string
:returns: :py:class`~alarmdecoder.messages.AUIMessage`
"""
msg = AUIMessage(data)
self.on_aui_message(message=msg)
return msg | python | def _handle_aui(self, data):
"""
Handle AUI messages.
:param data: RF message to parse
:type data: string
:returns: :py:class`~alarmdecoder.messages.AUIMessage`
"""
msg = AUIMessage(data)
self.on_aui_message(message=msg)
return msg | [
"def",
"_handle_aui",
"(",
"self",
",",
"data",
")",
":",
"msg",
"=",
"AUIMessage",
"(",
"data",
")",
"self",
".",
"on_aui_message",
"(",
"message",
"=",
"msg",
")",
"return",
"msg"
] | Handle AUI messages.
:param data: RF message to parse
:type data: string
:returns: :py:class`~alarmdecoder.messages.AUIMessage` | [
"Handle",
"AUI",
"messages",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/decoder.py#L531-L544 | train | 61,943 |
nutechsoftware/alarmdecoder | alarmdecoder/decoder.py | AlarmDecoder._handle_version | def _handle_version(self, data):
"""
Handles received version data.
:param data: Version string to parse
:type data: string
"""
_, version_string = data.split(':')
version_parts = version_string.split(',')
self.serial_number = version_parts[0]
s... | python | def _handle_version(self, data):
"""
Handles received version data.
:param data: Version string to parse
:type data: string
"""
_, version_string = data.split(':')
version_parts = version_string.split(',')
self.serial_number = version_parts[0]
s... | [
"def",
"_handle_version",
"(",
"self",
",",
"data",
")",
":",
"_",
",",
"version_string",
"=",
"data",
".",
"split",
"(",
"':'",
")",
"version_parts",
"=",
"version_string",
".",
"split",
"(",
"','",
")",
"self",
".",
"serial_number",
"=",
"version_parts",... | Handles received version data.
:param data: Version string to parse
:type data: string | [
"Handles",
"received",
"version",
"data",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/decoder.py#L546-L559 | train | 61,944 |
nutechsoftware/alarmdecoder | alarmdecoder/decoder.py | AlarmDecoder._handle_config | def _handle_config(self, data):
"""
Handles received configuration data.
:param data: Configuration string to parse
:type data: string
"""
_, config_string = data.split('>')
for setting in config_string.split('&'):
key, val = setting.split('=')
... | python | def _handle_config(self, data):
"""
Handles received configuration data.
:param data: Configuration string to parse
:type data: string
"""
_, config_string = data.split('>')
for setting in config_string.split('&'):
key, val = setting.split('=')
... | [
"def",
"_handle_config",
"(",
"self",
",",
"data",
")",
":",
"_",
",",
"config_string",
"=",
"data",
".",
"split",
"(",
"'>'",
")",
"for",
"setting",
"in",
"config_string",
".",
"split",
"(",
"'&'",
")",
":",
"key",
",",
"val",
"=",
"setting",
".",
... | Handles received configuration data.
:param data: Configuration string to parse
:type data: string | [
"Handles",
"received",
"configuration",
"data",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/decoder.py#L561-L591 | train | 61,945 |
nutechsoftware/alarmdecoder | alarmdecoder/decoder.py | AlarmDecoder._handle_sending | def _handle_sending(self, data):
"""
Handles results of a keypress send.
:param data: Sending string to parse
:type data: string
"""
matches = re.match('^!Sending(\.{1,5})done.*', data)
if matches is not None:
good_send = False
if len(mat... | python | def _handle_sending(self, data):
"""
Handles results of a keypress send.
:param data: Sending string to parse
:type data: string
"""
matches = re.match('^!Sending(\.{1,5})done.*', data)
if matches is not None:
good_send = False
if len(mat... | [
"def",
"_handle_sending",
"(",
"self",
",",
"data",
")",
":",
"matches",
"=",
"re",
".",
"match",
"(",
"'^!Sending(\\.{1,5})done.*'",
",",
"data",
")",
"if",
"matches",
"is",
"not",
"None",
":",
"good_send",
"=",
"False",
"if",
"len",
"(",
"matches",
"."... | Handles results of a keypress send.
:param data: Sending string to parse
:type data: string | [
"Handles",
"results",
"of",
"a",
"keypress",
"send",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/decoder.py#L593-L607 | train | 61,946 |
nutechsoftware/alarmdecoder | alarmdecoder/decoder.py | AlarmDecoder._update_internal_states | def _update_internal_states(self, message):
"""
Updates internal device states.
:param message: :py:class:`~alarmdecoder.messages.Message` to update internal states with
:type message: :py:class:`~alarmdecoder.messages.Message`, :py:class:`~alarmdecoder.messages.ExpanderMessage`, :py:cl... | python | def _update_internal_states(self, message):
"""
Updates internal device states.
:param message: :py:class:`~alarmdecoder.messages.Message` to update internal states with
:type message: :py:class:`~alarmdecoder.messages.Message`, :py:class:`~alarmdecoder.messages.ExpanderMessage`, :py:cl... | [
"def",
"_update_internal_states",
"(",
"self",
",",
"message",
")",
":",
"if",
"isinstance",
"(",
"message",
",",
"Message",
")",
"and",
"not",
"self",
".",
"_ignore_message_states",
":",
"self",
".",
"_update_armed_ready_status",
"(",
"message",
")",
"self",
... | Updates internal device states.
:param message: :py:class:`~alarmdecoder.messages.Message` to update internal states with
:type message: :py:class:`~alarmdecoder.messages.Message`, :py:class:`~alarmdecoder.messages.ExpanderMessage`, :py:class:`~alarmdecoder.messages.LRRMessage`, or :py:class:`~alarmdec... | [
"Updates",
"internal",
"device",
"states",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/decoder.py#L609-L628 | train | 61,947 |
nutechsoftware/alarmdecoder | alarmdecoder/decoder.py | AlarmDecoder._update_power_status | def _update_power_status(self, message=None, status=None):
"""
Uses the provided message to update the AC power state.
:param message: message to use to update
:type message: :py:class:`~alarmdecoder.messages.Message`
:param status: power status, overrides message bits.
... | python | def _update_power_status(self, message=None, status=None):
"""
Uses the provided message to update the AC power state.
:param message: message to use to update
:type message: :py:class:`~alarmdecoder.messages.Message`
:param status: power status, overrides message bits.
... | [
"def",
"_update_power_status",
"(",
"self",
",",
"message",
"=",
"None",
",",
"status",
"=",
"None",
")",
":",
"power_status",
"=",
"status",
"if",
"isinstance",
"(",
"message",
",",
"Message",
")",
":",
"power_status",
"=",
"message",
".",
"ac_power",
"if... | Uses the provided message to update the AC power state.
:param message: message to use to update
:type message: :py:class:`~alarmdecoder.messages.Message`
:param status: power status, overrides message bits.
:type status: bool
:returns: bool indicating the new status | [
"Uses",
"the",
"provided",
"message",
"to",
"update",
"the",
"AC",
"power",
"state",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/decoder.py#L630-L654 | train | 61,948 |
nutechsoftware/alarmdecoder | alarmdecoder/decoder.py | AlarmDecoder._update_chime_status | def _update_chime_status(self, message=None, status=None):
"""
Uses the provided message to update the Chime state.
:param message: message to use to update
:type message: :py:class:`~alarmdecoder.messages.Message`
:param status: chime status, overrides message bits.
:ty... | python | def _update_chime_status(self, message=None, status=None):
"""
Uses the provided message to update the Chime state.
:param message: message to use to update
:type message: :py:class:`~alarmdecoder.messages.Message`
:param status: chime status, overrides message bits.
:ty... | [
"def",
"_update_chime_status",
"(",
"self",
",",
"message",
"=",
"None",
",",
"status",
"=",
"None",
")",
":",
"chime_status",
"=",
"status",
"if",
"isinstance",
"(",
"message",
",",
"Message",
")",
":",
"chime_status",
"=",
"message",
".",
"chime_on",
"if... | Uses the provided message to update the Chime state.
:param message: message to use to update
:type message: :py:class:`~alarmdecoder.messages.Message`
:param status: chime status, overrides message bits.
:type status: bool
:returns: bool indicating the new status | [
"Uses",
"the",
"provided",
"message",
"to",
"update",
"the",
"Chime",
"state",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/decoder.py#L656-L680 | train | 61,949 |
nutechsoftware/alarmdecoder | alarmdecoder/decoder.py | AlarmDecoder._update_alarm_status | def _update_alarm_status(self, message=None, status=None, zone=None, user=None):
"""
Uses the provided message to update the alarm state.
:param message: message to use to update
:type message: :py:class:`~alarmdecoder.messages.Message`
:param status: alarm status, overrides mes... | python | def _update_alarm_status(self, message=None, status=None, zone=None, user=None):
"""
Uses the provided message to update the alarm state.
:param message: message to use to update
:type message: :py:class:`~alarmdecoder.messages.Message`
:param status: alarm status, overrides mes... | [
"def",
"_update_alarm_status",
"(",
"self",
",",
"message",
"=",
"None",
",",
"status",
"=",
"None",
",",
"zone",
"=",
"None",
",",
"user",
"=",
"None",
")",
":",
"alarm_status",
"=",
"status",
"alarm_zone",
"=",
"zone",
"if",
"isinstance",
"(",
"message... | Uses the provided message to update the alarm state.
:param message: message to use to update
:type message: :py:class:`~alarmdecoder.messages.Message`
:param status: alarm status, overrides message bits.
:type status: bool
:param user: user associated with alarm event
:... | [
"Uses",
"the",
"provided",
"message",
"to",
"update",
"the",
"alarm",
"state",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/decoder.py#L682-L711 | train | 61,950 |
nutechsoftware/alarmdecoder | alarmdecoder/decoder.py | AlarmDecoder._update_zone_bypass_status | def _update_zone_bypass_status(self, message=None, status=None, zone=None):
"""
Uses the provided message to update the zone bypass state.
:param message: message to use to update
:type message: :py:class:`~alarmdecoder.messages.Message`
:param status: bypass status, overrides m... | python | def _update_zone_bypass_status(self, message=None, status=None, zone=None):
"""
Uses the provided message to update the zone bypass state.
:param message: message to use to update
:type message: :py:class:`~alarmdecoder.messages.Message`
:param status: bypass status, overrides m... | [
"def",
"_update_zone_bypass_status",
"(",
"self",
",",
"message",
"=",
"None",
",",
"status",
"=",
"None",
",",
"zone",
"=",
"None",
")",
":",
"bypass_status",
"=",
"status",
"if",
"isinstance",
"(",
"message",
",",
"Message",
")",
":",
"bypass_status",
"=... | Uses the provided message to update the zone bypass state.
:param message: message to use to update
:type message: :py:class:`~alarmdecoder.messages.Message`
:param status: bypass status, overrides message bits.
:type status: bool
:param zone: zone associated with bypass event
... | [
"Uses",
"the",
"provided",
"message",
"to",
"update",
"the",
"zone",
"bypass",
"state",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/decoder.py#L713-L746 | train | 61,951 |
nutechsoftware/alarmdecoder | alarmdecoder/decoder.py | AlarmDecoder._update_armed_status | def _update_armed_status(self, message=None, status=None, status_stay=None):
"""
Uses the provided message to update the armed state.
:param message: message to use to update
:type message: :py:class:`~alarmdecoder.messages.Message`
:param status: armed status, overrides message... | python | def _update_armed_status(self, message=None, status=None, status_stay=None):
"""
Uses the provided message to update the armed state.
:param message: message to use to update
:type message: :py:class:`~alarmdecoder.messages.Message`
:param status: armed status, overrides message... | [
"def",
"_update_armed_status",
"(",
"self",
",",
"message",
"=",
"None",
",",
"status",
"=",
"None",
",",
"status_stay",
"=",
"None",
")",
":",
"arm_status",
"=",
"status",
"stay_status",
"=",
"status_stay",
"if",
"isinstance",
"(",
"message",
",",
"Message"... | Uses the provided message to update the armed state.
:param message: message to use to update
:type message: :py:class:`~alarmdecoder.messages.Message`
:param status: armed status, overrides message bits
:type status: bool
:param status_stay: armed stay status, overrides message... | [
"Uses",
"the",
"provided",
"message",
"to",
"update",
"the",
"armed",
"state",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/decoder.py#L794-L826 | train | 61,952 |
nutechsoftware/alarmdecoder | alarmdecoder/decoder.py | AlarmDecoder._update_battery_status | def _update_battery_status(self, message=None, status=None):
"""
Uses the provided message to update the battery state.
:param message: message to use to update
:type message: :py:class:`~alarmdecoder.messages.Message`
:param status: battery status, overrides message bits
... | python | def _update_battery_status(self, message=None, status=None):
"""
Uses the provided message to update the battery state.
:param message: message to use to update
:type message: :py:class:`~alarmdecoder.messages.Message`
:param status: battery status, overrides message bits
... | [
"def",
"_update_battery_status",
"(",
"self",
",",
"message",
"=",
"None",
",",
"status",
"=",
"None",
")",
":",
"battery_status",
"=",
"status",
"if",
"isinstance",
"(",
"message",
",",
"Message",
")",
":",
"battery_status",
"=",
"message",
".",
"battery_lo... | Uses the provided message to update the battery state.
:param message: message to use to update
:type message: :py:class:`~alarmdecoder.messages.Message`
:param status: battery status, overrides message bits
:type status: bool
:returns: boolean indicating the new status | [
"Uses",
"the",
"provided",
"message",
"to",
"update",
"the",
"battery",
"state",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/decoder.py#L828-L854 | train | 61,953 |
nutechsoftware/alarmdecoder | alarmdecoder/decoder.py | AlarmDecoder._update_fire_status | def _update_fire_status(self, message=None, status=None):
"""
Uses the provided message to update the fire alarm state.
:param message: message to use to update
:type message: :py:class:`~alarmdecoder.messages.Message`
:param status: fire status, overrides message bits
:... | python | def _update_fire_status(self, message=None, status=None):
"""
Uses the provided message to update the fire alarm state.
:param message: message to use to update
:type message: :py:class:`~alarmdecoder.messages.Message`
:param status: fire status, overrides message bits
:... | [
"def",
"_update_fire_status",
"(",
"self",
",",
"message",
"=",
"None",
",",
"status",
"=",
"None",
")",
":",
"fire_status",
"=",
"status",
"last_status",
"=",
"self",
".",
"_fire_status",
"if",
"isinstance",
"(",
"message",
",",
"Message",
")",
":",
"# Qu... | Uses the provided message to update the fire alarm state.
:param message: message to use to update
:type message: :py:class:`~alarmdecoder.messages.Message`
:param status: fire status, overrides message bits
:type status: bool
:returns: boolean indicating the new status | [
"Uses",
"the",
"provided",
"message",
"to",
"update",
"the",
"fire",
"alarm",
"state",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/decoder.py#L856-L886 | train | 61,954 |
nutechsoftware/alarmdecoder | alarmdecoder/decoder.py | AlarmDecoder._update_panic_status | def _update_panic_status(self, status=None):
"""
Updates the panic status of the alarm panel.
:param status: status to use to update
:type status: boolean
:returns: boolean indicating the new status
"""
if status is None:
return
if status !=... | python | def _update_panic_status(self, status=None):
"""
Updates the panic status of the alarm panel.
:param status: status to use to update
:type status: boolean
:returns: boolean indicating the new status
"""
if status is None:
return
if status !=... | [
"def",
"_update_panic_status",
"(",
"self",
",",
"status",
"=",
"None",
")",
":",
"if",
"status",
"is",
"None",
":",
"return",
"if",
"status",
"!=",
"self",
".",
"_panic_status",
":",
"self",
".",
"_panic_status",
",",
"old_status",
"=",
"status",
",",
"... | Updates the panic status of the alarm panel.
:param status: status to use to update
:type status: boolean
:returns: boolean indicating the new status | [
"Updates",
"the",
"panic",
"status",
"of",
"the",
"alarm",
"panel",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/decoder.py#L888-L906 | train | 61,955 |
nutechsoftware/alarmdecoder | alarmdecoder/decoder.py | AlarmDecoder._update_expander_status | def _update_expander_status(self, message):
"""
Uses the provided message to update the expander states.
:param message: message to use to update
:type message: :py:class:`~alarmdecoder.messages.ExpanderMessage`
:returns: boolean indicating the new status
"""
i... | python | def _update_expander_status(self, message):
"""
Uses the provided message to update the expander states.
:param message: message to use to update
:type message: :py:class:`~alarmdecoder.messages.ExpanderMessage`
:returns: boolean indicating the new status
"""
i... | [
"def",
"_update_expander_status",
"(",
"self",
",",
"message",
")",
":",
"if",
"message",
".",
"type",
"==",
"ExpanderMessage",
".",
"RELAY",
":",
"self",
".",
"_relay_status",
"[",
"(",
"message",
".",
"address",
",",
"message",
".",
"channel",
")",
"]",
... | Uses the provided message to update the expander states.
:param message: message to use to update
:type message: :py:class:`~alarmdecoder.messages.ExpanderMessage`
:returns: boolean indicating the new status | [
"Uses",
"the",
"provided",
"message",
"to",
"update",
"the",
"expander",
"states",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/decoder.py#L908-L923 | train | 61,956 |
nutechsoftware/alarmdecoder | alarmdecoder/decoder.py | AlarmDecoder._on_open | def _on_open(self, sender, *args, **kwargs):
"""
Internal handler for opening the device.
"""
self.get_config()
self.get_version()
self.on_open() | python | def _on_open(self, sender, *args, **kwargs):
"""
Internal handler for opening the device.
"""
self.get_config()
self.get_version()
self.on_open() | [
"def",
"_on_open",
"(",
"self",
",",
"sender",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"get_config",
"(",
")",
"self",
".",
"get_version",
"(",
")",
"self",
".",
"on_open",
"(",
")"
] | Internal handler for opening the device. | [
"Internal",
"handler",
"for",
"opening",
"the",
"device",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/decoder.py#L944-L951 | train | 61,957 |
nutechsoftware/alarmdecoder | alarmdecoder/decoder.py | AlarmDecoder._on_read | def _on_read(self, sender, *args, **kwargs):
"""
Internal handler for reading from the device.
"""
data = kwargs.get('data', None)
self.on_read(data=data)
self._handle_message(data) | python | def _on_read(self, sender, *args, **kwargs):
"""
Internal handler for reading from the device.
"""
data = kwargs.get('data', None)
self.on_read(data=data)
self._handle_message(data) | [
"def",
"_on_read",
"(",
"self",
",",
"sender",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"data",
"=",
"kwargs",
".",
"get",
"(",
"'data'",
",",
"None",
")",
"self",
".",
"on_read",
"(",
"data",
"=",
"data",
")",
"self",
".",
"_handle_m... | Internal handler for reading from the device. | [
"Internal",
"handler",
"for",
"reading",
"from",
"the",
"device",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/decoder.py#L959-L966 | train | 61,958 |
nutechsoftware/alarmdecoder | alarmdecoder/decoder.py | AlarmDecoder._on_write | def _on_write(self, sender, *args, **kwargs):
"""
Internal handler for writing to the device.
"""
self.on_write(data=kwargs.get('data', None)) | python | def _on_write(self, sender, *args, **kwargs):
"""
Internal handler for writing to the device.
"""
self.on_write(data=kwargs.get('data', None)) | [
"def",
"_on_write",
"(",
"self",
",",
"sender",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"on_write",
"(",
"data",
"=",
"kwargs",
".",
"get",
"(",
"'data'",
",",
"None",
")",
")"
] | Internal handler for writing to the device. | [
"Internal",
"handler",
"for",
"writing",
"to",
"the",
"device",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/decoder.py#L968-L972 | train | 61,959 |
nutechsoftware/alarmdecoder | alarmdecoder/zonetracking.py | Zonetracker.update | def update(self, message):
"""
Update zone statuses based on the current message.
:param message: message to use to update the zone tracking
:type message: :py:class:`~alarmdecoder.messages.Message` or :py:class:`~alarmdecoder.messages.ExpanderMessage`
"""
if isinstance(... | python | def update(self, message):
"""
Update zone statuses based on the current message.
:param message: message to use to update the zone tracking
:type message: :py:class:`~alarmdecoder.messages.Message` or :py:class:`~alarmdecoder.messages.ExpanderMessage`
"""
if isinstance(... | [
"def",
"update",
"(",
"self",
",",
"message",
")",
":",
"if",
"isinstance",
"(",
"message",
",",
"ExpanderMessage",
")",
":",
"zone",
"=",
"-",
"1",
"if",
"message",
".",
"type",
"==",
"ExpanderMessage",
".",
"ZONE",
":",
"zone",
"=",
"self",
".",
"e... | Update zone statuses based on the current message.
:param message: message to use to update the zone tracking
:type message: :py:class:`~alarmdecoder.messages.Message` or :py:class:`~alarmdecoder.messages.ExpanderMessage` | [
"Update",
"zone",
"statuses",
"based",
"on",
"the",
"current",
"message",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/zonetracking.py#L133-L213 | train | 61,960 |
nutechsoftware/alarmdecoder | alarmdecoder/zonetracking.py | Zonetracker.expander_to_zone | def expander_to_zone(self, address, channel, panel_type=ADEMCO):
"""
Convert an address and channel into a zone number.
:param address: expander address
:type address: int
:param channel: channel
:type channel: int
:returns: zone number associated with an addres... | python | def expander_to_zone(self, address, channel, panel_type=ADEMCO):
"""
Convert an address and channel into a zone number.
:param address: expander address
:type address: int
:param channel: channel
:type channel: int
:returns: zone number associated with an addres... | [
"def",
"expander_to_zone",
"(",
"self",
",",
"address",
",",
"channel",
",",
"panel_type",
"=",
"ADEMCO",
")",
":",
"zone",
"=",
"-",
"1",
"if",
"panel_type",
"==",
"ADEMCO",
":",
"# TODO: This is going to need to be reworked to support the larger",
"# panels wi... | Convert an address and channel into a zone number.
:param address: expander address
:type address: int
:param channel: channel
:type channel: int
:returns: zone number associated with an address and channel | [
"Convert",
"an",
"address",
"and",
"channel",
"into",
"a",
"zone",
"number",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/zonetracking.py#L215-L239 | train | 61,961 |
nutechsoftware/alarmdecoder | alarmdecoder/zonetracking.py | Zonetracker._clear_zones | def _clear_zones(self, zone):
"""
Clear all expired zones from our status list.
:param zone: current zone being processed
:type zone: int
"""
cleared_zones = []
found_last_faulted = found_current = at_end = False
# First pass: Find our start spot.
... | python | def _clear_zones(self, zone):
"""
Clear all expired zones from our status list.
:param zone: current zone being processed
:type zone: int
"""
cleared_zones = []
found_last_faulted = found_current = at_end = False
# First pass: Find our start spot.
... | [
"def",
"_clear_zones",
"(",
"self",
",",
"zone",
")",
":",
"cleared_zones",
"=",
"[",
"]",
"found_last_faulted",
"=",
"found_current",
"=",
"at_end",
"=",
"False",
"# First pass: Find our start spot.",
"it",
"=",
"iter",
"(",
"self",
".",
"_zones_faulted",
")",
... | Clear all expired zones from our status list.
:param zone: current zone being processed
:type zone: int | [
"Clear",
"all",
"expired",
"zones",
"from",
"our",
"status",
"list",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/zonetracking.py#L241-L299 | train | 61,962 |
nutechsoftware/alarmdecoder | alarmdecoder/zonetracking.py | Zonetracker._clear_expired_zones | def _clear_expired_zones(self):
"""
Update zone status for all expired zones.
"""
zones = []
for z in list(self._zones.keys()):
zones += [z]
for z in zones:
if self._zones[z].status != Zone.CLEAR and self._zone_expired(z):
self._u... | python | def _clear_expired_zones(self):
"""
Update zone status for all expired zones.
"""
zones = []
for z in list(self._zones.keys()):
zones += [z]
for z in zones:
if self._zones[z].status != Zone.CLEAR and self._zone_expired(z):
self._u... | [
"def",
"_clear_expired_zones",
"(",
"self",
")",
":",
"zones",
"=",
"[",
"]",
"for",
"z",
"in",
"list",
"(",
"self",
".",
"_zones",
".",
"keys",
"(",
")",
")",
":",
"zones",
"+=",
"[",
"z",
"]",
"for",
"z",
"in",
"zones",
":",
"if",
"self",
"."... | Update zone status for all expired zones. | [
"Update",
"zone",
"status",
"for",
"all",
"expired",
"zones",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/zonetracking.py#L301-L312 | train | 61,963 |
nutechsoftware/alarmdecoder | alarmdecoder/zonetracking.py | Zonetracker._add_zone | def _add_zone(self, zone, name='', status=Zone.CLEAR, expander=False):
"""
Adds a zone to the internal zone list.
:param zone: zone number
:type zone: int
:param name: human readable zone name
:type name: string
:param status: zone status
:type status: in... | python | def _add_zone(self, zone, name='', status=Zone.CLEAR, expander=False):
"""
Adds a zone to the internal zone list.
:param zone: zone number
:type zone: int
:param name: human readable zone name
:type name: string
:param status: zone status
:type status: in... | [
"def",
"_add_zone",
"(",
"self",
",",
"zone",
",",
"name",
"=",
"''",
",",
"status",
"=",
"Zone",
".",
"CLEAR",
",",
"expander",
"=",
"False",
")",
":",
"if",
"not",
"zone",
"in",
"self",
".",
"_zones",
":",
"self",
".",
"_zones",
"[",
"zone",
"]... | Adds a zone to the internal zone list.
:param zone: zone number
:type zone: int
:param name: human readable zone name
:type name: string
:param status: zone status
:type status: int | [
"Adds",
"a",
"zone",
"to",
"the",
"internal",
"zone",
"list",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/zonetracking.py#L314-L328 | train | 61,964 |
nutechsoftware/alarmdecoder | alarmdecoder/zonetracking.py | Zonetracker._update_zone | def _update_zone(self, zone, status=None):
"""
Updates a zones status.
:param zone: zone number
:type zone: int
:param status: zone status
:type status: int
:raises: IndexError
"""
if not zone in self._zones:
raise IndexError('Zone do... | python | def _update_zone(self, zone, status=None):
"""
Updates a zones status.
:param zone: zone number
:type zone: int
:param status: zone status
:type status: int
:raises: IndexError
"""
if not zone in self._zones:
raise IndexError('Zone do... | [
"def",
"_update_zone",
"(",
"self",
",",
"zone",
",",
"status",
"=",
"None",
")",
":",
"if",
"not",
"zone",
"in",
"self",
".",
"_zones",
":",
"raise",
"IndexError",
"(",
"'Zone does not exist and cannot be updated: %d'",
",",
"zone",
")",
"old_status",
"=",
... | Updates a zones status.
:param zone: zone number
:type zone: int
:param status: zone status
:type status: int
:raises: IndexError | [
"Updates",
"a",
"zones",
"status",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/zonetracking.py#L330-L358 | train | 61,965 |
nutechsoftware/alarmdecoder | alarmdecoder/zonetracking.py | Zonetracker._zone_expired | def _zone_expired(self, zone):
"""
Determine if a zone is expired or not.
:param zone: zone number
:type zone: int
:returns: whether or not the zone is expired
"""
return (time.time() > self._zones[zone].timestamp + Zonetracker.EXPIRE) and self._zones[zone].expa... | python | def _zone_expired(self, zone):
"""
Determine if a zone is expired or not.
:param zone: zone number
:type zone: int
:returns: whether or not the zone is expired
"""
return (time.time() > self._zones[zone].timestamp + Zonetracker.EXPIRE) and self._zones[zone].expa... | [
"def",
"_zone_expired",
"(",
"self",
",",
"zone",
")",
":",
"return",
"(",
"time",
".",
"time",
"(",
")",
">",
"self",
".",
"_zones",
"[",
"zone",
"]",
".",
"timestamp",
"+",
"Zonetracker",
".",
"EXPIRE",
")",
"and",
"self",
".",
"_zones",
"[",
"zo... | Determine if a zone is expired or not.
:param zone: zone number
:type zone: int
:returns: whether or not the zone is expired | [
"Determine",
"if",
"a",
"zone",
"is",
"expired",
"or",
"not",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/zonetracking.py#L360-L369 | train | 61,966 |
nutechsoftware/alarmdecoder | examples/virtual_zone_expander.py | main | def main():
"""
Example application that periodically faults a virtual zone and then
restores it.
This is an advanced feature that allows you to emulate a virtual zone. When
the AlarmDecoder is configured to emulate a zone expander we can fault and
restore those zones programmatically at will.... | python | def main():
"""
Example application that periodically faults a virtual zone and then
restores it.
This is an advanced feature that allows you to emulate a virtual zone. When
the AlarmDecoder is configured to emulate a zone expander we can fault and
restore those zones programmatically at will.... | [
"def",
"main",
"(",
")",
":",
"try",
":",
"# Retrieve the first USB device",
"device",
"=",
"AlarmDecoder",
"(",
"SerialDevice",
"(",
"interface",
"=",
"SERIAL_DEVICE",
")",
")",
"# Set up an event handlers and open the device",
"device",
".",
"on_zone_fault",
"+=",
"... | Example application that periodically faults a virtual zone and then
restores it.
This is an advanced feature that allows you to emulate a virtual zone. When
the AlarmDecoder is configured to emulate a zone expander we can fault and
restore those zones programmatically at will. These events can also b... | [
"Example",
"application",
"that",
"periodically",
"faults",
"a",
"virtual",
"zone",
"and",
"then",
"restores",
"it",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/examples/virtual_zone_expander.py#L12-L51 | train | 61,967 |
nutechsoftware/alarmdecoder | alarmdecoder/util.py | bytes_available | def bytes_available(device):
"""
Determines the number of bytes available for reading from an
AlarmDecoder device
:param device: the AlarmDecoder device
:type device: :py:class:`~alarmdecoder.devices.Device`
:returns: int
"""
bytes_avail = 0
if isinstance(device, alarmdecoder.devi... | python | def bytes_available(device):
"""
Determines the number of bytes available for reading from an
AlarmDecoder device
:param device: the AlarmDecoder device
:type device: :py:class:`~alarmdecoder.devices.Device`
:returns: int
"""
bytes_avail = 0
if isinstance(device, alarmdecoder.devi... | [
"def",
"bytes_available",
"(",
"device",
")",
":",
"bytes_avail",
"=",
"0",
"if",
"isinstance",
"(",
"device",
",",
"alarmdecoder",
".",
"devices",
".",
"SerialDevice",
")",
":",
"if",
"hasattr",
"(",
"device",
".",
"_device",
",",
"\"in_waiting\"",
")",
"... | Determines the number of bytes available for reading from an
AlarmDecoder device
:param device: the AlarmDecoder device
:type device: :py:class:`~alarmdecoder.devices.Device`
:returns: int | [
"Determines",
"the",
"number",
"of",
"bytes",
"available",
"for",
"reading",
"from",
"an",
"AlarmDecoder",
"device"
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/util.py#L61-L81 | train | 61,968 |
nutechsoftware/alarmdecoder | alarmdecoder/util.py | bytes_hack | def bytes_hack(buf):
"""
Hacky workaround for old installs of the library on systems without python-future that were
keeping the 2to3 update from working after auto-update.
"""
ub = None
if sys.version_info > (3,):
ub = buf
else:
ub = bytes(buf)
return ub | python | def bytes_hack(buf):
"""
Hacky workaround for old installs of the library on systems without python-future that were
keeping the 2to3 update from working after auto-update.
"""
ub = None
if sys.version_info > (3,):
ub = buf
else:
ub = bytes(buf)
return ub | [
"def",
"bytes_hack",
"(",
"buf",
")",
":",
"ub",
"=",
"None",
"if",
"sys",
".",
"version_info",
">",
"(",
"3",
",",
")",
":",
"ub",
"=",
"buf",
"else",
":",
"ub",
"=",
"bytes",
"(",
"buf",
")",
"return",
"ub"
] | Hacky workaround for old installs of the library on systems without python-future that were
keeping the 2to3 update from working after auto-update. | [
"Hacky",
"workaround",
"for",
"old",
"installs",
"of",
"the",
"library",
"on",
"systems",
"without",
"python",
"-",
"future",
"that",
"were",
"keeping",
"the",
"2to3",
"update",
"from",
"working",
"after",
"auto",
"-",
"update",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/util.py#L83-L94 | train | 61,969 |
nutechsoftware/alarmdecoder | alarmdecoder/util.py | read_firmware_file | def read_firmware_file(file_path):
"""
Reads a firmware file into a dequeue for processing.
:param file_path: Path to the firmware file
:type file_path: string
:returns: deque
"""
data_queue = deque()
with open(file_path) as firmware_handle:
for line in firmware_handle:
... | python | def read_firmware_file(file_path):
"""
Reads a firmware file into a dequeue for processing.
:param file_path: Path to the firmware file
:type file_path: string
:returns: deque
"""
data_queue = deque()
with open(file_path) as firmware_handle:
for line in firmware_handle:
... | [
"def",
"read_firmware_file",
"(",
"file_path",
")",
":",
"data_queue",
"=",
"deque",
"(",
")",
"with",
"open",
"(",
"file_path",
")",
"as",
"firmware_handle",
":",
"for",
"line",
"in",
"firmware_handle",
":",
"line",
"=",
"line",
".",
"rstrip",
"(",
")",
... | Reads a firmware file into a dequeue for processing.
:param file_path: Path to the firmware file
:type file_path: string
:returns: deque | [
"Reads",
"a",
"firmware",
"file",
"into",
"a",
"dequeue",
"for",
"processing",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/util.py#L96-L113 | train | 61,970 |
nutechsoftware/alarmdecoder | alarmdecoder/util.py | Firmware.read | def read(device):
"""
Reads data from the specified device.
:param device: the AlarmDecoder device
:type device: :py:class:`~alarmdecoder.devices.Device`
:returns: string
"""
response = None
bytes_avail = bytes_available(device)
if isinstance(de... | python | def read(device):
"""
Reads data from the specified device.
:param device: the AlarmDecoder device
:type device: :py:class:`~alarmdecoder.devices.Device`
:returns: string
"""
response = None
bytes_avail = bytes_available(device)
if isinstance(de... | [
"def",
"read",
"(",
"device",
")",
":",
"response",
"=",
"None",
"bytes_avail",
"=",
"bytes_available",
"(",
"device",
")",
"if",
"isinstance",
"(",
"device",
",",
"alarmdecoder",
".",
"devices",
".",
"SerialDevice",
")",
":",
"response",
"=",
"device",
".... | Reads data from the specified device.
:param device: the AlarmDecoder device
:type device: :py:class:`~alarmdecoder.devices.Device`
:returns: string | [
"Reads",
"data",
"from",
"the",
"specified",
"device",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/util.py#L132-L149 | train | 61,971 |
nutechsoftware/alarmdecoder | alarmdecoder/util.py | Firmware.upload | def upload(device, file_path, progress_callback=None, debug=False):
"""
Uploads firmware to an `AlarmDecoder`_ device.
:param file_path: firmware file path
:type file_path: string
:param progress_callback: callback function used to report progress
:type progress_callback... | python | def upload(device, file_path, progress_callback=None, debug=False):
"""
Uploads firmware to an `AlarmDecoder`_ device.
:param file_path: firmware file path
:type file_path: string
:param progress_callback: callback function used to report progress
:type progress_callback... | [
"def",
"upload",
"(",
"device",
",",
"file_path",
",",
"progress_callback",
"=",
"None",
",",
"debug",
"=",
"False",
")",
":",
"def",
"progress_stage",
"(",
"stage",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Callback to update progress for the specified stage.\"\"... | Uploads firmware to an `AlarmDecoder`_ device.
:param file_path: firmware file path
:type file_path: string
:param progress_callback: callback function used to report progress
:type progress_callback: function
:raises: :py:class:`~alarmdecoder.util.NoDeviceError`, :py:class:`~a... | [
"Uploads",
"firmware",
"to",
"an",
"AlarmDecoder",
"_",
"device",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/util.py#L152-L262 | train | 61,972 |
nutechsoftware/alarmdecoder | examples/usb_detection.py | create_device | def create_device(device_args):
"""
Creates an AlarmDecoder from the specified USB device arguments.
:param device_args: Tuple containing information on the USB device to open.
:type device_args: Tuple (vid, pid, serialnumber, interface_count, description)
"""
device = AlarmDecoder(USBDevice.fi... | python | def create_device(device_args):
"""
Creates an AlarmDecoder from the specified USB device arguments.
:param device_args: Tuple containing information on the USB device to open.
:type device_args: Tuple (vid, pid, serialnumber, interface_count, description)
"""
device = AlarmDecoder(USBDevice.fi... | [
"def",
"create_device",
"(",
"device_args",
")",
":",
"device",
"=",
"AlarmDecoder",
"(",
"USBDevice",
".",
"find",
"(",
"device_args",
")",
")",
"device",
".",
"on_message",
"+=",
"handle_message",
"device",
".",
"open",
"(",
")",
"return",
"device"
] | Creates an AlarmDecoder from the specified USB device arguments.
:param device_args: Tuple containing information on the USB device to open.
:type device_args: Tuple (vid, pid, serialnumber, interface_count, description) | [
"Creates",
"an",
"AlarmDecoder",
"from",
"the",
"specified",
"USB",
"device",
"arguments",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/examples/usb_detection.py#L34-L45 | train | 61,973 |
box/rotunicode | rotunicode/rotunicode.py | RotUnicode.encode | def encode(cls, string, errors='strict'):
"""Return the encoded version of a string.
:param string:
The input string to encode.
:type string:
`basestring`
:param errors:
The error handling scheme. Only 'strict' is supported.
:type errors:
... | python | def encode(cls, string, errors='strict'):
"""Return the encoded version of a string.
:param string:
The input string to encode.
:type string:
`basestring`
:param errors:
The error handling scheme. Only 'strict' is supported.
:type errors:
... | [
"def",
"encode",
"(",
"cls",
",",
"string",
",",
"errors",
"=",
"'strict'",
")",
":",
"if",
"errors",
"!=",
"'strict'",
":",
"raise",
"UnicodeError",
"(",
"'Unsupported error handling {0}'",
".",
"format",
"(",
"errors",
")",
")",
"unicode_string",
"=",
"cls... | Return the encoded version of a string.
:param string:
The input string to encode.
:type string:
`basestring`
:param errors:
The error handling scheme. Only 'strict' is supported.
:type errors:
`basestring`
:return:
T... | [
"Return",
"the",
"encoded",
"version",
"of",
"a",
"string",
"."
] | 6149b6bb5bb50d322db248acfdb910dc3cb1bcc2 | https://github.com/box/rotunicode/blob/6149b6bb5bb50d322db248acfdb910dc3cb1bcc2/rotunicode/rotunicode.py#L50-L73 | train | 61,974 |
box/rotunicode | rotunicode/rotunicode.py | RotUnicode.decode | def decode(cls, string, errors='strict'):
"""Return the decoded version of a string.
:param string:
The input string to decode.
:type string:
`basestring`
:param errors:
The error handling scheme. Only 'strict' is supported.
:type errors:
... | python | def decode(cls, string, errors='strict'):
"""Return the decoded version of a string.
:param string:
The input string to decode.
:type string:
`basestring`
:param errors:
The error handling scheme. Only 'strict' is supported.
:type errors:
... | [
"def",
"decode",
"(",
"cls",
",",
"string",
",",
"errors",
"=",
"'strict'",
")",
":",
"if",
"errors",
"!=",
"'strict'",
":",
"raise",
"UnicodeError",
"(",
"'Unsupported error handling {0}'",
".",
"format",
"(",
"errors",
")",
")",
"unicode_string",
"=",
"cls... | Return the decoded version of a string.
:param string:
The input string to decode.
:type string:
`basestring`
:param errors:
The error handling scheme. Only 'strict' is supported.
:type errors:
`basestring`
:return:
T... | [
"Return",
"the",
"decoded",
"version",
"of",
"a",
"string",
"."
] | 6149b6bb5bb50d322db248acfdb910dc3cb1bcc2 | https://github.com/box/rotunicode/blob/6149b6bb5bb50d322db248acfdb910dc3cb1bcc2/rotunicode/rotunicode.py#L76-L99 | train | 61,975 |
box/rotunicode | rotunicode/rotunicode.py | RotUnicode.search_function | def search_function(cls, encoding):
"""Search function to find 'rotunicode' codec."""
if encoding == cls._codec_name:
return codecs.CodecInfo(
name=cls._codec_name,
encode=cls.encode,
decode=cls.decode,
)
return None | python | def search_function(cls, encoding):
"""Search function to find 'rotunicode' codec."""
if encoding == cls._codec_name:
return codecs.CodecInfo(
name=cls._codec_name,
encode=cls.encode,
decode=cls.decode,
)
return None | [
"def",
"search_function",
"(",
"cls",
",",
"encoding",
")",
":",
"if",
"encoding",
"==",
"cls",
".",
"_codec_name",
":",
"return",
"codecs",
".",
"CodecInfo",
"(",
"name",
"=",
"cls",
".",
"_codec_name",
",",
"encode",
"=",
"cls",
".",
"encode",
",",
"... | Search function to find 'rotunicode' codec. | [
"Search",
"function",
"to",
"find",
"rotunicode",
"codec",
"."
] | 6149b6bb5bb50d322db248acfdb910dc3cb1bcc2 | https://github.com/box/rotunicode/blob/6149b6bb5bb50d322db248acfdb910dc3cb1bcc2/rotunicode/rotunicode.py#L103-L111 | train | 61,976 |
box/rotunicode | rotunicode/rotunicode.py | RotUnicode._ensure_unicode_string | def _ensure_unicode_string(string):
"""Returns a unicode string for string.
:param string:
The input string.
:type string:
`basestring`
:returns:
A unicode string.
:rtype:
`unicode`
"""
if not isinstance(string, si... | python | def _ensure_unicode_string(string):
"""Returns a unicode string for string.
:param string:
The input string.
:type string:
`basestring`
:returns:
A unicode string.
:rtype:
`unicode`
"""
if not isinstance(string, si... | [
"def",
"_ensure_unicode_string",
"(",
"string",
")",
":",
"if",
"not",
"isinstance",
"(",
"string",
",",
"six",
".",
"text_type",
")",
":",
"string",
"=",
"string",
".",
"decode",
"(",
"'utf-8'",
")",
"return",
"string"
] | Returns a unicode string for string.
:param string:
The input string.
:type string:
`basestring`
:returns:
A unicode string.
:rtype:
`unicode` | [
"Returns",
"a",
"unicode",
"string",
"for",
"string",
"."
] | 6149b6bb5bb50d322db248acfdb910dc3cb1bcc2 | https://github.com/box/rotunicode/blob/6149b6bb5bb50d322db248acfdb910dc3cb1bcc2/rotunicode/rotunicode.py#L114-L129 | train | 61,977 |
attilaolah/diffbot.py | diffbot.py | Client._get | def _get(url, params=None):
"""HTTP GET request."""
try:
response = requests.get(url, params=params)
response.raise_for_status()
# If JSON fails, return raw data
# (e.g. when downloading CSV job logs).
try:
return response.json(... | python | def _get(url, params=None):
"""HTTP GET request."""
try:
response = requests.get(url, params=params)
response.raise_for_status()
# If JSON fails, return raw data
# (e.g. when downloading CSV job logs).
try:
return response.json(... | [
"def",
"_get",
"(",
"url",
",",
"params",
"=",
"None",
")",
":",
"try",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"params",
"=",
"params",
")",
"response",
".",
"raise_for_status",
"(",
")",
"# If JSON fails, return raw data",
"# (e.g.... | HTTP GET request. | [
"HTTP",
"GET",
"request",
"."
] | b66d68a36a22c944297c0575413db23687029af4 | https://github.com/attilaolah/diffbot.py/blob/b66d68a36a22c944297c0575413db23687029af4/diffbot.py#L33-L46 | train | 61,978 |
attilaolah/diffbot.py | diffbot.py | Client._post | def _post(url, data, content_type, params=None):
"""HTTP POST request."""
try:
response = requests.post(url, params=params, data=data, headers={
'Content-Type': content_type,
})
response.raise_for_status()
return response.json()
exc... | python | def _post(url, data, content_type, params=None):
"""HTTP POST request."""
try:
response = requests.post(url, params=params, data=data, headers={
'Content-Type': content_type,
})
response.raise_for_status()
return response.json()
exc... | [
"def",
"_post",
"(",
"url",
",",
"data",
",",
"content_type",
",",
"params",
"=",
"None",
")",
":",
"try",
":",
"response",
"=",
"requests",
".",
"post",
"(",
"url",
",",
"params",
"=",
"params",
",",
"data",
"=",
"data",
",",
"headers",
"=",
"{",
... | HTTP POST request. | [
"HTTP",
"POST",
"request",
"."
] | b66d68a36a22c944297c0575413db23687029af4 | https://github.com/attilaolah/diffbot.py/blob/b66d68a36a22c944297c0575413db23687029af4/diffbot.py#L49-L62 | train | 61,979 |
attilaolah/diffbot.py | diffbot.py | Client.api | def api(self, name, url, **kwargs):
"""Generic API method."""
if name not in self._apis:
raise ValueError('API name must be one of {0}, not {1!r}.'.format(
tuple(self._apis), name))
fields = kwargs.get('fields')
timeout = kwargs.get('timeout')
text = k... | python | def api(self, name, url, **kwargs):
"""Generic API method."""
if name not in self._apis:
raise ValueError('API name must be one of {0}, not {1!r}.'.format(
tuple(self._apis), name))
fields = kwargs.get('fields')
timeout = kwargs.get('timeout')
text = k... | [
"def",
"api",
"(",
"self",
",",
"name",
",",
"url",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"name",
"not",
"in",
"self",
".",
"_apis",
":",
"raise",
"ValueError",
"(",
"'API name must be one of {0}, not {1!r}.'",
".",
"format",
"(",
"tuple",
"(",
"self"... | Generic API method. | [
"Generic",
"API",
"method",
"."
] | b66d68a36a22c944297c0575413db23687029af4 | https://github.com/attilaolah/diffbot.py/blob/b66d68a36a22c944297c0575413db23687029af4/diffbot.py#L68-L90 | train | 61,980 |
attilaolah/diffbot.py | diffbot.py | Client.crawl | def crawl(self, urls, name='crawl', api='analyze', **kwargs):
"""Crawlbot API.
Returns a diffbot.Job object to check and retrieve crawl status.
"""
# If multiple seed URLs are specified, join with whitespace.
if isinstance(urls, list):
urls = ' '.join(urls)
u... | python | def crawl(self, urls, name='crawl', api='analyze', **kwargs):
"""Crawlbot API.
Returns a diffbot.Job object to check and retrieve crawl status.
"""
# If multiple seed URLs are specified, join with whitespace.
if isinstance(urls, list):
urls = ' '.join(urls)
u... | [
"def",
"crawl",
"(",
"self",
",",
"urls",
",",
"name",
"=",
"'crawl'",
",",
"api",
"=",
"'analyze'",
",",
"*",
"*",
"kwargs",
")",
":",
"# If multiple seed URLs are specified, join with whitespace.",
"if",
"isinstance",
"(",
"urls",
",",
"list",
")",
":",
"u... | Crawlbot API.
Returns a diffbot.Job object to check and retrieve crawl status. | [
"Crawlbot",
"API",
"."
] | b66d68a36a22c944297c0575413db23687029af4 | https://github.com/attilaolah/diffbot.py/blob/b66d68a36a22c944297c0575413db23687029af4/diffbot.py#L116-L139 | train | 61,981 |
nutechsoftware/alarmdecoder | examples/lrr_example.py | handle_lrr_message | def handle_lrr_message(sender, message):
"""
Handles message events from the AlarmDecoder.
"""
print(sender, message.partition, message.event_type, message.event_data) | python | def handle_lrr_message(sender, message):
"""
Handles message events from the AlarmDecoder.
"""
print(sender, message.partition, message.event_type, message.event_data) | [
"def",
"handle_lrr_message",
"(",
"sender",
",",
"message",
")",
":",
"print",
"(",
"sender",
",",
"message",
".",
"partition",
",",
"message",
".",
"event_type",
",",
"message",
".",
"event_data",
")"
] | Handles message events from the AlarmDecoder. | [
"Handles",
"message",
"events",
"from",
"the",
"AlarmDecoder",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/examples/lrr_example.py#L25-L29 | train | 61,982 |
nutechsoftware/alarmdecoder | examples/alarm_email.py | main | def main():
"""
Example application that sends an email when an alarm event is
detected.
"""
try:
# Retrieve the first USB device
device = AlarmDecoder(SerialDevice(interface=SERIAL_DEVICE))
# Set up an event handler and open the device
device.on_alarm += handle_alar... | python | def main():
"""
Example application that sends an email when an alarm event is
detected.
"""
try:
# Retrieve the first USB device
device = AlarmDecoder(SerialDevice(interface=SERIAL_DEVICE))
# Set up an event handler and open the device
device.on_alarm += handle_alar... | [
"def",
"main",
"(",
")",
":",
"try",
":",
"# Retrieve the first USB device",
"device",
"=",
"AlarmDecoder",
"(",
"SerialDevice",
"(",
"interface",
"=",
"SERIAL_DEVICE",
")",
")",
"# Set up an event handler and open the device",
"device",
".",
"on_alarm",
"+=",
"handle... | Example application that sends an email when an alarm event is
detected. | [
"Example",
"application",
"that",
"sends",
"an",
"email",
"when",
"an",
"alarm",
"event",
"is",
"detected",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/examples/alarm_email.py#L19-L35 | train | 61,983 |
nutechsoftware/alarmdecoder | examples/alarm_email.py | handle_alarm | def handle_alarm(sender, **kwargs):
"""
Handles alarm events from the AlarmDecoder.
"""
zone = kwargs.pop('zone', None)
text = "Alarm: Zone {0}".format(zone)
# Build the email message
msg = MIMEText(text)
msg['Subject'] = SUBJECT
msg['From'] = FROM_ADDRESS
msg['To'] = TO_ADDRESS... | python | def handle_alarm(sender, **kwargs):
"""
Handles alarm events from the AlarmDecoder.
"""
zone = kwargs.pop('zone', None)
text = "Alarm: Zone {0}".format(zone)
# Build the email message
msg = MIMEText(text)
msg['Subject'] = SUBJECT
msg['From'] = FROM_ADDRESS
msg['To'] = TO_ADDRESS... | [
"def",
"handle_alarm",
"(",
"sender",
",",
"*",
"*",
"kwargs",
")",
":",
"zone",
"=",
"kwargs",
".",
"pop",
"(",
"'zone'",
",",
"None",
")",
"text",
"=",
"\"Alarm: Zone {0}\"",
".",
"format",
"(",
"zone",
")",
"# Build the email message",
"msg",
"=",
"MI... | Handles alarm events from the AlarmDecoder. | [
"Handles",
"alarm",
"events",
"from",
"the",
"AlarmDecoder",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/examples/alarm_email.py#L37-L60 | train | 61,984 |
nutechsoftware/alarmdecoder | examples/ssl_socket.py | main | def main():
"""
Example application that opens a device that has been exposed to the network
with ser2sock and SSL encryption and authentication.
"""
try:
# Retrieve an AD2 device that has been exposed with ser2sock on localhost:10000.
ssl_device = SocketDevice(interface=('localhost'... | python | def main():
"""
Example application that opens a device that has been exposed to the network
with ser2sock and SSL encryption and authentication.
"""
try:
# Retrieve an AD2 device that has been exposed with ser2sock on localhost:10000.
ssl_device = SocketDevice(interface=('localhost'... | [
"def",
"main",
"(",
")",
":",
"try",
":",
"# Retrieve an AD2 device that has been exposed with ser2sock on localhost:10000.",
"ssl_device",
"=",
"SocketDevice",
"(",
"interface",
"=",
"(",
"'localhost'",
",",
"10000",
")",
")",
"# Enable SSL and set the certificates to be use... | Example application that opens a device that has been exposed to the network
with ser2sock and SSL encryption and authentication. | [
"Example",
"application",
"that",
"opens",
"a",
"device",
"that",
"has",
"been",
"exposed",
"to",
"the",
"network",
"with",
"ser2sock",
"and",
"SSL",
"encryption",
"and",
"authentication",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/examples/ssl_socket.py#L12-L39 | train | 61,985 |
box/rotunicode | rotunicode/utils.py | ruencode | def ruencode(string, extension=False):
"""Encode a string using 'rotunicode' codec.
:param string:
The input string to encode.
:type string:
`basestring`
:param extension:
True if the entire input string should be encoded.
False to split the input string using :func:`os... | python | def ruencode(string, extension=False):
"""Encode a string using 'rotunicode' codec.
:param string:
The input string to encode.
:type string:
`basestring`
:param extension:
True if the entire input string should be encoded.
False to split the input string using :func:`os... | [
"def",
"ruencode",
"(",
"string",
",",
"extension",
"=",
"False",
")",
":",
"if",
"extension",
":",
"file_name",
"=",
"string",
"file_ext",
"=",
"''",
"else",
":",
"file_name",
",",
"file_ext",
"=",
"splitext",
"(",
"string",
")",
"encoded_value",
",",
"... | Encode a string using 'rotunicode' codec.
:param string:
The input string to encode.
:type string:
`basestring`
:param extension:
True if the entire input string should be encoded.
False to split the input string using :func:`os.path.splitext` and
encode only the fi... | [
"Encode",
"a",
"string",
"using",
"rotunicode",
"codec",
"."
] | 6149b6bb5bb50d322db248acfdb910dc3cb1bcc2 | https://github.com/box/rotunicode/blob/6149b6bb5bb50d322db248acfdb910dc3cb1bcc2/rotunicode/utils.py#L27-L54 | train | 61,986 |
box/rotunicode | rotunicode/utils.py | parse_escape_sequences | def parse_escape_sequences(string):
"""Parse a string for possible escape sequences.
Sample usage:
>>> parse_escape_sequences('foo\\nbar')
'foo\nbar'
>>> parse_escape_sequences('foo\\\\u0256')
'foo\\u0256'
:param string:
Any string.
:type string:
`basestring`
:raise... | python | def parse_escape_sequences(string):
"""Parse a string for possible escape sequences.
Sample usage:
>>> parse_escape_sequences('foo\\nbar')
'foo\nbar'
>>> parse_escape_sequences('foo\\\\u0256')
'foo\\u0256'
:param string:
Any string.
:type string:
`basestring`
:raise... | [
"def",
"parse_escape_sequences",
"(",
"string",
")",
":",
"string",
"=",
"safe_unicode",
"(",
"string",
")",
"characters",
"=",
"[",
"]",
"i",
"=",
"0",
"string_len",
"=",
"len",
"(",
"string",
")",
"while",
"i",
"<",
"string_len",
":",
"character",
"=",... | Parse a string for possible escape sequences.
Sample usage:
>>> parse_escape_sequences('foo\\nbar')
'foo\nbar'
>>> parse_escape_sequences('foo\\\\u0256')
'foo\\u0256'
:param string:
Any string.
:type string:
`basestring`
:raises:
:class:`ValueError` if a backsla... | [
"Parse",
"a",
"string",
"for",
"possible",
"escape",
"sequences",
"."
] | 6149b6bb5bb50d322db248acfdb910dc3cb1bcc2 | https://github.com/box/rotunicode/blob/6149b6bb5bb50d322db248acfdb910dc3cb1bcc2/rotunicode/utils.py#L96-L161 | train | 61,987 |
nutechsoftware/alarmdecoder | alarmdecoder/devices/usb_device.py | USBDevice.find_all | def find_all(cls, vid=None, pid=None):
"""
Returns all FTDI devices matching our vendor and product IDs.
:returns: list of devices
:raises: :py:class:`~alarmdecoder.util.CommError`
"""
if not have_pyftdi:
raise ImportError('The USBDevice class has been disabl... | python | def find_all(cls, vid=None, pid=None):
"""
Returns all FTDI devices matching our vendor and product IDs.
:returns: list of devices
:raises: :py:class:`~alarmdecoder.util.CommError`
"""
if not have_pyftdi:
raise ImportError('The USBDevice class has been disabl... | [
"def",
"find_all",
"(",
"cls",
",",
"vid",
"=",
"None",
",",
"pid",
"=",
"None",
")",
":",
"if",
"not",
"have_pyftdi",
":",
"raise",
"ImportError",
"(",
"'The USBDevice class has been disabled due to missing requirement: pyftdi or pyusb.'",
")",
"cls",
".",
"__devic... | Returns all FTDI devices matching our vendor and product IDs.
:returns: list of devices
:raises: :py:class:`~alarmdecoder.util.CommError` | [
"Returns",
"all",
"FTDI",
"devices",
"matching",
"our",
"vendor",
"and",
"product",
"IDs",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/devices/usb_device.py#L62-L84 | train | 61,988 |
nutechsoftware/alarmdecoder | alarmdecoder/devices/usb_device.py | USBDevice.start_detection | def start_detection(cls, on_attached=None, on_detached=None):
"""
Starts the device detection thread.
:param on_attached: function to be called when a device is attached **Callback definition:** *def callback(thread, device)*
:type on_attached: function
:param on_detached: func... | python | def start_detection(cls, on_attached=None, on_detached=None):
"""
Starts the device detection thread.
:param on_attached: function to be called when a device is attached **Callback definition:** *def callback(thread, device)*
:type on_attached: function
:param on_detached: func... | [
"def",
"start_detection",
"(",
"cls",
",",
"on_attached",
"=",
"None",
",",
"on_detached",
"=",
"None",
")",
":",
"if",
"not",
"have_pyftdi",
":",
"raise",
"ImportError",
"(",
"'The USBDevice class has been disabled due to missing requirement: pyftdi or pyusb.'",
")",
"... | Starts the device detection thread.
:param on_attached: function to be called when a device is attached **Callback definition:** *def callback(thread, device)*
:type on_attached: function
:param on_detached: function to be called when a device is detached **Callback definition:** *def callbac... | [
"Starts",
"the",
"device",
"detection",
"thread",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/devices/usb_device.py#L124-L144 | train | 61,989 |
nutechsoftware/alarmdecoder | alarmdecoder/devices/usb_device.py | USBDevice.interface | def interface(self, value):
"""
Sets the interface used to connect to the device.
:param value: may specify either the serial number or the device index
:type value: string or int
"""
self._interface = value
if isinstance(value, int):
self._device_num... | python | def interface(self, value):
"""
Sets the interface used to connect to the device.
:param value: may specify either the serial number or the device index
:type value: string or int
"""
self._interface = value
if isinstance(value, int):
self._device_num... | [
"def",
"interface",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"_interface",
"=",
"value",
"if",
"isinstance",
"(",
"value",
",",
"int",
")",
":",
"self",
".",
"_device_number",
"=",
"value",
"else",
":",
"self",
".",
"_serial_number",
"=",
"val... | Sets the interface used to connect to the device.
:param value: may specify either the serial number or the device index
:type value: string or int | [
"Sets",
"the",
"interface",
"used",
"to",
"connect",
"to",
"the",
"device",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/devices/usb_device.py#L170-L181 | train | 61,990 |
nutechsoftware/alarmdecoder | alarmdecoder/devices/usb_device.py | USBDevice._get_serial_number | def _get_serial_number(self):
"""
Retrieves the FTDI device serial number.
:returns: string containing the device serial number
"""
return usb.util.get_string(self._device.usb_dev, 64, self._device.usb_dev.iSerialNumber) | python | def _get_serial_number(self):
"""
Retrieves the FTDI device serial number.
:returns: string containing the device serial number
"""
return usb.util.get_string(self._device.usb_dev, 64, self._device.usb_dev.iSerialNumber) | [
"def",
"_get_serial_number",
"(",
"self",
")",
":",
"return",
"usb",
".",
"util",
".",
"get_string",
"(",
"self",
".",
"_device",
".",
"usb_dev",
",",
"64",
",",
"self",
".",
"_device",
".",
"usb_dev",
".",
"iSerialNumber",
")"
] | Retrieves the FTDI device serial number.
:returns: string containing the device serial number | [
"Retrieves",
"the",
"FTDI",
"device",
"serial",
"number",
"."
] | b0c014089e24455228cb4402cf30ba98157578cd | https://github.com/nutechsoftware/alarmdecoder/blob/b0c014089e24455228cb4402cf30ba98157578cd/alarmdecoder/devices/usb_device.py#L427-L433 | train | 61,991 |
mgedmin/imgdiff | imgdiff.py | parse_color | def parse_color(color):
"""Parse a color value.
I've decided not to expect a leading '#' because it's a comment character
in some shells.
>>> parse_color('4bf') == (0x44, 0xbb, 0xff, 0xff)
True
>>> parse_color('ccce') == (0xcc, 0xcc, 0xcc, 0xee)
True
>>> parse_color... | python | def parse_color(color):
"""Parse a color value.
I've decided not to expect a leading '#' because it's a comment character
in some shells.
>>> parse_color('4bf') == (0x44, 0xbb, 0xff, 0xff)
True
>>> parse_color('ccce') == (0xcc, 0xcc, 0xcc, 0xee)
True
>>> parse_color... | [
"def",
"parse_color",
"(",
"color",
")",
":",
"if",
"len",
"(",
"color",
")",
"not",
"in",
"(",
"3",
",",
"4",
",",
"6",
",",
"8",
")",
":",
"raise",
"ValueError",
"(",
"'bad color %s'",
"%",
"repr",
"(",
"color",
")",
")",
"if",
"len",
"(",
"c... | Parse a color value.
I've decided not to expect a leading '#' because it's a comment character
in some shells.
>>> parse_color('4bf') == (0x44, 0xbb, 0xff, 0xff)
True
>>> parse_color('ccce') == (0xcc, 0xcc, 0xcc, 0xee)
True
>>> parse_color('d8b4a2') == (0xd8, 0xb4, 0xa2... | [
"Parse",
"a",
"color",
"value",
"."
] | f80b173c6fb1f32f3e016d153b5b84a14d966e1a | https://github.com/mgedmin/imgdiff/blob/f80b173c6fb1f32f3e016d153b5b84a14d966e1a/imgdiff.py#L25-L58 | train | 61,992 |
mgedmin/imgdiff | imgdiff.py | check_color | def check_color(option, opt, value):
"""Validate and convert an option value of type 'color'.
``option`` is an optparse.Option instance.
``opt`` is a string with the user-supplied option name (e.g. '--bgcolor').
``value`` is the user-supplied value.
"""
try:
return parse_color(value)
... | python | def check_color(option, opt, value):
"""Validate and convert an option value of type 'color'.
``option`` is an optparse.Option instance.
``opt`` is a string with the user-supplied option name (e.g. '--bgcolor').
``value`` is the user-supplied value.
"""
try:
return parse_color(value)
... | [
"def",
"check_color",
"(",
"option",
",",
"opt",
",",
"value",
")",
":",
"try",
":",
"return",
"parse_color",
"(",
"value",
")",
"except",
"ValueError",
":",
"raise",
"optparse",
".",
"OptionValueError",
"(",
"\"option %s: invalid color value: %r\"",
"%",
"(",
... | Validate and convert an option value of type 'color'.
``option`` is an optparse.Option instance.
``opt`` is a string with the user-supplied option name (e.g. '--bgcolor').
``value`` is the user-supplied value. | [
"Validate",
"and",
"convert",
"an",
"option",
"value",
"of",
"type",
"color",
"."
] | f80b173c6fb1f32f3e016d153b5b84a14d966e1a | https://github.com/mgedmin/imgdiff/blob/f80b173c6fb1f32f3e016d153b5b84a14d966e1a/imgdiff.py#L61-L74 | train | 61,993 |
mgedmin/imgdiff | imgdiff.py | pick_orientation | def pick_orientation(img1, img2, spacing, desired_aspect=1.618):
"""Pick a tiling orientation for two images.
Returns either 'lr' for left-and-right, or 'tb' for top-and-bottom.
Picks the one that makes the combined image have a better aspect
ratio, where 'better' is defined as 'closer to 1:1.618'.
... | python | def pick_orientation(img1, img2, spacing, desired_aspect=1.618):
"""Pick a tiling orientation for two images.
Returns either 'lr' for left-and-right, or 'tb' for top-and-bottom.
Picks the one that makes the combined image have a better aspect
ratio, where 'better' is defined as 'closer to 1:1.618'.
... | [
"def",
"pick_orientation",
"(",
"img1",
",",
"img2",
",",
"spacing",
",",
"desired_aspect",
"=",
"1.618",
")",
":",
"w1",
",",
"h1",
"=",
"img1",
".",
"size",
"w2",
",",
"h2",
"=",
"img2",
".",
"size",
"size_a",
"=",
"(",
"w1",
"+",
"spacing",
"+",... | Pick a tiling orientation for two images.
Returns either 'lr' for left-and-right, or 'tb' for top-and-bottom.
Picks the one that makes the combined image have a better aspect
ratio, where 'better' is defined as 'closer to 1:1.618'. | [
"Pick",
"a",
"tiling",
"orientation",
"for",
"two",
"images",
"."
] | f80b173c6fb1f32f3e016d153b5b84a14d966e1a | https://github.com/mgedmin/imgdiff/blob/f80b173c6fb1f32f3e016d153b5b84a14d966e1a/imgdiff.py#L169-L189 | train | 61,994 |
mgedmin/imgdiff | imgdiff.py | tile_images | def tile_images(img1, img2, mask1, mask2, opts):
"""Combine two images into one by tiling them.
``mask1`` and ``mask2`` provide optional masks for alpha-blending;
pass None to avoid.
Fills unused areas with ``opts.bgcolor``.
Puts a ``opts.spacing``-wide bar with a thin line of ``opts.sepcolor``
... | python | def tile_images(img1, img2, mask1, mask2, opts):
"""Combine two images into one by tiling them.
``mask1`` and ``mask2`` provide optional masks for alpha-blending;
pass None to avoid.
Fills unused areas with ``opts.bgcolor``.
Puts a ``opts.spacing``-wide bar with a thin line of ``opts.sepcolor``
... | [
"def",
"tile_images",
"(",
"img1",
",",
"img2",
",",
"mask1",
",",
"mask2",
",",
"opts",
")",
":",
"w1",
",",
"h1",
"=",
"img1",
".",
"size",
"w2",
",",
"h2",
"=",
"img2",
".",
"size",
"if",
"opts",
".",
"orientation",
"==",
"'auto'",
":",
"opts"... | Combine two images into one by tiling them.
``mask1`` and ``mask2`` provide optional masks for alpha-blending;
pass None to avoid.
Fills unused areas with ``opts.bgcolor``.
Puts a ``opts.spacing``-wide bar with a thin line of ``opts.sepcolor``
color between them.
``opts.orientation`` can be ... | [
"Combine",
"two",
"images",
"into",
"one",
"by",
"tiling",
"them",
"."
] | f80b173c6fb1f32f3e016d153b5b84a14d966e1a | https://github.com/mgedmin/imgdiff/blob/f80b173c6fb1f32f3e016d153b5b84a14d966e1a/imgdiff.py#L192-L232 | train | 61,995 |
mgedmin/imgdiff | imgdiff.py | spawn_viewer | def spawn_viewer(viewer, img, filename, grace):
"""Launch an external program to view an image.
``img`` is an Image object.
``viewer`` is a command name. Arguments are not allowed; exactly one
argument will be passed: the name of the image file.
``filename`` is the suggested filename for a tempo... | python | def spawn_viewer(viewer, img, filename, grace):
"""Launch an external program to view an image.
``img`` is an Image object.
``viewer`` is a command name. Arguments are not allowed; exactly one
argument will be passed: the name of the image file.
``filename`` is the suggested filename for a tempo... | [
"def",
"spawn_viewer",
"(",
"viewer",
",",
"img",
",",
"filename",
",",
"grace",
")",
":",
"tempdir",
"=",
"tempfile",
".",
"mkdtemp",
"(",
"prefix",
"=",
"'imgdiff-'",
")",
"try",
":",
"imgfile",
"=",
"os",
".",
"path",
".",
"join",
"(",
"tempdir",
... | Launch an external program to view an image.
``img`` is an Image object.
``viewer`` is a command name. Arguments are not allowed; exactly one
argument will be passed: the name of the image file.
``filename`` is the suggested filename for a temporary file.
``grace`` is the number of seconds to w... | [
"Launch",
"an",
"external",
"program",
"to",
"view",
"an",
"image",
"."
] | f80b173c6fb1f32f3e016d153b5b84a14d966e1a | https://github.com/mgedmin/imgdiff/blob/f80b173c6fb1f32f3e016d153b5b84a14d966e1a/imgdiff.py#L235-L262 | train | 61,996 |
mgedmin/imgdiff | imgdiff.py | tweak_diff | def tweak_diff(diff, opacity):
"""Adjust a difference map into an opacity mask for a given lowest opacity.
Performs a linear map from [0; 255] to [opacity; 255].
The result is that similar areas will have a given opacity, while
dissimilar areas will be opaque.
"""
mask = diff.point(lambda i: o... | python | def tweak_diff(diff, opacity):
"""Adjust a difference map into an opacity mask for a given lowest opacity.
Performs a linear map from [0; 255] to [opacity; 255].
The result is that similar areas will have a given opacity, while
dissimilar areas will be opaque.
"""
mask = diff.point(lambda i: o... | [
"def",
"tweak_diff",
"(",
"diff",
",",
"opacity",
")",
":",
"mask",
"=",
"diff",
".",
"point",
"(",
"lambda",
"i",
":",
"opacity",
"+",
"i",
"*",
"(",
"255",
"-",
"opacity",
")",
"//",
"255",
")",
"return",
"mask"
] | Adjust a difference map into an opacity mask for a given lowest opacity.
Performs a linear map from [0; 255] to [opacity; 255].
The result is that similar areas will have a given opacity, while
dissimilar areas will be opaque. | [
"Adjust",
"a",
"difference",
"map",
"into",
"an",
"opacity",
"mask",
"for",
"a",
"given",
"lowest",
"opacity",
"."
] | f80b173c6fb1f32f3e016d153b5b84a14d966e1a | https://github.com/mgedmin/imgdiff/blob/f80b173c6fb1f32f3e016d153b5b84a14d966e1a/imgdiff.py#L265-L274 | train | 61,997 |
mgedmin/imgdiff | imgdiff.py | diff | def diff(img1, img2, x1y1, x2y2):
"""Compare two images with given alignments.
Returns a difference map.
``x1y1``: a tuple ``(x1, y1)`` to specify the top-left corner of the
aligned area with respect to ``img1``.
``x2y2``: a tuple ``(x2, y2)`` to specify the top-left corner of
the aligned are... | python | def diff(img1, img2, x1y1, x2y2):
"""Compare two images with given alignments.
Returns a difference map.
``x1y1``: a tuple ``(x1, y1)`` to specify the top-left corner of the
aligned area with respect to ``img1``.
``x2y2``: a tuple ``(x2, y2)`` to specify the top-left corner of
the aligned are... | [
"def",
"diff",
"(",
"img1",
",",
"img2",
",",
"x1y1",
",",
"x2y2",
")",
":",
"x1",
",",
"y1",
"=",
"x1y1",
"x2",
",",
"y2",
"=",
"x2y2",
"w1",
",",
"h1",
"=",
"img1",
".",
"size",
"w2",
",",
"h2",
"=",
"img2",
".",
"size",
"w",
",",
"h",
... | Compare two images with given alignments.
Returns a difference map.
``x1y1``: a tuple ``(x1, y1)`` to specify the top-left corner of the
aligned area with respect to ``img1``.
``x2y2``: a tuple ``(x2, y2)`` to specify the top-left corner of
the aligned area with respect to ``img2``.
Either `... | [
"Compare",
"two",
"images",
"with",
"given",
"alignments",
"."
] | f80b173c6fb1f32f3e016d153b5b84a14d966e1a | https://github.com/mgedmin/imgdiff/blob/f80b173c6fb1f32f3e016d153b5b84a14d966e1a/imgdiff.py#L277-L346 | train | 61,998 |
mgedmin/imgdiff | imgdiff.py | diff_badness | def diff_badness(diff):
"""Estimate the "badness" value of a difference map.
Returns 0 if the pictures are identical
Returns a large number if the pictures are completely different
(e.g. a black field and a white field). More specifically, returns
``255 * width * height`` where ``(width, height) ... | python | def diff_badness(diff):
"""Estimate the "badness" value of a difference map.
Returns 0 if the pictures are identical
Returns a large number if the pictures are completely different
(e.g. a black field and a white field). More specifically, returns
``255 * width * height`` where ``(width, height) ... | [
"def",
"diff_badness",
"(",
"diff",
")",
":",
"# identical pictures = black image = return 0",
"# completely different pictures = white image = return lots",
"return",
"sum",
"(",
"i",
"*",
"n",
"for",
"i",
",",
"n",
"in",
"enumerate",
"(",
"diff",
".",
"histogram",
"... | Estimate the "badness" value of a difference map.
Returns 0 if the pictures are identical
Returns a large number if the pictures are completely different
(e.g. a black field and a white field). More specifically, returns
``255 * width * height`` where ``(width, height) == diff.size``.
Returns so... | [
"Estimate",
"the",
"badness",
"value",
"of",
"a",
"difference",
"map",
"."
] | f80b173c6fb1f32f3e016d153b5b84a14d966e1a | https://github.com/mgedmin/imgdiff/blob/f80b173c6fb1f32f3e016d153b5b84a14d966e1a/imgdiff.py#L349-L362 | train | 61,999 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.