repository_name stringlengths 7 55 | func_path_in_repository stringlengths 4 223 | func_name stringlengths 1 134 | whole_func_string stringlengths 75 104k | language stringclasses 1
value | func_code_string stringlengths 75 104k | func_code_tokens listlengths 19 28.4k | func_documentation_string stringlengths 1 46.9k | func_documentation_tokens listlengths 1 1.97k | split_name stringclasses 1
value | func_code_url stringlengths 87 315 |
|---|---|---|---|---|---|---|---|---|---|---|
slinderman/pypolyagamma | pypolyagamma/utils.py | pgpdf | def pgpdf(omega, b, psi, trunc=200):
"""
Approximate the density log PG(omega | b, psi) using a
truncation of the density written as an infinite sum.
:param omega: point at which to evaluate density
:param b: first parameter of PG
:param psi: tilting of PG
:param trunc: number of terms in... | python | def pgpdf(omega, b, psi, trunc=200):
"""
Approximate the density log PG(omega | b, psi) using a
truncation of the density written as an infinite sum.
:param omega: point at which to evaluate density
:param b: first parameter of PG
:param psi: tilting of PG
:param trunc: number of terms in... | [
"def",
"pgpdf",
"(",
"omega",
",",
"b",
",",
"psi",
",",
"trunc",
"=",
"200",
")",
":",
"ns",
"=",
"np",
".",
"arange",
"(",
"trunc",
")",
"psi_ns",
"=",
"np",
".",
"array",
"(",
"[",
"_psi_n",
"(",
"omega",
",",
"n",
",",
"b",
")",
"for",
... | Approximate the density log PG(omega | b, psi) using a
truncation of the density written as an infinite sum.
:param omega: point at which to evaluate density
:param b: first parameter of PG
:param psi: tilting of PG
:param trunc: number of terms in sum | [
"Approximate",
"the",
"density",
"log",
"PG",
"(",
"omega",
"|",
"b",
"psi",
")",
"using",
"a",
"truncation",
"of",
"the",
"density",
"written",
"as",
"an",
"infinite",
"sum",
"."
] | train | https://github.com/slinderman/pypolyagamma/blob/abdc0c53e5114092998f51bf66f1900bc567f0bd/pypolyagamma/utils.py#L32-L49 |
slinderman/pypolyagamma | pypolyagamma/utils.py | psi_to_pi | def psi_to_pi(psi, axis=None):
"""
Convert psi to a probability vector pi
:param psi: Length K-1 vector
:return: Length K normalized probability vector
"""
if axis is None:
if psi.ndim == 1:
K = psi.size + 1
pi = np.zeros(K)
# Set pi[1..K-1... | python | def psi_to_pi(psi, axis=None):
"""
Convert psi to a probability vector pi
:param psi: Length K-1 vector
:return: Length K normalized probability vector
"""
if axis is None:
if psi.ndim == 1:
K = psi.size + 1
pi = np.zeros(K)
# Set pi[1..K-1... | [
"def",
"psi_to_pi",
"(",
"psi",
",",
"axis",
"=",
"None",
")",
":",
"if",
"axis",
"is",
"None",
":",
"if",
"psi",
".",
"ndim",
"==",
"1",
":",
"K",
"=",
"psi",
".",
"size",
"+",
"1",
"pi",
"=",
"np",
".",
"zeros",
"(",
"K",
")",
"# Set pi[1..... | Convert psi to a probability vector pi
:param psi: Length K-1 vector
:return: Length K normalized probability vector | [
"Convert",
"psi",
"to",
"a",
"probability",
"vector",
"pi",
":",
"param",
"psi",
":",
"Length",
"K",
"-",
"1",
"vector",
":",
"return",
":",
"Length",
"K",
"normalized",
"probability",
"vector"
] | train | https://github.com/slinderman/pypolyagamma/blob/abdc0c53e5114092998f51bf66f1900bc567f0bd/pypolyagamma/utils.py#L94-L146 |
IdentityPython/pyop | src/pyop/client_authentication.py | verify_client_authentication | def verify_client_authentication(clients, parsed_request, authz_header=None):
# type: (Mapping[str, str], Mapping[str, Mapping[str, Any]], Optional[str]) -> bool
"""
Verifies client authentication at the token endpoint, see
<a href="https://tools.ietf.org/html/rfc6749#section-2.3.1">"The OAuth 2.0 Autho... | python | def verify_client_authentication(clients, parsed_request, authz_header=None):
# type: (Mapping[str, str], Mapping[str, Mapping[str, Any]], Optional[str]) -> bool
"""
Verifies client authentication at the token endpoint, see
<a href="https://tools.ietf.org/html/rfc6749#section-2.3.1">"The OAuth 2.0 Autho... | [
"def",
"verify_client_authentication",
"(",
"clients",
",",
"parsed_request",
",",
"authz_header",
"=",
"None",
")",
":",
"# type: (Mapping[str, str], Mapping[str, Mapping[str, Any]], Optional[str]) -> bool",
"client_id",
"=",
"None",
"client_secret",
"=",
"None",
"authn_method... | Verifies client authentication at the token endpoint, see
<a href="https://tools.ietf.org/html/rfc6749#section-2.3.1">"The OAuth 2.0 Authorization Framework",
Section 2.3.1</a>
:param parsed_request: key-value pairs from parsed urlencoded request
:param clients: clients db
:param authz_header: the H... | [
"Verifies",
"client",
"authentication",
"at",
"the",
"token",
"endpoint",
"see",
"<a",
"href",
"=",
"https",
":",
"//",
"tools",
".",
"ietf",
".",
"org",
"/",
"html",
"/",
"rfc6749#section",
"-",
"2",
".",
"3",
".",
"1",
">",
"The",
"OAuth",
"2",
"."... | train | https://github.com/IdentityPython/pyop/blob/7b1385964f079c39752fce5f2dbcf458b8a92e56/src/pyop/client_authentication.py#L9-L64 |
harabchuk/kibana-dashboard-api | kibana_dashboard_api/dashboards.py | Dashboard.add_visualization | def add_visualization(self, visualization, size_x=6, size_y=3, col=0, row=0):
"""
Adds the visualization to the dashboard. Leave col and row = 0 for automatic placement of the visualization.
Visualizations are placed on a grid with 12 columns and unlimited rows.
:param visualization: pre... | python | def add_visualization(self, visualization, size_x=6, size_y=3, col=0, row=0):
"""
Adds the visualization to the dashboard. Leave col and row = 0 for automatic placement of the visualization.
Visualizations are placed on a grid with 12 columns and unlimited rows.
:param visualization: pre... | [
"def",
"add_visualization",
"(",
"self",
",",
"visualization",
",",
"size_x",
"=",
"6",
",",
"size_y",
"=",
"3",
",",
"col",
"=",
"0",
",",
"row",
"=",
"0",
")",
":",
"new_panel_index",
"=",
"self",
".",
"get_max_index",
"(",
")",
"+",
"1",
"if",
"... | Adds the visualization to the dashboard. Leave col and row = 0 for automatic placement of the visualization.
Visualizations are placed on a grid with 12 columns and unlimited rows.
:param visualization: previously loaded visualization
:param size_x width of the panel
:param size_y height... | [
"Adds",
"the",
"visualization",
"to",
"the",
"dashboard",
".",
"Leave",
"col",
"and",
"row",
"=",
"0",
"for",
"automatic",
"placement",
"of",
"the",
"visualization",
".",
"Visualizations",
"are",
"placed",
"on",
"a",
"grid",
"with",
"12",
"columns",
"and",
... | train | https://github.com/harabchuk/kibana-dashboard-api/blob/8a13d5078fa92fb73f06498757ba9f51632e8a23/kibana_dashboard_api/dashboards.py#L71-L99 |
harabchuk/kibana-dashboard-api | kibana_dashboard_api/dashboards.py | Dashboard.remove_visualization | def remove_visualization(self, visualization_id):
"""
Removes all visualizations with the specified id from the dashboard
:param visualization_id:
:return:
"""
for i, panel in enumerate(self.panels):
if panel['id'] == visualization_id:
del self... | python | def remove_visualization(self, visualization_id):
"""
Removes all visualizations with the specified id from the dashboard
:param visualization_id:
:return:
"""
for i, panel in enumerate(self.panels):
if panel['id'] == visualization_id:
del self... | [
"def",
"remove_visualization",
"(",
"self",
",",
"visualization_id",
")",
":",
"for",
"i",
",",
"panel",
"in",
"enumerate",
"(",
"self",
".",
"panels",
")",
":",
"if",
"panel",
"[",
"'id'",
"]",
"==",
"visualization_id",
":",
"del",
"self",
".",
"panels"... | Removes all visualizations with the specified id from the dashboard
:param visualization_id:
:return: | [
"Removes",
"all",
"visualizations",
"with",
"the",
"specified",
"id",
"from",
"the",
"dashboard",
":",
"param",
"visualization_id",
":",
":",
"return",
":"
] | train | https://github.com/harabchuk/kibana-dashboard-api/blob/8a13d5078fa92fb73f06498757ba9f51632e8a23/kibana_dashboard_api/dashboards.py#L101-L109 |
harabchuk/kibana-dashboard-api | kibana_dashboard_api/visualizations.py | VisualizationsManager.get_all | def get_all(self):
"""
Returns a list of all visualizations
:return: list of the Visualization instances
"""
res = self.es.search(index=self.index, doc_type=self.doc_type, body={'query': {'match_all': {}}})
if not res['hits']['total']:
return []
return... | python | def get_all(self):
"""
Returns a list of all visualizations
:return: list of the Visualization instances
"""
res = self.es.search(index=self.index, doc_type=self.doc_type, body={'query': {'match_all': {}}})
if not res['hits']['total']:
return []
return... | [
"def",
"get_all",
"(",
"self",
")",
":",
"res",
"=",
"self",
".",
"es",
".",
"search",
"(",
"index",
"=",
"self",
".",
"index",
",",
"doc_type",
"=",
"self",
".",
"doc_type",
",",
"body",
"=",
"{",
"'query'",
":",
"{",
"'match_all'",
":",
"{",
"}... | Returns a list of all visualizations
:return: list of the Visualization instances | [
"Returns",
"a",
"list",
"of",
"all",
"visualizations",
":",
"return",
":",
"list",
"of",
"the",
"Visualization",
"instances"
] | train | https://github.com/harabchuk/kibana-dashboard-api/blob/8a13d5078fa92fb73f06498757ba9f51632e8a23/kibana_dashboard_api/visualizations.py#L56-L64 |
harabchuk/kibana-dashboard-api | kibana_dashboard_api/visualizations.py | VisualizationsManager.add | def add(self, visualization):
"""
Creates a new visualization
:param visualization: instance of Visualization
:return:
"""
res = self.es.create(index=self.index,
id=visualization.id or str(uuid.uuid1()),
doc_type=s... | python | def add(self, visualization):
"""
Creates a new visualization
:param visualization: instance of Visualization
:return:
"""
res = self.es.create(index=self.index,
id=visualization.id or str(uuid.uuid1()),
doc_type=s... | [
"def",
"add",
"(",
"self",
",",
"visualization",
")",
":",
"res",
"=",
"self",
".",
"es",
".",
"create",
"(",
"index",
"=",
"self",
".",
"index",
",",
"id",
"=",
"visualization",
".",
"id",
"or",
"str",
"(",
"uuid",
".",
"uuid1",
"(",
")",
")",
... | Creates a new visualization
:param visualization: instance of Visualization
:return: | [
"Creates",
"a",
"new",
"visualization",
":",
"param",
"visualization",
":",
"instance",
"of",
"Visualization",
":",
"return",
":"
] | train | https://github.com/harabchuk/kibana-dashboard-api/blob/8a13d5078fa92fb73f06498757ba9f51632e8a23/kibana_dashboard_api/visualizations.py#L66-L76 |
harabchuk/kibana-dashboard-api | kibana_dashboard_api/visualizations.py | VisualizationsManager.update | def update(self, visualization):
"""
Updates existing visualization
:param visualization: instance of Visualization that was previously loaded
:return:
"""
res = self.es.update(index=self.index, id=visualization.id, doc_type=self.doc_type,
bod... | python | def update(self, visualization):
"""
Updates existing visualization
:param visualization: instance of Visualization that was previously loaded
:return:
"""
res = self.es.update(index=self.index, id=visualization.id, doc_type=self.doc_type,
bod... | [
"def",
"update",
"(",
"self",
",",
"visualization",
")",
":",
"res",
"=",
"self",
".",
"es",
".",
"update",
"(",
"index",
"=",
"self",
".",
"index",
",",
"id",
"=",
"visualization",
".",
"id",
",",
"doc_type",
"=",
"self",
".",
"doc_type",
",",
"bo... | Updates existing visualization
:param visualization: instance of Visualization that was previously loaded
:return: | [
"Updates",
"existing",
"visualization",
":",
"param",
"visualization",
":",
"instance",
"of",
"Visualization",
"that",
"was",
"previously",
"loaded",
":",
"return",
":"
] | train | https://github.com/harabchuk/kibana-dashboard-api/blob/8a13d5078fa92fb73f06498757ba9f51632e8a23/kibana_dashboard_api/visualizations.py#L78-L87 |
harabchuk/kibana-dashboard-api | kibana_dashboard_api/visualizations.py | VisualizationsManager.remove | def remove(self, visualization):
"""
Deletes the visualization
:param visualization: instance of Visualization that was previously loaded
:return:
"""
res = self.es.delete(index=self.index, id=visualization.id, doc_type=self.doc_type, refresh=True)
return res | python | def remove(self, visualization):
"""
Deletes the visualization
:param visualization: instance of Visualization that was previously loaded
:return:
"""
res = self.es.delete(index=self.index, id=visualization.id, doc_type=self.doc_type, refresh=True)
return res | [
"def",
"remove",
"(",
"self",
",",
"visualization",
")",
":",
"res",
"=",
"self",
".",
"es",
".",
"delete",
"(",
"index",
"=",
"self",
".",
"index",
",",
"id",
"=",
"visualization",
".",
"id",
",",
"doc_type",
"=",
"self",
".",
"doc_type",
",",
"re... | Deletes the visualization
:param visualization: instance of Visualization that was previously loaded
:return: | [
"Deletes",
"the",
"visualization",
":",
"param",
"visualization",
":",
"instance",
"of",
"Visualization",
"that",
"was",
"previously",
"loaded",
":",
"return",
":"
] | train | https://github.com/harabchuk/kibana-dashboard-api/blob/8a13d5078fa92fb73f06498757ba9f51632e8a23/kibana_dashboard_api/visualizations.py#L89-L96 |
harabchuk/kibana-dashboard-api | kibana_dashboard_api/paneltools.py | bottoms | def bottoms(panels):
"""
Finds bottom lines of all panels
:param panels:
:return: sorted by row list of tuples representing lines (col, row , col + len, row)
"""
bottom_lines = [(p['col'], p['row'] + p['size_y'], p['col'] + p['size_x'], p['row'] + p['size_y']) for p in panels]
return sorted(... | python | def bottoms(panels):
"""
Finds bottom lines of all panels
:param panels:
:return: sorted by row list of tuples representing lines (col, row , col + len, row)
"""
bottom_lines = [(p['col'], p['row'] + p['size_y'], p['col'] + p['size_x'], p['row'] + p['size_y']) for p in panels]
return sorted(... | [
"def",
"bottoms",
"(",
"panels",
")",
":",
"bottom_lines",
"=",
"[",
"(",
"p",
"[",
"'col'",
"]",
",",
"p",
"[",
"'row'",
"]",
"+",
"p",
"[",
"'size_y'",
"]",
",",
"p",
"[",
"'col'",
"]",
"+",
"p",
"[",
"'size_x'",
"]",
",",
"p",
"[",
"'row'"... | Finds bottom lines of all panels
:param panels:
:return: sorted by row list of tuples representing lines (col, row , col + len, row) | [
"Finds",
"bottom",
"lines",
"of",
"all",
"panels",
":",
"param",
"panels",
":",
":",
"return",
":",
"sorted",
"by",
"row",
"list",
"of",
"tuples",
"representing",
"lines",
"(",
"col",
"row",
"col",
"+",
"len",
"row",
")"
] | train | https://github.com/harabchuk/kibana-dashboard-api/blob/8a13d5078fa92fb73f06498757ba9f51632e8a23/kibana_dashboard_api/paneltools.py#L2-L9 |
harabchuk/kibana-dashboard-api | kibana_dashboard_api/paneltools.py | find_shape | def find_shape(bottom_lines, max_len):
"""
Finds a shape of lowest horizontal lines with step=1
:param bottom_lines:
:param max_len:
:return: list of levels (row values), list indexes are columns
"""
shape = [1] * max_len
for i in range(max_len):
for line in bottom_lines:
... | python | def find_shape(bottom_lines, max_len):
"""
Finds a shape of lowest horizontal lines with step=1
:param bottom_lines:
:param max_len:
:return: list of levels (row values), list indexes are columns
"""
shape = [1] * max_len
for i in range(max_len):
for line in bottom_lines:
... | [
"def",
"find_shape",
"(",
"bottom_lines",
",",
"max_len",
")",
":",
"shape",
"=",
"[",
"1",
"]",
"*",
"max_len",
"for",
"i",
"in",
"range",
"(",
"max_len",
")",
":",
"for",
"line",
"in",
"bottom_lines",
":",
"if",
"line",
"[",
"0",
"]",
"<=",
"i",
... | Finds a shape of lowest horizontal lines with step=1
:param bottom_lines:
:param max_len:
:return: list of levels (row values), list indexes are columns | [
"Finds",
"a",
"shape",
"of",
"lowest",
"horizontal",
"lines",
"with",
"step",
"=",
"1",
":",
"param",
"bottom_lines",
":",
":",
"param",
"max_len",
":",
":",
"return",
":",
"list",
"of",
"levels",
"(",
"row",
"values",
")",
"list",
"indexes",
"are",
"c... | train | https://github.com/harabchuk/kibana-dashboard-api/blob/8a13d5078fa92fb73f06498757ba9f51632e8a23/kibana_dashboard_api/paneltools.py#L12-L25 |
harabchuk/kibana-dashboard-api | kibana_dashboard_api/paneltools.py | longest_lines | def longest_lines(shape):
"""
Creates lines from shape
:param shape:
:return: list of dictionaries with col,row,len fields
"""
lines = []
for level in set(shape):
count = 0
for i in range(len(shape)):
if shape[i] <= level:
count += 1
el... | python | def longest_lines(shape):
"""
Creates lines from shape
:param shape:
:return: list of dictionaries with col,row,len fields
"""
lines = []
for level in set(shape):
count = 0
for i in range(len(shape)):
if shape[i] <= level:
count += 1
el... | [
"def",
"longest_lines",
"(",
"shape",
")",
":",
"lines",
"=",
"[",
"]",
"for",
"level",
"in",
"set",
"(",
"shape",
")",
":",
"count",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"shape",
")",
")",
":",
"if",
"shape",
"[",
"i",
"]",
... | Creates lines from shape
:param shape:
:return: list of dictionaries with col,row,len fields | [
"Creates",
"lines",
"from",
"shape",
":",
"param",
"shape",
":",
":",
"return",
":",
"list",
"of",
"dictionaries",
"with",
"col",
"row",
"len",
"fields"
] | train | https://github.com/harabchuk/kibana-dashboard-api/blob/8a13d5078fa92fb73f06498757ba9f51632e8a23/kibana_dashboard_api/paneltools.py#L28-L46 |
harabchuk/kibana-dashboard-api | kibana_dashboard_api/paneltools.py | append_panel | def append_panel(panels, size_x, size_y, max_col=12):
"""
Appends a panel to the list of panels. Finds the highest palce at the left for the new panel.
:param panels:
:param size_x:
:param size_y:
:param max_col:
:return: a new panel or None if it is not possible to place a panel with such s... | python | def append_panel(panels, size_x, size_y, max_col=12):
"""
Appends a panel to the list of panels. Finds the highest palce at the left for the new panel.
:param panels:
:param size_x:
:param size_y:
:param max_col:
:return: a new panel or None if it is not possible to place a panel with such s... | [
"def",
"append_panel",
"(",
"panels",
",",
"size_x",
",",
"size_y",
",",
"max_col",
"=",
"12",
")",
":",
"bottom_lines",
"=",
"bottoms",
"(",
"panels",
")",
"shape",
"=",
"find_shape",
"(",
"bottom_lines",
",",
"max_col",
")",
"lines",
"=",
"longest_lines"... | Appends a panel to the list of panels. Finds the highest palce at the left for the new panel.
:param panels:
:param size_x:
:param size_y:
:param max_col:
:return: a new panel or None if it is not possible to place a panel with such size_x | [
"Appends",
"a",
"panel",
"to",
"the",
"list",
"of",
"panels",
".",
"Finds",
"the",
"highest",
"palce",
"at",
"the",
"left",
"for",
"the",
"new",
"panel",
".",
":",
"param",
"panels",
":",
":",
"param",
"size_x",
":",
":",
"param",
"size_y",
":",
":",... | train | https://github.com/harabchuk/kibana-dashboard-api/blob/8a13d5078fa92fb73f06498757ba9f51632e8a23/kibana_dashboard_api/paneltools.py#L61-L83 |
aloetesting/aloe_django | aloe_django/management/commands/harvest.py | Command.run_from_argv | def run_from_argv(self, argv):
"""
Set the default Gherkin test runner for its options to be parsed.
"""
self.test_runner = test_runner_class
super(Command, self).run_from_argv(argv) | python | def run_from_argv(self, argv):
"""
Set the default Gherkin test runner for its options to be parsed.
"""
self.test_runner = test_runner_class
super(Command, self).run_from_argv(argv) | [
"def",
"run_from_argv",
"(",
"self",
",",
"argv",
")",
":",
"self",
".",
"test_runner",
"=",
"test_runner_class",
"super",
"(",
"Command",
",",
"self",
")",
".",
"run_from_argv",
"(",
"argv",
")"
] | Set the default Gherkin test runner for its options to be parsed. | [
"Set",
"the",
"default",
"Gherkin",
"test",
"runner",
"for",
"its",
"options",
"to",
"be",
"parsed",
"."
] | train | https://github.com/aloetesting/aloe_django/blob/672eac97c97644bfe334e70696a6dc5ddf4ced02/aloe_django/management/commands/harvest.py#L25-L31 |
aloetesting/aloe_django | aloe_django/management/commands/harvest.py | Command.handle | def handle(self, *test_labels, **options):
"""
Set the default Gherkin test runner.
"""
if not options.get('testrunner', None):
options['testrunner'] = test_runner_class
return super(Command, self).handle(*test_labels, **options) | python | def handle(self, *test_labels, **options):
"""
Set the default Gherkin test runner.
"""
if not options.get('testrunner', None):
options['testrunner'] = test_runner_class
return super(Command, self).handle(*test_labels, **options) | [
"def",
"handle",
"(",
"self",
",",
"*",
"test_labels",
",",
"*",
"*",
"options",
")",
":",
"if",
"not",
"options",
".",
"get",
"(",
"'testrunner'",
",",
"None",
")",
":",
"options",
"[",
"'testrunner'",
"]",
"=",
"test_runner_class",
"return",
"super",
... | Set the default Gherkin test runner. | [
"Set",
"the",
"default",
"Gherkin",
"test",
"runner",
"."
] | train | https://github.com/aloetesting/aloe_django/blob/672eac97c97644bfe334e70696a6dc5ddf4ced02/aloe_django/management/commands/harvest.py#L33-L40 |
aloetesting/aloe_django | aloe_django/__init__.py | django_url | def django_url(step, url=None):
"""
The URL for a page from the test server.
:param step: A Gherkin step
:param url: If specified, the relative URL to append.
"""
base_url = step.test.live_server_url
if url:
return urljoin(base_url, url)
else:
return base_url | python | def django_url(step, url=None):
"""
The URL for a page from the test server.
:param step: A Gherkin step
:param url: If specified, the relative URL to append.
"""
base_url = step.test.live_server_url
if url:
return urljoin(base_url, url)
else:
return base_url | [
"def",
"django_url",
"(",
"step",
",",
"url",
"=",
"None",
")",
":",
"base_url",
"=",
"step",
".",
"test",
".",
"live_server_url",
"if",
"url",
":",
"return",
"urljoin",
"(",
"base_url",
",",
"url",
")",
"else",
":",
"return",
"base_url"
] | The URL for a page from the test server.
:param step: A Gherkin step
:param url: If specified, the relative URL to append. | [
"The",
"URL",
"for",
"a",
"page",
"from",
"the",
"test",
"server",
"."
] | train | https://github.com/aloetesting/aloe_django/blob/672eac97c97644bfe334e70696a6dc5ddf4ced02/aloe_django/__init__.py#L38-L51 |
divio/aldryn-apphooks-config | aldryn_apphooks_config/managers/base.py | QuerySetMixin.namespace | def namespace(self, namespace, to=None):
"""
Filter by namespace. Try to guess which field to use in lookup.
Accept 'to' argument if you need to specify.
"""
fields = get_apphook_field_names(self.model)
if not fields:
raise ValueError(
ugettext... | python | def namespace(self, namespace, to=None):
"""
Filter by namespace. Try to guess which field to use in lookup.
Accept 'to' argument if you need to specify.
"""
fields = get_apphook_field_names(self.model)
if not fields:
raise ValueError(
ugettext... | [
"def",
"namespace",
"(",
"self",
",",
"namespace",
",",
"to",
"=",
"None",
")",
":",
"fields",
"=",
"get_apphook_field_names",
"(",
"self",
".",
"model",
")",
"if",
"not",
"fields",
":",
"raise",
"ValueError",
"(",
"ugettext",
"(",
"'Can\\'t find any relatio... | Filter by namespace. Try to guess which field to use in lookup.
Accept 'to' argument if you need to specify. | [
"Filter",
"by",
"namespace",
".",
"Try",
"to",
"guess",
"which",
"field",
"to",
"use",
"in",
"lookup",
".",
"Accept",
"to",
"argument",
"if",
"you",
"need",
"to",
"specify",
"."
] | train | https://github.com/divio/aldryn-apphooks-config/blob/5b8dfc7516982a8746fc08cf919c6ab116335d62/aldryn_apphooks_config/managers/base.py#L13-L48 |
divio/aldryn-apphooks-config | aldryn_apphooks_config/admin.py | ModelAppHookConfig._app_config_select | def _app_config_select(self, request, obj):
"""
Return the select value for apphook configs
:param request: request object
:param obj: current object
:return: False if no preselected value is available (more than one or no apphook
config is present), apphook con... | python | def _app_config_select(self, request, obj):
"""
Return the select value for apphook configs
:param request: request object
:param obj: current object
:return: False if no preselected value is available (more than one or no apphook
config is present), apphook con... | [
"def",
"_app_config_select",
"(",
"self",
",",
"request",
",",
"obj",
")",
":",
"if",
"not",
"obj",
"and",
"not",
"request",
".",
"GET",
".",
"get",
"(",
"self",
".",
"app_config_attribute",
",",
"False",
")",
":",
"config_model",
"=",
"get_apphook_model",... | Return the select value for apphook configs
:param request: request object
:param obj: current object
:return: False if no preselected value is available (more than one or no apphook
config is present), apphook config instance if exactly one apphook
config is d... | [
"Return",
"the",
"select",
"value",
"for",
"apphook",
"configs"
] | train | https://github.com/divio/aldryn-apphooks-config/blob/5b8dfc7516982a8746fc08cf919c6ab116335d62/aldryn_apphooks_config/admin.py#L49-L72 |
divio/aldryn-apphooks-config | aldryn_apphooks_config/admin.py | ModelAppHookConfig._set_config_defaults | def _set_config_defaults(self, request, form, obj=None):
"""
Cycle through app_config_values and sets the form value according to the
options in the current apphook config.
self.app_config_values is a dictionary containing config options as keys, form fields as
values::
... | python | def _set_config_defaults(self, request, form, obj=None):
"""
Cycle through app_config_values and sets the form value according to the
options in the current apphook config.
self.app_config_values is a dictionary containing config options as keys, form fields as
values::
... | [
"def",
"_set_config_defaults",
"(",
"self",
",",
"request",
",",
"form",
",",
"obj",
"=",
"None",
")",
":",
"for",
"config_option",
",",
"field",
"in",
"self",
".",
"app_config_values",
".",
"items",
"(",
")",
":",
"if",
"field",
"in",
"form",
".",
"ba... | Cycle through app_config_values and sets the form value according to the
options in the current apphook config.
self.app_config_values is a dictionary containing config options as keys, form fields as
values::
app_config_values = {
'apphook_config': 'form_field',
... | [
"Cycle",
"through",
"app_config_values",
"and",
"sets",
"the",
"form",
"value",
"according",
"to",
"the",
"options",
"in",
"the",
"current",
"apphook",
"config",
"."
] | train | https://github.com/divio/aldryn-apphooks-config/blob/5b8dfc7516982a8746fc08cf919c6ab116335d62/aldryn_apphooks_config/admin.py#L74-L95 |
divio/aldryn-apphooks-config | aldryn_apphooks_config/admin.py | ModelAppHookConfig.get_fieldsets | def get_fieldsets(self, request, obj=None):
"""
If the apphook config must be selected first, returns a fieldset with just the
app config field and help text
:param request:
:param obj:
:return:
"""
app_config_default = self._app_config_select(request, ob... | python | def get_fieldsets(self, request, obj=None):
"""
If the apphook config must be selected first, returns a fieldset with just the
app config field and help text
:param request:
:param obj:
:return:
"""
app_config_default = self._app_config_select(request, ob... | [
"def",
"get_fieldsets",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
")",
":",
"app_config_default",
"=",
"self",
".",
"_app_config_select",
"(",
"request",
",",
"obj",
")",
"if",
"app_config_default",
"is",
"None",
"and",
"request",
".",
"method",
... | If the apphook config must be selected first, returns a fieldset with just the
app config field and help text
:param request:
:param obj:
:return: | [
"If",
"the",
"apphook",
"config",
"must",
"be",
"selected",
"first",
"returns",
"a",
"fieldset",
"with",
"just",
"the",
"app",
"config",
"field",
"and",
"help",
"text",
":",
"param",
"request",
":",
":",
"param",
"obj",
":",
":",
"return",
":"
] | train | https://github.com/divio/aldryn-apphooks-config/blob/5b8dfc7516982a8746fc08cf919c6ab116335d62/aldryn_apphooks_config/admin.py#L97-L111 |
divio/aldryn-apphooks-config | aldryn_apphooks_config/admin.py | ModelAppHookConfig.get_config_data | def get_config_data(self, request, obj, name):
"""
Method that retrieves a configuration option for a specific AppHookConfig instance
:param request: the request object
:param obj: the model instance
:param name: name of the config option as defined in the config form
:... | python | def get_config_data(self, request, obj, name):
"""
Method that retrieves a configuration option for a specific AppHookConfig instance
:param request: the request object
:param obj: the model instance
:param name: name of the config option as defined in the config form
:... | [
"def",
"get_config_data",
"(",
"self",
",",
"request",
",",
"obj",
",",
"name",
")",
":",
"return_value",
"=",
"None",
"config",
"=",
"None",
"if",
"obj",
":",
"try",
":",
"config",
"=",
"getattr",
"(",
"obj",
",",
"self",
".",
"app_config_attribute",
... | Method that retrieves a configuration option for a specific AppHookConfig instance
:param request: the request object
:param obj: the model instance
:param name: name of the config option as defined in the config form
:return value: config value or None if no app config is found | [
"Method",
"that",
"retrieves",
"a",
"configuration",
"option",
"for",
"a",
"specific",
"AppHookConfig",
"instance"
] | train | https://github.com/divio/aldryn-apphooks-config/blob/5b8dfc7516982a8746fc08cf919c6ab116335d62/aldryn_apphooks_config/admin.py#L113-L138 |
divio/aldryn-apphooks-config | aldryn_apphooks_config/admin.py | ModelAppHookConfig.get_form | def get_form(self, request, obj=None, **kwargs):
"""
Provides a flexible way to get the right form according to the context
For the add view it checks whether the app_config is set; if not, a special form
to select the namespace is shown, which is reloaded after namespace selection.
... | python | def get_form(self, request, obj=None, **kwargs):
"""
Provides a flexible way to get the right form according to the context
For the add view it checks whether the app_config is set; if not, a special form
to select the namespace is shown, which is reloaded after namespace selection.
... | [
"def",
"get_form",
"(",
"self",
",",
"request",
",",
"obj",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"form",
"=",
"super",
"(",
"ModelAppHookConfig",
",",
"self",
")",
".",
"get_form",
"(",
"request",
",",
"obj",
",",
"*",
"*",
"kwargs",
")"... | Provides a flexible way to get the right form according to the context
For the add view it checks whether the app_config is set; if not, a special form
to select the namespace is shown, which is reloaded after namespace selection.
If only one namespace exists, the current is selected and the no... | [
"Provides",
"a",
"flexible",
"way",
"to",
"get",
"the",
"right",
"form",
"according",
"to",
"the",
"context"
] | train | https://github.com/divio/aldryn-apphooks-config/blob/5b8dfc7516982a8746fc08cf919c6ab116335d62/aldryn_apphooks_config/admin.py#L140-L164 |
aloetesting/aloe_django | aloe_django/steps/models.py | _models_generator | def _models_generator():
"""
Build a hash of model verbose names to models
"""
for app in apps.get_app_configs():
for model in app.get_models():
yield (str(model._meta.verbose_name).lower(), model)
yield (str(model._meta.verbose_name_plural).lower(), model) | python | def _models_generator():
"""
Build a hash of model verbose names to models
"""
for app in apps.get_app_configs():
for model in app.get_models():
yield (str(model._meta.verbose_name).lower(), model)
yield (str(model._meta.verbose_name_plural).lower(), model) | [
"def",
"_models_generator",
"(",
")",
":",
"for",
"app",
"in",
"apps",
".",
"get_app_configs",
"(",
")",
":",
"for",
"model",
"in",
"app",
".",
"get_models",
"(",
")",
":",
"yield",
"(",
"str",
"(",
"model",
".",
"_meta",
".",
"verbose_name",
")",
".... | Build a hash of model verbose names to models | [
"Build",
"a",
"hash",
"of",
"model",
"verbose",
"names",
"to",
"models"
] | train | https://github.com/aloetesting/aloe_django/blob/672eac97c97644bfe334e70696a6dc5ddf4ced02/aloe_django/steps/models.py#L29-L37 |
aloetesting/aloe_django | aloe_django/steps/models.py | get_model | def get_model(name):
"""
Convert a model's verbose name to the model class. This allows us to
use the models verbose name in steps.
"""
model = MODELS.get(name.lower(), None)
assert model, "Could not locate model by name '%s'" % name
return model | python | def get_model(name):
"""
Convert a model's verbose name to the model class. This allows us to
use the models verbose name in steps.
"""
model = MODELS.get(name.lower(), None)
assert model, "Could not locate model by name '%s'" % name
return model | [
"def",
"get_model",
"(",
"name",
")",
":",
"model",
"=",
"MODELS",
".",
"get",
"(",
"name",
".",
"lower",
"(",
")",
",",
"None",
")",
"assert",
"model",
",",
"\"Could not locate model by name '%s'\"",
"%",
"name",
"return",
"model"
] | Convert a model's verbose name to the model class. This allows us to
use the models verbose name in steps. | [
"Convert",
"a",
"model",
"s",
"verbose",
"name",
"to",
"the",
"model",
"class",
".",
"This",
"allows",
"us",
"to",
"use",
"the",
"models",
"verbose",
"name",
"in",
"steps",
"."
] | train | https://github.com/aloetesting/aloe_django/blob/672eac97c97644bfe334e70696a6dc5ddf4ced02/aloe_django/steps/models.py#L166-L176 |
aloetesting/aloe_django | aloe_django/steps/models.py | reset_sequence | def reset_sequence(model):
"""
Reset the ID sequence for a model.
"""
sql = connection.ops.sequence_reset_sql(no_style(), [model])
for cmd in sql:
connection.cursor().execute(cmd) | python | def reset_sequence(model):
"""
Reset the ID sequence for a model.
"""
sql = connection.ops.sequence_reset_sql(no_style(), [model])
for cmd in sql:
connection.cursor().execute(cmd) | [
"def",
"reset_sequence",
"(",
"model",
")",
":",
"sql",
"=",
"connection",
".",
"ops",
".",
"sequence_reset_sql",
"(",
"no_style",
"(",
")",
",",
"[",
"model",
"]",
")",
"for",
"cmd",
"in",
"sql",
":",
"connection",
".",
"cursor",
"(",
")",
".",
"exe... | Reset the ID sequence for a model. | [
"Reset",
"the",
"ID",
"sequence",
"for",
"a",
"model",
"."
] | train | https://github.com/aloetesting/aloe_django/blob/672eac97c97644bfe334e70696a6dc5ddf4ced02/aloe_django/steps/models.py#L179-L185 |
aloetesting/aloe_django | aloe_django/steps/models.py | _dump_model | def _dump_model(model, attrs=None):
"""
Dump the model fields for debugging.
"""
fields = []
for field in model._meta.fields:
fields.append((field.name, str(getattr(model, field.name))))
if attrs is not None:
for attr in attrs:
fields.append((attr, str(getattr(mode... | python | def _dump_model(model, attrs=None):
"""
Dump the model fields for debugging.
"""
fields = []
for field in model._meta.fields:
fields.append((field.name, str(getattr(model, field.name))))
if attrs is not None:
for attr in attrs:
fields.append((attr, str(getattr(mode... | [
"def",
"_dump_model",
"(",
"model",
",",
"attrs",
"=",
"None",
")",
":",
"fields",
"=",
"[",
"]",
"for",
"field",
"in",
"model",
".",
"_meta",
".",
"fields",
":",
"fields",
".",
"append",
"(",
"(",
"field",
".",
"name",
",",
"str",
"(",
"getattr",
... | Dump the model fields for debugging. | [
"Dump",
"the",
"model",
"fields",
"for",
"debugging",
"."
] | train | https://github.com/aloetesting/aloe_django/blob/672eac97c97644bfe334e70696a6dc5ddf4ced02/aloe_django/steps/models.py#L188-L212 |
aloetesting/aloe_django | aloe_django/steps/models.py | _model_exists_step | def _model_exists_step(self, model, should_exist):
"""
Test for the existence of a model matching the given data.
"""
model = get_model(model)
data = guess_types(self.hashes)
queryset = model.objects
try:
existence_check = _TEST_MODEL[model]
except KeyError:
existence_... | python | def _model_exists_step(self, model, should_exist):
"""
Test for the existence of a model matching the given data.
"""
model = get_model(model)
data = guess_types(self.hashes)
queryset = model.objects
try:
existence_check = _TEST_MODEL[model]
except KeyError:
existence_... | [
"def",
"_model_exists_step",
"(",
"self",
",",
"model",
",",
"should_exist",
")",
":",
"model",
"=",
"get_model",
"(",
"model",
")",
"data",
"=",
"guess_types",
"(",
"self",
".",
"hashes",
")",
"queryset",
"=",
"model",
".",
"objects",
"try",
":",
"exist... | Test for the existence of a model matching the given data. | [
"Test",
"for",
"the",
"existence",
"of",
"a",
"model",
"matching",
"the",
"given",
"data",
"."
] | train | https://github.com/aloetesting/aloe_django/blob/672eac97c97644bfe334e70696a6dc5ddf4ced02/aloe_django/steps/models.py#L247-L289 |
aloetesting/aloe_django | aloe_django/steps/models.py | write_models | def write_models(model, data, field):
"""
:param model: a Django model class
:param data: a list of hashes to build models from
:param field: a field name to match models on, or None
:returns: a list of models written
Create or update models for each data hash.
`field` is the field that is... | python | def write_models(model, data, field):
"""
:param model: a Django model class
:param data: a list of hashes to build models from
:param field: a field name to match models on, or None
:returns: a list of models written
Create or update models for each data hash.
`field` is the field that is... | [
"def",
"write_models",
"(",
"model",
",",
"data",
",",
"field",
")",
":",
"written",
"=",
"[",
"]",
"for",
"hash_",
"in",
"data",
":",
"if",
"field",
":",
"if",
"field",
"not",
"in",
"hash_",
":",
"raise",
"KeyError",
"(",
"(",
"\"The \\\"%s\\\" field ... | :param model: a Django model class
:param data: a list of hashes to build models from
:param field: a field name to match models on, or None
:returns: a list of models written
Create or update models for each data hash.
`field` is the field that is used to get the existing models out of
the da... | [
":",
"param",
"model",
":",
"a",
"Django",
"model",
"class",
":",
"param",
"data",
":",
"a",
"list",
"of",
"hashes",
"to",
"build",
"models",
"from",
":",
"param",
"field",
":",
"a",
"field",
"name",
"to",
"match",
"models",
"on",
"or",
"None",
":",
... | train | https://github.com/aloetesting/aloe_django/blob/672eac97c97644bfe334e70696a6dc5ddf4ced02/aloe_django/steps/models.py#L338-L375 |
aloetesting/aloe_django | aloe_django/steps/models.py | _write_models_step | def _write_models_step(self, model, field=None):
"""
Write or update a model.
"""
model = get_model(model)
data = guess_types(self.hashes)
try:
func = _WRITE_MODEL[model]
except KeyError:
func = partial(write_models, model)
func(data, field) | python | def _write_models_step(self, model, field=None):
"""
Write or update a model.
"""
model = get_model(model)
data = guess_types(self.hashes)
try:
func = _WRITE_MODEL[model]
except KeyError:
func = partial(write_models, model)
func(data, field) | [
"def",
"_write_models_step",
"(",
"self",
",",
"model",
",",
"field",
"=",
"None",
")",
":",
"model",
"=",
"get_model",
"(",
"model",
")",
"data",
"=",
"guess_types",
"(",
"self",
".",
"hashes",
")",
"try",
":",
"func",
"=",
"_WRITE_MODEL",
"[",
"model... | Write or update a model. | [
"Write",
"or",
"update",
"a",
"model",
"."
] | train | https://github.com/aloetesting/aloe_django/blob/672eac97c97644bfe334e70696a6dc5ddf4ced02/aloe_django/steps/models.py#L378-L391 |
aloetesting/aloe_django | aloe_django/steps/models.py | _create_models_for_relation_step | def _create_models_for_relation_step(self, rel_model_name,
rel_key, rel_value, model):
"""
Create a new model linked to the given model.
Syntax:
And `model` with `field` "`value`" has `new model` in the database:
Example:
.. code-block:: gherkin
... | python | def _create_models_for_relation_step(self, rel_model_name,
rel_key, rel_value, model):
"""
Create a new model linked to the given model.
Syntax:
And `model` with `field` "`value`" has `new model` in the database:
Example:
.. code-block:: gherkin
... | [
"def",
"_create_models_for_relation_step",
"(",
"self",
",",
"rel_model_name",
",",
"rel_key",
",",
"rel_value",
",",
"model",
")",
":",
"model",
"=",
"get_model",
"(",
"model",
")",
"lookup",
"=",
"{",
"rel_key",
":",
"rel_value",
"}",
"rel_model",
"=",
"ge... | Create a new model linked to the given model.
Syntax:
And `model` with `field` "`value`" has `new model` in the database:
Example:
.. code-block:: gherkin
And project with name "Ball Project" has goals in the database:
| description |
... | [
"Create",
"a",
"new",
"model",
"linked",
"to",
"the",
"given",
"model",
"."
] | train | https://github.com/aloetesting/aloe_django/blob/672eac97c97644bfe334e70696a6dc5ddf4ced02/aloe_django/steps/models.py#L441-L473 |
aloetesting/aloe_django | aloe_django/steps/models.py | _create_m2m_links_step | def _create_m2m_links_step(self, rel_model_name,
rel_key, rel_value, relation_name):
"""
Link many-to-many models together.
Syntax:
And `model` with `field` "`value`" is linked to `other model` in the
database:
Example:
.. code-block:: gherkin
... | python | def _create_m2m_links_step(self, rel_model_name,
rel_key, rel_value, relation_name):
"""
Link many-to-many models together.
Syntax:
And `model` with `field` "`value`" is linked to `other model` in the
database:
Example:
.. code-block:: gherkin
... | [
"def",
"_create_m2m_links_step",
"(",
"self",
",",
"rel_model_name",
",",
"rel_key",
",",
"rel_value",
",",
"relation_name",
")",
":",
"lookup",
"=",
"{",
"rel_key",
":",
"rel_value",
"}",
"rel_model",
"=",
"get_model",
"(",
"rel_model_name",
")",
".",
"object... | Link many-to-many models together.
Syntax:
And `model` with `field` "`value`" is linked to `other model` in the
database:
Example:
.. code-block:: gherkin
And article with name "Guidelines" is linked to tags in the database:
| name |
| coding |
... | [
"Link",
"many",
"-",
"to",
"-",
"many",
"models",
"together",
"."
] | train | https://github.com/aloetesting/aloe_django/blob/672eac97c97644bfe334e70696a6dc5ddf4ced02/aloe_django/steps/models.py#L478-L518 |
aloetesting/aloe_django | aloe_django/steps/models.py | _model_count_step | def _model_count_step(self, count, model):
"""
Count the number of models in the database.
Example:
.. code-block:: gherkin
Then there should be 0 goals in the database
"""
model = get_model(model)
expected = int(count)
found = model.objects.count()
assert found == expec... | python | def _model_count_step(self, count, model):
"""
Count the number of models in the database.
Example:
.. code-block:: gherkin
Then there should be 0 goals in the database
"""
model = get_model(model)
expected = int(count)
found = model.objects.count()
assert found == expec... | [
"def",
"_model_count_step",
"(",
"self",
",",
"count",
",",
"model",
")",
":",
"model",
"=",
"get_model",
"(",
"model",
")",
"expected",
"=",
"int",
"(",
"count",
")",
"found",
"=",
"model",
".",
"objects",
".",
"count",
"(",
")",
"assert",
"found",
... | Count the number of models in the database.
Example:
.. code-block:: gherkin
Then there should be 0 goals in the database | [
"Count",
"the",
"number",
"of",
"models",
"in",
"the",
"database",
"."
] | train | https://github.com/aloetesting/aloe_django/blob/672eac97c97644bfe334e70696a6dc5ddf4ced02/aloe_django/steps/models.py#L522-L538 |
aloetesting/aloe_django | aloe_django/steps/mail.py | mail_sent_count | def mail_sent_count(self, count):
"""
Test that `count` mails have been sent.
Syntax:
I have sent `count` emails
Example:
.. code-block:: gherkin
Then I have sent 2 emails
"""
expected = int(count)
actual = len(mail.outbox)
assert expected == actual, \
"E... | python | def mail_sent_count(self, count):
"""
Test that `count` mails have been sent.
Syntax:
I have sent `count` emails
Example:
.. code-block:: gherkin
Then I have sent 2 emails
"""
expected = int(count)
actual = len(mail.outbox)
assert expected == actual, \
"E... | [
"def",
"mail_sent_count",
"(",
"self",
",",
"count",
")",
":",
"expected",
"=",
"int",
"(",
"count",
")",
"actual",
"=",
"len",
"(",
"mail",
".",
"outbox",
")",
"assert",
"expected",
"==",
"actual",
",",
"\"Expected to send {0} email(s), got {1}.\"",
".",
"f... | Test that `count` mails have been sent.
Syntax:
I have sent `count` emails
Example:
.. code-block:: gherkin
Then I have sent 2 emails | [
"Test",
"that",
"count",
"mails",
"have",
"been",
"sent",
"."
] | train | https://github.com/aloetesting/aloe_django/blob/672eac97c97644bfe334e70696a6dc5ddf4ced02/aloe_django/steps/mail.py#L25-L42 |
aloetesting/aloe_django | aloe_django/steps/mail.py | mail_sent_content | def mail_sent_content(self, text, part):
"""
Test an email contains (assert text in) the given text in the relevant
message part (accessible as an attribute on the email object).
This step strictly applies whitespace.
Syntax:
I have sent an email with "`text`" in the `part`
Example:
... | python | def mail_sent_content(self, text, part):
"""
Test an email contains (assert text in) the given text in the relevant
message part (accessible as an attribute on the email object).
This step strictly applies whitespace.
Syntax:
I have sent an email with "`text`" in the `part`
Example:
... | [
"def",
"mail_sent_content",
"(",
"self",
",",
"text",
",",
"part",
")",
":",
"if",
"not",
"any",
"(",
"text",
"in",
"getattr",
"(",
"email",
",",
"part",
")",
"for",
"email",
"in",
"mail",
".",
"outbox",
")",
":",
"dump_emails",
"(",
"part",
")",
"... | Test an email contains (assert text in) the given text in the relevant
message part (accessible as an attribute on the email object).
This step strictly applies whitespace.
Syntax:
I have sent an email with "`text`" in the `part`
Example:
.. code-block:: gherkin
Then I have sen... | [
"Test",
"an",
"email",
"contains",
"(",
"assert",
"text",
"in",
")",
"the",
"given",
"text",
"in",
"the",
"relevant",
"message",
"part",
"(",
"accessible",
"as",
"an",
"attribute",
"on",
"the",
"email",
"object",
")",
"."
] | train | https://github.com/aloetesting/aloe_django/blob/672eac97c97644bfe334e70696a6dc5ddf4ced02/aloe_django/steps/mail.py#L61-L81 |
aloetesting/aloe_django | aloe_django/steps/mail.py | mail_sent_contains_html | def mail_sent_contains_html(self):
"""
Test that an email contains the HTML (assert HTML in) in the multiline as
one of its MIME alternatives.
The HTML is normalised by passing through Django's
:func:`django.test.html.parse_html`.
Example:
.. code-block:: gherkin
And I have sent ... | python | def mail_sent_contains_html(self):
"""
Test that an email contains the HTML (assert HTML in) in the multiline as
one of its MIME alternatives.
The HTML is normalised by passing through Django's
:func:`django.test.html.parse_html`.
Example:
.. code-block:: gherkin
And I have sent ... | [
"def",
"mail_sent_contains_html",
"(",
"self",
")",
":",
"for",
"email",
"in",
"mail",
".",
"outbox",
":",
"try",
":",
"html",
"=",
"next",
"(",
"content",
"for",
"content",
",",
"mime",
"in",
"email",
".",
"alternatives",
"if",
"mime",
"==",
"'text/html... | Test that an email contains the HTML (assert HTML in) in the multiline as
one of its MIME alternatives.
The HTML is normalised by passing through Django's
:func:`django.test.html.parse_html`.
Example:
.. code-block:: gherkin
And I have sent an email with the following HTML alternative:
... | [
"Test",
"that",
"an",
"email",
"contains",
"the",
"HTML",
"(",
"assert",
"HTML",
"in",
")",
"in",
"the",
"multiline",
"as",
"one",
"of",
"its",
"MIME",
"alternatives",
"."
] | train | https://github.com/aloetesting/aloe_django/blob/672eac97c97644bfe334e70696a6dc5ddf4ced02/aloe_django/steps/mail.py#L131-L167 |
aloetesting/aloe_django | aloe_django/steps/mail.py | dump_emails | def dump_emails(part):
"""Show the sent emails' tested parts, to aid in debugging."""
print("Sent emails:")
for email in mail.outbox:
print(getattr(email, part)) | python | def dump_emails(part):
"""Show the sent emails' tested parts, to aid in debugging."""
print("Sent emails:")
for email in mail.outbox:
print(getattr(email, part)) | [
"def",
"dump_emails",
"(",
"part",
")",
":",
"print",
"(",
"\"Sent emails:\"",
")",
"for",
"email",
"in",
"mail",
".",
"outbox",
":",
"print",
"(",
"getattr",
"(",
"email",
",",
"part",
")",
")"
] | Show the sent emails' tested parts, to aid in debugging. | [
"Show",
"the",
"sent",
"emails",
"tested",
"parts",
"to",
"aid",
"in",
"debugging",
"."
] | train | https://github.com/aloetesting/aloe_django/blob/672eac97c97644bfe334e70696a6dc5ddf4ced02/aloe_django/steps/mail.py#L208-L213 |
divio/aldryn-apphooks-config | aldryn_apphooks_config/templatetags/apphooks_config_tags.py | namespace_url | def namespace_url(context, view_name, *args, **kwargs):
"""
Returns an absolute URL matching named view with its parameters and the
provided application instance namespace.
If no namespace is passed as a kwarg (or it is "" or None), this templatetag
will look into the request object for the app_con... | python | def namespace_url(context, view_name, *args, **kwargs):
"""
Returns an absolute URL matching named view with its parameters and the
provided application instance namespace.
If no namespace is passed as a kwarg (or it is "" or None), this templatetag
will look into the request object for the app_con... | [
"def",
"namespace_url",
"(",
"context",
",",
"view_name",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"namespace",
"=",
"kwargs",
".",
"pop",
"(",
"'namespace'",
",",
"None",
")",
"if",
"not",
"namespace",
":",
"namespace",
",",
"__",
"=",
"... | Returns an absolute URL matching named view with its parameters and the
provided application instance namespace.
If no namespace is passed as a kwarg (or it is "" or None), this templatetag
will look into the request object for the app_config's namespace. If there
is still no namespace found, this tag ... | [
"Returns",
"an",
"absolute",
"URL",
"matching",
"named",
"view",
"with",
"its",
"parameters",
"and",
"the",
"provided",
"application",
"instance",
"namespace",
"."
] | train | https://github.com/divio/aldryn-apphooks-config/blob/5b8dfc7516982a8746fc08cf919c6ab116335d62/aldryn_apphooks_config/templatetags/apphooks_config_tags.py#L14-L60 |
divio/aldryn-apphooks-config | aldryn_apphooks_config/utils.py | get_app_instance | def get_app_instance(request):
"""
Returns a tuple containing the current namespace and the AppHookConfig instance
:param request: request object
:return: namespace, config
"""
app = None
if getattr(request, 'current_page', None) and request.current_page.application_urls:
app = apph... | python | def get_app_instance(request):
"""
Returns a tuple containing the current namespace and the AppHookConfig instance
:param request: request object
:return: namespace, config
"""
app = None
if getattr(request, 'current_page', None) and request.current_page.application_urls:
app = apph... | [
"def",
"get_app_instance",
"(",
"request",
")",
":",
"app",
"=",
"None",
"if",
"getattr",
"(",
"request",
",",
"'current_page'",
",",
"None",
")",
"and",
"request",
".",
"current_page",
".",
"application_urls",
":",
"app",
"=",
"apphook_pool",
".",
"get_apph... | Returns a tuple containing the current namespace and the AppHookConfig instance
:param request: request object
:return: namespace, config | [
"Returns",
"a",
"tuple",
"containing",
"the",
"current",
"namespace",
"and",
"the",
"AppHookConfig",
"instance"
] | train | https://github.com/divio/aldryn-apphooks-config/blob/5b8dfc7516982a8746fc08cf919c6ab116335d62/aldryn_apphooks_config/utils.py#L16-L35 |
divio/aldryn-apphooks-config | aldryn_apphooks_config/utils.py | setup_config | def setup_config(form_class, config_model=None):
"""
Register the provided form as config form for the provided config model
This can be used as a decorator by adding a `model` attribute to the config form::
@setup_config
class ExampleConfigForm(AppDataForm):
model = ExampleCon... | python | def setup_config(form_class, config_model=None):
"""
Register the provided form as config form for the provided config model
This can be used as a decorator by adding a `model` attribute to the config form::
@setup_config
class ExampleConfigForm(AppDataForm):
model = ExampleCon... | [
"def",
"setup_config",
"(",
"form_class",
",",
"config_model",
"=",
"None",
")",
":",
"# allow use as a decorator",
"if",
"config_model",
"is",
"None",
":",
"return",
"setup_config",
"(",
"form_class",
",",
"form_class",
".",
"model",
")",
"app_registry",
".",
"... | Register the provided form as config form for the provided config model
This can be used as a decorator by adding a `model` attribute to the config form::
@setup_config
class ExampleConfigForm(AppDataForm):
model = ExampleConfig
:param form_class: Form class derived from AppDataFo... | [
"Register",
"the",
"provided",
"form",
"as",
"config",
"form",
"for",
"the",
"provided",
"config",
"model"
] | train | https://github.com/divio/aldryn-apphooks-config/blob/5b8dfc7516982a8746fc08cf919c6ab116335d62/aldryn_apphooks_config/utils.py#L38-L56 |
divio/aldryn-apphooks-config | aldryn_apphooks_config/utils.py | _get_apphook_field_names | def _get_apphook_field_names(model):
"""
Return all foreign key field names for a AppHookConfig based model
"""
from .models import AppHookConfig # avoid circular dependencies
fields = []
for field in model._meta.fields:
if isinstance(field, ForeignKey) and issubclass(field.remote_field... | python | def _get_apphook_field_names(model):
"""
Return all foreign key field names for a AppHookConfig based model
"""
from .models import AppHookConfig # avoid circular dependencies
fields = []
for field in model._meta.fields:
if isinstance(field, ForeignKey) and issubclass(field.remote_field... | [
"def",
"_get_apphook_field_names",
"(",
"model",
")",
":",
"from",
".",
"models",
"import",
"AppHookConfig",
"# avoid circular dependencies",
"fields",
"=",
"[",
"]",
"for",
"field",
"in",
"model",
".",
"_meta",
".",
"fields",
":",
"if",
"isinstance",
"(",
"fi... | Return all foreign key field names for a AppHookConfig based model | [
"Return",
"all",
"foreign",
"key",
"field",
"names",
"for",
"a",
"AppHookConfig",
"based",
"model"
] | train | https://github.com/divio/aldryn-apphooks-config/blob/5b8dfc7516982a8746fc08cf919c6ab116335d62/aldryn_apphooks_config/utils.py#L59-L68 |
divio/aldryn-apphooks-config | aldryn_apphooks_config/utils.py | get_apphook_field_names | def get_apphook_field_names(model):
"""
Cache app-hook field names on model
:param model: model class or object
:return: list of foreign key field names to AppHookConfigs
"""
key = APP_CONFIG_FIELDS_KEY.format(
app_label=model._meta.app_label,
model_name=model._meta.object_name
... | python | def get_apphook_field_names(model):
"""
Cache app-hook field names on model
:param model: model class or object
:return: list of foreign key field names to AppHookConfigs
"""
key = APP_CONFIG_FIELDS_KEY.format(
app_label=model._meta.app_label,
model_name=model._meta.object_name
... | [
"def",
"get_apphook_field_names",
"(",
"model",
")",
":",
"key",
"=",
"APP_CONFIG_FIELDS_KEY",
".",
"format",
"(",
"app_label",
"=",
"model",
".",
"_meta",
".",
"app_label",
",",
"model_name",
"=",
"model",
".",
"_meta",
".",
"object_name",
")",
".",
"lower"... | Cache app-hook field names on model
:param model: model class or object
:return: list of foreign key field names to AppHookConfigs | [
"Cache",
"app",
"-",
"hook",
"field",
"names",
"on",
"model"
] | train | https://github.com/divio/aldryn-apphooks-config/blob/5b8dfc7516982a8746fc08cf919c6ab116335d62/aldryn_apphooks_config/utils.py#L71-L85 |
divio/aldryn-apphooks-config | aldryn_apphooks_config/utils.py | get_apphook_configs | def get_apphook_configs(obj):
"""
Get apphook configs for an object obj
:param obj: any model instance
:return: list of apphook configs for given obj
"""
keys = get_apphook_field_names(obj)
return [getattr(obj, key) for key in keys] if keys else [] | python | def get_apphook_configs(obj):
"""
Get apphook configs for an object obj
:param obj: any model instance
:return: list of apphook configs for given obj
"""
keys = get_apphook_field_names(obj)
return [getattr(obj, key) for key in keys] if keys else [] | [
"def",
"get_apphook_configs",
"(",
"obj",
")",
":",
"keys",
"=",
"get_apphook_field_names",
"(",
"obj",
")",
"return",
"[",
"getattr",
"(",
"obj",
",",
"key",
")",
"for",
"key",
"in",
"keys",
"]",
"if",
"keys",
"else",
"[",
"]"
] | Get apphook configs for an object obj
:param obj: any model instance
:return: list of apphook configs for given obj | [
"Get",
"apphook",
"configs",
"for",
"an",
"object",
"obj"
] | train | https://github.com/divio/aldryn-apphooks-config/blob/5b8dfc7516982a8746fc08cf919c6ab116335d62/aldryn_apphooks_config/utils.py#L88-L96 |
nugget/python-insteonplm | insteonplm/plm.py | IM.data_received | def data_received(self, data):
"""Receive data from the protocol.
Called when asyncio.Protocol detects received data from network.
"""
_LOGGER.debug("Starting: data_received")
_LOGGER.debug('Received %d bytes from PLM: %s',
len(data), binascii.hexlify(data)... | python | def data_received(self, data):
"""Receive data from the protocol.
Called when asyncio.Protocol detects received data from network.
"""
_LOGGER.debug("Starting: data_received")
_LOGGER.debug('Received %d bytes from PLM: %s',
len(data), binascii.hexlify(data)... | [
"def",
"data_received",
"(",
"self",
",",
"data",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Starting: data_received\"",
")",
"_LOGGER",
".",
"debug",
"(",
"'Received %d bytes from PLM: %s'",
",",
"len",
"(",
"data",
")",
",",
"binascii",
".",
"hexlify",
"(",
... | Receive data from the protocol.
Called when asyncio.Protocol detects received data from network. | [
"Receive",
"data",
"from",
"the",
"protocol",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/plm.py#L125-L137 |
nugget/python-insteonplm | insteonplm/plm.py | IM.connection_lost | def connection_lost(self, exc):
"""Reestablish the connection to the transport.
Called when asyncio.Protocol loses the network connection.
"""
if exc is None:
_LOGGER.warning('End of file received from Insteon Modem')
else:
_LOGGER.warning('Lost connectio... | python | def connection_lost(self, exc):
"""Reestablish the connection to the transport.
Called when asyncio.Protocol loses the network connection.
"""
if exc is None:
_LOGGER.warning('End of file received from Insteon Modem')
else:
_LOGGER.warning('Lost connectio... | [
"def",
"connection_lost",
"(",
"self",
",",
"exc",
")",
":",
"if",
"exc",
"is",
"None",
":",
"_LOGGER",
".",
"warning",
"(",
"'End of file received from Insteon Modem'",
")",
"else",
":",
"_LOGGER",
".",
"warning",
"(",
"'Lost connection to Insteon Modem: %s'",
",... | Reestablish the connection to the transport.
Called when asyncio.Protocol loses the network connection. | [
"Reestablish",
"the",
"connection",
"to",
"the",
"transport",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/plm.py#L139-L153 |
nugget/python-insteonplm | insteonplm/plm.py | IM.add_all_link_done_callback | def add_all_link_done_callback(self, callback):
"""Register a callback to be invoked when the ALDB is loaded."""
_LOGGER.debug('Added new callback %s ', callback)
self._cb_load_all_link_db_done.append(callback) | python | def add_all_link_done_callback(self, callback):
"""Register a callback to be invoked when the ALDB is loaded."""
_LOGGER.debug('Added new callback %s ', callback)
self._cb_load_all_link_db_done.append(callback) | [
"def",
"add_all_link_done_callback",
"(",
"self",
",",
"callback",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"'Added new callback %s '",
",",
"callback",
")",
"self",
".",
"_cb_load_all_link_db_done",
".",
"append",
"(",
"callback",
")"
] | Register a callback to be invoked when the ALDB is loaded. | [
"Register",
"a",
"callback",
"to",
"be",
"invoked",
"when",
"the",
"ALDB",
"is",
"loaded",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/plm.py#L160-L163 |
nugget/python-insteonplm | insteonplm/plm.py | IM.add_device_not_active_callback | def add_device_not_active_callback(self, callback):
"""Register callback to be invoked when a device is not responding."""
_LOGGER.debug('Added new callback %s ', callback)
self._cb_device_not_active.append(callback) | python | def add_device_not_active_callback(self, callback):
"""Register callback to be invoked when a device is not responding."""
_LOGGER.debug('Added new callback %s ', callback)
self._cb_device_not_active.append(callback) | [
"def",
"add_device_not_active_callback",
"(",
"self",
",",
"callback",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"'Added new callback %s '",
",",
"callback",
")",
"self",
".",
"_cb_device_not_active",
".",
"append",
"(",
"callback",
")"
] | Register callback to be invoked when a device is not responding. | [
"Register",
"callback",
"to",
"be",
"invoked",
"when",
"a",
"device",
"is",
"not",
"responding",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/plm.py#L165-L168 |
nugget/python-insteonplm | insteonplm/plm.py | IM.poll_devices | def poll_devices(self):
"""Request status updates from each device."""
for addr in self.devices:
device = self.devices[addr]
if not device.address.is_x10:
device.async_refresh_state() | python | def poll_devices(self):
"""Request status updates from each device."""
for addr in self.devices:
device = self.devices[addr]
if not device.address.is_x10:
device.async_refresh_state() | [
"def",
"poll_devices",
"(",
"self",
")",
":",
"for",
"addr",
"in",
"self",
".",
"devices",
":",
"device",
"=",
"self",
".",
"devices",
"[",
"addr",
"]",
"if",
"not",
"device",
".",
"address",
".",
"is_x10",
":",
"device",
".",
"async_refresh_state",
"(... | Request status updates from each device. | [
"Request",
"status",
"updates",
"from",
"each",
"device",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/plm.py#L171-L176 |
nugget/python-insteonplm | insteonplm/plm.py | IM.send_msg | def send_msg(self, msg, wait_nak=True, wait_timeout=WAIT_TIMEOUT):
"""Place a message on the send queue for sending.
Message are sent in the order they are placed in the queue.
"""
msg_info = MessageInfo(msg=msg, wait_nak=wait_nak,
wait_timeout=wait_timeou... | python | def send_msg(self, msg, wait_nak=True, wait_timeout=WAIT_TIMEOUT):
"""Place a message on the send queue for sending.
Message are sent in the order they are placed in the queue.
"""
msg_info = MessageInfo(msg=msg, wait_nak=wait_nak,
wait_timeout=wait_timeou... | [
"def",
"send_msg",
"(",
"self",
",",
"msg",
",",
"wait_nak",
"=",
"True",
",",
"wait_timeout",
"=",
"WAIT_TIMEOUT",
")",
":",
"msg_info",
"=",
"MessageInfo",
"(",
"msg",
"=",
"msg",
",",
"wait_nak",
"=",
"wait_nak",
",",
"wait_timeout",
"=",
"wait_timeout"... | Place a message on the send queue for sending.
Message are sent in the order they are placed in the queue. | [
"Place",
"a",
"message",
"on",
"the",
"send",
"queue",
"for",
"sending",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/plm.py#L178-L186 |
nugget/python-insteonplm | insteonplm/plm.py | IM.start_all_linking | def start_all_linking(self, mode, group):
"""Put the IM into All-Linking mode.
Puts the IM into All-Linking mode for 4 minutes.
Parameters:
mode: 0 | 1 | 3 | 255
0 - PLM is responder
1 - PLM is controller
3 - Device that initiat... | python | def start_all_linking(self, mode, group):
"""Put the IM into All-Linking mode.
Puts the IM into All-Linking mode for 4 minutes.
Parameters:
mode: 0 | 1 | 3 | 255
0 - PLM is responder
1 - PLM is controller
3 - Device that initiat... | [
"def",
"start_all_linking",
"(",
"self",
",",
"mode",
",",
"group",
")",
":",
"msg",
"=",
"StartAllLinking",
"(",
"mode",
",",
"group",
")",
"self",
".",
"send_msg",
"(",
"msg",
")"
] | Put the IM into All-Linking mode.
Puts the IM into All-Linking mode for 4 minutes.
Parameters:
mode: 0 | 1 | 3 | 255
0 - PLM is responder
1 - PLM is controller
3 - Device that initiated All-Linking is Controller
255 = De... | [
"Put",
"the",
"IM",
"into",
"All",
"-",
"Linking",
"mode",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/plm.py#L188-L203 |
nugget/python-insteonplm | insteonplm/plm.py | IM.add_x10_device | def add_x10_device(self, housecode, unitcode, feature='OnOff'):
"""Add an X10 device based on a feature description.
Current features are:
- OnOff
- Dimmable
- Sensor
- AllUnitsOff
- AllLightsOn
- AllLightsOff
"""
device = insteonplm.devic... | python | def add_x10_device(self, housecode, unitcode, feature='OnOff'):
"""Add an X10 device based on a feature description.
Current features are:
- OnOff
- Dimmable
- Sensor
- AllUnitsOff
- AllLightsOn
- AllLightsOff
"""
device = insteonplm.devic... | [
"def",
"add_x10_device",
"(",
"self",
",",
"housecode",
",",
"unitcode",
",",
"feature",
"=",
"'OnOff'",
")",
":",
"device",
"=",
"insteonplm",
".",
"devices",
".",
"create_x10",
"(",
"self",
",",
"housecode",
",",
"unitcode",
",",
"feature",
")",
"if",
... | Add an X10 device based on a feature description.
Current features are:
- OnOff
- Dimmable
- Sensor
- AllUnitsOff
- AllLightsOn
- AllLightsOff | [
"Add",
"an",
"X10",
"device",
"based",
"on",
"a",
"feature",
"description",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/plm.py#L205-L220 |
nugget/python-insteonplm | insteonplm/plm.py | IM.device_not_active | def device_not_active(self, addr):
"""Handle inactive devices."""
self.aldb_device_handled(addr)
for callback in self._cb_device_not_active:
callback(addr) | python | def device_not_active(self, addr):
"""Handle inactive devices."""
self.aldb_device_handled(addr)
for callback in self._cb_device_not_active:
callback(addr) | [
"def",
"device_not_active",
"(",
"self",
",",
"addr",
")",
":",
"self",
".",
"aldb_device_handled",
"(",
"addr",
")",
"for",
"callback",
"in",
"self",
".",
"_cb_device_not_active",
":",
"callback",
"(",
"addr",
")"
] | Handle inactive devices. | [
"Handle",
"inactive",
"devices",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/plm.py#L227-L231 |
nugget/python-insteonplm | insteonplm/plm.py | IM.aldb_device_handled | def aldb_device_handled(self, addr):
"""Remove device from ALDB device list."""
if isinstance(addr, Address):
remove_addr = addr.id
else:
remove_addr = addr
try:
self._aldb_devices.pop(remove_addr)
_LOGGER.debug('Removed ALDB device %s', re... | python | def aldb_device_handled(self, addr):
"""Remove device from ALDB device list."""
if isinstance(addr, Address):
remove_addr = addr.id
else:
remove_addr = addr
try:
self._aldb_devices.pop(remove_addr)
_LOGGER.debug('Removed ALDB device %s', re... | [
"def",
"aldb_device_handled",
"(",
"self",
",",
"addr",
")",
":",
"if",
"isinstance",
"(",
"addr",
",",
"Address",
")",
":",
"remove_addr",
"=",
"addr",
".",
"id",
"else",
":",
"remove_addr",
"=",
"addr",
"try",
":",
"self",
".",
"_aldb_devices",
".",
... | Remove device from ALDB device list. | [
"Remove",
"device",
"from",
"ALDB",
"device",
"list",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/plm.py#L233-L244 |
nugget/python-insteonplm | insteonplm/plm.py | IM.manage_aldb_record | def manage_aldb_record(self, control_code, control_flags, group, address,
data1, data2, data3):
"""Update an IM All-Link record.
Control Code values:
- 0x00 Find First Starting at the top of the ALDB, search for the
first ALL-Link Record matching the <ALL-Link... | python | def manage_aldb_record(self, control_code, control_flags, group, address,
data1, data2, data3):
"""Update an IM All-Link record.
Control Code values:
- 0x00 Find First Starting at the top of the ALDB, search for the
first ALL-Link Record matching the <ALL-Link... | [
"def",
"manage_aldb_record",
"(",
"self",
",",
"control_code",
",",
"control_flags",
",",
"group",
",",
"address",
",",
"data1",
",",
"data2",
",",
"data3",
")",
":",
"msg",
"=",
"ManageAllLinkRecord",
"(",
"control_code",
",",
"control_flags",
",",
"group",
... | Update an IM All-Link record.
Control Code values:
- 0x00 Find First Starting at the top of the ALDB, search for the
first ALL-Link Record matching the <ALL-Link Group> and <ID> in bytes
5 – 8. The search ignores byte 4, <ALL-Link Record Flags>. You will
receive an ACK at the en... | [
"Update",
"an",
"IM",
"All",
"-",
"Link",
"record",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/plm.py#L246-L312 |
nugget/python-insteonplm | insteonplm/plm.py | IM.pause_writing | async def pause_writing(self):
"""Pause writing."""
self._restart_writer = False
if self._writer_task:
self._writer_task.remove_done_callback(self.restart_writing)
self._writer_task.cancel()
await self._writer_task
await asyncio.sleep(0, loop=self.... | python | async def pause_writing(self):
"""Pause writing."""
self._restart_writer = False
if self._writer_task:
self._writer_task.remove_done_callback(self.restart_writing)
self._writer_task.cancel()
await self._writer_task
await asyncio.sleep(0, loop=self.... | [
"async",
"def",
"pause_writing",
"(",
"self",
")",
":",
"self",
".",
"_restart_writer",
"=",
"False",
"if",
"self",
".",
"_writer_task",
":",
"self",
".",
"_writer_task",
".",
"remove_done_callback",
"(",
"self",
".",
"restart_writing",
")",
"self",
".",
"_w... | Pause writing. | [
"Pause",
"writing",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/plm.py#L314-L321 |
nugget/python-insteonplm | insteonplm/plm.py | IM.restart_writing | def restart_writing(self, task=None):
"""Resume writing."""
if self._restart_writer:
self._writer_task = asyncio.ensure_future(
self._get_message_from_send_queue(), loop=self._loop)
self._writer_task.add_done_callback(self.restart_writing) | python | def restart_writing(self, task=None):
"""Resume writing."""
if self._restart_writer:
self._writer_task = asyncio.ensure_future(
self._get_message_from_send_queue(), loop=self._loop)
self._writer_task.add_done_callback(self.restart_writing) | [
"def",
"restart_writing",
"(",
"self",
",",
"task",
"=",
"None",
")",
":",
"if",
"self",
".",
"_restart_writer",
":",
"self",
".",
"_writer_task",
"=",
"asyncio",
".",
"ensure_future",
"(",
"self",
".",
"_get_message_from_send_queue",
"(",
")",
",",
"loop",
... | Resume writing. | [
"Resume",
"writing",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/plm.py#L324-L329 |
nugget/python-insteonplm | insteonplm/plm.py | IM._get_plm_info | def _get_plm_info(self):
"""Request PLM Info."""
_LOGGER.info('Requesting Insteon Modem Info')
msg = GetImInfo()
self.send_msg(msg, wait_nak=True, wait_timeout=.5) | python | def _get_plm_info(self):
"""Request PLM Info."""
_LOGGER.info('Requesting Insteon Modem Info')
msg = GetImInfo()
self.send_msg(msg, wait_nak=True, wait_timeout=.5) | [
"def",
"_get_plm_info",
"(",
"self",
")",
":",
"_LOGGER",
".",
"info",
"(",
"'Requesting Insteon Modem Info'",
")",
"msg",
"=",
"GetImInfo",
"(",
")",
"self",
".",
"send_msg",
"(",
"msg",
",",
"wait_nak",
"=",
"True",
",",
"wait_timeout",
"=",
".5",
")"
] | Request PLM Info. | [
"Request",
"PLM",
"Info",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/plm.py#L381-L385 |
nugget/python-insteonplm | insteonplm/plm.py | IM._load_all_link_database | def _load_all_link_database(self):
"""Load the ALL-Link Database into object."""
_LOGGER.debug("Starting: _load_all_link_database")
self.devices.state = 'loading'
self._get_first_all_link_record()
_LOGGER.debug("Ending: _load_all_link_database") | python | def _load_all_link_database(self):
"""Load the ALL-Link Database into object."""
_LOGGER.debug("Starting: _load_all_link_database")
self.devices.state = 'loading'
self._get_first_all_link_record()
_LOGGER.debug("Ending: _load_all_link_database") | [
"def",
"_load_all_link_database",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Starting: _load_all_link_database\"",
")",
"self",
".",
"devices",
".",
"state",
"=",
"'loading'",
"self",
".",
"_get_first_all_link_record",
"(",
")",
"_LOGGER",
".",
"debug... | Load the ALL-Link Database into object. | [
"Load",
"the",
"ALL",
"-",
"Link",
"Database",
"into",
"object",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/plm.py#L438-L443 |
nugget/python-insteonplm | insteonplm/plm.py | IM._get_first_all_link_record | def _get_first_all_link_record(self):
"""Request first ALL-Link record."""
_LOGGER.debug("Starting: _get_first_all_link_record")
_LOGGER.info('Requesting ALL-Link Records')
if self.aldb.status == ALDBStatus.LOADED:
self._next_all_link_rec_nak_retries = 3
self._han... | python | def _get_first_all_link_record(self):
"""Request first ALL-Link record."""
_LOGGER.debug("Starting: _get_first_all_link_record")
_LOGGER.info('Requesting ALL-Link Records')
if self.aldb.status == ALDBStatus.LOADED:
self._next_all_link_rec_nak_retries = 3
self._han... | [
"def",
"_get_first_all_link_record",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Starting: _get_first_all_link_record\"",
")",
"_LOGGER",
".",
"info",
"(",
"'Requesting ALL-Link Records'",
")",
"if",
"self",
".",
"aldb",
".",
"status",
"==",
"ALDBStatus"... | Request first ALL-Link record. | [
"Request",
"first",
"ALL",
"-",
"Link",
"record",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/plm.py#L445-L457 |
nugget/python-insteonplm | insteonplm/plm.py | IM._get_next_all_link_record | def _get_next_all_link_record(self):
"""Request next ALL-Link record."""
_LOGGER.debug("Starting: _get_next_all_link_record")
_LOGGER.debug("Requesting Next All-Link Record")
msg = GetNextAllLinkRecord()
self.send_msg(msg, wait_nak=True, wait_timeout=.5)
_LOGGER.debug("En... | python | def _get_next_all_link_record(self):
"""Request next ALL-Link record."""
_LOGGER.debug("Starting: _get_next_all_link_record")
_LOGGER.debug("Requesting Next All-Link Record")
msg = GetNextAllLinkRecord()
self.send_msg(msg, wait_nak=True, wait_timeout=.5)
_LOGGER.debug("En... | [
"def",
"_get_next_all_link_record",
"(",
"self",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Starting: _get_next_all_link_record\"",
")",
"_LOGGER",
".",
"debug",
"(",
"\"Requesting Next All-Link Record\"",
")",
"msg",
"=",
"GetNextAllLinkRecord",
"(",
")",
"self",
"."... | Request next ALL-Link record. | [
"Request",
"next",
"ALL",
"-",
"Link",
"record",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/plm.py#L459-L465 |
nugget/python-insteonplm | insteonplm/plm.py | IM.x10_all_units_off | def x10_all_units_off(self, housecode):
"""Send the X10 All Units Off command."""
if isinstance(housecode, str):
housecode = housecode.upper()
else:
raise TypeError('Housecode must be a string')
msg = X10Send.command_msg(housecode, X10_COMMAND_ALL_UNITS_OFF)
... | python | def x10_all_units_off(self, housecode):
"""Send the X10 All Units Off command."""
if isinstance(housecode, str):
housecode = housecode.upper()
else:
raise TypeError('Housecode must be a string')
msg = X10Send.command_msg(housecode, X10_COMMAND_ALL_UNITS_OFF)
... | [
"def",
"x10_all_units_off",
"(",
"self",
",",
"housecode",
")",
":",
"if",
"isinstance",
"(",
"housecode",
",",
"str",
")",
":",
"housecode",
"=",
"housecode",
".",
"upper",
"(",
")",
"else",
":",
"raise",
"TypeError",
"(",
"'Housecode must be a string'",
")... | Send the X10 All Units Off command. | [
"Send",
"the",
"X10",
"All",
"Units",
"Off",
"command",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/plm.py#L678-L686 |
nugget/python-insteonplm | insteonplm/plm.py | IM.x10_all_lights_off | def x10_all_lights_off(self, housecode):
"""Send the X10 All Lights Off command."""
msg = X10Send.command_msg(housecode, X10_COMMAND_ALL_LIGHTS_OFF)
self.send_msg(msg)
self._x10_command_to_device(housecode, X10_COMMAND_ALL_LIGHTS_OFF, msg) | python | def x10_all_lights_off(self, housecode):
"""Send the X10 All Lights Off command."""
msg = X10Send.command_msg(housecode, X10_COMMAND_ALL_LIGHTS_OFF)
self.send_msg(msg)
self._x10_command_to_device(housecode, X10_COMMAND_ALL_LIGHTS_OFF, msg) | [
"def",
"x10_all_lights_off",
"(",
"self",
",",
"housecode",
")",
":",
"msg",
"=",
"X10Send",
".",
"command_msg",
"(",
"housecode",
",",
"X10_COMMAND_ALL_LIGHTS_OFF",
")",
"self",
".",
"send_msg",
"(",
"msg",
")",
"self",
".",
"_x10_command_to_device",
"(",
"ho... | Send the X10 All Lights Off command. | [
"Send",
"the",
"X10",
"All",
"Lights",
"Off",
"command",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/plm.py#L688-L692 |
nugget/python-insteonplm | insteonplm/plm.py | IM.x10_all_lights_on | def x10_all_lights_on(self, housecode):
"""Send the X10 All Lights Off command."""
msg = X10Send.command_msg(housecode, X10_COMMAND_ALL_LIGHTS_ON)
self.send_msg(msg)
self._x10_command_to_device(housecode, X10_COMMAND_ALL_LIGHTS_ON, msg) | python | def x10_all_lights_on(self, housecode):
"""Send the X10 All Lights Off command."""
msg = X10Send.command_msg(housecode, X10_COMMAND_ALL_LIGHTS_ON)
self.send_msg(msg)
self._x10_command_to_device(housecode, X10_COMMAND_ALL_LIGHTS_ON, msg) | [
"def",
"x10_all_lights_on",
"(",
"self",
",",
"housecode",
")",
":",
"msg",
"=",
"X10Send",
".",
"command_msg",
"(",
"housecode",
",",
"X10_COMMAND_ALL_LIGHTS_ON",
")",
"self",
".",
"send_msg",
"(",
"msg",
")",
"self",
".",
"_x10_command_to_device",
"(",
"hous... | Send the X10 All Lights Off command. | [
"Send",
"the",
"X10",
"All",
"Lights",
"Off",
"command",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/plm.py#L694-L698 |
nugget/python-insteonplm | insteonplm/plm.py | PLM.connection_made | def connection_made(self, transport):
"""Start the PLM connection process.
Called when asyncio.Protocol establishes the network connection.
"""
_LOGGER.info('Connection established to PLM')
self.transport = transport
self._restart_writer = True
self.restart_writ... | python | def connection_made(self, transport):
"""Start the PLM connection process.
Called when asyncio.Protocol establishes the network connection.
"""
_LOGGER.info('Connection established to PLM')
self.transport = transport
self._restart_writer = True
self.restart_writ... | [
"def",
"connection_made",
"(",
"self",
",",
"transport",
")",
":",
"_LOGGER",
".",
"info",
"(",
"'Connection established to PLM'",
")",
"self",
".",
"transport",
"=",
"transport",
"self",
".",
"_restart_writer",
"=",
"True",
"self",
".",
"restart_writing",
"(",
... | Start the PLM connection process.
Called when asyncio.Protocol establishes the network connection. | [
"Start",
"the",
"PLM",
"connection",
"process",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/plm.py#L752-L770 |
nugget/python-insteonplm | insteonplm/plm.py | Hub.connection_made | def connection_made(self, transport):
"""Start the Hub connection process.
Called when asyncio.Protocol establishes the network connection.
"""
_LOGGER.info('Connection established to Hub')
_LOGGER.debug('Transport: %s', transport)
self.transport = transport
sel... | python | def connection_made(self, transport):
"""Start the Hub connection process.
Called when asyncio.Protocol establishes the network connection.
"""
_LOGGER.info('Connection established to Hub')
_LOGGER.debug('Transport: %s', transport)
self.transport = transport
sel... | [
"def",
"connection_made",
"(",
"self",
",",
"transport",
")",
":",
"_LOGGER",
".",
"info",
"(",
"'Connection established to Hub'",
")",
"_LOGGER",
".",
"debug",
"(",
"'Transport: %s'",
",",
"transport",
")",
"self",
".",
"transport",
"=",
"transport",
"self",
... | Start the Hub connection process.
Called when asyncio.Protocol establishes the network connection. | [
"Start",
"the",
"Hub",
"connection",
"process",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/plm.py#L795-L808 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | create | def create(plm, address, cat, subcat, firmware=None):
"""Create a device from device info data."""
from insteonplm.devices.ipdb import IPDB
ipdb = IPDB()
product = ipdb[[cat, subcat]]
deviceclass = product.deviceclass
device = None
if deviceclass is not None:
device = deviceclass(plm... | python | def create(plm, address, cat, subcat, firmware=None):
"""Create a device from device info data."""
from insteonplm.devices.ipdb import IPDB
ipdb = IPDB()
product = ipdb[[cat, subcat]]
deviceclass = product.deviceclass
device = None
if deviceclass is not None:
device = deviceclass(plm... | [
"def",
"create",
"(",
"plm",
",",
"address",
",",
"cat",
",",
"subcat",
",",
"firmware",
"=",
"None",
")",
":",
"from",
"insteonplm",
".",
"devices",
".",
"ipdb",
"import",
"IPDB",
"ipdb",
"=",
"IPDB",
"(",
")",
"product",
"=",
"ipdb",
"[",
"[",
"c... | Create a device from device info data. | [
"Create",
"a",
"device",
"from",
"device",
"info",
"data",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L55-L67 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | create_x10 | def create_x10(plm, housecode, unitcode, feature):
"""Create an X10 device from a feature definition."""
from insteonplm.devices.ipdb import IPDB
ipdb = IPDB()
product = ipdb.x10(feature)
deviceclass = product.deviceclass
device = None
if deviceclass:
device = deviceclass(plm, housec... | python | def create_x10(plm, housecode, unitcode, feature):
"""Create an X10 device from a feature definition."""
from insteonplm.devices.ipdb import IPDB
ipdb = IPDB()
product = ipdb.x10(feature)
deviceclass = product.deviceclass
device = None
if deviceclass:
device = deviceclass(plm, housec... | [
"def",
"create_x10",
"(",
"plm",
",",
"housecode",
",",
"unitcode",
",",
"feature",
")",
":",
"from",
"insteonplm",
".",
"devices",
".",
"ipdb",
"import",
"IPDB",
"ipdb",
"=",
"IPDB",
"(",
")",
"product",
"=",
"ipdb",
".",
"x10",
"(",
"feature",
")",
... | Create an X10 device from a feature definition. | [
"Create",
"an",
"X10",
"device",
"from",
"a",
"feature",
"definition",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L70-L79 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | Device.id_request | def id_request(self):
"""Request a device ID from a device."""
import inspect
curframe = inspect.currentframe()
calframe = inspect.getouterframes(curframe, 2)
_LOGGER.debug('caller name: %s', calframe[1][3])
msg = StandardSend(self.address, COMMAND_ID_REQUEST_0X10_0X00)
... | python | def id_request(self):
"""Request a device ID from a device."""
import inspect
curframe = inspect.currentframe()
calframe = inspect.getouterframes(curframe, 2)
_LOGGER.debug('caller name: %s', calframe[1][3])
msg = StandardSend(self.address, COMMAND_ID_REQUEST_0X10_0X00)
... | [
"def",
"id_request",
"(",
"self",
")",
":",
"import",
"inspect",
"curframe",
"=",
"inspect",
".",
"currentframe",
"(",
")",
"calframe",
"=",
"inspect",
".",
"getouterframes",
"(",
"curframe",
",",
"2",
")",
"_LOGGER",
".",
"debug",
"(",
"'caller name: %s'",
... | Request a device ID from a device. | [
"Request",
"a",
"device",
"ID",
"from",
"a",
"device",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L187-L194 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | Device.product_data_request | def product_data_request(self):
"""Request product data from a device.
Not supported by all devices.
Required after 01-Feb-2007.
"""
msg = StandardSend(self._address,
COMMAND_PRODUCT_DATA_REQUEST_0X03_0X00)
self._send_msg(msg) | python | def product_data_request(self):
"""Request product data from a device.
Not supported by all devices.
Required after 01-Feb-2007.
"""
msg = StandardSend(self._address,
COMMAND_PRODUCT_DATA_REQUEST_0X03_0X00)
self._send_msg(msg) | [
"def",
"product_data_request",
"(",
"self",
")",
":",
"msg",
"=",
"StandardSend",
"(",
"self",
".",
"_address",
",",
"COMMAND_PRODUCT_DATA_REQUEST_0X03_0X00",
")",
"self",
".",
"_send_msg",
"(",
"msg",
")"
] | Request product data from a device.
Not supported by all devices.
Required after 01-Feb-2007. | [
"Request",
"product",
"data",
"from",
"a",
"device",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L196-L204 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | Device.assign_to_all_link_group | def assign_to_all_link_group(self, group=0x01):
"""Assign a device to an All-Link Group.
The default is group 0x01.
"""
msg = StandardSend(self._address,
COMMAND_ASSIGN_TO_ALL_LINK_GROUP_0X01_NONE,
cmd2=group)
self._send_msg(... | python | def assign_to_all_link_group(self, group=0x01):
"""Assign a device to an All-Link Group.
The default is group 0x01.
"""
msg = StandardSend(self._address,
COMMAND_ASSIGN_TO_ALL_LINK_GROUP_0X01_NONE,
cmd2=group)
self._send_msg(... | [
"def",
"assign_to_all_link_group",
"(",
"self",
",",
"group",
"=",
"0x01",
")",
":",
"msg",
"=",
"StandardSend",
"(",
"self",
".",
"_address",
",",
"COMMAND_ASSIGN_TO_ALL_LINK_GROUP_0X01_NONE",
",",
"cmd2",
"=",
"group",
")",
"self",
".",
"_send_msg",
"(",
"ms... | Assign a device to an All-Link Group.
The default is group 0x01. | [
"Assign",
"a",
"device",
"to",
"an",
"All",
"-",
"Link",
"Group",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L206-L214 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | Device.delete_from_all_link_group | def delete_from_all_link_group(self, group):
"""Delete a device to an All-Link Group."""
msg = StandardSend(self._address,
COMMAND_DELETE_FROM_ALL_LINK_GROUP_0X02_NONE,
cmd2=group)
self._send_msg(msg) | python | def delete_from_all_link_group(self, group):
"""Delete a device to an All-Link Group."""
msg = StandardSend(self._address,
COMMAND_DELETE_FROM_ALL_LINK_GROUP_0X02_NONE,
cmd2=group)
self._send_msg(msg) | [
"def",
"delete_from_all_link_group",
"(",
"self",
",",
"group",
")",
":",
"msg",
"=",
"StandardSend",
"(",
"self",
".",
"_address",
",",
"COMMAND_DELETE_FROM_ALL_LINK_GROUP_0X02_NONE",
",",
"cmd2",
"=",
"group",
")",
"self",
".",
"_send_msg",
"(",
"msg",
")"
] | Delete a device to an All-Link Group. | [
"Delete",
"a",
"device",
"to",
"an",
"All",
"-",
"Link",
"Group",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L216-L221 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | Device.fx_username | def fx_username(self):
"""Get FX Username.
Only required for devices that support FX Commands.
FX Addressee responds with an ED 0x0301 FX Username Response message
"""
msg = StandardSend(self._address, COMMAND_FX_USERNAME_0X03_0X01)
self._send_msg(msg) | python | def fx_username(self):
"""Get FX Username.
Only required for devices that support FX Commands.
FX Addressee responds with an ED 0x0301 FX Username Response message
"""
msg = StandardSend(self._address, COMMAND_FX_USERNAME_0X03_0X01)
self._send_msg(msg) | [
"def",
"fx_username",
"(",
"self",
")",
":",
"msg",
"=",
"StandardSend",
"(",
"self",
".",
"_address",
",",
"COMMAND_FX_USERNAME_0X03_0X01",
")",
"self",
".",
"_send_msg",
"(",
"msg",
")"
] | Get FX Username.
Only required for devices that support FX Commands.
FX Addressee responds with an ED 0x0301 FX Username Response message | [
"Get",
"FX",
"Username",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L223-L230 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | Device.device_text_string_request | def device_text_string_request(self):
"""Get FX Username.
Only required for devices that support FX Commands.
FX Addressee responds with an ED 0x0301 FX Username Response message.
"""
msg = StandardSend(self._address, COMMAND_FX_USERNAME_0X03_0X01)
self._send_msg(msg) | python | def device_text_string_request(self):
"""Get FX Username.
Only required for devices that support FX Commands.
FX Addressee responds with an ED 0x0301 FX Username Response message.
"""
msg = StandardSend(self._address, COMMAND_FX_USERNAME_0X03_0X01)
self._send_msg(msg) | [
"def",
"device_text_string_request",
"(",
"self",
")",
":",
"msg",
"=",
"StandardSend",
"(",
"self",
".",
"_address",
",",
"COMMAND_FX_USERNAME_0X03_0X01",
")",
"self",
".",
"_send_msg",
"(",
"msg",
")"
] | Get FX Username.
Only required for devices that support FX Commands.
FX Addressee responds with an ED 0x0301 FX Username Response message. | [
"Get",
"FX",
"Username",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L232-L239 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | Device.enter_linking_mode | def enter_linking_mode(self, group=0x01):
"""Tell a device to enter All-Linking Mode.
Same as holding down the Set button for 10 sec.
Default group is 0x01.
Not supported by i1 devices.
"""
msg = ExtendedSend(self._address,
COMMAND_ENTER_LINKI... | python | def enter_linking_mode(self, group=0x01):
"""Tell a device to enter All-Linking Mode.
Same as holding down the Set button for 10 sec.
Default group is 0x01.
Not supported by i1 devices.
"""
msg = ExtendedSend(self._address,
COMMAND_ENTER_LINKI... | [
"def",
"enter_linking_mode",
"(",
"self",
",",
"group",
"=",
"0x01",
")",
":",
"msg",
"=",
"ExtendedSend",
"(",
"self",
".",
"_address",
",",
"COMMAND_ENTER_LINKING_MODE_0X09_NONE",
",",
"cmd2",
"=",
"group",
",",
"userdata",
"=",
"Userdata",
"(",
")",
")",
... | Tell a device to enter All-Linking Mode.
Same as holding down the Set button for 10 sec.
Default group is 0x01.
Not supported by i1 devices. | [
"Tell",
"a",
"device",
"to",
"enter",
"All",
"-",
"Linking",
"Mode",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L241-L254 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | Device.enter_unlinking_mode | def enter_unlinking_mode(self, group):
"""Unlink a device from an All-Link group.
Not supported by i1 devices.
"""
msg = StandardSend(self._address,
COMMAND_ENTER_UNLINKING_MODE_0X0A_NONE,
cmd2=group)
self._send_msg(msg) | python | def enter_unlinking_mode(self, group):
"""Unlink a device from an All-Link group.
Not supported by i1 devices.
"""
msg = StandardSend(self._address,
COMMAND_ENTER_UNLINKING_MODE_0X0A_NONE,
cmd2=group)
self._send_msg(msg) | [
"def",
"enter_unlinking_mode",
"(",
"self",
",",
"group",
")",
":",
"msg",
"=",
"StandardSend",
"(",
"self",
".",
"_address",
",",
"COMMAND_ENTER_UNLINKING_MODE_0X0A_NONE",
",",
"cmd2",
"=",
"group",
")",
"self",
".",
"_send_msg",
"(",
"msg",
")"
] | Unlink a device from an All-Link group.
Not supported by i1 devices. | [
"Unlink",
"a",
"device",
"from",
"an",
"All",
"-",
"Link",
"group",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L256-L264 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | Device.get_engine_version | def get_engine_version(self):
"""Get the device engine version."""
msg = StandardSend(self._address,
COMMAND_GET_INSTEON_ENGINE_VERSION_0X0D_0X00)
self._send_msg(msg) | python | def get_engine_version(self):
"""Get the device engine version."""
msg = StandardSend(self._address,
COMMAND_GET_INSTEON_ENGINE_VERSION_0X0D_0X00)
self._send_msg(msg) | [
"def",
"get_engine_version",
"(",
"self",
")",
":",
"msg",
"=",
"StandardSend",
"(",
"self",
".",
"_address",
",",
"COMMAND_GET_INSTEON_ENGINE_VERSION_0X0D_0X00",
")",
"self",
".",
"_send_msg",
"(",
"msg",
")"
] | Get the device engine version. | [
"Get",
"the",
"device",
"engine",
"version",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L266-L270 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | Device.ping | def ping(self):
"""Ping a device."""
msg = StandardSend(self._address, COMMAND_PING_0X0F_0X00)
self._send_msg(msg) | python | def ping(self):
"""Ping a device."""
msg = StandardSend(self._address, COMMAND_PING_0X0F_0X00)
self._send_msg(msg) | [
"def",
"ping",
"(",
"self",
")",
":",
"msg",
"=",
"StandardSend",
"(",
"self",
".",
"_address",
",",
"COMMAND_PING_0X0F_0X00",
")",
"self",
".",
"_send_msg",
"(",
"msg",
")"
] | Ping a device. | [
"Ping",
"a",
"device",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L272-L275 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | Device.create_default_links | def create_default_links(self):
"""Create the default links between the IM and the device."""
self._plm.manage_aldb_record(0x40, 0xe2, 0x00, self.address,
self.cat, self.subcat, self.product_key)
self.manage_aldb_record(0x41, 0xa2, 0x00, self._plm.address,
... | python | def create_default_links(self):
"""Create the default links between the IM and the device."""
self._plm.manage_aldb_record(0x40, 0xe2, 0x00, self.address,
self.cat, self.subcat, self.product_key)
self.manage_aldb_record(0x41, 0xa2, 0x00, self._plm.address,
... | [
"def",
"create_default_links",
"(",
"self",
")",
":",
"self",
".",
"_plm",
".",
"manage_aldb_record",
"(",
"0x40",
",",
"0xe2",
",",
"0x00",
",",
"self",
".",
"address",
",",
"self",
".",
"cat",
",",
"self",
".",
"subcat",
",",
"self",
".",
"product_ke... | Create the default links between the IM and the device. | [
"Create",
"the",
"default",
"links",
"between",
"the",
"IM",
"and",
"the",
"device",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L277-L301 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | Device.read_aldb | def read_aldb(self, mem_addr=0x0000, num_recs=0):
"""Read the device All-Link Database."""
if self._aldb.version == ALDBVersion.Null:
_LOGGER.info('Device %s does not contain an All-Link Database',
self._address.human)
else:
_LOGGER.info('Reading ... | python | def read_aldb(self, mem_addr=0x0000, num_recs=0):
"""Read the device All-Link Database."""
if self._aldb.version == ALDBVersion.Null:
_LOGGER.info('Device %s does not contain an All-Link Database',
self._address.human)
else:
_LOGGER.info('Reading ... | [
"def",
"read_aldb",
"(",
"self",
",",
"mem_addr",
"=",
"0x0000",
",",
"num_recs",
"=",
"0",
")",
":",
"if",
"self",
".",
"_aldb",
".",
"version",
"==",
"ALDBVersion",
".",
"Null",
":",
"_LOGGER",
".",
"info",
"(",
"'Device %s does not contain an All-Link Dat... | Read the device All-Link Database. | [
"Read",
"the",
"device",
"All",
"-",
"Link",
"Database",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L303-L313 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | Device.manage_aldb_record | def manage_aldb_record(self, control_code, control_flags, group, address,
data1, data2, data3):
"""Update an IM All-Link record.
Control Code values:
- 0x00 Find First Starting at the top of the ALDB, search for the
first ALL-Link Record matching the <ALL-Link... | python | def manage_aldb_record(self, control_code, control_flags, group, address,
data1, data2, data3):
"""Update an IM All-Link record.
Control Code values:
- 0x00 Find First Starting at the top of the ALDB, search for the
first ALL-Link Record matching the <ALL-Link... | [
"def",
"manage_aldb_record",
"(",
"self",
",",
"control_code",
",",
"control_flags",
",",
"group",
",",
"address",
",",
"data1",
",",
"data2",
",",
"data3",
")",
":",
"found_first",
"=",
"False",
"for",
"memaddr",
"in",
"self",
".",
"aldb",
":",
"found",
... | Update an IM All-Link record.
Control Code values:
- 0x00 Find First Starting at the top of the ALDB, search for the
first ALL-Link Record matching the <ALL-Link Group> and <ID> in bytes
5 – 8. The search ignores byte 4, <ALL-Link Record Flags>. You will
receive an ACK at the en... | [
"Update",
"an",
"IM",
"All",
"-",
"Link",
"record",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L318-L430 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | Device.write_aldb | def write_aldb(self, mem_addr: int, mode: str, group: int, target,
data1=0x00, data2=0x00, data3=0x00):
"""Write to the device All-Link Database.
Parameters:
Required:
mode: r - device is a responder of target
c - device is a controller o... | python | def write_aldb(self, mem_addr: int, mode: str, group: int, target,
data1=0x00, data2=0x00, data3=0x00):
"""Write to the device All-Link Database.
Parameters:
Required:
mode: r - device is a responder of target
c - device is a controller o... | [
"def",
"write_aldb",
"(",
"self",
",",
"mem_addr",
":",
"int",
",",
"mode",
":",
"str",
",",
"group",
":",
"int",
",",
"target",
",",
"data1",
"=",
"0x00",
",",
"data2",
"=",
"0x00",
",",
"data3",
"=",
"0x00",
")",
":",
"if",
"isinstance",
"(",
"... | Write to the device All-Link Database.
Parameters:
Required:
mode: r - device is a responder of target
c - device is a controller of target
group: Link group
target: Address of the other device
Optional:
data1: Dev... | [
"Write",
"to",
"the",
"device",
"All",
"-",
"Link",
"Database",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L441-L473 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | Device.del_aldb | def del_aldb(self, mem_addr: int):
"""Delete an All-Link Database record."""
self._aldb.del_record(mem_addr)
self._aldb.add_loaded_callback(self._aldb_loaded_callback) | python | def del_aldb(self, mem_addr: int):
"""Delete an All-Link Database record."""
self._aldb.del_record(mem_addr)
self._aldb.add_loaded_callback(self._aldb_loaded_callback) | [
"def",
"del_aldb",
"(",
"self",
",",
"mem_addr",
":",
"int",
")",
":",
"self",
".",
"_aldb",
".",
"del_record",
"(",
"mem_addr",
")",
"self",
".",
"_aldb",
".",
"add_loaded_callback",
"(",
"self",
".",
"_aldb_loaded_callback",
")"
] | Delete an All-Link Database record. | [
"Delete",
"an",
"All",
"-",
"Link",
"Database",
"record",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L475-L478 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | Device._refresh_aldb_records | def _refresh_aldb_records(self, linkcode, address, group):
"""Refresh the IM and device ALDB records."""
if self.aldb.status in [ALDBStatus.LOADED, ALDBStatus.PARTIAL]:
for mem_addr in self.aldb:
rec = self.aldb[mem_addr]
if linkcode in [0, 1, 3]:
... | python | def _refresh_aldb_records(self, linkcode, address, group):
"""Refresh the IM and device ALDB records."""
if self.aldb.status in [ALDBStatus.LOADED, ALDBStatus.PARTIAL]:
for mem_addr in self.aldb:
rec = self.aldb[mem_addr]
if linkcode in [0, 1, 3]:
... | [
"def",
"_refresh_aldb_records",
"(",
"self",
",",
"linkcode",
",",
"address",
",",
"group",
")",
":",
"if",
"self",
".",
"aldb",
".",
"status",
"in",
"[",
"ALDBStatus",
".",
"LOADED",
",",
"ALDBStatus",
".",
"PARTIAL",
"]",
":",
"for",
"mem_addr",
"in",
... | Refresh the IM and device ALDB records. | [
"Refresh",
"the",
"IM",
"and",
"device",
"ALDB",
"records",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L537-L556 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | Device.receive_message | def receive_message(self, msg):
"""Receive a messages sent to this device."""
_LOGGER.debug('Starting Device.receive_message')
if hasattr(msg, 'isack') and msg.isack:
_LOGGER.debug('Got Message ACK')
if self._sent_msg_wait_for_directACK.get('callback') is not None:
... | python | def receive_message(self, msg):
"""Receive a messages sent to this device."""
_LOGGER.debug('Starting Device.receive_message')
if hasattr(msg, 'isack') and msg.isack:
_LOGGER.debug('Got Message ACK')
if self._sent_msg_wait_for_directACK.get('callback') is not None:
... | [
"def",
"receive_message",
"(",
"self",
",",
"msg",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"'Starting Device.receive_message'",
")",
"if",
"hasattr",
"(",
"msg",
",",
"'isack'",
")",
"and",
"msg",
".",
"isack",
":",
"_LOGGER",
".",
"debug",
"(",
"'Got Mess... | Receive a messages sent to this device. | [
"Receive",
"a",
"messages",
"sent",
"to",
"this",
"device",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L666-L696 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | X10Device.receive_message | def receive_message(self, msg):
"""Receive a message sent to this device."""
_LOGGER.debug('Starting X10Device.receive_message')
if hasattr(msg, 'isack') and msg.isack:
_LOGGER.debug('Got Message ACK')
if self._send_msg_lock.locked():
self._send_msg_lock.r... | python | def receive_message(self, msg):
"""Receive a message sent to this device."""
_LOGGER.debug('Starting X10Device.receive_message')
if hasattr(msg, 'isack') and msg.isack:
_LOGGER.debug('Got Message ACK')
if self._send_msg_lock.locked():
self._send_msg_lock.r... | [
"def",
"receive_message",
"(",
"self",
",",
"msg",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"'Starting X10Device.receive_message'",
")",
"if",
"hasattr",
"(",
"msg",
",",
"'isack'",
")",
"and",
"msg",
".",
"isack",
":",
"_LOGGER",
".",
"debug",
"(",
"'Got M... | Receive a message sent to this device. | [
"Receive",
"a",
"message",
"sent",
"to",
"this",
"device",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L851-L864 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | StateList.add | def add(self, plm, device, stateType, stateName, group, defaultValue=None):
"""Add a state to the StateList."""
self._stateList[group] = stateType(plm, device, stateName, group,
defaultValue=defaultValue) | python | def add(self, plm, device, stateType, stateName, group, defaultValue=None):
"""Add a state to the StateList."""
self._stateList[group] = stateType(plm, device, stateName, group,
defaultValue=defaultValue) | [
"def",
"add",
"(",
"self",
",",
"plm",
",",
"device",
",",
"stateType",
",",
"stateName",
",",
"group",
",",
"defaultValue",
"=",
"None",
")",
":",
"self",
".",
"_stateList",
"[",
"group",
"]",
"=",
"stateType",
"(",
"plm",
",",
"device",
",",
"state... | Add a state to the StateList. | [
"Add",
"a",
"state",
"to",
"the",
"StateList",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L922-L925 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | ALDBRecord.create_from_userdata | def create_from_userdata(userdata):
"""Create ALDB Record from the userdata dictionary."""
memhi = userdata.get('d3')
memlo = userdata.get('d4')
memory = memhi << 8 | memlo
control_flags = userdata.get('d6')
group = userdata.get('d7')
addrhi = userdata.get('d8')
... | python | def create_from_userdata(userdata):
"""Create ALDB Record from the userdata dictionary."""
memhi = userdata.get('d3')
memlo = userdata.get('d4')
memory = memhi << 8 | memlo
control_flags = userdata.get('d6')
group = userdata.get('d7')
addrhi = userdata.get('d8')
... | [
"def",
"create_from_userdata",
"(",
"userdata",
")",
":",
"memhi",
"=",
"userdata",
".",
"get",
"(",
"'d3'",
")",
"memlo",
"=",
"userdata",
".",
"get",
"(",
"'d4'",
")",
"memory",
"=",
"memhi",
"<<",
"8",
"|",
"memlo",
"control_flags",
"=",
"userdata",
... | Create ALDB Record from the userdata dictionary. | [
"Create",
"ALDB",
"Record",
"from",
"the",
"userdata",
"dictionary",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L1009-L1024 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | ALDBRecord.to_userdata | def to_userdata(self):
"""Return a Userdata dictionary."""
userdata = Userdata({'d3': self.memhi,
'd4': self.memlo,
'd6': self.control_flags,
'd7': self.group,
'd8': self.address.bytes[2],... | python | def to_userdata(self):
"""Return a Userdata dictionary."""
userdata = Userdata({'d3': self.memhi,
'd4': self.memlo,
'd6': self.control_flags,
'd7': self.group,
'd8': self.address.bytes[2],... | [
"def",
"to_userdata",
"(",
"self",
")",
":",
"userdata",
"=",
"Userdata",
"(",
"{",
"'d3'",
":",
"self",
".",
"memhi",
",",
"'d4'",
":",
"self",
".",
"memlo",
",",
"'d6'",
":",
"self",
".",
"control_flags",
",",
"'d7'",
":",
"self",
".",
"group",
"... | Return a Userdata dictionary. | [
"Return",
"a",
"Userdata",
"dictionary",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L1026-L1038 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | ControlFlags.byte | def byte(self):
"""Return a byte representation of ControlFlags."""
flags = int(self._in_use) << 7 \
| int(self._controller) << 6 \
| int(self._bit5) << 5 \
| int(self._bit4) << 4 \
| int(self._used_before) << 1
return flags | python | def byte(self):
"""Return a byte representation of ControlFlags."""
flags = int(self._in_use) << 7 \
| int(self._controller) << 6 \
| int(self._bit5) << 5 \
| int(self._bit4) << 4 \
| int(self._used_before) << 1
return flags | [
"def",
"byte",
"(",
"self",
")",
":",
"flags",
"=",
"int",
"(",
"self",
".",
"_in_use",
")",
"<<",
"7",
"|",
"int",
"(",
"self",
".",
"_controller",
")",
"<<",
"6",
"|",
"int",
"(",
"self",
".",
"_bit5",
")",
"<<",
"5",
"|",
"int",
"(",
"self... | Return a byte representation of ControlFlags. | [
"Return",
"a",
"byte",
"representation",
"of",
"ControlFlags",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L1099-L1106 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | ControlFlags.create_from_byte | def create_from_byte(control_flags):
"""Create a ControlFlags class from a control flags byte."""
in_use = bool(control_flags & 1 << 7)
controller = bool(control_flags & 1 << 6)
bit5 = bool(control_flags & 1 << 5)
bit4 = bool(control_flags & 1 << 4)
used_before = bool(con... | python | def create_from_byte(control_flags):
"""Create a ControlFlags class from a control flags byte."""
in_use = bool(control_flags & 1 << 7)
controller = bool(control_flags & 1 << 6)
bit5 = bool(control_flags & 1 << 5)
bit4 = bool(control_flags & 1 << 4)
used_before = bool(con... | [
"def",
"create_from_byte",
"(",
"control_flags",
")",
":",
"in_use",
"=",
"bool",
"(",
"control_flags",
"&",
"1",
"<<",
"7",
")",
"controller",
"=",
"bool",
"(",
"control_flags",
"&",
"1",
"<<",
"6",
")",
"bit5",
"=",
"bool",
"(",
"control_flags",
"&",
... | Create a ControlFlags class from a control flags byte. | [
"Create",
"a",
"ControlFlags",
"class",
"from",
"a",
"control",
"flags",
"byte",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L1109-L1118 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | ALDB.add_loaded_callback | def add_loaded_callback(self, callback):
"""Add a callback to be run when the ALDB load is complete."""
if callback not in self._cb_aldb_loaded:
self._cb_aldb_loaded.append(callback) | python | def add_loaded_callback(self, callback):
"""Add a callback to be run when the ALDB load is complete."""
if callback not in self._cb_aldb_loaded:
self._cb_aldb_loaded.append(callback) | [
"def",
"add_loaded_callback",
"(",
"self",
",",
"callback",
")",
":",
"if",
"callback",
"not",
"in",
"self",
".",
"_cb_aldb_loaded",
":",
"self",
".",
"_cb_aldb_loaded",
".",
"append",
"(",
"callback",
")"
] | Add a callback to be run when the ALDB load is complete. | [
"Add",
"a",
"callback",
"to",
"be",
"run",
"when",
"the",
"ALDB",
"load",
"is",
"complete",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L1207-L1210 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | ALDB.load | async def load(self, mem_addr=0x0000, rec_count=0, retry=0):
"""Read the device database and load."""
if self._version == ALDBVersion.Null:
self._status = ALDBStatus.LOADED
_LOGGER.debug('Device has no ALDB')
else:
self._status = ALDBStatus.LOADING
... | python | async def load(self, mem_addr=0x0000, rec_count=0, retry=0):
"""Read the device database and load."""
if self._version == ALDBVersion.Null:
self._status = ALDBStatus.LOADED
_LOGGER.debug('Device has no ALDB')
else:
self._status = ALDBStatus.LOADING
... | [
"async",
"def",
"load",
"(",
"self",
",",
"mem_addr",
"=",
"0x0000",
",",
"rec_count",
"=",
"0",
",",
"retry",
"=",
"0",
")",
":",
"if",
"self",
".",
"_version",
"==",
"ALDBVersion",
".",
"Null",
":",
"self",
".",
"_status",
"=",
"ALDBStatus",
".",
... | Read the device database and load. | [
"Read",
"the",
"device",
"database",
"and",
"load",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L1212-L1255 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | ALDB.write_record | def write_record(self, mem_addr: int, mode: str, group: int, target,
data1=0x00, data2=0x00, data3=0x00):
"""Write an All-Link database record."""
if not (self._have_first_record() and self._have_last_record()):
_LOGGER.error('Must load the Insteon All-Link Database befo... | python | def write_record(self, mem_addr: int, mode: str, group: int, target,
data1=0x00, data2=0x00, data3=0x00):
"""Write an All-Link database record."""
if not (self._have_first_record() and self._have_last_record()):
_LOGGER.error('Must load the Insteon All-Link Database befo... | [
"def",
"write_record",
"(",
"self",
",",
"mem_addr",
":",
"int",
",",
"mode",
":",
"str",
",",
"group",
":",
"int",
",",
"target",
",",
"data1",
"=",
"0x00",
",",
"data2",
"=",
"0x00",
",",
"data3",
"=",
"0x00",
")",
":",
"if",
"not",
"(",
"self"... | Write an All-Link database record. | [
"Write",
"an",
"All",
"-",
"Link",
"database",
"record",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L1266-L1302 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | ALDB.del_record | def del_record(self, mem_addr: int):
"""Write an All-Link database record."""
record = self._records.get(mem_addr)
if not record:
_LOGGER.error('Must load the Insteon All-Link Database record '
'before deleting it')
else:
self._prior_stat... | python | def del_record(self, mem_addr: int):
"""Write an All-Link database record."""
record = self._records.get(mem_addr)
if not record:
_LOGGER.error('Must load the Insteon All-Link Database record '
'before deleting it')
else:
self._prior_stat... | [
"def",
"del_record",
"(",
"self",
",",
"mem_addr",
":",
"int",
")",
":",
"record",
"=",
"self",
".",
"_records",
".",
"get",
"(",
"mem_addr",
")",
"if",
"not",
"record",
":",
"_LOGGER",
".",
"error",
"(",
"'Must load the Insteon All-Link Database record '",
... | Write an All-Link database record. | [
"Write",
"an",
"All",
"-",
"Link",
"database",
"record",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L1305-L1345 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | ALDB.find_matching_link | def find_matching_link(self, mode, group, addr):
"""Find a matching link in the current device.
Mode: r | c is the mode of the link in the linked device
This method will search for a corresponding link in the
reverse direction.
group: All-Link group number
ad... | python | def find_matching_link(self, mode, group, addr):
"""Find a matching link in the current device.
Mode: r | c is the mode of the link in the linked device
This method will search for a corresponding link in the
reverse direction.
group: All-Link group number
ad... | [
"def",
"find_matching_link",
"(",
"self",
",",
"mode",
",",
"group",
",",
"addr",
")",
":",
"found_rec",
"=",
"None",
"mode_test",
"=",
"None",
"if",
"mode",
".",
"lower",
"(",
")",
"in",
"[",
"'c'",
",",
"'r'",
"]",
":",
"link_group",
"=",
"int",
... | Find a matching link in the current device.
Mode: r | c is the mode of the link in the linked device
This method will search for a corresponding link in the
reverse direction.
group: All-Link group number
addr: Inteon address of the linked device | [
"Find",
"a",
"matching",
"link",
"in",
"the",
"current",
"device",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L1347-L1371 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | ALDB.record_received | def record_received(self, msg):
"""Handle ALDB record received from device."""
release_lock = False
userdata = msg.userdata
rec = ALDBRecord.create_from_userdata(userdata)
self._records[rec.mem_addr] = rec
_LOGGER.debug('ALDB Record: %s', rec)
rec_count = self._... | python | def record_received(self, msg):
"""Handle ALDB record received from device."""
release_lock = False
userdata = msg.userdata
rec = ALDBRecord.create_from_userdata(userdata)
self._records[rec.mem_addr] = rec
_LOGGER.debug('ALDB Record: %s', rec)
rec_count = self._... | [
"def",
"record_received",
"(",
"self",
",",
"msg",
")",
":",
"release_lock",
"=",
"False",
"userdata",
"=",
"msg",
".",
"userdata",
"rec",
"=",
"ALDBRecord",
".",
"create_from_userdata",
"(",
"userdata",
")",
"self",
".",
"_records",
"[",
"rec",
".",
"mem_... | Handle ALDB record received from device. | [
"Handle",
"ALDB",
"record",
"received",
"from",
"device",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L1373-L1391 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | ALDB.load_saved_records | def load_saved_records(self, status, records):
"""Load ALDB records from a set of saved records."""
if isinstance(status, ALDBStatus):
self._status = status
else:
self._status = ALDBStatus(status)
for mem_addr in records:
rec = records[mem_addr]
... | python | def load_saved_records(self, status, records):
"""Load ALDB records from a set of saved records."""
if isinstance(status, ALDBStatus):
self._status = status
else:
self._status = ALDBStatus(status)
for mem_addr in records:
rec = records[mem_addr]
... | [
"def",
"load_saved_records",
"(",
"self",
",",
"status",
",",
"records",
")",
":",
"if",
"isinstance",
"(",
"status",
",",
"ALDBStatus",
")",
":",
"self",
".",
"_status",
"=",
"status",
"else",
":",
"self",
".",
"_status",
"=",
"ALDBStatus",
"(",
"status... | Load ALDB records from a set of saved records. | [
"Load",
"ALDB",
"records",
"from",
"a",
"set",
"of",
"saved",
"records",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L1393-L1414 |
nugget/python-insteonplm | insteonplm/devices/__init__.py | ALDB._set_load_action | def _set_load_action(self, mem_addr, rec_count, retries,
read_complete=False):
"""Calculate the next record to read.
If the last record was successful and one record was being read then
look for the next record until we get to the high water mark.
If the last r... | python | def _set_load_action(self, mem_addr, rec_count, retries,
read_complete=False):
"""Calculate the next record to read.
If the last record was successful and one record was being read then
look for the next record until we get to the high water mark.
If the last r... | [
"def",
"_set_load_action",
"(",
"self",
",",
"mem_addr",
",",
"rec_count",
",",
"retries",
",",
"read_complete",
"=",
"False",
")",
":",
"if",
"self",
".",
"_have_all_records",
"(",
")",
":",
"mem_addr",
"=",
"None",
"rec_count",
"=",
"0",
"retries",
"=",
... | Calculate the next record to read.
If the last record was successful and one record was being read then
look for the next record until we get to the high water mark.
If the last read was successful and all records were being read then
look for the first record.
if the last rea... | [
"Calculate",
"the",
"next",
"record",
"to",
"read",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/devices/__init__.py#L1497-L1543 |
nugget/python-insteonplm | insteonplm/states/__init__.py | State.register_updates | def register_updates(self, callback):
"""Register a callback to notify a listener of state changes."""
_LOGGER.debug("Registered callback for state: %s", self._stateName)
self._observer_callbacks.append(callback) | python | def register_updates(self, callback):
"""Register a callback to notify a listener of state changes."""
_LOGGER.debug("Registered callback for state: %s", self._stateName)
self._observer_callbacks.append(callback) | [
"def",
"register_updates",
"(",
"self",
",",
"callback",
")",
":",
"_LOGGER",
".",
"debug",
"(",
"\"Registered callback for state: %s\"",
",",
"self",
".",
"_stateName",
")",
"self",
".",
"_observer_callbacks",
".",
"append",
"(",
"callback",
")"
] | Register a callback to notify a listener of state changes. | [
"Register",
"a",
"callback",
"to",
"notify",
"a",
"listener",
"of",
"state",
"changes",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/__init__.py#L114-L117 |
nugget/python-insteonplm | insteonplm/states/__init__.py | State._update_subscribers | def _update_subscribers(self, val):
"""Save state value and notify listeners of the change."""
self._value = val
for callback in self._observer_callbacks:
callback(self._address, self._group, val) | python | def _update_subscribers(self, val):
"""Save state value and notify listeners of the change."""
self._value = val
for callback in self._observer_callbacks:
callback(self._address, self._group, val) | [
"def",
"_update_subscribers",
"(",
"self",
",",
"val",
")",
":",
"self",
".",
"_value",
"=",
"val",
"for",
"callback",
"in",
"self",
".",
"_observer_callbacks",
":",
"callback",
"(",
"self",
".",
"_address",
",",
"self",
".",
"_group",
",",
"val",
")"
] | Save state value and notify listeners of the change. | [
"Save",
"state",
"value",
"and",
"notify",
"listeners",
"of",
"the",
"change",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/states/__init__.py#L119-L123 |
nugget/python-insteonplm | insteonplm/messages/extendedReceive.py | ExtendedReceive.from_raw_message | def from_raw_message(cls, rawmessage):
"""Create message from raw byte stream."""
userdata = Userdata.from_raw_message(rawmessage[11:25])
return ExtendedReceive(rawmessage[2:5],
rawmessage[5:8],
{'cmd1': rawmessage[9],
... | python | def from_raw_message(cls, rawmessage):
"""Create message from raw byte stream."""
userdata = Userdata.from_raw_message(rawmessage[11:25])
return ExtendedReceive(rawmessage[2:5],
rawmessage[5:8],
{'cmd1': rawmessage[9],
... | [
"def",
"from_raw_message",
"(",
"cls",
",",
"rawmessage",
")",
":",
"userdata",
"=",
"Userdata",
".",
"from_raw_message",
"(",
"rawmessage",
"[",
"11",
":",
"25",
"]",
")",
"return",
"ExtendedReceive",
"(",
"rawmessage",
"[",
"2",
":",
"5",
"]",
",",
"ra... | Create message from raw byte stream. | [
"Create",
"message",
"from",
"raw",
"byte",
"stream",
"."
] | train | https://github.com/nugget/python-insteonplm/blob/65548041f1b0729ae1ae904443dd81b0c6cbf1bf/insteonplm/messages/extendedReceive.py#L46-L54 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.