id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
45,600
mapnik/Cascadenik
cascadenik/compile.py
post_process_symbolizer_image_file
def post_process_symbolizer_image_file(file_href, dirs): """ Given an image file href and a set of directories, modify the image file name so it's correct with respect to the output and cache directories. """ # support latest mapnik features of auto-detection # of image sizes and jpeg reading su...
python
def post_process_symbolizer_image_file(file_href, dirs): """ Given an image file href and a set of directories, modify the image file name so it's correct with respect to the output and cache directories. """ # support latest mapnik features of auto-detection # of image sizes and jpeg reading su...
[ "def", "post_process_symbolizer_image_file", "(", "file_href", ",", "dirs", ")", ":", "# support latest mapnik features of auto-detection", "# of image sizes and jpeg reading support...", "# http://trac.mapnik.org/ticket/508", "mapnik_auto_image_support", "=", "(", "MAPNIK_VERSION", ">...
Given an image file href and a set of directories, modify the image file name so it's correct with respect to the output and cache directories.
[ "Given", "an", "image", "file", "href", "and", "a", "set", "of", "directories", "modify", "the", "image", "file", "name", "so", "it", "s", "correct", "with", "respect", "to", "the", "output", "and", "cache", "directories", "." ]
82f66859340a31dfcb24af127274f262d4f3ad85
https://github.com/mapnik/Cascadenik/blob/82f66859340a31dfcb24af127274f262d4f3ad85/cascadenik/compile.py#L1119-L1165
45,601
mapnik/Cascadenik
cascadenik/compile.py
localize_shapefile
def localize_shapefile(shp_href, dirs): """ Given a shapefile href and a set of directories, modify the shapefile name so it's correct with respect to the output and cache directories. """ # support latest mapnik features of auto-detection # of image sizes and jpeg reading support... # http:...
python
def localize_shapefile(shp_href, dirs): """ Given a shapefile href and a set of directories, modify the shapefile name so it's correct with respect to the output and cache directories. """ # support latest mapnik features of auto-detection # of image sizes and jpeg reading support... # http:...
[ "def", "localize_shapefile", "(", "shp_href", ",", "dirs", ")", ":", "# support latest mapnik features of auto-detection", "# of image sizes and jpeg reading support...", "# http://trac.mapnik.org/ticket/508", "mapnik_requires_absolute_paths", "=", "(", "MAPNIK_VERSION", "<", "601", ...
Given a shapefile href and a set of directories, modify the shapefile name so it's correct with respect to the output and cache directories.
[ "Given", "a", "shapefile", "href", "and", "a", "set", "of", "directories", "modify", "the", "shapefile", "name", "so", "it", "s", "correct", "with", "respect", "to", "the", "output", "and", "cache", "directories", "." ]
82f66859340a31dfcb24af127274f262d4f3ad85
https://github.com/mapnik/Cascadenik/blob/82f66859340a31dfcb24af127274f262d4f3ad85/cascadenik/compile.py#L1385-L1421
45,602
mapnik/Cascadenik
cascadenik/compile.py
localize_file_datasource
def localize_file_datasource(file_href, dirs): """ Handle localizing file-based datasources other than shapefiles. This will only work for single-file based types. """ # support latest mapnik features of auto-detection # of image sizes and jpeg reading support... # http://trac.mapnik.or...
python
def localize_file_datasource(file_href, dirs): """ Handle localizing file-based datasources other than shapefiles. This will only work for single-file based types. """ # support latest mapnik features of auto-detection # of image sizes and jpeg reading support... # http://trac.mapnik.or...
[ "def", "localize_file_datasource", "(", "file_href", ",", "dirs", ")", ":", "# support latest mapnik features of auto-detection", "# of image sizes and jpeg reading support...", "# http://trac.mapnik.org/ticket/508", "mapnik_requires_absolute_paths", "=", "(", "MAPNIK_VERSION", "<", ...
Handle localizing file-based datasources other than shapefiles. This will only work for single-file based types.
[ "Handle", "localizing", "file", "-", "based", "datasources", "other", "than", "shapefiles", ".", "This", "will", "only", "work", "for", "single", "-", "file", "based", "types", "." ]
82f66859340a31dfcb24af127274f262d4f3ad85
https://github.com/mapnik/Cascadenik/blob/82f66859340a31dfcb24af127274f262d4f3ad85/cascadenik/compile.py#L1423-L1447
45,603
mapnik/Cascadenik
cascadenik/compile.py
Range.midpoint
def midpoint(self): """ Return a point guranteed to fall within this range, hopefully near the middle. """ minpoint = self.leftedge if self.leftop is gt: minpoint += 1 maxpoint = self.rightedge if self.rightop is lt: maxpoint -= 1 i...
python
def midpoint(self): """ Return a point guranteed to fall within this range, hopefully near the middle. """ minpoint = self.leftedge if self.leftop is gt: minpoint += 1 maxpoint = self.rightedge if self.rightop is lt: maxpoint -= 1 i...
[ "def", "midpoint", "(", "self", ")", ":", "minpoint", "=", "self", ".", "leftedge", "if", "self", ".", "leftop", "is", "gt", ":", "minpoint", "+=", "1", "maxpoint", "=", "self", ".", "rightedge", "if", "self", ".", "rightop", "is", "lt", ":", "maxpoi...
Return a point guranteed to fall within this range, hopefully near the middle.
[ "Return", "a", "point", "guranteed", "to", "fall", "within", "this", "range", "hopefully", "near", "the", "middle", "." ]
82f66859340a31dfcb24af127274f262d4f3ad85
https://github.com/mapnik/Cascadenik/blob/82f66859340a31dfcb24af127274f262d4f3ad85/cascadenik/compile.py#L186-L206
45,604
mapnik/Cascadenik
cascadenik/compile.py
Range.isOpen
def isOpen(self): """ Return true if this range has any room in it. """ if self.leftedge and self.rightedge and self.leftedge > self.rightedge: return False if self.leftedge == self.rightedge: if self.leftop is gt or self.rightop is lt: return...
python
def isOpen(self): """ Return true if this range has any room in it. """ if self.leftedge and self.rightedge and self.leftedge > self.rightedge: return False if self.leftedge == self.rightedge: if self.leftop is gt or self.rightop is lt: return...
[ "def", "isOpen", "(", "self", ")", ":", "if", "self", ".", "leftedge", "and", "self", ".", "rightedge", "and", "self", ".", "leftedge", ">", "self", ".", "rightedge", ":", "return", "False", "if", "self", ".", "leftedge", "==", "self", ".", "rightedge"...
Return true if this range has any room in it.
[ "Return", "true", "if", "this", "range", "has", "any", "room", "in", "it", "." ]
82f66859340a31dfcb24af127274f262d4f3ad85
https://github.com/mapnik/Cascadenik/blob/82f66859340a31dfcb24af127274f262d4f3ad85/cascadenik/compile.py#L208-L218
45,605
mapnik/Cascadenik
cascadenik/compile.py
Range.toFilter
def toFilter(self, property): """ Convert this range to a Filter with a tests having a given property. """ if self.leftedge == self.rightedge and self.leftop is ge and self.rightop is le: # equivalent to == return Filter(style.SelectorAttributeTest(property, '=', self.lef...
python
def toFilter(self, property): """ Convert this range to a Filter with a tests having a given property. """ if self.leftedge == self.rightedge and self.leftop is ge and self.rightop is le: # equivalent to == return Filter(style.SelectorAttributeTest(property, '=', self.lef...
[ "def", "toFilter", "(", "self", ",", "property", ")", ":", "if", "self", ".", "leftedge", "==", "self", ".", "rightedge", "and", "self", ".", "leftop", "is", "ge", "and", "self", ".", "rightop", "is", "le", ":", "# equivalent to ==", "return", "Filter", ...
Convert this range to a Filter with a tests having a given property.
[ "Convert", "this", "range", "to", "a", "Filter", "with", "a", "tests", "having", "a", "given", "property", "." ]
82f66859340a31dfcb24af127274f262d4f3ad85
https://github.com/mapnik/Cascadenik/blob/82f66859340a31dfcb24af127274f262d4f3ad85/cascadenik/compile.py#L220-L237
45,606
mapnik/Cascadenik
cascadenik/compile.py
Filter.isOpen
def isOpen(self): """ Return true if this filter is not trivially false, i.e. self-contradictory. """ equals = {} nequals = {} for test in self.tests: if test.op == '=': if equals.has_key(test.property) and test.value != equals[test.property]:...
python
def isOpen(self): """ Return true if this filter is not trivially false, i.e. self-contradictory. """ equals = {} nequals = {} for test in self.tests: if test.op == '=': if equals.has_key(test.property) and test.value != equals[test.property]:...
[ "def", "isOpen", "(", "self", ")", ":", "equals", "=", "{", "}", "nequals", "=", "{", "}", "for", "test", "in", "self", ".", "tests", ":", "if", "test", ".", "op", "==", "'='", ":", "if", "equals", ".", "has_key", "(", "test", ".", "property", ...
Return true if this filter is not trivially false, i.e. self-contradictory.
[ "Return", "true", "if", "this", "filter", "is", "not", "trivially", "false", "i", ".", "e", ".", "self", "-", "contradictory", "." ]
82f66859340a31dfcb24af127274f262d4f3ad85
https://github.com/mapnik/Cascadenik/blob/82f66859340a31dfcb24af127274f262d4f3ad85/cascadenik/compile.py#L265-L293
45,607
mapnik/Cascadenik
cascadenik/compile.py
Filter.minusExtras
def minusExtras(self): """ Return a new Filter that's equal to this one, without extra terms that don't add meaning. """ assert self.isOpen() trimmed = self.clone() equals = {} for test in trimmed.tests: if test.op == '='...
python
def minusExtras(self): """ Return a new Filter that's equal to this one, without extra terms that don't add meaning. """ assert self.isOpen() trimmed = self.clone() equals = {} for test in trimmed.tests: if test.op == '='...
[ "def", "minusExtras", "(", "self", ")", ":", "assert", "self", ".", "isOpen", "(", ")", "trimmed", "=", "self", ".", "clone", "(", ")", "equals", "=", "{", "}", "for", "test", "in", "trimmed", ".", "tests", ":", "if", "test", ".", "op", "==", "'=...
Return a new Filter that's equal to this one, without extra terms that don't add meaning.
[ "Return", "a", "new", "Filter", "that", "s", "equal", "to", "this", "one", "without", "extra", "terms", "that", "don", "t", "add", "meaning", "." ]
82f66859340a31dfcb24af127274f262d4f3ad85
https://github.com/mapnik/Cascadenik/blob/82f66859340a31dfcb24af127274f262d4f3ad85/cascadenik/compile.py#L300-L323
45,608
GGiecold/Concurrent_AP
Concurrent_AP.py
add_preference
def add_preference(hdf5_file, preference): """Assign the value 'preference' to the diagonal entries of the matrix of similarities stored in the HDF5 data structure at 'hdf5_file'. """ Worker.hdf5_lock.acquire() with tables.open_file(hdf5_file, 'r+') as fileh: S = fileh.roo...
python
def add_preference(hdf5_file, preference): """Assign the value 'preference' to the diagonal entries of the matrix of similarities stored in the HDF5 data structure at 'hdf5_file'. """ Worker.hdf5_lock.acquire() with tables.open_file(hdf5_file, 'r+') as fileh: S = fileh.roo...
[ "def", "add_preference", "(", "hdf5_file", ",", "preference", ")", ":", "Worker", ".", "hdf5_lock", ".", "acquire", "(", ")", "with", "tables", ".", "open_file", "(", "hdf5_file", ",", "'r+'", ")", "as", "fileh", ":", "S", "=", "fileh", ".", "root", "....
Assign the value 'preference' to the diagonal entries of the matrix of similarities stored in the HDF5 data structure at 'hdf5_file'.
[ "Assign", "the", "value", "preference", "to", "the", "diagonal", "entries", "of", "the", "matrix", "of", "similarities", "stored", "in", "the", "HDF5", "data", "structure", "at", "hdf5_file", "." ]
d4cebe06268b5d520352a83cadb2f7520650460c
https://github.com/GGiecold/Concurrent_AP/blob/d4cebe06268b5d520352a83cadb2f7520650460c/Concurrent_AP.py#L565-L578
45,609
GGiecold/Concurrent_AP
Concurrent_AP.py
add_fluctuations
def add_fluctuations(hdf5_file, N_columns, N_processes): """This procedure organizes the addition of small fluctuations on top of a matrix of similarities at 'hdf5_file' across 'N_processes' different processes. Each of those processes is an instance of the class 'Fluctuations_Worker' def...
python
def add_fluctuations(hdf5_file, N_columns, N_processes): """This procedure organizes the addition of small fluctuations on top of a matrix of similarities at 'hdf5_file' across 'N_processes' different processes. Each of those processes is an instance of the class 'Fluctuations_Worker' def...
[ "def", "add_fluctuations", "(", "hdf5_file", ",", "N_columns", ",", "N_processes", ")", ":", "random_state", "=", "np", ".", "random", ".", "RandomState", "(", "0", ")", "slice_queue", "=", "multiprocessing", ".", "JoinableQueue", "(", ")", "pid_list", "=", ...
This procedure organizes the addition of small fluctuations on top of a matrix of similarities at 'hdf5_file' across 'N_processes' different processes. Each of those processes is an instance of the class 'Fluctuations_Worker' defined elsewhere in this module.
[ "This", "procedure", "organizes", "the", "addition", "of", "small", "fluctuations", "on", "top", "of", "a", "matrix", "of", "similarities", "at", "hdf5_file", "across", "N_processes", "different", "processes", ".", "Each", "of", "those", "processes", "is", "an",...
d4cebe06268b5d520352a83cadb2f7520650460c
https://github.com/GGiecold/Concurrent_AP/blob/d4cebe06268b5d520352a83cadb2f7520650460c/Concurrent_AP.py#L581-L608
45,610
GGiecold/Concurrent_AP
Concurrent_AP.py
compute_responsibilities
def compute_responsibilities(hdf5_file, N_columns, damping, N_processes): """Organize the computation and update of the responsibility matrix for Affinity Propagation clustering with 'damping' as the eponymous damping parameter. Each of the processes concurrently involved in this task is a...
python
def compute_responsibilities(hdf5_file, N_columns, damping, N_processes): """Organize the computation and update of the responsibility matrix for Affinity Propagation clustering with 'damping' as the eponymous damping parameter. Each of the processes concurrently involved in this task is a...
[ "def", "compute_responsibilities", "(", "hdf5_file", ",", "N_columns", ",", "damping", ",", "N_processes", ")", ":", "slice_queue", "=", "multiprocessing", ".", "JoinableQueue", "(", ")", "pid_list", "=", "[", "]", "for", "i", "in", "range", "(", "N_processes"...
Organize the computation and update of the responsibility matrix for Affinity Propagation clustering with 'damping' as the eponymous damping parameter. Each of the processes concurrently involved in this task is an instance of the class 'Responsibilities_worker' defined above.
[ "Organize", "the", "computation", "and", "update", "of", "the", "responsibility", "matrix", "for", "Affinity", "Propagation", "clustering", "with", "damping", "as", "the", "eponymous", "damping", "parameter", ".", "Each", "of", "the", "processes", "concurrently", ...
d4cebe06268b5d520352a83cadb2f7520650460c
https://github.com/GGiecold/Concurrent_AP/blob/d4cebe06268b5d520352a83cadb2f7520650460c/Concurrent_AP.py#L611-L634
45,611
GGiecold/Concurrent_AP
Concurrent_AP.py
to_numpy_array
def to_numpy_array(multiprocessing_array, shape, dtype): """Convert a share multiprocessing array to a numpy array. No data copying involved. """ return np.frombuffer(multiprocessing_array.get_obj(), dtype = dtype).reshape(shape)
python
def to_numpy_array(multiprocessing_array, shape, dtype): """Convert a share multiprocessing array to a numpy array. No data copying involved. """ return np.frombuffer(multiprocessing_array.get_obj(), dtype = dtype).reshape(shape)
[ "def", "to_numpy_array", "(", "multiprocessing_array", ",", "shape", ",", "dtype", ")", ":", "return", "np", ".", "frombuffer", "(", "multiprocessing_array", ".", "get_obj", "(", ")", ",", "dtype", "=", "dtype", ")", ".", "reshape", "(", "shape", ")" ]
Convert a share multiprocessing array to a numpy array. No data copying involved.
[ "Convert", "a", "share", "multiprocessing", "array", "to", "a", "numpy", "array", ".", "No", "data", "copying", "involved", "." ]
d4cebe06268b5d520352a83cadb2f7520650460c
https://github.com/GGiecold/Concurrent_AP/blob/d4cebe06268b5d520352a83cadb2f7520650460c/Concurrent_AP.py#L655-L661
45,612
GGiecold/Concurrent_AP
Concurrent_AP.py
compute_rows_sum
def compute_rows_sum(hdf5_file, path, N_columns, N_processes, method = 'Process'): """Parallel computation of the sums across the rows of two-dimensional array accessible at the node specified by 'path' in the 'hdf5_file' hierarchical data format. """ assert isinstance(me...
python
def compute_rows_sum(hdf5_file, path, N_columns, N_processes, method = 'Process'): """Parallel computation of the sums across the rows of two-dimensional array accessible at the node specified by 'path' in the 'hdf5_file' hierarchical data format. """ assert isinstance(me...
[ "def", "compute_rows_sum", "(", "hdf5_file", ",", "path", ",", "N_columns", ",", "N_processes", ",", "method", "=", "'Process'", ")", ":", "assert", "isinstance", "(", "method", ",", "str", ")", ",", "\"parameter 'method' must consist in a string of characters\"", "...
Parallel computation of the sums across the rows of two-dimensional array accessible at the node specified by 'path' in the 'hdf5_file' hierarchical data format.
[ "Parallel", "computation", "of", "the", "sums", "across", "the", "rows", "of", "two", "-", "dimensional", "array", "accessible", "at", "the", "node", "specified", "by", "path", "in", "the", "hdf5_file", "hierarchical", "data", "format", "." ]
d4cebe06268b5d520352a83cadb2f7520650460c
https://github.com/GGiecold/Concurrent_AP/blob/d4cebe06268b5d520352a83cadb2f7520650460c/Concurrent_AP.py#L664-L709
45,613
GGiecold/Concurrent_AP
Concurrent_AP.py
check_convergence
def check_convergence(hdf5_file, iteration, convergence_iter, max_iter): """If the estimated number of clusters has not changed for 'convergence_iter' consecutive iterations in a total of 'max_iter' rounds of message-passing, the procedure herewith returns 'True'. Otherwise, returns 'False'...
python
def check_convergence(hdf5_file, iteration, convergence_iter, max_iter): """If the estimated number of clusters has not changed for 'convergence_iter' consecutive iterations in a total of 'max_iter' rounds of message-passing, the procedure herewith returns 'True'. Otherwise, returns 'False'...
[ "def", "check_convergence", "(", "hdf5_file", ",", "iteration", ",", "convergence_iter", ",", "max_iter", ")", ":", "Worker", ".", "hdf5_lock", ".", "acquire", "(", ")", "with", "tables", ".", "open_file", "(", "hdf5_file", ",", "'r+'", ")", "as", "fileh", ...
If the estimated number of clusters has not changed for 'convergence_iter' consecutive iterations in a total of 'max_iter' rounds of message-passing, the procedure herewith returns 'True'. Otherwise, returns 'False'. Parameter 'iteration' identifies the run of message-passing t...
[ "If", "the", "estimated", "number", "of", "clusters", "has", "not", "changed", "for", "convergence_iter", "consecutive", "iterations", "in", "a", "total", "of", "max_iter", "rounds", "of", "message", "-", "passing", "the", "procedure", "herewith", "returns", "Tr...
d4cebe06268b5d520352a83cadb2f7520650460c
https://github.com/GGiecold/Concurrent_AP/blob/d4cebe06268b5d520352a83cadb2f7520650460c/Concurrent_AP.py#L757-L790
45,614
GGiecold/Concurrent_AP
Concurrent_AP.py
cluster_labels_A
def cluster_labels_A(hdf5_file, c, lock, I, rows_slice): """One of the task to be performed by a pool of subprocesses, as the first step in identifying the cluster labels and indices of the cluster centers for Affinity Propagation clustering. """ with Worker.hdf5_lock: with tables.o...
python
def cluster_labels_A(hdf5_file, c, lock, I, rows_slice): """One of the task to be performed by a pool of subprocesses, as the first step in identifying the cluster labels and indices of the cluster centers for Affinity Propagation clustering. """ with Worker.hdf5_lock: with tables.o...
[ "def", "cluster_labels_A", "(", "hdf5_file", ",", "c", ",", "lock", ",", "I", ",", "rows_slice", ")", ":", "with", "Worker", ".", "hdf5_lock", ":", "with", "tables", ".", "open_file", "(", "hdf5_file", ",", "'r+'", ")", "as", "fileh", ":", "S", "=", ...
One of the task to be performed by a pool of subprocesses, as the first step in identifying the cluster labels and indices of the cluster centers for Affinity Propagation clustering.
[ "One", "of", "the", "task", "to", "be", "performed", "by", "a", "pool", "of", "subprocesses", "as", "the", "first", "step", "in", "identifying", "the", "cluster", "labels", "and", "indices", "of", "the", "cluster", "centers", "for", "Affinity", "Propagation"...
d4cebe06268b5d520352a83cadb2f7520650460c
https://github.com/GGiecold/Concurrent_AP/blob/d4cebe06268b5d520352a83cadb2f7520650460c/Concurrent_AP.py#L827-L843
45,615
GGiecold/Concurrent_AP
Concurrent_AP.py
cluster_labels_B
def cluster_labels_B(hdf5_file, s_reduced, lock, I, ii, iix, rows_slice): """Second task to be performed by a pool of subprocesses before the cluster labels and cluster center indices can be identified. """ with Worker.hdf5_lock: with tables.open_file(hdf5_file, 'r+') as fileh: ...
python
def cluster_labels_B(hdf5_file, s_reduced, lock, I, ii, iix, rows_slice): """Second task to be performed by a pool of subprocesses before the cluster labels and cluster center indices can be identified. """ with Worker.hdf5_lock: with tables.open_file(hdf5_file, 'r+') as fileh: ...
[ "def", "cluster_labels_B", "(", "hdf5_file", ",", "s_reduced", ",", "lock", ",", "I", ",", "ii", ",", "iix", ",", "rows_slice", ")", ":", "with", "Worker", ".", "hdf5_lock", ":", "with", "tables", ".", "open_file", "(", "hdf5_file", ",", "'r+'", ")", "...
Second task to be performed by a pool of subprocesses before the cluster labels and cluster center indices can be identified.
[ "Second", "task", "to", "be", "performed", "by", "a", "pool", "of", "subprocesses", "before", "the", "cluster", "labels", "and", "cluster", "center", "indices", "can", "be", "identified", "." ]
d4cebe06268b5d520352a83cadb2f7520650460c
https://github.com/GGiecold/Concurrent_AP/blob/d4cebe06268b5d520352a83cadb2f7520650460c/Concurrent_AP.py#L846-L862
45,616
GGiecold/Concurrent_AP
Concurrent_AP.py
output_clusters
def output_clusters(labels, cluster_centers_indices): """Write in tab-separated files the vectors of cluster identities and of indices of cluster centers. """ here = os.getcwd() try: output_directory = os.path.join(here, 'concurrent_AP_output') os.makedirs(output_dir...
python
def output_clusters(labels, cluster_centers_indices): """Write in tab-separated files the vectors of cluster identities and of indices of cluster centers. """ here = os.getcwd() try: output_directory = os.path.join(here, 'concurrent_AP_output') os.makedirs(output_dir...
[ "def", "output_clusters", "(", "labels", ",", "cluster_centers_indices", ")", ":", "here", "=", "os", ".", "getcwd", "(", ")", "try", ":", "output_directory", "=", "os", ".", "path", ".", "join", "(", "here", ",", "'concurrent_AP_output'", ")", "os", ".", ...
Write in tab-separated files the vectors of cluster identities and of indices of cluster centers.
[ "Write", "in", "tab", "-", "separated", "files", "the", "vectors", "of", "cluster", "identities", "and", "of", "indices", "of", "cluster", "centers", "." ]
d4cebe06268b5d520352a83cadb2f7520650460c
https://github.com/GGiecold/Concurrent_AP/blob/d4cebe06268b5d520352a83cadb2f7520650460c/Concurrent_AP.py#L993-L1020
45,617
ttsteiger/cryptocompy
cryptocompy/coin.py
get_coin_snapshot
def get_coin_snapshot(fsym, tsym): """ Get blockchain information, aggregated data as well as data for the individual exchanges available for the specified currency pair. Args: fsym: FROM symbol. tsym: TO symbol. Returns: The function returns a dictionairy containing blockain as well as trading inform...
python
def get_coin_snapshot(fsym, tsym): """ Get blockchain information, aggregated data as well as data for the individual exchanges available for the specified currency pair. Args: fsym: FROM symbol. tsym: TO symbol. Returns: The function returns a dictionairy containing blockain as well as trading inform...
[ "def", "get_coin_snapshot", "(", "fsym", ",", "tsym", ")", ":", "# load data", "url", "=", "build_url", "(", "'coinsnapshot'", ",", "fsym", "=", "fsym", ",", "tsym", "=", "tsym", ")", "data", "=", "load_data", "(", "url", ")", "[", "'Data'", "]", "retu...
Get blockchain information, aggregated data as well as data for the individual exchanges available for the specified currency pair. Args: fsym: FROM symbol. tsym: TO symbol. Returns: The function returns a dictionairy containing blockain as well as trading information from the different exchanges were t...
[ "Get", "blockchain", "information", "aggregated", "data", "as", "well", "as", "data", "for", "the", "individual", "exchanges", "available", "for", "the", "specified", "currency", "pair", "." ]
b0514079202587a5bfb3a4f2c871196315b9302e
https://github.com/ttsteiger/cryptocompy/blob/b0514079202587a5bfb3a4f2c871196315b9302e/cryptocompy/coin.py#L56-L101
45,618
mapnik/Cascadenik
cascadenik/style.py
Selector.matches
def matches(self, tag, id, classes): """ Given an id and a list of classes, return True if this selector would match. """ element = self.elements[0] unmatched_ids = [name[1:] for name in element.names if name.startswith('#')] unmatched_classes = [name[1:] for name in element.name...
python
def matches(self, tag, id, classes): """ Given an id and a list of classes, return True if this selector would match. """ element = self.elements[0] unmatched_ids = [name[1:] for name in element.names if name.startswith('#')] unmatched_classes = [name[1:] for name in element.name...
[ "def", "matches", "(", "self", ",", "tag", ",", "id", ",", "classes", ")", ":", "element", "=", "self", ".", "elements", "[", "0", "]", "unmatched_ids", "=", "[", "name", "[", "1", ":", "]", "for", "name", "in", "element", ".", "names", "if", "na...
Given an id and a list of classes, return True if this selector would match.
[ "Given", "an", "id", "and", "a", "list", "of", "classes", "return", "True", "if", "this", "selector", "would", "match", "." ]
82f66859340a31dfcb24af127274f262d4f3ad85
https://github.com/mapnik/Cascadenik/blob/82f66859340a31dfcb24af127274f262d4f3ad85/cascadenik/style.py#L451-L473
45,619
mapnik/Cascadenik
cascadenik/style.py
Selector.scaledBy
def scaledBy(self, scale): """ Return a new Selector with scale denominators scaled by a number. """ scaled = deepcopy(self) for test in scaled.elements[0].tests: if type(test.value) in (int, float): if test.property == 'scale-denominator': ...
python
def scaledBy(self, scale): """ Return a new Selector with scale denominators scaled by a number. """ scaled = deepcopy(self) for test in scaled.elements[0].tests: if type(test.value) in (int, float): if test.property == 'scale-denominator': ...
[ "def", "scaledBy", "(", "self", ",", "scale", ")", ":", "scaled", "=", "deepcopy", "(", "self", ")", "for", "test", "in", "scaled", ".", "elements", "[", "0", "]", ".", "tests", ":", "if", "type", "(", "test", ".", "value", ")", "in", "(", "int",...
Return a new Selector with scale denominators scaled by a number.
[ "Return", "a", "new", "Selector", "with", "scale", "denominators", "scaled", "by", "a", "number", "." ]
82f66859340a31dfcb24af127274f262d4f3ad85
https://github.com/mapnik/Cascadenik/blob/82f66859340a31dfcb24af127274f262d4f3ad85/cascadenik/style.py#L514-L526
45,620
mapnik/Cascadenik
cascadenik/style.py
Value.scaledBy
def scaledBy(self, scale): """ Return a new Value scaled by a given number for ints and floats. """ scaled = deepcopy(self) if type(scaled.value) in (int, float): scaled.value *= scale elif isinstance(scaled.value, numbers): scaled.value.values = tupl...
python
def scaledBy(self, scale): """ Return a new Value scaled by a given number for ints and floats. """ scaled = deepcopy(self) if type(scaled.value) in (int, float): scaled.value *= scale elif isinstance(scaled.value, numbers): scaled.value.values = tupl...
[ "def", "scaledBy", "(", "self", ",", "scale", ")", ":", "scaled", "=", "deepcopy", "(", "self", ")", "if", "type", "(", "scaled", ".", "value", ")", "in", "(", "int", ",", "float", ")", ":", "scaled", ".", "value", "*=", "scale", "elif", "isinstanc...
Return a new Value scaled by a given number for ints and floats.
[ "Return", "a", "new", "Value", "scaled", "by", "a", "given", "number", "for", "ints", "and", "floats", "." ]
82f66859340a31dfcb24af127274f262d4f3ad85
https://github.com/mapnik/Cascadenik/blob/82f66859340a31dfcb24af127274f262d4f3ad85/cascadenik/style.py#L802-L812
45,621
ttsteiger/cryptocompy
cryptocompy/mining.py
get_mining_contracts
def get_mining_contracts(): """ Get all the mining contracts information available. Returns: This function returns two major dictionaries. The first one contains information about the coins for which mining contracts data is available: coin_data: {symbol1: {'BlockNumber': ..., '...
python
def get_mining_contracts(): """ Get all the mining contracts information available. Returns: This function returns two major dictionaries. The first one contains information about the coins for which mining contracts data is available: coin_data: {symbol1: {'BlockNumber': ..., '...
[ "def", "get_mining_contracts", "(", ")", ":", "# load data", "url", "=", "build_url", "(", "'miningcontracts'", ")", "data", "=", "load_data", "(", "url", ")", "coin_data", "=", "data", "[", "'CoinData'", "]", "mining_data", "=", "data", "[", "'MiningData'", ...
Get all the mining contracts information available. Returns: This function returns two major dictionaries. The first one contains information about the coins for which mining contracts data is available: coin_data: {symbol1: {'BlockNumber': ..., 'BlockReward': ..., 'B...
[ "Get", "all", "the", "mining", "contracts", "information", "available", "." ]
b0514079202587a5bfb3a4f2c871196315b9302e
https://github.com/ttsteiger/cryptocompy/blob/b0514079202587a5bfb3a4f2c871196315b9302e/cryptocompy/mining.py#L6-L65
45,622
ttsteiger/cryptocompy
cryptocompy/mining.py
get_mining_equipment
def get_mining_equipment(): """Get all the mining equipment information available. Returns: This function returns two major dictionaries. The first one contains information about the coins for which mining equipment data is available. coin_data: {symbol1: {'BlockNumber': ..., 'BlockReward': ....
python
def get_mining_equipment(): """Get all the mining equipment information available. Returns: This function returns two major dictionaries. The first one contains information about the coins for which mining equipment data is available. coin_data: {symbol1: {'BlockNumber': ..., 'BlockReward': ....
[ "def", "get_mining_equipment", "(", ")", ":", "# load data", "url", "=", "build_url", "(", "'miningequipment'", ")", "data", "=", "load_data", "(", "url", ")", "coin_data", "=", "data", "[", "'CoinData'", "]", "mining_data", "=", "data", "[", "'MiningData'", ...
Get all the mining equipment information available. Returns: This function returns two major dictionaries. The first one contains information about the coins for which mining equipment data is available. coin_data: {symbol1: {'BlockNumber': ..., 'BlockReward': ..., 'BlockRewardRe...
[ "Get", "all", "the", "mining", "equipment", "information", "available", "." ]
b0514079202587a5bfb3a4f2c871196315b9302e
https://github.com/ttsteiger/cryptocompy/blob/b0514079202587a5bfb3a4f2c871196315b9302e/cryptocompy/mining.py#L68-L120
45,623
mapnik/Cascadenik
cascadenik-compile.py
main
def main(src_file, dest_file, **kwargs): """ Given an input layers file and a directory, print the compiled XML file to stdout and save any encountered external image files to the named directory. """ mmap = mapnik.Map(1, 1) # allow [zoom] filters to work mmap.srs = '+proj=merc +a=63...
python
def main(src_file, dest_file, **kwargs): """ Given an input layers file and a directory, print the compiled XML file to stdout and save any encountered external image files to the named directory. """ mmap = mapnik.Map(1, 1) # allow [zoom] filters to work mmap.srs = '+proj=merc +a=63...
[ "def", "main", "(", "src_file", ",", "dest_file", ",", "*", "*", "kwargs", ")", ":", "mmap", "=", "mapnik", ".", "Map", "(", "1", ",", "1", ")", "# allow [zoom] filters to work", "mmap", ".", "srs", "=", "'+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 ...
Given an input layers file and a directory, print the compiled XML file to stdout and save any encountered external image files to the named directory.
[ "Given", "an", "input", "layers", "file", "and", "a", "directory", "print", "the", "compiled", "XML", "file", "to", "stdout", "and", "save", "any", "encountered", "external", "image", "files", "to", "the", "named", "directory", "." ]
82f66859340a31dfcb24af127274f262d4f3ad85
https://github.com/mapnik/Cascadenik/blob/82f66859340a31dfcb24af127274f262d4f3ad85/cascadenik-compile.py#L24-L52
45,624
mapnik/Cascadenik
cascadenik/safe64.py
chunk
def chunk(url): """ create filesystem-safe places for url-keyed data to be stored """ chunks = lambda l, n: [l[x: x+n] for x in xrange(0, len(l), n)] url_64 = base64.urlsafe_b64encode(url) return chunks(url_64, 255)
python
def chunk(url): """ create filesystem-safe places for url-keyed data to be stored """ chunks = lambda l, n: [l[x: x+n] for x in xrange(0, len(l), n)] url_64 = base64.urlsafe_b64encode(url) return chunks(url_64, 255)
[ "def", "chunk", "(", "url", ")", ":", "chunks", "=", "lambda", "l", ",", "n", ":", "[", "l", "[", "x", ":", "x", "+", "n", "]", "for", "x", "in", "xrange", "(", "0", ",", "len", "(", "l", ")", ",", "n", ")", "]", "url_64", "=", "base64", ...
create filesystem-safe places for url-keyed data to be stored
[ "create", "filesystem", "-", "safe", "places", "for", "url", "-", "keyed", "data", "to", "be", "stored" ]
82f66859340a31dfcb24af127274f262d4f3ad85
https://github.com/mapnik/Cascadenik/blob/82f66859340a31dfcb24af127274f262d4f3ad85/cascadenik/safe64.py#L15-L19
45,625
mapnik/Cascadenik
cascadenik-style.py
main
def main(filename): """ Given an input file containing nothing but styles, print out an unrolled list of declarations in cascade order. """ input = open(filename, 'r').read() declarations = cascadenik.stylesheet_declarations(input, is_merc=True) for dec in declarations: print de...
python
def main(filename): """ Given an input file containing nothing but styles, print out an unrolled list of declarations in cascade order. """ input = open(filename, 'r').read() declarations = cascadenik.stylesheet_declarations(input, is_merc=True) for dec in declarations: print de...
[ "def", "main", "(", "filename", ")", ":", "input", "=", "open", "(", "filename", ",", "'r'", ")", ".", "read", "(", ")", "declarations", "=", "cascadenik", ".", "stylesheet_declarations", "(", "input", ",", "is_merc", "=", "True", ")", "for", "dec", "i...
Given an input file containing nothing but styles, print out an unrolled list of declarations in cascade order.
[ "Given", "an", "input", "file", "containing", "nothing", "but", "styles", "print", "out", "an", "unrolled", "list", "of", "declarations", "in", "cascade", "order", "." ]
82f66859340a31dfcb24af127274f262d4f3ad85
https://github.com/mapnik/Cascadenik/blob/82f66859340a31dfcb24af127274f262d4f3ad85/cascadenik-style.py#L12-L38
45,626
theolind/pymysensors
mysensors/const_20.py
validate_gps
def validate_gps(value): """Validate GPS value.""" try: latitude, longitude, altitude = value.split(',') vol.Coerce(float)(latitude) vol.Coerce(float)(longitude) vol.Coerce(float)(altitude) except (TypeError, ValueError, vol.Invalid): raise vol.Invalid( 'G...
python
def validate_gps(value): """Validate GPS value.""" try: latitude, longitude, altitude = value.split(',') vol.Coerce(float)(latitude) vol.Coerce(float)(longitude) vol.Coerce(float)(altitude) except (TypeError, ValueError, vol.Invalid): raise vol.Invalid( 'G...
[ "def", "validate_gps", "(", "value", ")", ":", "try", ":", "latitude", ",", "longitude", ",", "altitude", "=", "value", ".", "split", "(", "','", ")", "vol", ".", "Coerce", "(", "float", ")", "(", "latitude", ")", "vol", ".", "Coerce", "(", "float", ...
Validate GPS value.
[ "Validate", "GPS", "value", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/const_20.py#L281-L291
45,627
theolind/pymysensors
mysensors/gateway_tcp.py
TCPGateway._connect
def _connect(self): """Connect to socket. This should be run in a new thread.""" while self.protocol: _LOGGER.info('Trying to connect to %s', self.server_address) try: sock = socket.create_connection( self.server_address, self.reconnect_timeout...
python
def _connect(self): """Connect to socket. This should be run in a new thread.""" while self.protocol: _LOGGER.info('Trying to connect to %s', self.server_address) try: sock = socket.create_connection( self.server_address, self.reconnect_timeout...
[ "def", "_connect", "(", "self", ")", ":", "while", "self", ".", "protocol", ":", "_LOGGER", ".", "info", "(", "'Trying to connect to %s'", ",", "self", ".", "server_address", ")", "try", ":", "sock", "=", "socket", ".", "create_connection", "(", "self", "....
Connect to socket. This should be run in a new thread.
[ "Connect", "to", "socket", ".", "This", "should", "be", "run", "in", "a", "new", "thread", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/gateway_tcp.py#L76-L108
45,628
theolind/pymysensors
mysensors/gateway_tcp.py
AsyncTCPGateway._connect
def _connect(self): """Connect to the socket.""" try: while True: _LOGGER.info('Trying to connect to %s', self.server_address) try: yield from asyncio.wait_for( self.loop.create_connection( ...
python
def _connect(self): """Connect to the socket.""" try: while True: _LOGGER.info('Trying to connect to %s', self.server_address) try: yield from asyncio.wait_for( self.loop.create_connection( ...
[ "def", "_connect", "(", "self", ")", ":", "try", ":", "while", "True", ":", "_LOGGER", ".", "info", "(", "'Trying to connect to %s'", ",", "self", ".", "server_address", ")", "try", ":", "yield", "from", "asyncio", ".", "wait_for", "(", "self", ".", "loo...
Connect to the socket.
[ "Connect", "to", "the", "socket", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/gateway_tcp.py#L127-L161
45,629
theolind/pymysensors
mysensors/gateway_tcp.py
TCPTransport.run
def run(self): """Transport thread loop.""" # pylint: disable=broad-except self.protocol = self.protocol_factory() try: self.protocol.connection_made(self) except Exception as exc: self.alive = False self.protocol.connection_lost(exc) ...
python
def run(self): """Transport thread loop.""" # pylint: disable=broad-except self.protocol = self.protocol_factory() try: self.protocol.connection_made(self) except Exception as exc: self.alive = False self.protocol.connection_lost(exc) ...
[ "def", "run", "(", "self", ")", ":", "# pylint: disable=broad-except", "self", ".", "protocol", "=", "self", ".", "protocol_factory", "(", ")", "try", ":", "self", ".", "protocol", ".", "connection_made", "(", "self", ")", "except", "Exception", "as", "exc",...
Transport thread loop.
[ "Transport", "thread", "loop", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/gateway_tcp.py#L223-L260
45,630
theolind/pymysensors
mysensors/util.py
Registry.register
def register(self, name): """Return decorator to register item with a specific name.""" def decorator(func): """Register decorated function.""" self[name] = func return func return decorator
python
def register(self, name): """Return decorator to register item with a specific name.""" def decorator(func): """Register decorated function.""" self[name] = func return func return decorator
[ "def", "register", "(", "self", ",", "name", ")", ":", "def", "decorator", "(", "func", ")", ":", "\"\"\"Register decorated function.\"\"\"", "self", "[", "name", "]", "=", "func", "return", "func", "return", "decorator" ]
Return decorator to register item with a specific name.
[ "Return", "decorator", "to", "register", "item", "with", "a", "specific", "name", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/util.py#L10-L17
45,631
theolind/pymysensors
mysensors/gateway_mqtt.py
BaseMQTTGateway._handle_subscription
def _handle_subscription(self, topics): """Handle subscription of topics.""" if not isinstance(topics, list): topics = [topics] for topic in topics: topic_levels = topic.split('/') try: qos = int(topic_levels[-2]) except ValueError:...
python
def _handle_subscription(self, topics): """Handle subscription of topics.""" if not isinstance(topics, list): topics = [topics] for topic in topics: topic_levels = topic.split('/') try: qos = int(topic_levels[-2]) except ValueError:...
[ "def", "_handle_subscription", "(", "self", ",", "topics", ")", ":", "if", "not", "isinstance", "(", "topics", ",", "list", ")", ":", "topics", "=", "[", "topics", "]", "for", "topic", "in", "topics", ":", "topic_levels", "=", "topic", ".", "split", "(...
Handle subscription of topics.
[ "Handle", "subscription", "of", "topics", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/gateway_mqtt.py#L34-L49
45,632
theolind/pymysensors
mysensors/gateway_mqtt.py
BaseMQTTGateway._init_topics
def _init_topics(self): """Set up initial subscription of mysensors topics.""" _LOGGER.info('Setting up initial MQTT topic subscription') init_topics = [ '{}/+/+/0/+/+'.format(self._in_prefix), '{}/+/+/3/+/+'.format(self._in_prefix), ] self._handle_subscri...
python
def _init_topics(self): """Set up initial subscription of mysensors topics.""" _LOGGER.info('Setting up initial MQTT topic subscription') init_topics = [ '{}/+/+/0/+/+'.format(self._in_prefix), '{}/+/+/3/+/+'.format(self._in_prefix), ] self._handle_subscri...
[ "def", "_init_topics", "(", "self", ")", ":", "_LOGGER", ".", "info", "(", "'Setting up initial MQTT topic subscription'", ")", "init_topics", "=", "[", "'{}/+/+/0/+/+'", ".", "format", "(", "self", ".", "_in_prefix", ")", ",", "'{}/+/+/3/+/+'", ".", "format", "...
Set up initial subscription of mysensors topics.
[ "Set", "up", "initial", "subscription", "of", "mysensors", "topics", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/gateway_mqtt.py#L51-L74
45,633
theolind/pymysensors
mysensors/gateway_mqtt.py
BaseMQTTGateway._parse_mqtt_to_message
def _parse_mqtt_to_message(self, topic, payload, qos): """Parse a MQTT topic and payload. Return a mysensors command string. """ topic_levels = topic.split('/') topic_levels = not_prefix = topic_levels[-5:] prefix_end_idx = topic.find('/'.join(not_prefix)) - 1 pr...
python
def _parse_mqtt_to_message(self, topic, payload, qos): """Parse a MQTT topic and payload. Return a mysensors command string. """ topic_levels = topic.split('/') topic_levels = not_prefix = topic_levels[-5:] prefix_end_idx = topic.find('/'.join(not_prefix)) - 1 pr...
[ "def", "_parse_mqtt_to_message", "(", "self", ",", "topic", ",", "payload", ",", "qos", ")", ":", "topic_levels", "=", "topic", ".", "split", "(", "'/'", ")", "topic_levels", "=", "not_prefix", "=", "topic_levels", "[", "-", "5", ":", "]", "prefix_end_idx"...
Parse a MQTT topic and payload. Return a mysensors command string.
[ "Parse", "a", "MQTT", "topic", "and", "payload", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/gateway_mqtt.py#L76-L93
45,634
theolind/pymysensors
mysensors/gateway_mqtt.py
BaseMQTTGateway._parse_message_to_mqtt
def _parse_message_to_mqtt(self, data): """Parse a mysensors command string. Return a MQTT topic, payload and qos-level as a tuple. """ msg = Message(data, self) payload = str(msg.payload) msg.payload = '' # prefix/node/child/type/ack/subtype : payload re...
python
def _parse_message_to_mqtt(self, data): """Parse a mysensors command string. Return a MQTT topic, payload and qos-level as a tuple. """ msg = Message(data, self) payload = str(msg.payload) msg.payload = '' # prefix/node/child/type/ack/subtype : payload re...
[ "def", "_parse_message_to_mqtt", "(", "self", ",", "data", ")", ":", "msg", "=", "Message", "(", "data", ",", "self", ")", "payload", "=", "str", "(", "msg", ".", "payload", ")", "msg", ".", "payload", "=", "''", "# prefix/node/child/type/ack/subtype : paylo...
Parse a mysensors command string. Return a MQTT topic, payload and qos-level as a tuple.
[ "Parse", "a", "mysensors", "command", "string", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/gateway_mqtt.py#L95-L105
45,635
theolind/pymysensors
mysensors/gateway_mqtt.py
BaseMQTTGateway._handle_presentation
def _handle_presentation(self, msg): """Process a MQTT presentation message.""" ret_msg = handle_presentation(msg) if msg.child_id == 255 or ret_msg is None: return # this is a presentation of a child sensor topics = [ '{}/{}/{}/{}/+/+'.format( ...
python
def _handle_presentation(self, msg): """Process a MQTT presentation message.""" ret_msg = handle_presentation(msg) if msg.child_id == 255 or ret_msg is None: return # this is a presentation of a child sensor topics = [ '{}/{}/{}/{}/+/+'.format( ...
[ "def", "_handle_presentation", "(", "self", ",", "msg", ")", ":", "ret_msg", "=", "handle_presentation", "(", "msg", ")", "if", "msg", ".", "child_id", "==", "255", "or", "ret_msg", "is", "None", ":", "return", "# this is a presentation of a child sensor", "topi...
Process a MQTT presentation message.
[ "Process", "a", "MQTT", "presentation", "message", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/gateway_mqtt.py#L107-L123
45,636
theolind/pymysensors
mysensors/gateway_mqtt.py
BaseMQTTGateway.recv
def recv(self, topic, payload, qos): """Receive a MQTT message. Call this method when a message is received from the MQTT broker. """ data = self._parse_mqtt_to_message(topic, payload, qos) if data is None: return _LOGGER.debug('Receiving %s', data) s...
python
def recv(self, topic, payload, qos): """Receive a MQTT message. Call this method when a message is received from the MQTT broker. """ data = self._parse_mqtt_to_message(topic, payload, qos) if data is None: return _LOGGER.debug('Receiving %s', data) s...
[ "def", "recv", "(", "self", ",", "topic", ",", "payload", ",", "qos", ")", ":", "data", "=", "self", ".", "_parse_mqtt_to_message", "(", "topic", ",", "payload", ",", "qos", ")", "if", "data", "is", "None", ":", "return", "_LOGGER", ".", "debug", "("...
Receive a MQTT message. Call this method when a message is received from the MQTT broker.
[ "Receive", "a", "MQTT", "message", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/gateway_mqtt.py#L129-L138
45,637
theolind/pymysensors
mysensors/gateway_mqtt.py
BaseMQTTGateway.send
def send(self, message): """Publish a command string to the gateway via MQTT.""" if not message: return topic, payload, qos = self._parse_message_to_mqtt(message) try: _LOGGER.debug('Publishing %s', message.strip()) self._pub_callback(topic, payload, q...
python
def send(self, message): """Publish a command string to the gateway via MQTT.""" if not message: return topic, payload, qos = self._parse_message_to_mqtt(message) try: _LOGGER.debug('Publishing %s', message.strip()) self._pub_callback(topic, payload, q...
[ "def", "send", "(", "self", ",", "message", ")", ":", "if", "not", "message", ":", "return", "topic", ",", "payload", ",", "qos", "=", "self", ".", "_parse_message_to_mqtt", "(", "message", ")", "try", ":", "_LOGGER", ".", "debug", "(", "'Publishing %s'"...
Publish a command string to the gateway via MQTT.
[ "Publish", "a", "command", "string", "to", "the", "gateway", "via", "MQTT", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/gateway_mqtt.py#L140-L149
45,638
ambitioninc/django-regex-field
regex_field/fields.py
RegexField.contribute_to_class
def contribute_to_class(self, cls, name, virtual_only=False): """ Cast to the correct value every """ super(RegexField, self).contribute_to_class(cls, name, virtual_only) setattr(cls, name, CastOnAssignDescriptor(self))
python
def contribute_to_class(self, cls, name, virtual_only=False): """ Cast to the correct value every """ super(RegexField, self).contribute_to_class(cls, name, virtual_only) setattr(cls, name, CastOnAssignDescriptor(self))
[ "def", "contribute_to_class", "(", "self", ",", "cls", ",", "name", ",", "virtual_only", "=", "False", ")", ":", "super", "(", "RegexField", ",", "self", ")", ".", "contribute_to_class", "(", "cls", ",", "name", ",", "virtual_only", ")", "setattr", "(", ...
Cast to the correct value every
[ "Cast", "to", "the", "correct", "value", "every" ]
0cf6f5f627002175e40474f75f76128830ae3cdf
https://github.com/ambitioninc/django-regex-field/blob/0cf6f5f627002175e40474f75f76128830ae3cdf/regex_field/fields.py#L60-L65
45,639
ambitioninc/django-regex-field
regex_field/fields.py
RegexField.run_validators
def run_validators(self, value): """ Make sure value is a string so it can run through django validators """ value = self.to_python(value) value = self.value_to_string(value) return super(RegexField, self).run_validators(value)
python
def run_validators(self, value): """ Make sure value is a string so it can run through django validators """ value = self.to_python(value) value = self.value_to_string(value) return super(RegexField, self).run_validators(value)
[ "def", "run_validators", "(", "self", ",", "value", ")", ":", "value", "=", "self", ".", "to_python", "(", "value", ")", "value", "=", "self", ".", "value_to_string", "(", "value", ")", "return", "super", "(", "RegexField", ",", "self", ")", ".", "run_...
Make sure value is a string so it can run through django validators
[ "Make", "sure", "value", "is", "a", "string", "so", "it", "can", "run", "through", "django", "validators" ]
0cf6f5f627002175e40474f75f76128830ae3cdf
https://github.com/ambitioninc/django-regex-field/blob/0cf6f5f627002175e40474f75f76128830ae3cdf/regex_field/fields.py#L102-L108
45,640
theolind/pymysensors
mysensors/const_15.py
validate_hex
def validate_hex(value): """Validate that value has hex format.""" try: binascii.unhexlify(value) except Exception: raise vol.Invalid( '{} is not of hex format'.format(value)) return value
python
def validate_hex(value): """Validate that value has hex format.""" try: binascii.unhexlify(value) except Exception: raise vol.Invalid( '{} is not of hex format'.format(value)) return value
[ "def", "validate_hex", "(", "value", ")", ":", "try", ":", "binascii", ".", "unhexlify", "(", "value", ")", "except", "Exception", ":", "raise", "vol", ".", "Invalid", "(", "'{} is not of hex format'", ".", "format", "(", "value", ")", ")", "return", "valu...
Validate that value has hex format.
[ "Validate", "that", "value", "has", "hex", "format", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/const_15.py#L261-L268
45,641
theolind/pymysensors
mysensors/const_15.py
validate_v_rgb
def validate_v_rgb(value): """Validate a V_RGB value.""" if len(value) != 6: raise vol.Invalid( '{} is not six characters long'.format(value)) return validate_hex(value)
python
def validate_v_rgb(value): """Validate a V_RGB value.""" if len(value) != 6: raise vol.Invalid( '{} is not six characters long'.format(value)) return validate_hex(value)
[ "def", "validate_v_rgb", "(", "value", ")", ":", "if", "len", "(", "value", ")", "!=", "6", ":", "raise", "vol", ".", "Invalid", "(", "'{} is not six characters long'", ".", "format", "(", "value", ")", ")", "return", "validate_hex", "(", "value", ")" ]
Validate a V_RGB value.
[ "Validate", "a", "V_RGB", "value", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/const_15.py#L271-L276
45,642
theolind/pymysensors
mysensors/const_15.py
validate_v_rgbw
def validate_v_rgbw(value): """Validate a V_RGBW value.""" if len(value) != 8: raise vol.Invalid( '{} is not eight characters long'.format(value)) return validate_hex(value)
python
def validate_v_rgbw(value): """Validate a V_RGBW value.""" if len(value) != 8: raise vol.Invalid( '{} is not eight characters long'.format(value)) return validate_hex(value)
[ "def", "validate_v_rgbw", "(", "value", ")", ":", "if", "len", "(", "value", ")", "!=", "8", ":", "raise", "vol", ".", "Invalid", "(", "'{} is not eight characters long'", ".", "format", "(", "value", ")", ")", "return", "validate_hex", "(", "value", ")" ]
Validate a V_RGBW value.
[ "Validate", "a", "V_RGBW", "value", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/const_15.py#L279-L284
45,643
theolind/pymysensors
mysensors/message.py
Message.copy
def copy(self, **kwargs): """Copy a message, optionally replace attributes with kwargs.""" msg = Message(self.encode(), self.gateway) for key, val in kwargs.items(): setattr(msg, key, val) return msg
python
def copy(self, **kwargs): """Copy a message, optionally replace attributes with kwargs.""" msg = Message(self.encode(), self.gateway) for key, val in kwargs.items(): setattr(msg, key, val) return msg
[ "def", "copy", "(", "self", ",", "*", "*", "kwargs", ")", ":", "msg", "=", "Message", "(", "self", ".", "encode", "(", ")", ",", "self", ".", "gateway", ")", "for", "key", ",", "val", "in", "kwargs", ".", "items", "(", ")", ":", "setattr", "(",...
Copy a message, optionally replace attributes with kwargs.
[ "Copy", "a", "message", "optionally", "replace", "attributes", "with", "kwargs", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/message.py#L34-L39
45,644
theolind/pymysensors
mysensors/message.py
Message.modify
def modify(self, **kwargs): """Modify and return message, replace attributes with kwargs.""" for key, val in kwargs.items(): setattr(self, key, val) return self
python
def modify(self, **kwargs): """Modify and return message, replace attributes with kwargs.""" for key, val in kwargs.items(): setattr(self, key, val) return self
[ "def", "modify", "(", "self", ",", "*", "*", "kwargs", ")", ":", "for", "key", ",", "val", "in", "kwargs", ".", "items", "(", ")", ":", "setattr", "(", "self", ",", "key", ",", "val", ")", "return", "self" ]
Modify and return message, replace attributes with kwargs.
[ "Modify", "and", "return", "message", "replace", "attributes", "with", "kwargs", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/message.py#L41-L45
45,645
theolind/pymysensors
mysensors/message.py
Message.decode
def decode(self, data, delimiter=';'): """Decode a message from command string.""" try: list_data = data.rstrip().split(delimiter) self.payload = list_data.pop() (self.node_id, self.child_id, self.type, self.ack, sel...
python
def decode(self, data, delimiter=';'): """Decode a message from command string.""" try: list_data = data.rstrip().split(delimiter) self.payload = list_data.pop() (self.node_id, self.child_id, self.type, self.ack, sel...
[ "def", "decode", "(", "self", ",", "data", ",", "delimiter", "=", "';'", ")", ":", "try", ":", "list_data", "=", "data", ".", "rstrip", "(", ")", ".", "split", "(", "delimiter", ")", "self", ".", "payload", "=", "list_data", ".", "pop", "(", ")", ...
Decode a message from command string.
[ "Decode", "a", "message", "from", "command", "string", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/message.py#L47-L60
45,646
theolind/pymysensors
mysensors/message.py
Message.encode
def encode(self, delimiter=';'): """Encode a command string from message.""" try: return delimiter.join([str(f) for f in [ self.node_id, self.child_id, int(self.type), self.ack, int(self.sub_type), ...
python
def encode(self, delimiter=';'): """Encode a command string from message.""" try: return delimiter.join([str(f) for f in [ self.node_id, self.child_id, int(self.type), self.ack, int(self.sub_type), ...
[ "def", "encode", "(", "self", ",", "delimiter", "=", "';'", ")", ":", "try", ":", "return", "delimiter", ".", "join", "(", "[", "str", "(", "f", ")", "for", "f", "in", "[", "self", ".", "node_id", ",", "self", ".", "child_id", ",", "int", "(", ...
Encode a command string from message.
[ "Encode", "a", "command", "string", "from", "message", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/message.py#L62-L74
45,647
theolind/pymysensors
mysensors/message.py
Message.validate
def validate(self, protocol_version): """Validate message.""" const = get_const(protocol_version) valid_node_ids = vol.All(vol.Coerce(int), vol.Range( min=0, max=BROADCAST_ID, msg='Not valid node_id: {}'.format( self.node_id))) valid_child_ids = vol.All(vol.Co...
python
def validate(self, protocol_version): """Validate message.""" const = get_const(protocol_version) valid_node_ids = vol.All(vol.Coerce(int), vol.Range( min=0, max=BROADCAST_ID, msg='Not valid node_id: {}'.format( self.node_id))) valid_child_ids = vol.All(vol.Co...
[ "def", "validate", "(", "self", ",", "protocol_version", ")", ":", "const", "=", "get_const", "(", "protocol_version", ")", "valid_node_ids", "=", "vol", ".", "All", "(", "vol", ".", "Coerce", "(", "int", ")", ",", "vol", ".", "Range", "(", "min", "=",...
Validate message.
[ "Validate", "message", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/message.py#L76-L119
45,648
theolind/pymysensors
mysensors/persistence.py
Persistence._save_pickle
def _save_pickle(self, filename): """Save sensors to pickle file.""" with open(filename, 'wb') as file_handle: pickle.dump(self._sensors, file_handle, pickle.HIGHEST_PROTOCOL) file_handle.flush() os.fsync(file_handle.fileno())
python
def _save_pickle(self, filename): """Save sensors to pickle file.""" with open(filename, 'wb') as file_handle: pickle.dump(self._sensors, file_handle, pickle.HIGHEST_PROTOCOL) file_handle.flush() os.fsync(file_handle.fileno())
[ "def", "_save_pickle", "(", "self", ",", "filename", ")", ":", "with", "open", "(", "filename", ",", "'wb'", ")", "as", "file_handle", ":", "pickle", ".", "dump", "(", "self", ".", "_sensors", ",", "file_handle", ",", "pickle", ".", "HIGHEST_PROTOCOL", "...
Save sensors to pickle file.
[ "Save", "sensors", "to", "pickle", "file", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/persistence.py#L25-L30
45,649
theolind/pymysensors
mysensors/persistence.py
Persistence._load_pickle
def _load_pickle(self, filename): """Load sensors from pickle file.""" with open(filename, 'rb') as file_handle: self._sensors.update(pickle.load(file_handle))
python
def _load_pickle(self, filename): """Load sensors from pickle file.""" with open(filename, 'rb') as file_handle: self._sensors.update(pickle.load(file_handle))
[ "def", "_load_pickle", "(", "self", ",", "filename", ")", ":", "with", "open", "(", "filename", ",", "'rb'", ")", "as", "file_handle", ":", "self", ".", "_sensors", ".", "update", "(", "pickle", ".", "load", "(", "file_handle", ")", ")" ]
Load sensors from pickle file.
[ "Load", "sensors", "from", "pickle", "file", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/persistence.py#L32-L35
45,650
theolind/pymysensors
mysensors/persistence.py
Persistence._save_json
def _save_json(self, filename): """Save sensors to json file.""" with open(filename, 'w') as file_handle: json.dump(self._sensors, file_handle, cls=MySensorsJSONEncoder, indent=4) file_handle.flush() os.fsync(file_handle.fileno())
python
def _save_json(self, filename): """Save sensors to json file.""" with open(filename, 'w') as file_handle: json.dump(self._sensors, file_handle, cls=MySensorsJSONEncoder, indent=4) file_handle.flush() os.fsync(file_handle.fileno())
[ "def", "_save_json", "(", "self", ",", "filename", ")", ":", "with", "open", "(", "filename", ",", "'w'", ")", "as", "file_handle", ":", "json", ".", "dump", "(", "self", ".", "_sensors", ",", "file_handle", ",", "cls", "=", "MySensorsJSONEncoder", ",", ...
Save sensors to json file.
[ "Save", "sensors", "to", "json", "file", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/persistence.py#L37-L43
45,651
theolind/pymysensors
mysensors/persistence.py
Persistence._load_json
def _load_json(self, filename): """Load sensors from json file.""" with open(filename, 'r') as file_handle: self._sensors.update(json.load( file_handle, cls=MySensorsJSONDecoder))
python
def _load_json(self, filename): """Load sensors from json file.""" with open(filename, 'r') as file_handle: self._sensors.update(json.load( file_handle, cls=MySensorsJSONDecoder))
[ "def", "_load_json", "(", "self", ",", "filename", ")", ":", "with", "open", "(", "filename", ",", "'r'", ")", "as", "file_handle", ":", "self", ".", "_sensors", ".", "update", "(", "json", ".", "load", "(", "file_handle", ",", "cls", "=", "MySensorsJS...
Load sensors from json file.
[ "Load", "sensors", "from", "json", "file", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/persistence.py#L45-L49
45,652
theolind/pymysensors
mysensors/persistence.py
Persistence.save_sensors
def save_sensors(self): """Save sensors to file.""" if not self.need_save: return fname = os.path.realpath(self.persistence_file) exists = os.path.isfile(fname) dirname = os.path.dirname(fname) if (not os.access(dirname, os.W_OK) or exists and ...
python
def save_sensors(self): """Save sensors to file.""" if not self.need_save: return fname = os.path.realpath(self.persistence_file) exists = os.path.isfile(fname) dirname = os.path.dirname(fname) if (not os.access(dirname, os.W_OK) or exists and ...
[ "def", "save_sensors", "(", "self", ")", ":", "if", "not", "self", ".", "need_save", ":", "return", "fname", "=", "os", ".", "path", ".", "realpath", "(", "self", ".", "persistence_file", ")", "exists", "=", "os", ".", "path", ".", "isfile", "(", "fn...
Save sensors to file.
[ "Save", "sensors", "to", "file", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/persistence.py#L51-L71
45,653
theolind/pymysensors
mysensors/persistence.py
Persistence._load_sensors
def _load_sensors(self, path=None): """Load sensors from file.""" if path is None: path = self.persistence_file exists = os.path.isfile(path) if exists and os.access(path, os.R_OK): if path == self.persistence_bak: os.rename(path, self.persistence_...
python
def _load_sensors(self, path=None): """Load sensors from file.""" if path is None: path = self.persistence_file exists = os.path.isfile(path) if exists and os.access(path, os.R_OK): if path == self.persistence_bak: os.rename(path, self.persistence_...
[ "def", "_load_sensors", "(", "self", ",", "path", "=", "None", ")", ":", "if", "path", "is", "None", ":", "path", "=", "self", ".", "persistence_file", "exists", "=", "os", ".", "path", ".", "isfile", "(", "path", ")", "if", "exists", "and", "os", ...
Load sensors from file.
[ "Load", "sensors", "from", "file", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/persistence.py#L73-L86
45,654
theolind/pymysensors
mysensors/persistence.py
Persistence.safe_load_sensors
def safe_load_sensors(self): """Load sensors safely from file.""" try: loaded = self._load_sensors() except (EOFError, ValueError): _LOGGER.error('Bad file contents: %s', self.persistence_file) loaded = False if not loaded: _LOGGER.warning(...
python
def safe_load_sensors(self): """Load sensors safely from file.""" try: loaded = self._load_sensors() except (EOFError, ValueError): _LOGGER.error('Bad file contents: %s', self.persistence_file) loaded = False if not loaded: _LOGGER.warning(...
[ "def", "safe_load_sensors", "(", "self", ")", ":", "try", ":", "loaded", "=", "self", ".", "_load_sensors", "(", ")", "except", "(", "EOFError", ",", "ValueError", ")", ":", "_LOGGER", ".", "error", "(", "'Bad file contents: %s'", ",", "self", ".", "persis...
Load sensors safely from file.
[ "Load", "sensors", "safely", "from", "file", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/persistence.py#L88-L104
45,655
theolind/pymysensors
mysensors/persistence.py
Persistence._perform_file_action
def _perform_file_action(self, filename, action): """Perform action on specific file types. Dynamic dispatch function for performing actions on specific file types. """ ext = os.path.splitext(filename)[1] try: func = getattr(self, '_{}_{}'.format(action, ext[...
python
def _perform_file_action(self, filename, action): """Perform action on specific file types. Dynamic dispatch function for performing actions on specific file types. """ ext = os.path.splitext(filename)[1] try: func = getattr(self, '_{}_{}'.format(action, ext[...
[ "def", "_perform_file_action", "(", "self", ",", "filename", ",", "action", ")", ":", "ext", "=", "os", ".", "path", ".", "splitext", "(", "filename", ")", "[", "1", "]", "try", ":", "func", "=", "getattr", "(", "self", ",", "'_{}_{}'", ".", "format"...
Perform action on specific file types. Dynamic dispatch function for performing actions on specific file types.
[ "Perform", "action", "on", "specific", "file", "types", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/persistence.py#L106-L117
45,656
theolind/pymysensors
mysensors/persistence.py
MySensorsJSONEncoder.default
def default(self, obj): """Serialize obj into JSON.""" # pylint: disable=method-hidden, protected-access, arguments-differ if isinstance(obj, Sensor): return { 'sensor_id': obj.sensor_id, 'children': obj.children, 'type': obj.type, ...
python
def default(self, obj): """Serialize obj into JSON.""" # pylint: disable=method-hidden, protected-access, arguments-differ if isinstance(obj, Sensor): return { 'sensor_id': obj.sensor_id, 'children': obj.children, 'type': obj.type, ...
[ "def", "default", "(", "self", ",", "obj", ")", ":", "# pylint: disable=method-hidden, protected-access, arguments-differ", "if", "isinstance", "(", "obj", ",", "Sensor", ")", ":", "return", "{", "'sensor_id'", ":", "obj", ".", "sensor_id", ",", "'children'", ":",...
Serialize obj into JSON.
[ "Serialize", "obj", "into", "JSON", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/persistence.py#L123-L144
45,657
theolind/pymysensors
mysensors/persistence.py
MySensorsJSONDecoder.dict_to_object
def dict_to_object(self, obj): # pylint: disable=no-self-use """Return object from dict.""" if not isinstance(obj, dict): return obj if 'sensor_id' in obj: sensor = Sensor(obj['sensor_id']) for key, val in obj.items(): setattr(sensor, key, val...
python
def dict_to_object(self, obj): # pylint: disable=no-self-use """Return object from dict.""" if not isinstance(obj, dict): return obj if 'sensor_id' in obj: sensor = Sensor(obj['sensor_id']) for key, val in obj.items(): setattr(sensor, key, val...
[ "def", "dict_to_object", "(", "self", ",", "obj", ")", ":", "# pylint: disable=no-self-use", "if", "not", "isinstance", "(", "obj", ",", "dict", ")", ":", "return", "obj", "if", "'sensor_id'", "in", "obj", ":", "sensor", "=", "Sensor", "(", "obj", "[", "...
Return object from dict.
[ "Return", "object", "from", "dict", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/persistence.py#L154-L170
45,658
theolind/pymysensors
mysensors/const.py
get_const
def get_const(protocol_version): """Return the const module for the protocol_version.""" path = next(( CONST_VERSIONS[const_version] for const_version in sorted(CONST_VERSIONS, reverse=True) if parse_ver(protocol_version) >= parse_ver(const_version) ), 'mysensors.const_14') if pa...
python
def get_const(protocol_version): """Return the const module for the protocol_version.""" path = next(( CONST_VERSIONS[const_version] for const_version in sorted(CONST_VERSIONS, reverse=True) if parse_ver(protocol_version) >= parse_ver(const_version) ), 'mysensors.const_14') if pa...
[ "def", "get_const", "(", "protocol_version", ")", ":", "path", "=", "next", "(", "(", "CONST_VERSIONS", "[", "const_version", "]", "for", "const_version", "in", "sorted", "(", "CONST_VERSIONS", ",", "reverse", "=", "True", ")", "if", "parse_ver", "(", "proto...
Return the const module for the protocol_version.
[ "Return", "the", "const", "module", "for", "the", "protocol_version", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/const.py#L19-L30
45,659
theolind/pymysensors
mysensors/ota.py
fw_hex_to_int
def fw_hex_to_int(hex_str, words): """Unpack hex string into integers. Use little-endian and unsigned int format. Specify number of words to unpack with argument words. """ return struct.unpack('<{}H'.format(words), binascii.unhexlify(hex_str))
python
def fw_hex_to_int(hex_str, words): """Unpack hex string into integers. Use little-endian and unsigned int format. Specify number of words to unpack with argument words. """ return struct.unpack('<{}H'.format(words), binascii.unhexlify(hex_str))
[ "def", "fw_hex_to_int", "(", "hex_str", ",", "words", ")", ":", "return", "struct", ".", "unpack", "(", "'<{}H'", ".", "format", "(", "words", ")", ",", "binascii", ".", "unhexlify", "(", "hex_str", ")", ")" ]
Unpack hex string into integers. Use little-endian and unsigned int format. Specify number of words to unpack with argument words.
[ "Unpack", "hex", "string", "into", "integers", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/ota.py#L14-L20
45,660
theolind/pymysensors
mysensors/ota.py
fw_int_to_hex
def fw_int_to_hex(*args): """Pack integers into hex string. Use little-endian and unsigned int format. """ return binascii.hexlify( struct.pack('<{}H'.format(len(args)), *args)).decode('utf-8')
python
def fw_int_to_hex(*args): """Pack integers into hex string. Use little-endian and unsigned int format. """ return binascii.hexlify( struct.pack('<{}H'.format(len(args)), *args)).decode('utf-8')
[ "def", "fw_int_to_hex", "(", "*", "args", ")", ":", "return", "binascii", ".", "hexlify", "(", "struct", ".", "pack", "(", "'<{}H'", ".", "format", "(", "len", "(", "args", ")", ")", ",", "*", "args", ")", ")", ".", "decode", "(", "'utf-8'", ")" ]
Pack integers into hex string. Use little-endian and unsigned int format.
[ "Pack", "integers", "into", "hex", "string", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/ota.py#L23-L29
45,661
theolind/pymysensors
mysensors/ota.py
compute_crc
def compute_crc(data): """Compute CRC16 of data and return an int.""" crc16 = crcmod.predefined.Crc('modbus') crc16.update(data) return int(crc16.hexdigest(), 16)
python
def compute_crc(data): """Compute CRC16 of data and return an int.""" crc16 = crcmod.predefined.Crc('modbus') crc16.update(data) return int(crc16.hexdigest(), 16)
[ "def", "compute_crc", "(", "data", ")", ":", "crc16", "=", "crcmod", ".", "predefined", ".", "Crc", "(", "'modbus'", ")", "crc16", ".", "update", "(", "data", ")", "return", "int", "(", "crc16", ".", "hexdigest", "(", ")", ",", "16", ")" ]
Compute CRC16 of data and return an int.
[ "Compute", "CRC16", "of", "data", "and", "return", "an", "int", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/ota.py#L32-L36
45,662
theolind/pymysensors
mysensors/ota.py
load_fw
def load_fw(path): """Open firmware file and return a binary string.""" fname = os.path.realpath(path) exists = os.path.isfile(fname) if not exists or not os.access(fname, os.R_OK): _LOGGER.error( 'Firmware path %s does not exist or is not readable', path) return ...
python
def load_fw(path): """Open firmware file and return a binary string.""" fname = os.path.realpath(path) exists = os.path.isfile(fname) if not exists or not os.access(fname, os.R_OK): _LOGGER.error( 'Firmware path %s does not exist or is not readable', path) return ...
[ "def", "load_fw", "(", "path", ")", ":", "fname", "=", "os", ".", "path", ".", "realpath", "(", "path", ")", "exists", "=", "os", ".", "path", ".", "isfile", "(", "fname", ")", "if", "not", "exists", "or", "not", "os", ".", "access", "(", "fname"...
Open firmware file and return a binary string.
[ "Open", "firmware", "file", "and", "return", "a", "binary", "string", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/ota.py#L39-L56
45,663
theolind/pymysensors
mysensors/ota.py
prepare_fw
def prepare_fw(bin_string): """Check that firmware is valid and return dict with binary data.""" pads = len(bin_string) % 128 # 128 bytes per page for atmega328 for _ in range(128 - pads): # pad up to even 128 bytes bin_string += b'\xff' fware = { 'blocks': int(len(bin_string) / FIRMWA...
python
def prepare_fw(bin_string): """Check that firmware is valid and return dict with binary data.""" pads = len(bin_string) % 128 # 128 bytes per page for atmega328 for _ in range(128 - pads): # pad up to even 128 bytes bin_string += b'\xff' fware = { 'blocks': int(len(bin_string) / FIRMWA...
[ "def", "prepare_fw", "(", "bin_string", ")", ":", "pads", "=", "len", "(", "bin_string", ")", "%", "128", "# 128 bytes per page for atmega328", "for", "_", "in", "range", "(", "128", "-", "pads", ")", ":", "# pad up to even 128 bytes", "bin_string", "+=", "b'\...
Check that firmware is valid and return dict with binary data.
[ "Check", "that", "firmware", "is", "valid", "and", "return", "dict", "with", "binary", "data", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/ota.py#L59-L69
45,664
theolind/pymysensors
mysensors/ota.py
OTAFirmware._get_fw
def _get_fw(self, msg, updates, req_fw_type=None, req_fw_ver=None): """Get firmware type, version and a dict holding binary data.""" fw_type = None fw_ver = None if not isinstance(updates, tuple): updates = (updates, ) for store in updates: fw_id = store.p...
python
def _get_fw(self, msg, updates, req_fw_type=None, req_fw_ver=None): """Get firmware type, version and a dict holding binary data.""" fw_type = None fw_ver = None if not isinstance(updates, tuple): updates = (updates, ) for store in updates: fw_id = store.p...
[ "def", "_get_fw", "(", "self", ",", "msg", ",", "updates", ",", "req_fw_type", "=", "None", ",", "req_fw_ver", "=", "None", ")", ":", "fw_type", "=", "None", "fw_ver", "=", "None", "if", "not", "isinstance", "(", "updates", ",", "tuple", ")", ":", "u...
Get firmware type, version and a dict holding binary data.
[ "Get", "firmware", "type", "version", "and", "a", "dict", "holding", "binary", "data", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/ota.py#L84-L108
45,665
theolind/pymysensors
mysensors/ota.py
OTAFirmware.respond_fw
def respond_fw(self, msg): """Respond to a firmware request.""" req_fw_type, req_fw_ver, req_blk = fw_hex_to_int(msg.payload, 3) _LOGGER.debug( 'Received firmware request with firmware type %s, ' 'firmware version %s, block index %s', req_fw_type, req_fw_ver, ...
python
def respond_fw(self, msg): """Respond to a firmware request.""" req_fw_type, req_fw_ver, req_blk = fw_hex_to_int(msg.payload, 3) _LOGGER.debug( 'Received firmware request with firmware type %s, ' 'firmware version %s, block index %s', req_fw_type, req_fw_ver, ...
[ "def", "respond_fw", "(", "self", ",", "msg", ")", ":", "req_fw_type", ",", "req_fw_ver", ",", "req_blk", "=", "fw_hex_to_int", "(", "msg", ".", "payload", ",", "3", ")", "_LOGGER", ".", "debug", "(", "'Received firmware request with firmware type %s, '", "'firm...
Respond to a firmware request.
[ "Respond", "to", "a", "firmware", "request", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/ota.py#L110-L128
45,666
theolind/pymysensors
mysensors/ota.py
OTAFirmware.respond_fw_config
def respond_fw_config(self, msg): """Respond to a firmware config request.""" (req_fw_type, req_fw_ver, req_blocks, req_crc, bloader_ver) = fw_hex_to_int(msg.payload, 5) _LOGGER.debug( 'Received firmware config request with firmware type %s, ' ...
python
def respond_fw_config(self, msg): """Respond to a firmware config request.""" (req_fw_type, req_fw_ver, req_blocks, req_crc, bloader_ver) = fw_hex_to_int(msg.payload, 5) _LOGGER.debug( 'Received firmware config request with firmware type %s, ' ...
[ "def", "respond_fw_config", "(", "self", ",", "msg", ")", ":", "(", "req_fw_type", ",", "req_fw_ver", ",", "req_blocks", ",", "req_crc", ",", "bloader_ver", ")", "=", "fw_hex_to_int", "(", "msg", ".", "payload", ",", "5", ")", "_LOGGER", ".", "debug", "(...
Respond to a firmware config request.
[ "Respond", "to", "a", "firmware", "config", "request", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/ota.py#L130-L157
45,667
theolind/pymysensors
mysensors/ota.py
OTAFirmware.make_update
def make_update(self, nids, fw_type, fw_ver, fw_bin=None): """Start firmware update process for one or more node_id.""" try: fw_type, fw_ver = int(fw_type), int(fw_ver) except ValueError: _LOGGER.error( 'Firmware type %s or version %s not valid, ' ...
python
def make_update(self, nids, fw_type, fw_ver, fw_bin=None): """Start firmware update process for one or more node_id.""" try: fw_type, fw_ver = int(fw_type), int(fw_ver) except ValueError: _LOGGER.error( 'Firmware type %s or version %s not valid, ' ...
[ "def", "make_update", "(", "self", ",", "nids", ",", "fw_type", ",", "fw_ver", ",", "fw_bin", "=", "None", ")", ":", "try", ":", "fw_type", ",", "fw_ver", "=", "int", "(", "fw_type", ")", ",", "int", "(", "fw_ver", ")", "except", "ValueError", ":", ...
Start firmware update process for one or more node_id.
[ "Start", "firmware", "update", "process", "for", "one", "or", "more", "node_id", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/ota.py#L159-L184
45,668
theolind/pymysensors
mysensors/handler.py
handle_smartsleep
def handle_smartsleep(msg): """Process a message before going back to smartsleep.""" while msg.gateway.sensors[msg.node_id].queue: msg.gateway.add_job( str, msg.gateway.sensors[msg.node_id].queue.popleft()) for child in msg.gateway.sensors[msg.node_id].children.values(): new_chil...
python
def handle_smartsleep(msg): """Process a message before going back to smartsleep.""" while msg.gateway.sensors[msg.node_id].queue: msg.gateway.add_job( str, msg.gateway.sensors[msg.node_id].queue.popleft()) for child in msg.gateway.sensors[msg.node_id].children.values(): new_chil...
[ "def", "handle_smartsleep", "(", "msg", ")", ":", "while", "msg", ".", "gateway", ".", "sensors", "[", "msg", ".", "node_id", "]", ".", "queue", ":", "msg", ".", "gateway", ".", "add_job", "(", "str", ",", "msg", ".", "gateway", ".", "sensors", "[", ...
Process a message before going back to smartsleep.
[ "Process", "a", "message", "before", "going", "back", "to", "smartsleep", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/handler.py#L14-L28
45,669
theolind/pymysensors
mysensors/handler.py
handle_presentation
def handle_presentation(msg): """Process a presentation message.""" if msg.child_id == SYSTEM_CHILD_ID: # this is a presentation of the sensor platform sensorid = msg.gateway.add_sensor(msg.node_id) if sensorid is None: return None msg.gateway.sensors[msg.node_id].typ...
python
def handle_presentation(msg): """Process a presentation message.""" if msg.child_id == SYSTEM_CHILD_ID: # this is a presentation of the sensor platform sensorid = msg.gateway.add_sensor(msg.node_id) if sensorid is None: return None msg.gateway.sensors[msg.node_id].typ...
[ "def", "handle_presentation", "(", "msg", ")", ":", "if", "msg", ".", "child_id", "==", "SYSTEM_CHILD_ID", ":", "# this is a presentation of the sensor platform", "sensorid", "=", "msg", ".", "gateway", ".", "add_sensor", "(", "msg", ".", "node_id", ")", "if", "...
Process a presentation message.
[ "Process", "a", "presentation", "message", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/handler.py#L32-L55
45,670
theolind/pymysensors
mysensors/handler.py
handle_set
def handle_set(msg): """Process a set message.""" if not msg.gateway.is_sensor(msg.node_id, msg.child_id): return None msg.gateway.sensors[msg.node_id].set_child_value( msg.child_id, msg.sub_type, msg.payload) if msg.gateway.sensors[msg.node_id].new_state: msg.gateway.sensors[msg...
python
def handle_set(msg): """Process a set message.""" if not msg.gateway.is_sensor(msg.node_id, msg.child_id): return None msg.gateway.sensors[msg.node_id].set_child_value( msg.child_id, msg.sub_type, msg.payload) if msg.gateway.sensors[msg.node_id].new_state: msg.gateway.sensors[msg...
[ "def", "handle_set", "(", "msg", ")", ":", "if", "not", "msg", ".", "gateway", ".", "is_sensor", "(", "msg", ".", "node_id", ",", "msg", ".", "child_id", ")", ":", "return", "None", "msg", ".", "gateway", ".", "sensors", "[", "msg", ".", "node_id", ...
Process a set message.
[ "Process", "a", "set", "message", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/handler.py#L59-L76
45,671
theolind/pymysensors
mysensors/handler.py
handle_req
def handle_req(msg): """Process a req message. This will return the value if it exists. If no value exists, nothing is returned. """ if not msg.gateway.is_sensor(msg.node_id, msg.child_id): return None value = msg.gateway.sensors[msg.node_id].children[ msg.child_id].values.get(m...
python
def handle_req(msg): """Process a req message. This will return the value if it exists. If no value exists, nothing is returned. """ if not msg.gateway.is_sensor(msg.node_id, msg.child_id): return None value = msg.gateway.sensors[msg.node_id].children[ msg.child_id].values.get(m...
[ "def", "handle_req", "(", "msg", ")", ":", "if", "not", "msg", ".", "gateway", ".", "is_sensor", "(", "msg", ".", "node_id", ",", "msg", ".", "child_id", ")", ":", "return", "None", "value", "=", "msg", ".", "gateway", ".", "sensors", "[", "msg", "...
Process a req message. This will return the value if it exists. If no value exists, nothing is returned.
[ "Process", "a", "req", "message", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/handler.py#L80-L93
45,672
theolind/pymysensors
mysensors/handler.py
handle_internal
def handle_internal(msg): """Process an internal message.""" internal = msg.gateway.const.Internal(msg.sub_type) handler = internal.get_handler(msg.gateway.handlers) if handler is None: return None return handler(msg)
python
def handle_internal(msg): """Process an internal message.""" internal = msg.gateway.const.Internal(msg.sub_type) handler = internal.get_handler(msg.gateway.handlers) if handler is None: return None return handler(msg)
[ "def", "handle_internal", "(", "msg", ")", ":", "internal", "=", "msg", ".", "gateway", ".", "const", ".", "Internal", "(", "msg", ".", "sub_type", ")", "handler", "=", "internal", ".", "get_handler", "(", "msg", ".", "gateway", ".", "handlers", ")", "...
Process an internal message.
[ "Process", "an", "internal", "message", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/handler.py#L97-L103
45,673
theolind/pymysensors
mysensors/handler.py
handle_stream
def handle_stream(msg): """Process a stream type message.""" if not msg.gateway.is_sensor(msg.node_id): return None stream = msg.gateway.const.Stream(msg.sub_type) handler = stream.get_handler(msg.gateway.handlers) if handler is None: return None return handler(msg)
python
def handle_stream(msg): """Process a stream type message.""" if not msg.gateway.is_sensor(msg.node_id): return None stream = msg.gateway.const.Stream(msg.sub_type) handler = stream.get_handler(msg.gateway.handlers) if handler is None: return None return handler(msg)
[ "def", "handle_stream", "(", "msg", ")", ":", "if", "not", "msg", ".", "gateway", ".", "is_sensor", "(", "msg", ".", "node_id", ")", ":", "return", "None", "stream", "=", "msg", ".", "gateway", ".", "const", ".", "Stream", "(", "msg", ".", "sub_type"...
Process a stream type message.
[ "Process", "a", "stream", "type", "message", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/handler.py#L107-L115
45,674
theolind/pymysensors
mysensors/handler.py
handle_id_request
def handle_id_request(msg): """Process an internal id request message.""" node_id = msg.gateway.add_sensor() return msg.copy( ack=0, sub_type=msg.gateway.const.Internal['I_ID_RESPONSE'], payload=node_id) if node_id is not None else None
python
def handle_id_request(msg): """Process an internal id request message.""" node_id = msg.gateway.add_sensor() return msg.copy( ack=0, sub_type=msg.gateway.const.Internal['I_ID_RESPONSE'], payload=node_id) if node_id is not None else None
[ "def", "handle_id_request", "(", "msg", ")", ":", "node_id", "=", "msg", ".", "gateway", ".", "add_sensor", "(", ")", "return", "msg", ".", "copy", "(", "ack", "=", "0", ",", "sub_type", "=", "msg", ".", "gateway", ".", "const", ".", "Internal", "[",...
Process an internal id request message.
[ "Process", "an", "internal", "id", "request", "message", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/handler.py#L131-L136
45,675
theolind/pymysensors
mysensors/handler.py
handle_time
def handle_time(msg): """Process an internal time request message.""" return msg.copy(ack=0, payload=calendar.timegm(time.localtime()))
python
def handle_time(msg): """Process an internal time request message.""" return msg.copy(ack=0, payload=calendar.timegm(time.localtime()))
[ "def", "handle_time", "(", "msg", ")", ":", "return", "msg", ".", "copy", "(", "ack", "=", "0", ",", "payload", "=", "calendar", ".", "timegm", "(", "time", ".", "localtime", "(", ")", ")", ")" ]
Process an internal time request message.
[ "Process", "an", "internal", "time", "request", "message", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/handler.py#L146-L148
45,676
theolind/pymysensors
mysensors/handler.py
handle_battery_level
def handle_battery_level(msg): """Process an internal battery level message.""" if not msg.gateway.is_sensor(msg.node_id): return None msg.gateway.sensors[msg.node_id].battery_level = msg.payload msg.gateway.alert(msg) return None
python
def handle_battery_level(msg): """Process an internal battery level message.""" if not msg.gateway.is_sensor(msg.node_id): return None msg.gateway.sensors[msg.node_id].battery_level = msg.payload msg.gateway.alert(msg) return None
[ "def", "handle_battery_level", "(", "msg", ")", ":", "if", "not", "msg", ".", "gateway", ".", "is_sensor", "(", "msg", ".", "node_id", ")", ":", "return", "None", "msg", ".", "gateway", ".", "sensors", "[", "msg", ".", "node_id", "]", ".", "battery_lev...
Process an internal battery level message.
[ "Process", "an", "internal", "battery", "level", "message", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/handler.py#L152-L158
45,677
theolind/pymysensors
mysensors/handler.py
handle_sketch_name
def handle_sketch_name(msg): """Process an internal sketch name message.""" if not msg.gateway.is_sensor(msg.node_id): return None msg.gateway.sensors[msg.node_id].sketch_name = msg.payload msg.gateway.alert(msg) return None
python
def handle_sketch_name(msg): """Process an internal sketch name message.""" if not msg.gateway.is_sensor(msg.node_id): return None msg.gateway.sensors[msg.node_id].sketch_name = msg.payload msg.gateway.alert(msg) return None
[ "def", "handle_sketch_name", "(", "msg", ")", ":", "if", "not", "msg", ".", "gateway", ".", "is_sensor", "(", "msg", ".", "node_id", ")", ":", "return", "None", "msg", ".", "gateway", ".", "sensors", "[", "msg", ".", "node_id", "]", ".", "sketch_name",...
Process an internal sketch name message.
[ "Process", "an", "internal", "sketch", "name", "message", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/handler.py#L162-L168
45,678
theolind/pymysensors
mysensors/handler.py
handle_sketch_version
def handle_sketch_version(msg): """Process an internal sketch version message.""" if not msg.gateway.is_sensor(msg.node_id): return None msg.gateway.sensors[msg.node_id].sketch_version = msg.payload msg.gateway.alert(msg) return None
python
def handle_sketch_version(msg): """Process an internal sketch version message.""" if not msg.gateway.is_sensor(msg.node_id): return None msg.gateway.sensors[msg.node_id].sketch_version = msg.payload msg.gateway.alert(msg) return None
[ "def", "handle_sketch_version", "(", "msg", ")", ":", "if", "not", "msg", ".", "gateway", ".", "is_sensor", "(", "msg", ".", "node_id", ")", ":", "return", "None", "msg", ".", "gateway", ".", "sensors", "[", "msg", ".", "node_id", "]", ".", "sketch_ver...
Process an internal sketch version message.
[ "Process", "an", "internal", "sketch", "version", "message", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/handler.py#L172-L178
45,679
theolind/pymysensors
mysensors/handler.py
handle_log_message
def handle_log_message(msg): # pylint: disable=useless-return """Process an internal log message.""" msg.gateway.can_log = True _LOGGER.debug( 'n:%s c:%s t:%s s:%s p:%s', msg.node_id, msg.child_id, msg.type, msg.sub_type, msg.payload) return None
python
def handle_log_message(msg): # pylint: disable=useless-return """Process an internal log message.""" msg.gateway.can_log = True _LOGGER.debug( 'n:%s c:%s t:%s s:%s p:%s', msg.node_id, msg.child_id, msg.type, msg.sub_type, msg.payload) return None
[ "def", "handle_log_message", "(", "msg", ")", ":", "# pylint: disable=useless-return", "msg", ".", "gateway", ".", "can_log", "=", "True", "_LOGGER", ".", "debug", "(", "'n:%s c:%s t:%s s:%s p:%s'", ",", "msg", ".", "node_id", ",", "msg", ".", "child_id", ",", ...
Process an internal log message.
[ "Process", "an", "internal", "log", "message", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/handler.py#L182-L188
45,680
theolind/pymysensors
mqtt.py
MQTT.publish
def publish(self, topic, payload, qos, retain): """Publish an MQTT message.""" self._mqttc.publish(topic, payload, qos, retain)
python
def publish(self, topic, payload, qos, retain): """Publish an MQTT message.""" self._mqttc.publish(topic, payload, qos, retain)
[ "def", "publish", "(", "self", ",", "topic", ",", "payload", ",", "qos", ",", "retain", ")", ":", "self", ".", "_mqttc", ".", "publish", "(", "topic", ",", "payload", ",", "qos", ",", "retain", ")" ]
Publish an MQTT message.
[ "Publish", "an", "MQTT", "message", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mqtt.py#L18-L20
45,681
theolind/pymysensors
mqtt.py
MQTT.subscribe
def subscribe(self, topic, callback, qos): """Subscribe to an MQTT topic.""" if topic in self.topics: return def _message_callback(mqttc, userdata, msg): """Callback added to callback list for received message.""" callback(msg.topic, msg.payload.decode('utf-8...
python
def subscribe(self, topic, callback, qos): """Subscribe to an MQTT topic.""" if topic in self.topics: return def _message_callback(mqttc, userdata, msg): """Callback added to callback list for received message.""" callback(msg.topic, msg.payload.decode('utf-8...
[ "def", "subscribe", "(", "self", ",", "topic", ",", "callback", ",", "qos", ")", ":", "if", "topic", "in", "self", ".", "topics", ":", "return", "def", "_message_callback", "(", "mqttc", ",", "userdata", ",", "msg", ")", ":", "\"\"\"Callback added to callb...
Subscribe to an MQTT topic.
[ "Subscribe", "to", "an", "MQTT", "topic", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mqtt.py#L22-L33
45,682
theolind/pymysensors
mysensors/gateway_serial.py
SerialGateway._connect
def _connect(self): """Connect to the serial port. This should be run in a new thread.""" while self.protocol: _LOGGER.info('Trying to connect to %s', self.port) try: ser = serial.serial_for_url( self.port, self.baud, timeout=self.timeout) ...
python
def _connect(self): """Connect to the serial port. This should be run in a new thread.""" while self.protocol: _LOGGER.info('Trying to connect to %s', self.port) try: ser = serial.serial_for_url( self.port, self.baud, timeout=self.timeout) ...
[ "def", "_connect", "(", "self", ")", ":", "while", "self", ".", "protocol", ":", "_LOGGER", ".", "info", "(", "'Trying to connect to %s'", ",", "self", ".", "port", ")", "try", ":", "ser", "=", "serial", ".", "serial_for_url", "(", "self", ".", "port", ...
Connect to the serial port. This should be run in a new thread.
[ "Connect", "to", "the", "serial", "port", ".", "This", "should", "be", "run", "in", "a", "new", "thread", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/gateway_serial.py#L44-L66
45,683
theolind/pymysensors
mysensors/gateway_serial.py
AsyncSerialGateway._connect
def _connect(self): """Connect to the serial port.""" try: while True: _LOGGER.info('Trying to connect to %s', self.port) try: yield from serial_asyncio.create_serial_connection( self.loop, lambda: self.protocol, sel...
python
def _connect(self): """Connect to the serial port.""" try: while True: _LOGGER.info('Trying to connect to %s', self.port) try: yield from serial_asyncio.create_serial_connection( self.loop, lambda: self.protocol, sel...
[ "def", "_connect", "(", "self", ")", ":", "try", ":", "while", "True", ":", "_LOGGER", ".", "info", "(", "'Trying to connect to %s'", ",", "self", ".", "port", ")", "try", ":", "yield", "from", "serial_asyncio", ".", "create_serial_connection", "(", "self", ...
Connect to the serial port.
[ "Connect", "to", "the", "serial", "port", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/gateway_serial.py#L79-L96
45,684
theolind/pymysensors
mysensors/validation.py
is_version
def is_version(value): """Validate that value is a valid version string.""" try: value = str(value) if not parse_ver('1.4') <= parse_ver(value): raise ValueError() return value except (AttributeError, TypeError, ValueError): raise vol.Invalid( '{} is n...
python
def is_version(value): """Validate that value is a valid version string.""" try: value = str(value) if not parse_ver('1.4') <= parse_ver(value): raise ValueError() return value except (AttributeError, TypeError, ValueError): raise vol.Invalid( '{} is n...
[ "def", "is_version", "(", "value", ")", ":", "try", ":", "value", "=", "str", "(", "value", ")", "if", "not", "parse_ver", "(", "'1.4'", ")", "<=", "parse_ver", "(", "value", ")", ":", "raise", "ValueError", "(", ")", "return", "value", "except", "("...
Validate that value is a valid version string.
[ "Validate", "that", "value", "is", "a", "valid", "version", "string", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/validation.py#L15-L24
45,685
theolind/pymysensors
mysensors/validation.py
is_battery_level
def is_battery_level(value): """Validate that value is a valid battery level integer.""" try: value = percent_int(value) return value except vol.Invalid: _LOGGER.warning( '%s is not a valid battery level, falling back to battery level 0', value) return...
python
def is_battery_level(value): """Validate that value is a valid battery level integer.""" try: value = percent_int(value) return value except vol.Invalid: _LOGGER.warning( '%s is not a valid battery level, falling back to battery level 0', value) return...
[ "def", "is_battery_level", "(", "value", ")", ":", "try", ":", "value", "=", "percent_int", "(", "value", ")", "return", "value", "except", "vol", ".", "Invalid", ":", "_LOGGER", ".", "warning", "(", "'%s is not a valid battery level, falling back to battery level 0...
Validate that value is a valid battery level integer.
[ "Validate", "that", "value", "is", "a", "valid", "battery", "level", "integer", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/validation.py#L38-L47
45,686
theolind/pymysensors
mysensors/validation.py
is_heartbeat
def is_heartbeat(value): """Validate that value is a valid heartbeat integer.""" try: value = vol.Coerce(int)(value) return value except vol.Invalid: _LOGGER.warning( '%s is not a valid heartbeat value, falling back to heartbeat 0', value) return 0
python
def is_heartbeat(value): """Validate that value is a valid heartbeat integer.""" try: value = vol.Coerce(int)(value) return value except vol.Invalid: _LOGGER.warning( '%s is not a valid heartbeat value, falling back to heartbeat 0', value) return 0
[ "def", "is_heartbeat", "(", "value", ")", ":", "try", ":", "value", "=", "vol", ".", "Coerce", "(", "int", ")", "(", "value", ")", "return", "value", "except", "vol", ".", "Invalid", ":", "_LOGGER", ".", "warning", "(", "'%s is not a valid heartbeat value,...
Validate that value is a valid heartbeat integer.
[ "Validate", "that", "value", "is", "a", "valid", "heartbeat", "integer", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/validation.py#L50-L59
45,687
thusoy/python-crypt
pcrypt.py
mksalt
def mksalt(method=None, rounds=None): """Generate a salt for the specified method. If not specified, the strongest available method will be used. """ if method is None: method = methods[0] salt = ['${0}$'.format(method.ident) if method.ident else ''] if rounds: salt.append('round...
python
def mksalt(method=None, rounds=None): """Generate a salt for the specified method. If not specified, the strongest available method will be used. """ if method is None: method = methods[0] salt = ['${0}$'.format(method.ident) if method.ident else ''] if rounds: salt.append('round...
[ "def", "mksalt", "(", "method", "=", "None", ",", "rounds", "=", "None", ")", ":", "if", "method", "is", "None", ":", "method", "=", "methods", "[", "0", "]", "salt", "=", "[", "'${0}$'", ".", "format", "(", "method", ".", "ident", ")", "if", "me...
Generate a salt for the specified method. If not specified, the strongest available method will be used.
[ "Generate", "a", "salt", "for", "the", "specified", "method", ".", "If", "not", "specified", "the", "strongest", "available", "method", "will", "be", "used", "." ]
0835f7568c14762890cea70b7605d04b3459e4a0
https://github.com/thusoy/python-crypt/blob/0835f7568c14762890cea70b7605d04b3459e4a0/pcrypt.py#L46-L56
45,688
thusoy/python-crypt
pcrypt.py
double_prompt_for_plaintext_password
def double_prompt_for_plaintext_password(): """Get the desired password from the user through a double prompt.""" password = 1 password_repeat = 2 while password != password_repeat: password = getpass.getpass('Enter password: ') password_repeat = getpass.getpass('Repeat password: ') ...
python
def double_prompt_for_plaintext_password(): """Get the desired password from the user through a double prompt.""" password = 1 password_repeat = 2 while password != password_repeat: password = getpass.getpass('Enter password: ') password_repeat = getpass.getpass('Repeat password: ') ...
[ "def", "double_prompt_for_plaintext_password", "(", ")", ":", "password", "=", "1", "password_repeat", "=", "2", "while", "password", "!=", "password_repeat", ":", "password", "=", "getpass", ".", "getpass", "(", "'Enter password: '", ")", "password_repeat", "=", ...
Get the desired password from the user through a double prompt.
[ "Get", "the", "desired", "password", "from", "the", "user", "through", "a", "double", "prompt", "." ]
0835f7568c14762890cea70b7605d04b3459e4a0
https://github.com/thusoy/python-crypt/blob/0835f7568c14762890cea70b7605d04b3459e4a0/pcrypt.py#L286-L295
45,689
theolind/pymysensors
mysensors/__init__.py
Gateway.logic
def logic(self, data): """Parse the data and respond to it appropriately. Response is returned to the caller and has to be sent data as a mysensors command string. """ try: msg = Message(data, self) msg.validate(self.protocol_version) except (Valu...
python
def logic(self, data): """Parse the data and respond to it appropriately. Response is returned to the caller and has to be sent data as a mysensors command string. """ try: msg = Message(data, self) msg.validate(self.protocol_version) except (Valu...
[ "def", "logic", "(", "self", ",", "data", ")", ":", "try", ":", "msg", "=", "Message", "(", "data", ",", "self", ")", "msg", ".", "validate", "(", "self", ".", "protocol_version", ")", "except", "(", "ValueError", ",", "vol", ".", "Invalid", ")", "...
Parse the data and respond to it appropriately. Response is returned to the caller and has to be sent data as a mysensors command string.
[ "Parse", "the", "data", "and", "respond", "to", "it", "appropriately", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L57-L75
45,690
theolind/pymysensors
mysensors/__init__.py
Gateway.alert
def alert(self, msg): """Tell anyone who wants to know that a sensor was updated.""" if self.event_callback is not None: try: self.event_callback(msg) except Exception as exception: # pylint: disable=broad-except _LOGGER.exception(exception) ...
python
def alert(self, msg): """Tell anyone who wants to know that a sensor was updated.""" if self.event_callback is not None: try: self.event_callback(msg) except Exception as exception: # pylint: disable=broad-except _LOGGER.exception(exception) ...
[ "def", "alert", "(", "self", ",", "msg", ")", ":", "if", "self", ".", "event_callback", "is", "not", "None", ":", "try", ":", "self", ".", "event_callback", "(", "msg", ")", "except", "Exception", "as", "exception", ":", "# pylint: disable=broad-except", "...
Tell anyone who wants to know that a sensor was updated.
[ "Tell", "anyone", "who", "wants", "to", "know", "that", "a", "sensor", "was", "updated", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L77-L86
45,691
theolind/pymysensors
mysensors/__init__.py
Gateway._get_next_id
def _get_next_id(self): """Return the next available sensor id.""" if self.sensors: next_id = max(self.sensors.keys()) + 1 else: next_id = 1 if next_id <= self.const.MAX_NODE_ID: return next_id return None
python
def _get_next_id(self): """Return the next available sensor id.""" if self.sensors: next_id = max(self.sensors.keys()) + 1 else: next_id = 1 if next_id <= self.const.MAX_NODE_ID: return next_id return None
[ "def", "_get_next_id", "(", "self", ")", ":", "if", "self", ".", "sensors", ":", "next_id", "=", "max", "(", "self", ".", "sensors", ".", "keys", "(", ")", ")", "+", "1", "else", ":", "next_id", "=", "1", "if", "next_id", "<=", "self", ".", "cons...
Return the next available sensor id.
[ "Return", "the", "next", "available", "sensor", "id", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L88-L96
45,692
theolind/pymysensors
mysensors/__init__.py
Gateway.add_sensor
def add_sensor(self, sensorid=None): """Add a sensor to the gateway.""" if sensorid is None: sensorid = self._get_next_id() if sensorid is not None and sensorid not in self.sensors: self.sensors[sensorid] = Sensor(sensorid) return sensorid if sensorid in self.sens...
python
def add_sensor(self, sensorid=None): """Add a sensor to the gateway.""" if sensorid is None: sensorid = self._get_next_id() if sensorid is not None and sensorid not in self.sensors: self.sensors[sensorid] = Sensor(sensorid) return sensorid if sensorid in self.sens...
[ "def", "add_sensor", "(", "self", ",", "sensorid", "=", "None", ")", ":", "if", "sensorid", "is", "None", ":", "sensorid", "=", "self", ".", "_get_next_id", "(", ")", "if", "sensorid", "is", "not", "None", "and", "sensorid", "not", "in", "self", ".", ...
Add a sensor to the gateway.
[ "Add", "a", "sensor", "to", "the", "gateway", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L98-L104
45,693
theolind/pymysensors
mysensors/__init__.py
Gateway.is_sensor
def is_sensor(self, sensorid, child_id=None): """Return True if a sensor and its child exist.""" ret = sensorid in self.sensors if not ret: _LOGGER.warning('Node %s is unknown', sensorid) if ret and child_id is not None: ret = child_id in self.sensors[sensorid].ch...
python
def is_sensor(self, sensorid, child_id=None): """Return True if a sensor and its child exist.""" ret = sensorid in self.sensors if not ret: _LOGGER.warning('Node %s is unknown', sensorid) if ret and child_id is not None: ret = child_id in self.sensors[sensorid].ch...
[ "def", "is_sensor", "(", "self", ",", "sensorid", ",", "child_id", "=", "None", ")", ":", "ret", "=", "sensorid", "in", "self", ".", "sensors", "if", "not", "ret", ":", "_LOGGER", ".", "warning", "(", "'Node %s is unknown'", ",", "sensorid", ")", "if", ...
Return True if a sensor and its child exist.
[ "Return", "True", "if", "a", "sensor", "and", "its", "child", "exist", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L106-L124
45,694
theolind/pymysensors
mysensors/__init__.py
Gateway.run_job
def run_job(self, job=None): """Run a job, either passed in or from the queue. A job is a tuple of function and optional args. Keyword arguments can be passed via use of functools.partial. The job should return a string that should be sent by the gateway protocol. The function will ...
python
def run_job(self, job=None): """Run a job, either passed in or from the queue. A job is a tuple of function and optional args. Keyword arguments can be passed via use of functools.partial. The job should return a string that should be sent by the gateway protocol. The function will ...
[ "def", "run_job", "(", "self", ",", "job", "=", "None", ")", ":", "if", "job", "is", "None", ":", "if", "not", "self", ".", "queue", ":", "return", "None", "job", "=", "self", ".", "queue", ".", "popleft", "(", ")", "start", "=", "timer", "(", ...
Run a job, either passed in or from the queue. A job is a tuple of function and optional args. Keyword arguments can be passed via use of functools.partial. The job should return a string that should be sent by the gateway protocol. The function will be called with the arguments and the...
[ "Run", "a", "job", "either", "passed", "in", "or", "from", "the", "queue", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L137-L157
45,695
theolind/pymysensors
mysensors/__init__.py
Gateway.set_child_value
def set_child_value( self, sensor_id, child_id, value_type, value, **kwargs): """Add a command to set a sensor value, to the queue. A queued command will be sent to the sensor when the gateway thread has sent all previously queued commands. If the sensor attribute new_state...
python
def set_child_value( self, sensor_id, child_id, value_type, value, **kwargs): """Add a command to set a sensor value, to the queue. A queued command will be sent to the sensor when the gateway thread has sent all previously queued commands. If the sensor attribute new_state...
[ "def", "set_child_value", "(", "self", ",", "sensor_id", ",", "child_id", ",", "value_type", ",", "value", ",", "*", "*", "kwargs", ")", ":", "if", "not", "self", ".", "is_sensor", "(", "sensor_id", ",", "child_id", ")", ":", "return", "if", "self", "....
Add a command to set a sensor value, to the queue. A queued command will be sent to the sensor when the gateway thread has sent all previously queued commands. If the sensor attribute new_state returns True, the command will be buffered in a queue on the sensor, and only the internal s...
[ "Add", "a", "command", "to", "set", "a", "sensor", "value", "to", "the", "queue", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L168-L189
45,696
theolind/pymysensors
mysensors/__init__.py
ThreadingGateway._poll_queue
def _poll_queue(self): """Poll the queue for work.""" while not self._stop_event.is_set(): reply = self.run_job() self.send(reply) if self.queue: continue time.sleep(0.02)
python
def _poll_queue(self): """Poll the queue for work.""" while not self._stop_event.is_set(): reply = self.run_job() self.send(reply) if self.queue: continue time.sleep(0.02)
[ "def", "_poll_queue", "(", "self", ")", ":", "while", "not", "self", ".", "_stop_event", ".", "is_set", "(", ")", ":", "reply", "=", "self", ".", "run_job", "(", ")", "self", ".", "send", "(", "reply", ")", "if", "self", ".", "queue", ":", "continu...
Poll the queue for work.
[ "Poll", "the", "queue", "for", "work", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L236-L243
45,697
theolind/pymysensors
mysensors/__init__.py
ThreadingGateway.stop
def stop(self): """Stop the background thread.""" self._stop_event.set() if not self.persistence: return if self._cancel_save is not None: self._cancel_save() self._cancel_save = None self.persistence.save_sensors()
python
def stop(self): """Stop the background thread.""" self._stop_event.set() if not self.persistence: return if self._cancel_save is not None: self._cancel_save() self._cancel_save = None self.persistence.save_sensors()
[ "def", "stop", "(", "self", ")", ":", "self", ".", "_stop_event", ".", "set", "(", ")", "if", "not", "self", ".", "persistence", ":", "return", "if", "self", ".", "_cancel_save", "is", "not", "None", ":", "self", ".", "_cancel_save", "(", ")", "self"...
Stop the background thread.
[ "Stop", "the", "background", "thread", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L262-L270
45,698
theolind/pymysensors
mysensors/__init__.py
ThreadingGateway.update_fw
def update_fw(self, nids, fw_type, fw_ver, fw_path=None): """Update firwmare of all node_ids in nids.""" fw_bin = None if fw_path: fw_bin = load_fw(fw_path) if not fw_bin: return self.ota.make_update(nids, fw_type, fw_ver, fw_bin)
python
def update_fw(self, nids, fw_type, fw_ver, fw_path=None): """Update firwmare of all node_ids in nids.""" fw_bin = None if fw_path: fw_bin = load_fw(fw_path) if not fw_bin: return self.ota.make_update(nids, fw_type, fw_ver, fw_bin)
[ "def", "update_fw", "(", "self", ",", "nids", ",", "fw_type", ",", "fw_ver", ",", "fw_path", "=", "None", ")", ":", "fw_bin", "=", "None", "if", "fw_path", ":", "fw_bin", "=", "load_fw", "(", "fw_path", ")", "if", "not", "fw_bin", ":", "return", "sel...
Update firwmare of all node_ids in nids.
[ "Update", "firwmare", "of", "all", "node_ids", "in", "nids", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L272-L279
45,699
theolind/pymysensors
mysensors/__init__.py
BaseTransportGateway._disconnect
def _disconnect(self): """Disconnect from the transport.""" if not self.protocol or not self.protocol.transport: self.protocol = None # Make sure protocol is None return _LOGGER.info('Disconnecting from gateway') self.protocol.transport.close() self.proto...
python
def _disconnect(self): """Disconnect from the transport.""" if not self.protocol or not self.protocol.transport: self.protocol = None # Make sure protocol is None return _LOGGER.info('Disconnecting from gateway') self.protocol.transport.close() self.proto...
[ "def", "_disconnect", "(", "self", ")", ":", "if", "not", "self", ".", "protocol", "or", "not", "self", ".", "protocol", ".", "transport", ":", "self", ".", "protocol", "=", "None", "# Make sure protocol is None", "return", "_LOGGER", ".", "info", "(", "'D...
Disconnect from the transport.
[ "Disconnect", "from", "the", "transport", "." ]
a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6
https://github.com/theolind/pymysensors/blob/a139ab6e2f6b71ebaf37282f69bfd0f7fe6193b6/mysensors/__init__.py#L294-L301