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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
220,100 | dedupeio/dedupe | dedupe/api.py | Matching.thresholdBlocks | def thresholdBlocks(self, blocks, recall_weight=1.5): # pragma: nocover
"""
Returns the threshold that maximizes the expected F score, a
weighted average of precision and recall for a sample of
blocked data.
Arguments:
blocks -- Sequence of tuples of records, where eac... | python | def thresholdBlocks(self, blocks, recall_weight=1.5): # pragma: nocover
"""
Returns the threshold that maximizes the expected F score, a
weighted average of precision and recall for a sample of
blocked data.
Arguments:
blocks -- Sequence of tuples of records, where eac... | [
"def",
"thresholdBlocks",
"(",
"self",
",",
"blocks",
",",
"recall_weight",
"=",
"1.5",
")",
":",
"# pragma: nocover",
"candidate_records",
"=",
"itertools",
".",
"chain",
".",
"from_iterable",
"(",
"self",
".",
"_blockedPairs",
"(",
"blocks",
")",
")",
"proba... | Returns the threshold that maximizes the expected F score, a
weighted average of precision and recall for a sample of
blocked data.
Arguments:
blocks -- Sequence of tuples of records, where each tuple is a
set of records covered by a blocking predicate
recall... | [
"Returns",
"the",
"threshold",
"that",
"maximizes",
"the",
"expected",
"F",
"score",
"a",
"weighted",
"average",
"of",
"precision",
"and",
"recall",
"for",
"a",
"sample",
"of",
"blocked",
"data",
"."
] | 9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b | https://github.com/dedupeio/dedupe/blob/9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b/dedupe/api.py#L52-L94 |
220,101 | dedupeio/dedupe | dedupe/api.py | DedupeMatching.match | def match(self, data, threshold=0.5, generator=False): # pragma: no cover
"""Identifies records that all refer to the same entity, returns
tuples
containing a set of record ids and a confidence score as a
float between 0 and 1. The record_ids within each set should
refer to the... | python | def match(self, data, threshold=0.5, generator=False): # pragma: no cover
"""Identifies records that all refer to the same entity, returns
tuples
containing a set of record ids and a confidence score as a
float between 0 and 1. The record_ids within each set should
refer to the... | [
"def",
"match",
"(",
"self",
",",
"data",
",",
"threshold",
"=",
"0.5",
",",
"generator",
"=",
"False",
")",
":",
"# pragma: no cover",
"blocked_pairs",
"=",
"self",
".",
"_blockData",
"(",
"data",
")",
"clusters",
"=",
"self",
".",
"matchBlocks",
"(",
"... | Identifies records that all refer to the same entity, returns
tuples
containing a set of record ids and a confidence score as a
float between 0 and 1. The record_ids within each set should
refer to the same entity and the confidence score is a measure
of our confidence that all ... | [
"Identifies",
"records",
"that",
"all",
"refer",
"to",
"the",
"same",
"entity",
"returns",
"tuples"
] | 9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b | https://github.com/dedupeio/dedupe/blob/9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b/dedupe/api.py#L190-L223 |
220,102 | dedupeio/dedupe | dedupe/api.py | ActiveMatching.readTraining | def readTraining(self, training_file):
'''
Read training from previously built training data file object
Arguments:
training_file -- file object containing the training data
'''
logger.info('reading training from file')
training_pairs = json.load(training_file,... | python | def readTraining(self, training_file):
'''
Read training from previously built training data file object
Arguments:
training_file -- file object containing the training data
'''
logger.info('reading training from file')
training_pairs = json.load(training_file,... | [
"def",
"readTraining",
"(",
"self",
",",
"training_file",
")",
":",
"logger",
".",
"info",
"(",
"'reading training from file'",
")",
"training_pairs",
"=",
"json",
".",
"load",
"(",
"training_file",
",",
"cls",
"=",
"serializer",
".",
"dedupe_decoder",
")",
"s... | Read training from previously built training data file object
Arguments:
training_file -- file object containing the training data | [
"Read",
"training",
"from",
"previously",
"built",
"training",
"data",
"file",
"object"
] | 9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b | https://github.com/dedupeio/dedupe/blob/9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b/dedupe/api.py#L635-L647 |
220,103 | dedupeio/dedupe | dedupe/api.py | ActiveMatching.writeTraining | def writeTraining(self, file_obj): # pragma: no cover
"""
Write to a json file that contains labeled examples
Keyword arguments:
file_obj -- file object to write training data to
"""
json.dump(self.training_pairs,
file_obj,
default=s... | python | def writeTraining(self, file_obj): # pragma: no cover
"""
Write to a json file that contains labeled examples
Keyword arguments:
file_obj -- file object to write training data to
"""
json.dump(self.training_pairs,
file_obj,
default=s... | [
"def",
"writeTraining",
"(",
"self",
",",
"file_obj",
")",
":",
"# pragma: no cover",
"json",
".",
"dump",
"(",
"self",
".",
"training_pairs",
",",
"file_obj",
",",
"default",
"=",
"serializer",
".",
"_to_json",
",",
"tuple_as_array",
"=",
"False",
",",
"ens... | Write to a json file that contains labeled examples
Keyword arguments:
file_obj -- file object to write training data to | [
"Write",
"to",
"a",
"json",
"file",
"that",
"contains",
"labeled",
"examples"
] | 9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b | https://github.com/dedupeio/dedupe/blob/9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b/dedupe/api.py#L680-L692 |
220,104 | dedupeio/dedupe | dedupe/api.py | RecordLink.sample | def sample(self, data_1, data_2, sample_size=15000,
blocked_proportion=.5, original_length_1=None,
original_length_2=None):
'''
Draws a random sample of combinations of records from
the first and second datasets, and initializes active
learning with this sam... | python | def sample(self, data_1, data_2, sample_size=15000,
blocked_proportion=.5, original_length_1=None,
original_length_2=None):
'''
Draws a random sample of combinations of records from
the first and second datasets, and initializes active
learning with this sam... | [
"def",
"sample",
"(",
"self",
",",
"data_1",
",",
"data_2",
",",
"sample_size",
"=",
"15000",
",",
"blocked_proportion",
"=",
".5",
",",
"original_length_1",
"=",
"None",
",",
"original_length_2",
"=",
"None",
")",
":",
"self",
".",
"_checkData",
"(",
"dat... | Draws a random sample of combinations of records from
the first and second datasets, and initializes active
learning with this sample
Arguments:
data_1 -- Dictionary of records from first dataset, where the
keys are record_ids and the values are dictionaries... | [
"Draws",
"a",
"random",
"sample",
"of",
"combinations",
"of",
"records",
"from",
"the",
"first",
"and",
"second",
"datasets",
"and",
"initializes",
"active",
"learning",
"with",
"this",
"sample"
] | 9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b | https://github.com/dedupeio/dedupe/blob/9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b/dedupe/api.py#L816-L841 |
220,105 | dedupeio/dedupe | dedupe/clustering.py | condensedDistance | def condensedDistance(dupes):
'''
Convert the pairwise list of distances in dupes to "condensed
distance matrix" required by the hierarchical clustering
algorithms. Also return a dictionary that maps the distance matrix
to the record_ids.
The formula for an index of the condensed matrix is
... | python | def condensedDistance(dupes):
'''
Convert the pairwise list of distances in dupes to "condensed
distance matrix" required by the hierarchical clustering
algorithms. Also return a dictionary that maps the distance matrix
to the record_ids.
The formula for an index of the condensed matrix is
... | [
"def",
"condensedDistance",
"(",
"dupes",
")",
":",
"candidate_set",
"=",
"numpy",
".",
"unique",
"(",
"dupes",
"[",
"'pairs'",
"]",
")",
"i_to_id",
"=",
"dict",
"(",
"enumerate",
"(",
"candidate_set",
")",
")",
"ids",
"=",
"candidate_set",
".",
"searchsor... | Convert the pairwise list of distances in dupes to "condensed
distance matrix" required by the hierarchical clustering
algorithms. Also return a dictionary that maps the distance matrix
to the record_ids.
The formula for an index of the condensed matrix is
index = {N choose 2}-{N-row choose 2} + (... | [
"Convert",
"the",
"pairwise",
"list",
"of",
"distances",
"in",
"dupes",
"to",
"condensed",
"distance",
"matrix",
"required",
"by",
"the",
"hierarchical",
"clustering",
"algorithms",
".",
"Also",
"return",
"a",
"dictionary",
"that",
"maps",
"the",
"distance",
"ma... | 9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b | https://github.com/dedupeio/dedupe/blob/9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b/dedupe/clustering.py#L95-L131 |
220,106 | dedupeio/dedupe | dedupe/clustering.py | cluster | def cluster(dupes, threshold=.5, max_components=30000):
'''
Takes in a list of duplicate pairs and clusters them in to a
list records that all refer to the same entity based on a given
threshold
Keyword arguments:
threshold -- number betweent 0 and 1 (default is .5). lowering the
... | python | def cluster(dupes, threshold=.5, max_components=30000):
'''
Takes in a list of duplicate pairs and clusters them in to a
list records that all refer to the same entity based on a given
threshold
Keyword arguments:
threshold -- number betweent 0 and 1 (default is .5). lowering the
... | [
"def",
"cluster",
"(",
"dupes",
",",
"threshold",
"=",
".5",
",",
"max_components",
"=",
"30000",
")",
":",
"distance_threshold",
"=",
"1",
"-",
"threshold",
"dupe_sub_graphs",
"=",
"connected_components",
"(",
"dupes",
",",
"max_components",
")",
"for",
"sub_... | Takes in a list of duplicate pairs and clusters them in to a
list records that all refer to the same entity based on a given
threshold
Keyword arguments:
threshold -- number betweent 0 and 1 (default is .5). lowering the
number will increase precision, raising it will increase
... | [
"Takes",
"in",
"a",
"list",
"of",
"duplicate",
"pairs",
"and",
"clusters",
"them",
"in",
"to",
"a",
"list",
"records",
"that",
"all",
"refer",
"to",
"the",
"same",
"entity",
"based",
"on",
"a",
"given",
"threshold"
] | 9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b | https://github.com/dedupeio/dedupe/blob/9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b/dedupe/clustering.py#L134-L174 |
220,107 | dedupeio/dedupe | dedupe/clustering.py | confidences | def confidences(cluster, condensed_distances, d):
'''
We calculate a per record score that is similar to a standard
deviation. The main reason is that these record scores can be
used to calculate the standard deviation of an entire cluster,
which is a reasonable metric for clusters.
'''
sc... | python | def confidences(cluster, condensed_distances, d):
'''
We calculate a per record score that is similar to a standard
deviation. The main reason is that these record scores can be
used to calculate the standard deviation of an entire cluster,
which is a reasonable metric for clusters.
'''
sc... | [
"def",
"confidences",
"(",
"cluster",
",",
"condensed_distances",
",",
"d",
")",
":",
"scores",
"=",
"dict",
".",
"fromkeys",
"(",
"cluster",
",",
"0.0",
")",
"squared_distances",
"=",
"condensed_distances",
"**",
"2",
"for",
"i",
",",
"j",
"in",
"itertool... | We calculate a per record score that is similar to a standard
deviation. The main reason is that these record scores can be
used to calculate the standard deviation of an entire cluster,
which is a reasonable metric for clusters. | [
"We",
"calculate",
"a",
"per",
"record",
"score",
"that",
"is",
"similar",
"to",
"a",
"standard",
"deviation",
".",
"The",
"main",
"reason",
"is",
"that",
"these",
"record",
"scores",
"can",
"be",
"used",
"to",
"calculate",
"the",
"standard",
"deviation",
... | 9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b | https://github.com/dedupeio/dedupe/blob/9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b/dedupe/clustering.py#L177-L196 |
220,108 | dedupeio/dedupe | dedupe/convenience.py | consoleLabel | def consoleLabel(deduper): # pragma: no cover
'''
Command line interface for presenting and labeling training pairs
by the user
Argument :
A deduper object
'''
finished = False
use_previous = False
fields = unique(field.field
for field
in de... | python | def consoleLabel(deduper): # pragma: no cover
'''
Command line interface for presenting and labeling training pairs
by the user
Argument :
A deduper object
'''
finished = False
use_previous = False
fields = unique(field.field
for field
in de... | [
"def",
"consoleLabel",
"(",
"deduper",
")",
":",
"# pragma: no cover",
"finished",
"=",
"False",
"use_previous",
"=",
"False",
"fields",
"=",
"unique",
"(",
"field",
".",
"field",
"for",
"field",
"in",
"deduper",
".",
"data_model",
".",
"primary_fields",
")",
... | Command line interface for presenting and labeling training pairs
by the user
Argument :
A deduper object | [
"Command",
"line",
"interface",
"for",
"presenting",
"and",
"labeling",
"training",
"pairs",
"by",
"the",
"user"
] | 9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b | https://github.com/dedupeio/dedupe/blob/9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b/dedupe/convenience.py#L19-L105 |
220,109 | dedupeio/dedupe | dedupe/convenience.py | trainingDataLink | def trainingDataLink(data_1, data_2, common_key, training_size=50000): # pragma: nocover
'''
Construct training data for consumption by the ActiveLearning
markPairs method from already linked datasets.
Arguments :
data_1 -- Dictionary of records from first dataset, where the keys
... | python | def trainingDataLink(data_1, data_2, common_key, training_size=50000): # pragma: nocover
'''
Construct training data for consumption by the ActiveLearning
markPairs method from already linked datasets.
Arguments :
data_1 -- Dictionary of records from first dataset, where the keys
... | [
"def",
"trainingDataLink",
"(",
"data_1",
",",
"data_2",
",",
"common_key",
",",
"training_size",
"=",
"50000",
")",
":",
"# pragma: nocover",
"identified_records",
"=",
"collections",
".",
"defaultdict",
"(",
"lambda",
":",
"[",
"[",
"]",
",",
"[",
"]",
"]"... | Construct training data for consumption by the ActiveLearning
markPairs method from already linked datasets.
Arguments :
data_1 -- Dictionary of records from first dataset, where the keys
are record_ids and the values are dictionaries with the
keys being fie... | [
"Construct",
"training",
"data",
"for",
"consumption",
"by",
"the",
"ActiveLearning",
"markPairs",
"method",
"from",
"already",
"linked",
"datasets",
"."
] | 9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b | https://github.com/dedupeio/dedupe/blob/9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b/dedupe/convenience.py#L108-L167 |
220,110 | dedupeio/dedupe | dedupe/convenience.py | trainingDataDedupe | def trainingDataDedupe(data, common_key, training_size=50000): # pragma: nocover
'''
Construct training data for consumption by the ActiveLearning
markPairs method from an already deduplicated dataset.
Arguments :
data -- Dictionary of records, where the keys are record_ids and
... | python | def trainingDataDedupe(data, common_key, training_size=50000): # pragma: nocover
'''
Construct training data for consumption by the ActiveLearning
markPairs method from an already deduplicated dataset.
Arguments :
data -- Dictionary of records, where the keys are record_ids and
... | [
"def",
"trainingDataDedupe",
"(",
"data",
",",
"common_key",
",",
"training_size",
"=",
"50000",
")",
":",
"# pragma: nocover",
"identified_records",
"=",
"collections",
".",
"defaultdict",
"(",
"list",
")",
"matched_pairs",
"=",
"set",
"(",
")",
"distinct_pairs",... | Construct training data for consumption by the ActiveLearning
markPairs method from an already deduplicated dataset.
Arguments :
data -- Dictionary of records, where the keys are record_ids and
the values are dictionaries with the keys being
field names
... | [
"Construct",
"training",
"data",
"for",
"consumption",
"by",
"the",
"ActiveLearning",
"markPairs",
"method",
"from",
"an",
"already",
"deduplicated",
"dataset",
"."
] | 9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b | https://github.com/dedupeio/dedupe/blob/9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b/dedupe/convenience.py#L170-L228 |
220,111 | dedupeio/dedupe | dedupe/labeler.py | unique | def unique(seq):
"""Return the unique elements of a collection even if those elements are
unhashable and unsortable, like dicts and sets"""
cleaned = []
for each in seq:
if each not in cleaned:
cleaned.append(each)
return cleaned | python | def unique(seq):
"""Return the unique elements of a collection even if those elements are
unhashable and unsortable, like dicts and sets"""
cleaned = []
for each in seq:
if each not in cleaned:
cleaned.append(each)
return cleaned | [
"def",
"unique",
"(",
"seq",
")",
":",
"cleaned",
"=",
"[",
"]",
"for",
"each",
"in",
"seq",
":",
"if",
"each",
"not",
"in",
"cleaned",
":",
"cleaned",
".",
"append",
"(",
"each",
")",
"return",
"cleaned"
] | Return the unique elements of a collection even if those elements are
unhashable and unsortable, like dicts and sets | [
"Return",
"the",
"unique",
"elements",
"of",
"a",
"collection",
"even",
"if",
"those",
"elements",
"are",
"unhashable",
"and",
"unsortable",
"like",
"dicts",
"and",
"sets"
] | 9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b | https://github.com/dedupeio/dedupe/blob/9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b/dedupe/labeler.py#L383-L390 |
220,112 | dedupeio/dedupe | dedupe/training.py | BlockLearner.learn | def learn(self, matches, recall):
'''
Takes in a set of training pairs and predicates and tries to find
a good set of blocking rules.
'''
compound_length = 2
dupe_cover = Cover(self.blocker.predicates, matches)
dupe_cover.dominators(cost=self.total_cover)
... | python | def learn(self, matches, recall):
'''
Takes in a set of training pairs and predicates and tries to find
a good set of blocking rules.
'''
compound_length = 2
dupe_cover = Cover(self.blocker.predicates, matches)
dupe_cover.dominators(cost=self.total_cover)
... | [
"def",
"learn",
"(",
"self",
",",
"matches",
",",
"recall",
")",
":",
"compound_length",
"=",
"2",
"dupe_cover",
"=",
"Cover",
"(",
"self",
".",
"blocker",
".",
"predicates",
",",
"matches",
")",
"dupe_cover",
".",
"dominators",
"(",
"cost",
"=",
"self",... | Takes in a set of training pairs and predicates and tries to find
a good set of blocking rules. | [
"Takes",
"in",
"a",
"set",
"of",
"training",
"pairs",
"and",
"predicates",
"and",
"tries",
"to",
"find",
"a",
"good",
"set",
"of",
"blocking",
"rules",
"."
] | 9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b | https://github.com/dedupeio/dedupe/blob/9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b/dedupe/training.py#L24-L62 |
220,113 | dedupeio/dedupe | dedupe/blocking.py | Blocker.unindex | def unindex(self, data, field):
'''Remove index of a given set of data'''
indices = extractIndices(self.index_fields[field])
for doc in data:
if doc:
for _, index, preprocess in indices:
index.unindex(preprocess(doc))
for index_type, inde... | python | def unindex(self, data, field):
'''Remove index of a given set of data'''
indices = extractIndices(self.index_fields[field])
for doc in data:
if doc:
for _, index, preprocess in indices:
index.unindex(preprocess(doc))
for index_type, inde... | [
"def",
"unindex",
"(",
"self",
",",
"data",
",",
"field",
")",
":",
"indices",
"=",
"extractIndices",
"(",
"self",
".",
"index_fields",
"[",
"field",
"]",
")",
"for",
"doc",
"in",
"data",
":",
"if",
"doc",
":",
"for",
"_",
",",
"index",
",",
"prepr... | Remove index of a given set of data | [
"Remove",
"index",
"of",
"a",
"given",
"set",
"of",
"data"
] | 9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b | https://github.com/dedupeio/dedupe/blob/9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b/dedupe/blocking.py#L80-L95 |
220,114 | marcgibbons/django-rest-swagger | example_app/snippets/models.py | Snippet.save | def save(self, *args, **kwargs):
"""
Use the `pygments` library to create a highlighted HTML
representation of the code snippet.
"""
lexer = get_lexer_by_name(self.language)
linenos = self.linenos and 'table' or False
options = self.title and {'title': self.title}... | python | def save(self, *args, **kwargs):
"""
Use the `pygments` library to create a highlighted HTML
representation of the code snippet.
"""
lexer = get_lexer_by_name(self.language)
linenos = self.linenos and 'table' or False
options = self.title and {'title': self.title}... | [
"def",
"save",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"lexer",
"=",
"get_lexer_by_name",
"(",
"self",
".",
"language",
")",
"linenos",
"=",
"self",
".",
"linenos",
"and",
"'table'",
"or",
"False",
"options",
"=",
"self",
".... | Use the `pygments` library to create a highlighted HTML
representation of the code snippet. | [
"Use",
"the",
"pygments",
"library",
"to",
"create",
"a",
"highlighted",
"HTML",
"representation",
"of",
"the",
"code",
"snippet",
"."
] | 102d22eaefb7898342ba2fb5af5618b9e3a32f1d | https://github.com/marcgibbons/django-rest-swagger/blob/102d22eaefb7898342ba2fb5af5618b9e3a32f1d/example_app/snippets/models.py#L38-L54 |
220,115 | adafruit/Adafruit_Blinka | src/adafruit_blinka/microcontroller/generic_linux/i2c.py | I2C.scan | def scan(self):
"""Try to read a byte from each address, if you get an OSError it means the device isnt there"""
found = []
for addr in range(0,0x80):
try:
self._i2c_bus.read_byte(addr)
except OSError:
continue
found.append(addr... | python | def scan(self):
"""Try to read a byte from each address, if you get an OSError it means the device isnt there"""
found = []
for addr in range(0,0x80):
try:
self._i2c_bus.read_byte(addr)
except OSError:
continue
found.append(addr... | [
"def",
"scan",
"(",
"self",
")",
":",
"found",
"=",
"[",
"]",
"for",
"addr",
"in",
"range",
"(",
"0",
",",
"0x80",
")",
":",
"try",
":",
"self",
".",
"_i2c_bus",
".",
"read_byte",
"(",
"addr",
")",
"except",
"OSError",
":",
"continue",
"found",
"... | Try to read a byte from each address, if you get an OSError it means the device isnt there | [
"Try",
"to",
"read",
"a",
"byte",
"from",
"each",
"address",
"if",
"you",
"get",
"an",
"OSError",
"it",
"means",
"the",
"device",
"isnt",
"there"
] | b4a2b3bf7d8cc88477027b827bd0a8e9b19588ff | https://github.com/adafruit/Adafruit_Blinka/blob/b4a2b3bf7d8cc88477027b827bd0a8e9b19588ff/src/adafruit_blinka/microcontroller/generic_linux/i2c.py#L24-L33 |
220,116 | adafruit/Adafruit_Blinka | src/adafruit_blinka/microcontroller/bcm283x/pulseio/PulseIn.py | final | def final():
"""In case the program is cancelled or quit, we need to clean up the PulseIn
helper process and also the message queue, this is called at exit to do so"""
if DEBUG:
print("Cleaning up message queues", queues)
print("Cleaning up processes", procs)
for q in queues:
q.r... | python | def final():
"""In case the program is cancelled or quit, we need to clean up the PulseIn
helper process and also the message queue, this is called at exit to do so"""
if DEBUG:
print("Cleaning up message queues", queues)
print("Cleaning up processes", procs)
for q in queues:
q.r... | [
"def",
"final",
"(",
")",
":",
"if",
"DEBUG",
":",
"print",
"(",
"\"Cleaning up message queues\"",
",",
"queues",
")",
"print",
"(",
"\"Cleaning up processes\"",
",",
"procs",
")",
"for",
"q",
"in",
"queues",
":",
"q",
".",
"remove",
"(",
")",
"for",
"pr... | In case the program is cancelled or quit, we need to clean up the PulseIn
helper process and also the message queue, this is called at exit to do so | [
"In",
"case",
"the",
"program",
"is",
"cancelled",
"or",
"quit",
"we",
"need",
"to",
"clean",
"up",
"the",
"PulseIn",
"helper",
"process",
"and",
"also",
"the",
"message",
"queue",
"this",
"is",
"called",
"at",
"exit",
"to",
"do",
"so"
] | b4a2b3bf7d8cc88477027b827bd0a8e9b19588ff | https://github.com/adafruit/Adafruit_Blinka/blob/b4a2b3bf7d8cc88477027b827bd0a8e9b19588ff/src/adafruit_blinka/microcontroller/bcm283x/pulseio/PulseIn.py#L16-L25 |
220,117 | adafruit/Adafruit_Blinka | src/adafruit_blinka/microcontroller/bcm283x/pulseio/PulseIn.py | PulseIn._wait_receive_msg | def _wait_receive_msg(self, timeout=0.25, type=2):
"""Internal helper that will wait for new messages of a given type,
and throw an exception on timeout"""
stamp = time.monotonic()
while (time.monotonic() - stamp) < timeout:
try:
message = self._mq.receive(blo... | python | def _wait_receive_msg(self, timeout=0.25, type=2):
"""Internal helper that will wait for new messages of a given type,
and throw an exception on timeout"""
stamp = time.monotonic()
while (time.monotonic() - stamp) < timeout:
try:
message = self._mq.receive(blo... | [
"def",
"_wait_receive_msg",
"(",
"self",
",",
"timeout",
"=",
"0.25",
",",
"type",
"=",
"2",
")",
":",
"stamp",
"=",
"time",
".",
"monotonic",
"(",
")",
"while",
"(",
"time",
".",
"monotonic",
"(",
")",
"-",
"stamp",
")",
"<",
"timeout",
":",
"try"... | Internal helper that will wait for new messages of a given type,
and throw an exception on timeout | [
"Internal",
"helper",
"that",
"will",
"wait",
"for",
"new",
"messages",
"of",
"a",
"given",
"type",
"and",
"throw",
"an",
"exception",
"on",
"timeout"
] | b4a2b3bf7d8cc88477027b827bd0a8e9b19588ff | https://github.com/adafruit/Adafruit_Blinka/blob/b4a2b3bf7d8cc88477027b827bd0a8e9b19588ff/src/adafruit_blinka/microcontroller/bcm283x/pulseio/PulseIn.py#L69-L80 |
220,118 | adafruit/Adafruit_Blinka | src/adafruit_blinka/microcontroller/bcm283x/pulseio/PulseIn.py | PulseIn.deinit | def deinit(self):
"""Deinitialises the PulseIn and releases any hardware and software
resources for reuse."""
# Clean up after ourselves
self._process.terminate()
procs.remove(self._process)
self._mq.remove()
queues.remove(self._mq) | python | def deinit(self):
"""Deinitialises the PulseIn and releases any hardware and software
resources for reuse."""
# Clean up after ourselves
self._process.terminate()
procs.remove(self._process)
self._mq.remove()
queues.remove(self._mq) | [
"def",
"deinit",
"(",
"self",
")",
":",
"# Clean up after ourselves",
"self",
".",
"_process",
".",
"terminate",
"(",
")",
"procs",
".",
"remove",
"(",
"self",
".",
"_process",
")",
"self",
".",
"_mq",
".",
"remove",
"(",
")",
"queues",
".",
"remove",
... | Deinitialises the PulseIn and releases any hardware and software
resources for reuse. | [
"Deinitialises",
"the",
"PulseIn",
"and",
"releases",
"any",
"hardware",
"and",
"software",
"resources",
"for",
"reuse",
"."
] | b4a2b3bf7d8cc88477027b827bd0a8e9b19588ff | https://github.com/adafruit/Adafruit_Blinka/blob/b4a2b3bf7d8cc88477027b827bd0a8e9b19588ff/src/adafruit_blinka/microcontroller/bcm283x/pulseio/PulseIn.py#L82-L89 |
220,119 | adafruit/Adafruit_Blinka | src/adafruit_blinka/microcontroller/bcm283x/pulseio/PulseIn.py | PulseIn.resume | def resume(self, trigger_duration=0):
"""Resumes pulse capture after an optional trigger pulse."""
if trigger_duration != 0:
self._mq.send("t%d" % trigger_duration, True, type=1)
else:
self._mq.send("r", True, type=1)
self._paused = False | python | def resume(self, trigger_duration=0):
"""Resumes pulse capture after an optional trigger pulse."""
if trigger_duration != 0:
self._mq.send("t%d" % trigger_duration, True, type=1)
else:
self._mq.send("r", True, type=1)
self._paused = False | [
"def",
"resume",
"(",
"self",
",",
"trigger_duration",
"=",
"0",
")",
":",
"if",
"trigger_duration",
"!=",
"0",
":",
"self",
".",
"_mq",
".",
"send",
"(",
"\"t%d\"",
"%",
"trigger_duration",
",",
"True",
",",
"type",
"=",
"1",
")",
"else",
":",
"self... | Resumes pulse capture after an optional trigger pulse. | [
"Resumes",
"pulse",
"capture",
"after",
"an",
"optional",
"trigger",
"pulse",
"."
] | b4a2b3bf7d8cc88477027b827bd0a8e9b19588ff | https://github.com/adafruit/Adafruit_Blinka/blob/b4a2b3bf7d8cc88477027b827bd0a8e9b19588ff/src/adafruit_blinka/microcontroller/bcm283x/pulseio/PulseIn.py#L99-L105 |
220,120 | adafruit/Adafruit_Blinka | src/adafruit_blinka/microcontroller/bcm283x/pulseio/PulseIn.py | PulseIn.pause | def pause(self):
"""Pause pulse capture"""
self._mq.send("p", True, type=1)
self._paused = True | python | def pause(self):
"""Pause pulse capture"""
self._mq.send("p", True, type=1)
self._paused = True | [
"def",
"pause",
"(",
"self",
")",
":",
"self",
".",
"_mq",
".",
"send",
"(",
"\"p\"",
",",
"True",
",",
"type",
"=",
"1",
")",
"self",
".",
"_paused",
"=",
"True"
] | Pause pulse capture | [
"Pause",
"pulse",
"capture"
] | b4a2b3bf7d8cc88477027b827bd0a8e9b19588ff | https://github.com/adafruit/Adafruit_Blinka/blob/b4a2b3bf7d8cc88477027b827bd0a8e9b19588ff/src/adafruit_blinka/microcontroller/bcm283x/pulseio/PulseIn.py#L107-L110 |
220,121 | adafruit/Adafruit_Blinka | src/adafruit_blinka/microcontroller/bcm283x/pulseio/PulseIn.py | PulseIn.popleft | def popleft(self):
"""Removes and returns the oldest read pulse."""
self._mq.send("^", True, type=1)
message = self._wait_receive_msg()
reply = int(message[0].decode('utf-8'))
#print(reply)
if reply == -1:
raise IndexError("pop from empty list")
return... | python | def popleft(self):
"""Removes and returns the oldest read pulse."""
self._mq.send("^", True, type=1)
message = self._wait_receive_msg()
reply = int(message[0].decode('utf-8'))
#print(reply)
if reply == -1:
raise IndexError("pop from empty list")
return... | [
"def",
"popleft",
"(",
"self",
")",
":",
"self",
".",
"_mq",
".",
"send",
"(",
"\"^\"",
",",
"True",
",",
"type",
"=",
"1",
")",
"message",
"=",
"self",
".",
"_wait_receive_msg",
"(",
")",
"reply",
"=",
"int",
"(",
"message",
"[",
"0",
"]",
".",
... | Removes and returns the oldest read pulse. | [
"Removes",
"and",
"returns",
"the",
"oldest",
"read",
"pulse",
"."
] | b4a2b3bf7d8cc88477027b827bd0a8e9b19588ff | https://github.com/adafruit/Adafruit_Blinka/blob/b4a2b3bf7d8cc88477027b827bd0a8e9b19588ff/src/adafruit_blinka/microcontroller/bcm283x/pulseio/PulseIn.py#L128-L136 |
220,122 | jupyter-widgets/ipyleaflet | ipyleaflet/leaflet.py | LayerGroup._validate_layers | def _validate_layers(self, proposal):
'''Validate layers list.
Makes sure only one instance of any given layer can exist in the
layers list.
'''
self._layer_ids = [l.model_id for l in proposal.value]
if len(set(self._layer_ids)) != len(self._layer_ids):
raise... | python | def _validate_layers(self, proposal):
'''Validate layers list.
Makes sure only one instance of any given layer can exist in the
layers list.
'''
self._layer_ids = [l.model_id for l in proposal.value]
if len(set(self._layer_ids)) != len(self._layer_ids):
raise... | [
"def",
"_validate_layers",
"(",
"self",
",",
"proposal",
")",
":",
"self",
".",
"_layer_ids",
"=",
"[",
"l",
".",
"model_id",
"for",
"l",
"in",
"proposal",
".",
"value",
"]",
"if",
"len",
"(",
"set",
"(",
"self",
".",
"_layer_ids",
")",
")",
"!=",
... | Validate layers list.
Makes sure only one instance of any given layer can exist in the
layers list. | [
"Validate",
"layers",
"list",
"."
] | 74488d4699a5663fc28aabf94ebf08d956a30598 | https://github.com/jupyter-widgets/ipyleaflet/blob/74488d4699a5663fc28aabf94ebf08d956a30598/ipyleaflet/leaflet.py#L431-L440 |
220,123 | jupyter-widgets/ipyleaflet | ipyleaflet/leaflet.py | GeoJSON.on_hover | def on_hover(self, callback, remove=False):
'''
The hover callback takes an unpacked set of keyword arguments.
'''
self._hover_callbacks.register_callback(callback, remove=remove) | python | def on_hover(self, callback, remove=False):
'''
The hover callback takes an unpacked set of keyword arguments.
'''
self._hover_callbacks.register_callback(callback, remove=remove) | [
"def",
"on_hover",
"(",
"self",
",",
"callback",
",",
"remove",
"=",
"False",
")",
":",
"self",
".",
"_hover_callbacks",
".",
"register_callback",
"(",
"callback",
",",
"remove",
"=",
"remove",
")"
] | The hover callback takes an unpacked set of keyword arguments. | [
"The",
"hover",
"callback",
"takes",
"an",
"unpacked",
"set",
"of",
"keyword",
"arguments",
"."
] | 74488d4699a5663fc28aabf94ebf08d956a30598 | https://github.com/jupyter-widgets/ipyleaflet/blob/74488d4699a5663fc28aabf94ebf08d956a30598/ipyleaflet/leaflet.py#L490-L494 |
220,124 | jupyter-widgets/ipyleaflet | ipyleaflet/leaflet.py | Map._validate_controls | def _validate_controls(self, proposal):
'''Validate controls list.
Makes sure only one instance of any given layer can exist in the
controls list.
'''
self._control_ids = [c.model_id for c in proposal.value]
if len(set(self._control_ids)) != len(self._control_ids):
... | python | def _validate_controls(self, proposal):
'''Validate controls list.
Makes sure only one instance of any given layer can exist in the
controls list.
'''
self._control_ids = [c.model_id for c in proposal.value]
if len(set(self._control_ids)) != len(self._control_ids):
... | [
"def",
"_validate_controls",
"(",
"self",
",",
"proposal",
")",
":",
"self",
".",
"_control_ids",
"=",
"[",
"c",
".",
"model_id",
"for",
"c",
"in",
"proposal",
".",
"value",
"]",
"if",
"len",
"(",
"set",
"(",
"self",
".",
"_control_ids",
")",
")",
"!... | Validate controls list.
Makes sure only one instance of any given layer can exist in the
controls list. | [
"Validate",
"controls",
"list",
"."
] | 74488d4699a5663fc28aabf94ebf08d956a30598 | https://github.com/jupyter-widgets/ipyleaflet/blob/74488d4699a5663fc28aabf94ebf08d956a30598/ipyleaflet/leaflet.py#L881-L890 |
220,125 | mbedmicro/pyOCD | pyocd/debug/context.py | DebugContext.read_core_register | def read_core_register(self, reg):
"""
read CPU register
Unpack floating point register values
"""
regIndex = register_name_to_index(reg)
regValue = self.read_core_register_raw(regIndex)
# Convert int to float.
if is_single_float_register(regIndex):
... | python | def read_core_register(self, reg):
"""
read CPU register
Unpack floating point register values
"""
regIndex = register_name_to_index(reg)
regValue = self.read_core_register_raw(regIndex)
# Convert int to float.
if is_single_float_register(regIndex):
... | [
"def",
"read_core_register",
"(",
"self",
",",
"reg",
")",
":",
"regIndex",
"=",
"register_name_to_index",
"(",
"reg",
")",
"regValue",
"=",
"self",
".",
"read_core_register_raw",
"(",
"regIndex",
")",
"# Convert int to float.",
"if",
"is_single_float_register",
"("... | read CPU register
Unpack floating point register values | [
"read",
"CPU",
"register",
"Unpack",
"floating",
"point",
"register",
"values"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/debug/context.py#L58-L70 |
220,126 | mbedmicro/pyOCD | pyocd/debug/context.py | DebugContext.write_core_register | def write_core_register(self, reg, data):
"""
write a CPU register.
Will need to pack floating point register values before writing.
"""
regIndex = register_name_to_index(reg)
# Convert float to int.
if is_single_float_register(regIndex) and type(data) is float:
... | python | def write_core_register(self, reg, data):
"""
write a CPU register.
Will need to pack floating point register values before writing.
"""
regIndex = register_name_to_index(reg)
# Convert float to int.
if is_single_float_register(regIndex) and type(data) is float:
... | [
"def",
"write_core_register",
"(",
"self",
",",
"reg",
",",
"data",
")",
":",
"regIndex",
"=",
"register_name_to_index",
"(",
"reg",
")",
"# Convert float to int.",
"if",
"is_single_float_register",
"(",
"regIndex",
")",
"and",
"type",
"(",
"data",
")",
"is",
... | write a CPU register.
Will need to pack floating point register values before writing. | [
"write",
"a",
"CPU",
"register",
".",
"Will",
"need",
"to",
"pack",
"floating",
"point",
"register",
"values",
"before",
"writing",
"."
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/debug/context.py#L84-L95 |
220,127 | mbedmicro/pyOCD | pyocd/probe/cmsis_dap_probe.py | CMSISDAPProbe.connect | def connect(self, protocol=None):
"""Initialize DAP IO pins for JTAG or SWD"""
# Convert protocol to port enum.
if protocol is not None:
port = self.PORT_MAP[protocol]
else:
port = DAPAccess.PORT.DEFAULT
try:
self._link.connect(port)
... | python | def connect(self, protocol=None):
"""Initialize DAP IO pins for JTAG or SWD"""
# Convert protocol to port enum.
if protocol is not None:
port = self.PORT_MAP[protocol]
else:
port = DAPAccess.PORT.DEFAULT
try:
self._link.connect(port)
... | [
"def",
"connect",
"(",
"self",
",",
"protocol",
"=",
"None",
")",
":",
"# Convert protocol to port enum.",
"if",
"protocol",
"is",
"not",
"None",
":",
"port",
"=",
"self",
".",
"PORT_MAP",
"[",
"protocol",
"]",
"else",
":",
"port",
"=",
"DAPAccess",
".",
... | Initialize DAP IO pins for JTAG or SWD | [
"Initialize",
"DAP",
"IO",
"pins",
"for",
"JTAG",
"or",
"SWD"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/cmsis_dap_probe.py#L165-L182 |
220,128 | mbedmicro/pyOCD | pyocd/probe/cmsis_dap_probe.py | CMSISDAPProbe.set_clock | def set_clock(self, frequency):
"""Set the frequency for JTAG and SWD in Hz
This function is safe to call before connect is called.
"""
try:
self._link.set_clock(frequency)
except DAPAccess.Error as exc:
six.raise_from(self._convert_exception(exc), exc) | python | def set_clock(self, frequency):
"""Set the frequency for JTAG and SWD in Hz
This function is safe to call before connect is called.
"""
try:
self._link.set_clock(frequency)
except DAPAccess.Error as exc:
six.raise_from(self._convert_exception(exc), exc) | [
"def",
"set_clock",
"(",
"self",
",",
"frequency",
")",
":",
"try",
":",
"self",
".",
"_link",
".",
"set_clock",
"(",
"frequency",
")",
"except",
"DAPAccess",
".",
"Error",
"as",
"exc",
":",
"six",
".",
"raise_from",
"(",
"self",
".",
"_convert_exception... | Set the frequency for JTAG and SWD in Hz
This function is safe to call before connect is called. | [
"Set",
"the",
"frequency",
"for",
"JTAG",
"and",
"SWD",
"in",
"Hz"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/cmsis_dap_probe.py#L201-L209 |
220,129 | mbedmicro/pyOCD | pyocd/probe/cmsis_dap_probe.py | CMSISDAPProbe.reset | def reset(self):
"""Reset the target"""
try:
self._invalidate_cached_registers()
self._link.reset()
except DAPAccess.Error as exc:
six.raise_from(self._convert_exception(exc), exc) | python | def reset(self):
"""Reset the target"""
try:
self._invalidate_cached_registers()
self._link.reset()
except DAPAccess.Error as exc:
six.raise_from(self._convert_exception(exc), exc) | [
"def",
"reset",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_invalidate_cached_registers",
"(",
")",
"self",
".",
"_link",
".",
"reset",
"(",
")",
"except",
"DAPAccess",
".",
"Error",
"as",
"exc",
":",
"six",
".",
"raise_from",
"(",
"self",
".",
... | Reset the target | [
"Reset",
"the",
"target"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/cmsis_dap_probe.py#L211-L217 |
220,130 | mbedmicro/pyOCD | pyocd/probe/cmsis_dap_probe.py | CMSISDAPProbe.assert_reset | def assert_reset(self, asserted):
"""Assert or de-assert target reset line"""
try:
self._invalidate_cached_registers()
self._link.assert_reset(asserted)
except DAPAccess.Error as exc:
six.raise_from(self._convert_exception(exc), exc) | python | def assert_reset(self, asserted):
"""Assert or de-assert target reset line"""
try:
self._invalidate_cached_registers()
self._link.assert_reset(asserted)
except DAPAccess.Error as exc:
six.raise_from(self._convert_exception(exc), exc) | [
"def",
"assert_reset",
"(",
"self",
",",
"asserted",
")",
":",
"try",
":",
"self",
".",
"_invalidate_cached_registers",
"(",
")",
"self",
".",
"_link",
".",
"assert_reset",
"(",
"asserted",
")",
"except",
"DAPAccess",
".",
"Error",
"as",
"exc",
":",
"six",... | Assert or de-assert target reset line | [
"Assert",
"or",
"de",
"-",
"assert",
"target",
"reset",
"line"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/cmsis_dap_probe.py#L219-L225 |
220,131 | mbedmicro/pyOCD | pyocd/debug/svd/parser.py | _get_text | def _get_text(node, tag, default=None):
"""Get the text for the provided tag from the provided node"""
try:
return node.find(tag).text
except AttributeError:
return default | python | def _get_text(node, tag, default=None):
"""Get the text for the provided tag from the provided node"""
try:
return node.find(tag).text
except AttributeError:
return default | [
"def",
"_get_text",
"(",
"node",
",",
"tag",
",",
"default",
"=",
"None",
")",
":",
"try",
":",
"return",
"node",
".",
"find",
"(",
"tag",
")",
".",
"text",
"except",
"AttributeError",
":",
"return",
"default"
] | Get the text for the provided tag from the provided node | [
"Get",
"the",
"text",
"for",
"the",
"provided",
"tag",
"from",
"the",
"provided",
"node"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/debug/svd/parser.py#L33-L38 |
220,132 | mbedmicro/pyOCD | pyocd/coresight/cortex_m.py | CortexM.init | def init(self):
"""
Cortex M initialization. The bus must be accessible when this method is called.
"""
if not self.call_delegate('will_start_debug_core', core=self):
if self.halt_on_connect:
self.halt()
self._read_core_type()
self._che... | python | def init(self):
"""
Cortex M initialization. The bus must be accessible when this method is called.
"""
if not self.call_delegate('will_start_debug_core', core=self):
if self.halt_on_connect:
self.halt()
self._read_core_type()
self._che... | [
"def",
"init",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"call_delegate",
"(",
"'will_start_debug_core'",
",",
"core",
"=",
"self",
")",
":",
"if",
"self",
".",
"halt_on_connect",
":",
"self",
".",
"halt",
"(",
")",
"self",
".",
"_read_core_type",... | Cortex M initialization. The bus must be accessible when this method is called. | [
"Cortex",
"M",
"initialization",
".",
"The",
"bus",
"must",
"be",
"accessible",
"when",
"this",
"method",
"is",
"called",
"."
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/coresight/cortex_m.py#L478-L490 |
220,133 | mbedmicro/pyOCD | pyocd/coresight/cortex_m.py | CortexM.write_memory | def write_memory(self, addr, value, transfer_size=32):
"""
write a memory location.
By default the transfer size is a word
"""
self.ap.write_memory(addr, value, transfer_size) | python | def write_memory(self, addr, value, transfer_size=32):
"""
write a memory location.
By default the transfer size is a word
"""
self.ap.write_memory(addr, value, transfer_size) | [
"def",
"write_memory",
"(",
"self",
",",
"addr",
",",
"value",
",",
"transfer_size",
"=",
"32",
")",
":",
"self",
".",
"ap",
".",
"write_memory",
"(",
"addr",
",",
"value",
",",
"transfer_size",
")"
] | write a memory location.
By default the transfer size is a word | [
"write",
"a",
"memory",
"location",
".",
"By",
"default",
"the",
"transfer",
"size",
"is",
"a",
"word"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/coresight/cortex_m.py#L592-L597 |
220,134 | mbedmicro/pyOCD | pyocd/coresight/cortex_m.py | CortexM.read_memory | def read_memory(self, addr, transfer_size=32, now=True):
"""
read a memory location. By default, a word will
be read
"""
result = self.ap.read_memory(addr, transfer_size, now)
# Read callback returned for async reads.
def read_memory_cb():
return self... | python | def read_memory(self, addr, transfer_size=32, now=True):
"""
read a memory location. By default, a word will
be read
"""
result = self.ap.read_memory(addr, transfer_size, now)
# Read callback returned for async reads.
def read_memory_cb():
return self... | [
"def",
"read_memory",
"(",
"self",
",",
"addr",
",",
"transfer_size",
"=",
"32",
",",
"now",
"=",
"True",
")",
":",
"result",
"=",
"self",
".",
"ap",
".",
"read_memory",
"(",
"addr",
",",
"transfer_size",
",",
"now",
")",
"# Read callback returned for asyn... | read a memory location. By default, a word will
be read | [
"read",
"a",
"memory",
"location",
".",
"By",
"default",
"a",
"word",
"will",
"be",
"read"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/coresight/cortex_m.py#L599-L613 |
220,135 | mbedmicro/pyOCD | pyocd/coresight/cortex_m.py | CortexM.read_memory_block8 | def read_memory_block8(self, addr, size):
"""
read a block of unaligned bytes in memory. Returns
an array of byte values
"""
data = self.ap.read_memory_block8(addr, size)
return self.bp_manager.filter_memory_unaligned_8(addr, size, data) | python | def read_memory_block8(self, addr, size):
"""
read a block of unaligned bytes in memory. Returns
an array of byte values
"""
data = self.ap.read_memory_block8(addr, size)
return self.bp_manager.filter_memory_unaligned_8(addr, size, data) | [
"def",
"read_memory_block8",
"(",
"self",
",",
"addr",
",",
"size",
")",
":",
"data",
"=",
"self",
".",
"ap",
".",
"read_memory_block8",
"(",
"addr",
",",
"size",
")",
"return",
"self",
".",
"bp_manager",
".",
"filter_memory_unaligned_8",
"(",
"addr",
",",... | read a block of unaligned bytes in memory. Returns
an array of byte values | [
"read",
"a",
"block",
"of",
"unaligned",
"bytes",
"in",
"memory",
".",
"Returns",
"an",
"array",
"of",
"byte",
"values"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/coresight/cortex_m.py#L615-L621 |
220,136 | mbedmicro/pyOCD | pyocd/coresight/cortex_m.py | CortexM.read_memory_block32 | def read_memory_block32(self, addr, size):
"""
read a block of aligned words in memory. Returns
an array of word values
"""
data = self.ap.read_memory_block32(addr, size)
return self.bp_manager.filter_memory_aligned_32(addr, size, data) | python | def read_memory_block32(self, addr, size):
"""
read a block of aligned words in memory. Returns
an array of word values
"""
data = self.ap.read_memory_block32(addr, size)
return self.bp_manager.filter_memory_aligned_32(addr, size, data) | [
"def",
"read_memory_block32",
"(",
"self",
",",
"addr",
",",
"size",
")",
":",
"data",
"=",
"self",
".",
"ap",
".",
"read_memory_block32",
"(",
"addr",
",",
"size",
")",
"return",
"self",
".",
"bp_manager",
".",
"filter_memory_aligned_32",
"(",
"addr",
","... | read a block of aligned words in memory. Returns
an array of word values | [
"read",
"a",
"block",
"of",
"aligned",
"words",
"in",
"memory",
".",
"Returns",
"an",
"array",
"of",
"word",
"values"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/coresight/cortex_m.py#L635-L641 |
220,137 | mbedmicro/pyOCD | pyocd/coresight/cortex_m.py | CortexM.halt | def halt(self):
"""
halt the core
"""
self.notify(Notification(event=Target.EVENT_PRE_HALT, source=self, data=Target.HALT_REASON_USER))
self.write_memory(CortexM.DHCSR, CortexM.DBGKEY | CortexM.C_DEBUGEN | CortexM.C_HALT)
self.flush()
self.notify(Notification(even... | python | def halt(self):
"""
halt the core
"""
self.notify(Notification(event=Target.EVENT_PRE_HALT, source=self, data=Target.HALT_REASON_USER))
self.write_memory(CortexM.DHCSR, CortexM.DBGKEY | CortexM.C_DEBUGEN | CortexM.C_HALT)
self.flush()
self.notify(Notification(even... | [
"def",
"halt",
"(",
"self",
")",
":",
"self",
".",
"notify",
"(",
"Notification",
"(",
"event",
"=",
"Target",
".",
"EVENT_PRE_HALT",
",",
"source",
"=",
"self",
",",
"data",
"=",
"Target",
".",
"HALT_REASON_USER",
")",
")",
"self",
".",
"write_memory",
... | halt the core | [
"halt",
"the",
"core"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/coresight/cortex_m.py#L643-L650 |
220,138 | mbedmicro/pyOCD | pyocd/coresight/cortex_m.py | CortexM.step | def step(self, disable_interrupts=True, start=0, end=0):
"""
perform an instruction level step. This function preserves the previous
interrupt mask state
"""
# Was 'if self.get_state() != TARGET_HALTED:'
# but now value of dhcsr is saved
dhcsr = self.read_memory(... | python | def step(self, disable_interrupts=True, start=0, end=0):
"""
perform an instruction level step. This function preserves the previous
interrupt mask state
"""
# Was 'if self.get_state() != TARGET_HALTED:'
# but now value of dhcsr is saved
dhcsr = self.read_memory(... | [
"def",
"step",
"(",
"self",
",",
"disable_interrupts",
"=",
"True",
",",
"start",
"=",
"0",
",",
"end",
"=",
"0",
")",
":",
"# Was 'if self.get_state() != TARGET_HALTED:'",
"# but now value of dhcsr is saved",
"dhcsr",
"=",
"self",
".",
"read_memory",
"(",
"Cortex... | perform an instruction level step. This function preserves the previous
interrupt mask state | [
"perform",
"an",
"instruction",
"level",
"step",
".",
"This",
"function",
"preserves",
"the",
"previous",
"interrupt",
"mask",
"state"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/coresight/cortex_m.py#L652-L708 |
220,139 | mbedmicro/pyOCD | pyocd/coresight/cortex_m.py | CortexM.reset_and_halt | def reset_and_halt(self, reset_type=None):
"""
perform a reset and stop the core on the reset handler
"""
delegateResult = self.call_delegate('set_reset_catch', core=self, reset_type=reset_type)
# halt the target
if not delegateResult:
self.h... | python | def reset_and_halt(self, reset_type=None):
"""
perform a reset and stop the core on the reset handler
"""
delegateResult = self.call_delegate('set_reset_catch', core=self, reset_type=reset_type)
# halt the target
if not delegateResult:
self.h... | [
"def",
"reset_and_halt",
"(",
"self",
",",
"reset_type",
"=",
"None",
")",
":",
"delegateResult",
"=",
"self",
".",
"call_delegate",
"(",
"'set_reset_catch'",
",",
"core",
"=",
"self",
",",
"reset_type",
"=",
"reset_type",
")",
"# halt the target",
"if",
"not"... | perform a reset and stop the core on the reset handler | [
"perform",
"a",
"reset",
"and",
"stop",
"the",
"core",
"on",
"the",
"reset",
"handler"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/coresight/cortex_m.py#L889-L925 |
220,140 | mbedmicro/pyOCD | pyocd/coresight/cortex_m.py | CortexM.resume | def resume(self):
"""
resume the execution
"""
if self.get_state() != Target.TARGET_HALTED:
logging.debug('cannot resume: target not halted')
return
self.notify(Notification(event=Target.EVENT_PRE_RUN, source=self, data=Target.RUN_TYPE_RESUME))
sel... | python | def resume(self):
"""
resume the execution
"""
if self.get_state() != Target.TARGET_HALTED:
logging.debug('cannot resume: target not halted')
return
self.notify(Notification(event=Target.EVENT_PRE_RUN, source=self, data=Target.RUN_TYPE_RESUME))
sel... | [
"def",
"resume",
"(",
"self",
")",
":",
"if",
"self",
".",
"get_state",
"(",
")",
"!=",
"Target",
".",
"TARGET_HALTED",
":",
"logging",
".",
"debug",
"(",
"'cannot resume: target not halted'",
")",
"return",
"self",
".",
"notify",
"(",
"Notification",
"(",
... | resume the execution | [
"resume",
"the",
"execution"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/coresight/cortex_m.py#L956-L968 |
220,141 | mbedmicro/pyOCD | pyocd/coresight/cortex_m.py | CortexM.read_core_registers_raw | def read_core_registers_raw(self, reg_list):
"""
Read one or more core registers
Read core registers in reg_list and return a list of values.
If any register in reg_list is a string, find the number
associated to this register in the lookup table CORE_REGISTER.
"""
... | python | def read_core_registers_raw(self, reg_list):
"""
Read one or more core registers
Read core registers in reg_list and return a list of values.
If any register in reg_list is a string, find the number
associated to this register in the lookup table CORE_REGISTER.
"""
... | [
"def",
"read_core_registers_raw",
"(",
"self",
",",
"reg_list",
")",
":",
"# convert to index only",
"reg_list",
"=",
"[",
"register_name_to_index",
"(",
"reg",
")",
"for",
"reg",
"in",
"reg_list",
"]",
"# Sanity check register values",
"for",
"reg",
"in",
"reg_list... | Read one or more core registers
Read core registers in reg_list and return a list of values.
If any register in reg_list is a string, find the number
associated to this register in the lookup table CORE_REGISTER. | [
"Read",
"one",
"or",
"more",
"core",
"registers"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/coresight/cortex_m.py#L996-L1081 |
220,142 | mbedmicro/pyOCD | pyocd/coresight/cortex_m.py | CortexM.write_core_registers_raw | def write_core_registers_raw(self, reg_list, data_list):
"""
Write one or more core registers
Write core registers in reg_list with the associated value in
data_list. If any register in reg_list is a string, find the number
associated to this register in the lookup table CORE_R... | python | def write_core_registers_raw(self, reg_list, data_list):
"""
Write one or more core registers
Write core registers in reg_list with the associated value in
data_list. If any register in reg_list is a string, find the number
associated to this register in the lookup table CORE_R... | [
"def",
"write_core_registers_raw",
"(",
"self",
",",
"reg_list",
",",
"data_list",
")",
":",
"assert",
"len",
"(",
"reg_list",
")",
"==",
"len",
"(",
"data_list",
")",
"# convert to index only",
"reg_list",
"=",
"[",
"register_name_to_index",
"(",
"reg",
")",
... | Write one or more core registers
Write core registers in reg_list with the associated value in
data_list. If any register in reg_list is a string, find the number
associated to this register in the lookup table CORE_REGISTER. | [
"Write",
"one",
"or",
"more",
"core",
"registers"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/coresight/cortex_m.py#L1104-L1176 |
220,143 | mbedmicro/pyOCD | pyocd/coresight/cortex_m.py | CortexM.set_watchpoint | def set_watchpoint(self, addr, size, type):
"""
set a hardware watchpoint
"""
return self.dwt.set_watchpoint(addr, size, type) | python | def set_watchpoint(self, addr, size, type):
"""
set a hardware watchpoint
"""
return self.dwt.set_watchpoint(addr, size, type) | [
"def",
"set_watchpoint",
"(",
"self",
",",
"addr",
",",
"size",
",",
"type",
")",
":",
"return",
"self",
".",
"dwt",
".",
"set_watchpoint",
"(",
"addr",
",",
"size",
",",
"type",
")"
] | set a hardware watchpoint | [
"set",
"a",
"hardware",
"watchpoint"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/coresight/cortex_m.py#L1199-L1203 |
220,144 | mbedmicro/pyOCD | pyocd/coresight/cortex_m.py | CortexM.remove_watchpoint | def remove_watchpoint(self, addr, size, type):
"""
remove a hardware watchpoint
"""
return self.dwt.remove_watchpoint(addr, size, type) | python | def remove_watchpoint(self, addr, size, type):
"""
remove a hardware watchpoint
"""
return self.dwt.remove_watchpoint(addr, size, type) | [
"def",
"remove_watchpoint",
"(",
"self",
",",
"addr",
",",
"size",
",",
"type",
")",
":",
"return",
"self",
".",
"dwt",
".",
"remove_watchpoint",
"(",
"addr",
",",
"size",
",",
"type",
")"
] | remove a hardware watchpoint | [
"remove",
"a",
"hardware",
"watchpoint"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/coresight/cortex_m.py#L1205-L1209 |
220,145 | mbedmicro/pyOCD | pyocd/target/builtin/target_CC3220SF.py | Flash_cc3220sf.init | def init(self):
"""
Download the flash algorithm in RAM
"""
self.target.halt()
self.target.reset_and_halt()
# update core register to execute the init subroutine
result = self._call_function_and_wait(self.flash_algo['pc_init'], init=True)
# check the r... | python | def init(self):
"""
Download the flash algorithm in RAM
"""
self.target.halt()
self.target.reset_and_halt()
# update core register to execute the init subroutine
result = self._call_function_and_wait(self.flash_algo['pc_init'], init=True)
# check the r... | [
"def",
"init",
"(",
"self",
")",
":",
"self",
".",
"target",
".",
"halt",
"(",
")",
"self",
".",
"target",
".",
"reset_and_halt",
"(",
")",
"# update core register to execute the init subroutine",
"result",
"=",
"self",
".",
"_call_function_and_wait",
"(",
"self... | Download the flash algorithm in RAM | [
"Download",
"the",
"flash",
"algorithm",
"in",
"RAM"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/target/builtin/target_CC3220SF.py#L75-L111 |
220,146 | mbedmicro/pyOCD | pyocd/debug/svd/model.py | _check_type | def _check_type(value, expected_type):
"""Perform type checking on the provided value
This is a helper that will raise ``TypeError`` if the provided value is
not an instance of the provided type. This method should be used sparingly
but can be good for preventing problems earlier when you want to rest... | python | def _check_type(value, expected_type):
"""Perform type checking on the provided value
This is a helper that will raise ``TypeError`` if the provided value is
not an instance of the provided type. This method should be used sparingly
but can be good for preventing problems earlier when you want to rest... | [
"def",
"_check_type",
"(",
"value",
",",
"expected_type",
")",
":",
"if",
"not",
"isinstance",
"(",
"value",
",",
"expected_type",
")",
":",
"raise",
"TypeError",
"(",
"\"Value {value!r} has unexpected type {actual_type!r}, expected {expected_type!r}\"",
".",
"format",
... | Perform type checking on the provided value
This is a helper that will raise ``TypeError`` if the provided value is
not an instance of the provided type. This method should be used sparingly
but can be good for preventing problems earlier when you want to restrict
duck typing to make the types of fiel... | [
"Perform",
"type",
"checking",
"on",
"the",
"provided",
"value"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/debug/svd/model.py#L26-L42 |
220,147 | mbedmicro/pyOCD | pyocd/probe/stlink/detect/windows.py | _get_cached_mounted_points | def _get_cached_mounted_points():
"""! Get the volumes present on the system
@return List of mount points and their associated target id
Ex. [{ 'mount_point': 'D:', 'target_id_usb_id': 'xxxx'}, ...]
"""
result = []
try:
# Open the registry key for mounted devices
mounted_device... | python | def _get_cached_mounted_points():
"""! Get the volumes present on the system
@return List of mount points and their associated target id
Ex. [{ 'mount_point': 'D:', 'target_id_usb_id': 'xxxx'}, ...]
"""
result = []
try:
# Open the registry key for mounted devices
mounted_device... | [
"def",
"_get_cached_mounted_points",
"(",
")",
":",
"result",
"=",
"[",
"]",
"try",
":",
"# Open the registry key for mounted devices",
"mounted_devices_key",
"=",
"winreg",
".",
"OpenKey",
"(",
"winreg",
".",
"HKEY_LOCAL_MACHINE",
",",
"\"SYSTEM\\\\MountedDevices\"",
"... | ! Get the volumes present on the system
@return List of mount points and their associated target id
Ex. [{ 'mount_point': 'D:', 'target_id_usb_id': 'xxxx'}, ...] | [
"!",
"Get",
"the",
"volumes",
"present",
"on",
"the",
"system"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/windows.py#L64-L96 |
220,148 | mbedmicro/pyOCD | pyocd/probe/stlink/detect/windows.py | _vid_pid_path_to_usb_info | def _vid_pid_path_to_usb_info(vid_pid_path):
"""! Provide the vendor ID and product ID of a device based on its entry in the registry
@return Returns {'vendor_id': '<vendor ID>', 'product': '<product ID>'}
@details If the vendor ID or product ID can't be determined, they will be returned
as None.
""... | python | def _vid_pid_path_to_usb_info(vid_pid_path):
"""! Provide the vendor ID and product ID of a device based on its entry in the registry
@return Returns {'vendor_id': '<vendor ID>', 'product': '<product ID>'}
@details If the vendor ID or product ID can't be determined, they will be returned
as None.
""... | [
"def",
"_vid_pid_path_to_usb_info",
"(",
"vid_pid_path",
")",
":",
"result",
"=",
"{",
"\"vendor_id\"",
":",
"None",
",",
"\"product_id\"",
":",
"None",
"}",
"for",
"component",
"in",
"vid_pid_path",
".",
"split",
"(",
"\"&\"",
")",
":",
"component_part",
"=",... | ! Provide the vendor ID and product ID of a device based on its entry in the registry
@return Returns {'vendor_id': '<vendor ID>', 'product': '<product ID>'}
@details If the vendor ID or product ID can't be determined, they will be returned
as None. | [
"!",
"Provide",
"the",
"vendor",
"ID",
"and",
"product",
"ID",
"of",
"a",
"device",
"based",
"on",
"its",
"entry",
"in",
"the",
"registry"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/windows.py#L189-L209 |
220,149 | mbedmicro/pyOCD | pyocd/probe/stlink/detect/windows.py | _iter_keys_as_str | def _iter_keys_as_str(key):
"""! Iterate over subkeys of a key returning subkey as string
"""
for i in range(winreg.QueryInfoKey(key)[0]):
yield winreg.EnumKey(key, i) | python | def _iter_keys_as_str(key):
"""! Iterate over subkeys of a key returning subkey as string
"""
for i in range(winreg.QueryInfoKey(key)[0]):
yield winreg.EnumKey(key, i) | [
"def",
"_iter_keys_as_str",
"(",
"key",
")",
":",
"for",
"i",
"in",
"range",
"(",
"winreg",
".",
"QueryInfoKey",
"(",
"key",
")",
"[",
"0",
"]",
")",
":",
"yield",
"winreg",
".",
"EnumKey",
"(",
"key",
",",
"i",
")"
] | ! Iterate over subkeys of a key returning subkey as string | [
"!",
"Iterate",
"over",
"subkeys",
"of",
"a",
"key",
"returning",
"subkey",
"as",
"string"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/windows.py#L212-L216 |
220,150 | mbedmicro/pyOCD | pyocd/probe/stlink/detect/windows.py | _iter_keys | def _iter_keys(key):
"""! Iterate over subkeys of a key
"""
for i in range(winreg.QueryInfoKey(key)[0]):
yield winreg.OpenKey(key, winreg.EnumKey(key, i)) | python | def _iter_keys(key):
"""! Iterate over subkeys of a key
"""
for i in range(winreg.QueryInfoKey(key)[0]):
yield winreg.OpenKey(key, winreg.EnumKey(key, i)) | [
"def",
"_iter_keys",
"(",
"key",
")",
":",
"for",
"i",
"in",
"range",
"(",
"winreg",
".",
"QueryInfoKey",
"(",
"key",
")",
"[",
"0",
"]",
")",
":",
"yield",
"winreg",
".",
"OpenKey",
"(",
"key",
",",
"winreg",
".",
"EnumKey",
"(",
"key",
",",
"i"... | ! Iterate over subkeys of a key | [
"!",
"Iterate",
"over",
"subkeys",
"of",
"a",
"key"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/windows.py#L219-L223 |
220,151 | mbedmicro/pyOCD | pyocd/probe/stlink/detect/windows.py | _iter_vals | def _iter_vals(key):
"""! Iterate over values of a key
"""
for i in range(winreg.QueryInfoKey(key)[1]):
yield winreg.EnumValue(key, i) | python | def _iter_vals(key):
"""! Iterate over values of a key
"""
for i in range(winreg.QueryInfoKey(key)[1]):
yield winreg.EnumValue(key, i) | [
"def",
"_iter_vals",
"(",
"key",
")",
":",
"for",
"i",
"in",
"range",
"(",
"winreg",
".",
"QueryInfoKey",
"(",
"key",
")",
"[",
"1",
"]",
")",
":",
"yield",
"winreg",
".",
"EnumValue",
"(",
"key",
",",
"i",
")"
] | ! Iterate over values of a key | [
"!",
"Iterate",
"over",
"values",
"of",
"a",
"key"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/windows.py#L226-L230 |
220,152 | mbedmicro/pyOCD | pyocd/probe/stlink/detect/windows.py | MbedLsToolsWindows.mount_point_ready | def mount_point_ready(self, path):
"""! Check if a mount point is ready for file operations
@return Returns True if the given path exists, False otherwise
@details Calling the Windows command `dir` instead of using the python
`os.path.exists`. The latter causes a Python error box to appe... | python | def mount_point_ready(self, path):
"""! Check if a mount point is ready for file operations
@return Returns True if the given path exists, False otherwise
@details Calling the Windows command `dir` instead of using the python
`os.path.exists`. The latter causes a Python error box to appe... | [
"def",
"mount_point_ready",
"(",
"self",
",",
"path",
")",
":",
"stdout",
",",
"stderr",
",",
"retcode",
"=",
"self",
".",
"_run_cli_process",
"(",
"\"dir %s\"",
"%",
"path",
")",
"result",
"=",
"True",
"if",
"retcode",
"==",
"0",
"else",
"False",
"retur... | ! Check if a mount point is ready for file operations
@return Returns True if the given path exists, False otherwise
@details Calling the Windows command `dir` instead of using the python
`os.path.exists`. The latter causes a Python error box to appear claiming
there is "No Disk" for som... | [
"!",
"Check",
"if",
"a",
"mount",
"point",
"is",
"ready",
"for",
"file",
"operations"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/windows.py#L478-L490 |
220,153 | mbedmicro/pyOCD | pyocd/target/pack/flash_algo.py | PackFlashAlgo._create_algo_bin | def _create_algo_bin(self, ro_rw_zi):
"""Create a binary blob of the flash algo which can execute from ram"""
sect_ro, sect_rw, sect_zi = ro_rw_zi
algo_size = sect_ro.length + sect_rw.length + sect_zi.length
algo_data = bytearray(algo_size)
for section in (sect_ro, sect_rw):
... | python | def _create_algo_bin(self, ro_rw_zi):
"""Create a binary blob of the flash algo which can execute from ram"""
sect_ro, sect_rw, sect_zi = ro_rw_zi
algo_size = sect_ro.length + sect_rw.length + sect_zi.length
algo_data = bytearray(algo_size)
for section in (sect_ro, sect_rw):
... | [
"def",
"_create_algo_bin",
"(",
"self",
",",
"ro_rw_zi",
")",
":",
"sect_ro",
",",
"sect_rw",
",",
"sect_zi",
"=",
"ro_rw_zi",
"algo_size",
"=",
"sect_ro",
".",
"length",
"+",
"sect_rw",
".",
"length",
"+",
"sect_zi",
".",
"length",
"algo_data",
"=",
"byte... | Create a binary blob of the flash algo which can execute from ram | [
"Create",
"a",
"binary",
"blob",
"of",
"the",
"flash",
"algo",
"which",
"can",
"execute",
"from",
"ram"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/target/pack/flash_algo.py#L232-L243 |
220,154 | mbedmicro/pyOCD | pyocd/target/pack/flash_algo.py | PackFlashInfo._sector_and_sz_itr | def _sector_and_sz_itr(self, elf, data_start):
"""Iterator which returns starting address and sector size"""
for entry_start in itertools.count(data_start, self.FLASH_SECTORS_STRUCT_SIZE):
data = elf.read(entry_start, self.FLASH_SECTORS_STRUCT_SIZE)
size, start = struct.unpack(se... | python | def _sector_and_sz_itr(self, elf, data_start):
"""Iterator which returns starting address and sector size"""
for entry_start in itertools.count(data_start, self.FLASH_SECTORS_STRUCT_SIZE):
data = elf.read(entry_start, self.FLASH_SECTORS_STRUCT_SIZE)
size, start = struct.unpack(se... | [
"def",
"_sector_and_sz_itr",
"(",
"self",
",",
"elf",
",",
"data_start",
")",
":",
"for",
"entry_start",
"in",
"itertools",
".",
"count",
"(",
"data_start",
",",
"self",
".",
"FLASH_SECTORS_STRUCT_SIZE",
")",
":",
"data",
"=",
"elf",
".",
"read",
"(",
"ent... | Iterator which returns starting address and sector size | [
"Iterator",
"which",
"returns",
"starting",
"address",
"and",
"sector",
"size"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/target/pack/flash_algo.py#L292-L300 |
220,155 | mbedmicro/pyOCD | pyocd/probe/stlink/detect/darwin.py | _prune | def _prune(current, keys):
""" Reduce the amount of data we have to sift through to only
include the specified keys, and children that contain the
specified keys
"""
pruned_current = {k: current[k] for k in keys if k in current}
pruned_children = list(
filter(
None, [... | python | def _prune(current, keys):
""" Reduce the amount of data we have to sift through to only
include the specified keys, and children that contain the
specified keys
"""
pruned_current = {k: current[k] for k in keys if k in current}
pruned_children = list(
filter(
None, [... | [
"def",
"_prune",
"(",
"current",
",",
"keys",
")",
":",
"pruned_current",
"=",
"{",
"k",
":",
"current",
"[",
"k",
"]",
"for",
"k",
"in",
"keys",
"if",
"k",
"in",
"current",
"}",
"pruned_children",
"=",
"list",
"(",
"filter",
"(",
"None",
",",
"[",... | Reduce the amount of data we have to sift through to only
include the specified keys, and children that contain the
specified keys | [
"Reduce",
"the",
"amount",
"of",
"data",
"we",
"have",
"to",
"sift",
"through",
"to",
"only",
"include",
"the",
"specified",
"keys",
"and",
"children",
"that",
"contain",
"the",
"specified",
"keys"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/darwin.py#L46-L63 |
220,156 | mbedmicro/pyOCD | pyocd/gdbserver/context_facade.py | GDBDebugContextFacade.get_register_context | def get_register_context(self):
"""
return hexadecimal dump of registers as expected by GDB
"""
logging.debug("GDB getting register context")
resp = b''
reg_num_list = [reg.reg_num for reg in self._register_list]
vals = self._context.read_core_registers_raw(reg_nu... | python | def get_register_context(self):
"""
return hexadecimal dump of registers as expected by GDB
"""
logging.debug("GDB getting register context")
resp = b''
reg_num_list = [reg.reg_num for reg in self._register_list]
vals = self._context.read_core_registers_raw(reg_nu... | [
"def",
"get_register_context",
"(",
"self",
")",
":",
"logging",
".",
"debug",
"(",
"\"GDB getting register context\"",
")",
"resp",
"=",
"b''",
"reg_num_list",
"=",
"[",
"reg",
".",
"reg_num",
"for",
"reg",
"in",
"self",
".",
"_register_list",
"]",
"vals",
... | return hexadecimal dump of registers as expected by GDB | [
"return",
"hexadecimal",
"dump",
"of",
"registers",
"as",
"expected",
"by",
"GDB"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/gdbserver/context_facade.py#L60-L76 |
220,157 | mbedmicro/pyOCD | pyocd/gdbserver/context_facade.py | GDBDebugContextFacade.set_register_context | def set_register_context(self, data):
"""
Set registers from GDB hexadecimal string.
"""
logging.debug("GDB setting register context")
reg_num_list = []
reg_data_list = []
for reg in self._register_list:
if reg.bitsize == 64:
regValue =... | python | def set_register_context(self, data):
"""
Set registers from GDB hexadecimal string.
"""
logging.debug("GDB setting register context")
reg_num_list = []
reg_data_list = []
for reg in self._register_list:
if reg.bitsize == 64:
regValue =... | [
"def",
"set_register_context",
"(",
"self",
",",
"data",
")",
":",
"logging",
".",
"debug",
"(",
"\"GDB setting register context\"",
")",
"reg_num_list",
"=",
"[",
"]",
"reg_data_list",
"=",
"[",
"]",
"for",
"reg",
"in",
"self",
".",
"_register_list",
":",
"... | Set registers from GDB hexadecimal string. | [
"Set",
"registers",
"from",
"GDB",
"hexadecimal",
"string",
"."
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/gdbserver/context_facade.py#L78-L95 |
220,158 | mbedmicro/pyOCD | pyocd/gdbserver/context_facade.py | GDBDebugContextFacade.set_register | def set_register(self, reg, data):
"""
Set single register from GDB hexadecimal string.
reg parameter is the index of register in targetXML sent to GDB.
"""
if reg < 0:
return
elif reg < len(self._register_list):
regName = self._register_list[reg].... | python | def set_register(self, reg, data):
"""
Set single register from GDB hexadecimal string.
reg parameter is the index of register in targetXML sent to GDB.
"""
if reg < 0:
return
elif reg < len(self._register_list):
regName = self._register_list[reg].... | [
"def",
"set_register",
"(",
"self",
",",
"reg",
",",
"data",
")",
":",
"if",
"reg",
"<",
"0",
":",
"return",
"elif",
"reg",
"<",
"len",
"(",
"self",
".",
"_register_list",
")",
":",
"regName",
"=",
"self",
".",
"_register_list",
"[",
"reg",
"]",
".... | Set single register from GDB hexadecimal string.
reg parameter is the index of register in targetXML sent to GDB. | [
"Set",
"single",
"register",
"from",
"GDB",
"hexadecimal",
"string",
".",
"reg",
"parameter",
"is",
"the",
"index",
"of",
"register",
"in",
"targetXML",
"sent",
"to",
"GDB",
"."
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/gdbserver/context_facade.py#L97-L112 |
220,159 | mbedmicro/pyOCD | pyocd/probe/pydapaccess/dap_access_cmsis_dap.py | _get_interfaces | def _get_interfaces():
"""Get the connected USB devices"""
# Get CMSIS-DAPv1 interfaces.
v1_interfaces = INTERFACE[USB_BACKEND].get_all_connected_interfaces()
# Get CMSIS-DAPv2 interfaces.
v2_interfaces = INTERFACE[USB_BACKEND_V2].get_all_connected_interfaces()
# Prefer v2 over v1 if a... | python | def _get_interfaces():
"""Get the connected USB devices"""
# Get CMSIS-DAPv1 interfaces.
v1_interfaces = INTERFACE[USB_BACKEND].get_all_connected_interfaces()
# Get CMSIS-DAPv2 interfaces.
v2_interfaces = INTERFACE[USB_BACKEND_V2].get_all_connected_interfaces()
# Prefer v2 over v1 if a... | [
"def",
"_get_interfaces",
"(",
")",
":",
"# Get CMSIS-DAPv1 interfaces.",
"v1_interfaces",
"=",
"INTERFACE",
"[",
"USB_BACKEND",
"]",
".",
"get_all_connected_interfaces",
"(",
")",
"# Get CMSIS-DAPv2 interfaces.",
"v2_interfaces",
"=",
"INTERFACE",
"[",
"USB_BACKEND_V2",
... | Get the connected USB devices | [
"Get",
"the",
"connected",
"USB",
"devices"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/pydapaccess/dap_access_cmsis_dap.py#L51-L66 |
220,160 | mbedmicro/pyOCD | pyocd/probe/pydapaccess/dap_access_cmsis_dap.py | _Transfer.add_response | def add_response(self, data):
"""
Add data read from the remote device to this object.
The size of data added must match exactly the size
that get_data_size returns.
"""
assert len(data) == self._size_bytes
result = []
for i in range(0, self._size_bytes, ... | python | def add_response(self, data):
"""
Add data read from the remote device to this object.
The size of data added must match exactly the size
that get_data_size returns.
"""
assert len(data) == self._size_bytes
result = []
for i in range(0, self._size_bytes, ... | [
"def",
"add_response",
"(",
"self",
",",
"data",
")",
":",
"assert",
"len",
"(",
"data",
")",
"==",
"self",
".",
"_size_bytes",
"result",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"self",
".",
"_size_bytes",
",",
"4",
")",
":",
"wo... | Add data read from the remote device to this object.
The size of data added must match exactly the size
that get_data_size returns. | [
"Add",
"data",
"read",
"from",
"the",
"remote",
"device",
"to",
"this",
"object",
"."
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/pydapaccess/dap_access_cmsis_dap.py#L107-L120 |
220,161 | mbedmicro/pyOCD | pyocd/probe/pydapaccess/dap_access_cmsis_dap.py | _Transfer.get_result | def get_result(self):
"""
Get the result of this transfer.
"""
while self._result is None:
if len(self.daplink._commands_to_read) > 0:
self.daplink._read_packet()
else:
assert not self.daplink._crnt_cmd.get_empty()
s... | python | def get_result(self):
"""
Get the result of this transfer.
"""
while self._result is None:
if len(self.daplink._commands_to_read) > 0:
self.daplink._read_packet()
else:
assert not self.daplink._crnt_cmd.get_empty()
s... | [
"def",
"get_result",
"(",
"self",
")",
":",
"while",
"self",
".",
"_result",
"is",
"None",
":",
"if",
"len",
"(",
"self",
".",
"daplink",
".",
"_commands_to_read",
")",
">",
"0",
":",
"self",
".",
"daplink",
".",
"_read_packet",
"(",
")",
"else",
":"... | Get the result of this transfer. | [
"Get",
"the",
"result",
"of",
"this",
"transfer",
"."
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/pydapaccess/dap_access_cmsis_dap.py#L129-L148 |
220,162 | mbedmicro/pyOCD | pyocd/probe/pydapaccess/dap_access_cmsis_dap.py | _Command._get_free_words | def _get_free_words(self, blockAllowed, isRead):
"""
Return the number of words free in the transmit packet
"""
if blockAllowed:
# DAP_TransferBlock request packet:
# BYTE | BYTE *****| SHORT**********| BYTE *************| WORD *********|
# > 0x06 | ... | python | def _get_free_words(self, blockAllowed, isRead):
"""
Return the number of words free in the transmit packet
"""
if blockAllowed:
# DAP_TransferBlock request packet:
# BYTE | BYTE *****| SHORT**********| BYTE *************| WORD *********|
# > 0x06 | ... | [
"def",
"_get_free_words",
"(",
"self",
",",
"blockAllowed",
",",
"isRead",
")",
":",
"if",
"blockAllowed",
":",
"# DAP_TransferBlock request packet:",
"# BYTE | BYTE *****| SHORT**********| BYTE *************| WORD *********|",
"# > 0x06 | DAP Index | Transfer Count | Transfer Reques... | Return the number of words free in the transmit packet | [
"Return",
"the",
"number",
"of",
"words",
"free",
"in",
"the",
"transmit",
"packet"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/pydapaccess/dap_access_cmsis_dap.py#L176-L215 |
220,163 | mbedmicro/pyOCD | pyocd/probe/pydapaccess/dap_access_cmsis_dap.py | _Command.add | def add(self, count, request, data, dap_index):
"""
Add a single or block register transfer operation to this command
"""
assert self._data_encoded is False
if self._dap_index is None:
self._dap_index = dap_index
assert self._dap_index == dap_index
if... | python | def add(self, count, request, data, dap_index):
"""
Add a single or block register transfer operation to this command
"""
assert self._data_encoded is False
if self._dap_index is None:
self._dap_index = dap_index
assert self._dap_index == dap_index
if... | [
"def",
"add",
"(",
"self",
",",
"count",
",",
"request",
",",
"data",
",",
"dap_index",
")",
":",
"assert",
"self",
".",
"_data_encoded",
"is",
"False",
"if",
"self",
".",
"_dap_index",
"is",
"None",
":",
"self",
".",
"_dap_index",
"=",
"dap_index",
"a... | Add a single or block register transfer operation to this command | [
"Add",
"a",
"single",
"or",
"block",
"register",
"transfer",
"operation",
"to",
"this",
"command"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/pydapaccess/dap_access_cmsis_dap.py#L261-L284 |
220,164 | mbedmicro/pyOCD | pyocd/probe/pydapaccess/dap_access_cmsis_dap.py | _Command.decode_data | def decode_data(self, data):
"""
Decode the response data
"""
assert self.get_empty() is False
assert self._data_encoded is True
if self._block_allowed:
data = self._decode_transfer_block_data(data)
else:
data = self._decode_transfer_data(d... | python | def decode_data(self, data):
"""
Decode the response data
"""
assert self.get_empty() is False
assert self._data_encoded is True
if self._block_allowed:
data = self._decode_transfer_block_data(data)
else:
data = self._decode_transfer_data(d... | [
"def",
"decode_data",
"(",
"self",
",",
"data",
")",
":",
"assert",
"self",
".",
"get_empty",
"(",
")",
"is",
"False",
"assert",
"self",
".",
"_data_encoded",
"is",
"True",
"if",
"self",
".",
"_block_allowed",
":",
"data",
"=",
"self",
".",
"_decode_tran... | Decode the response data | [
"Decode",
"the",
"response",
"data"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/pydapaccess/dap_access_cmsis_dap.py#L429-L439 |
220,165 | mbedmicro/pyOCD | pyocd/probe/pydapaccess/dap_access_cmsis_dap.py | DAPAccessCMSISDAP.get_connected_devices | def get_connected_devices():
"""
Return an array of all mbed boards connected
"""
all_daplinks = []
all_interfaces = _get_interfaces()
for interface in all_interfaces:
try:
new_daplink = DAPAccessCMSISDAP(None, interface=interface)
... | python | def get_connected_devices():
"""
Return an array of all mbed boards connected
"""
all_daplinks = []
all_interfaces = _get_interfaces()
for interface in all_interfaces:
try:
new_daplink = DAPAccessCMSISDAP(None, interface=interface)
... | [
"def",
"get_connected_devices",
"(",
")",
":",
"all_daplinks",
"=",
"[",
"]",
"all_interfaces",
"=",
"_get_interfaces",
"(",
")",
"for",
"interface",
"in",
"all_interfaces",
":",
"try",
":",
"new_daplink",
"=",
"DAPAccessCMSISDAP",
"(",
"None",
",",
"interface",... | Return an array of all mbed boards connected | [
"Return",
"an",
"array",
"of",
"all",
"mbed",
"boards",
"connected"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/pydapaccess/dap_access_cmsis_dap.py#L452-L465 |
220,166 | mbedmicro/pyOCD | pyocd/probe/pydapaccess/dap_access_cmsis_dap.py | DAPAccessCMSISDAP.set_deferred_transfer | def set_deferred_transfer(self, enable):
"""
Allow transfers to be delayed and buffered
By default deferred transfers are turned off. All reads and
writes will be completed by the time the function returns.
When enabled packets are buffered and sent all at once, which
... | python | def set_deferred_transfer(self, enable):
"""
Allow transfers to be delayed and buffered
By default deferred transfers are turned off. All reads and
writes will be completed by the time the function returns.
When enabled packets are buffered and sent all at once, which
... | [
"def",
"set_deferred_transfer",
"(",
"self",
",",
"enable",
")",
":",
"if",
"self",
".",
"_deferred_transfer",
"and",
"not",
"enable",
":",
"self",
".",
"flush",
"(",
")",
"self",
".",
"_deferred_transfer",
"=",
"enable"
] | Allow transfers to be delayed and buffered
By default deferred transfers are turned off. All reads and
writes will be completed by the time the function returns.
When enabled packets are buffered and sent all at once, which
increases speed. When memory is written to, the transfer
... | [
"Allow",
"transfers",
"to",
"be",
"delayed",
"and",
"buffered"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/pydapaccess/dap_access_cmsis_dap.py#L626-L650 |
220,167 | mbedmicro/pyOCD | pyocd/probe/pydapaccess/dap_access_cmsis_dap.py | DAPAccessCMSISDAP._init_deferred_buffers | def _init_deferred_buffers(self):
"""
Initialize or reinitalize all the deferred transfer buffers
Calling this method will drop all pending transactions
so use with care.
"""
# List of transfers that have been started, but
# not completed (started by write_reg, r... | python | def _init_deferred_buffers(self):
"""
Initialize or reinitalize all the deferred transfer buffers
Calling this method will drop all pending transactions
so use with care.
"""
# List of transfers that have been started, but
# not completed (started by write_reg, r... | [
"def",
"_init_deferred_buffers",
"(",
"self",
")",
":",
"# List of transfers that have been started, but",
"# not completed (started by write_reg, read_reg,",
"# reg_write_repeat and reg_read_repeat)",
"self",
".",
"_transfer_list",
"=",
"collections",
".",
"deque",
"(",
")",
"# ... | Initialize or reinitalize all the deferred transfer buffers
Calling this method will drop all pending transactions
so use with care. | [
"Initialize",
"or",
"reinitalize",
"all",
"the",
"deferred",
"transfer",
"buffers"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/pydapaccess/dap_access_cmsis_dap.py#L851-L869 |
220,168 | mbedmicro/pyOCD | pyocd/probe/pydapaccess/dap_access_cmsis_dap.py | DAPAccessCMSISDAP._read_packet | def _read_packet(self):
"""
Reads and decodes a single packet
Reads a single packet from the device and
stores the data from it in the current Command
object
"""
# Grab command, send it and decode response
cmd = self._commands_to_read.popleft()
tr... | python | def _read_packet(self):
"""
Reads and decodes a single packet
Reads a single packet from the device and
stores the data from it in the current Command
object
"""
# Grab command, send it and decode response
cmd = self._commands_to_read.popleft()
tr... | [
"def",
"_read_packet",
"(",
"self",
")",
":",
"# Grab command, send it and decode response",
"cmd",
"=",
"self",
".",
"_commands_to_read",
".",
"popleft",
"(",
")",
"try",
":",
"raw_data",
"=",
"self",
".",
"_interface",
".",
"read",
"(",
")",
"raw_data",
"=",... | Reads and decodes a single packet
Reads a single packet from the device and
stores the data from it in the current Command
object | [
"Reads",
"and",
"decodes",
"a",
"single",
"packet"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/pydapaccess/dap_access_cmsis_dap.py#L871-L912 |
220,169 | mbedmicro/pyOCD | pyocd/probe/pydapaccess/dap_access_cmsis_dap.py | DAPAccessCMSISDAP._send_packet | def _send_packet(self):
"""
Send a single packet to the interface
This function guarentees that the number of packets
that are stored in daplink's buffer (the number of
packets written but not read) does not exceed the
number supported by the given device.
"""
... | python | def _send_packet(self):
"""
Send a single packet to the interface
This function guarentees that the number of packets
that are stored in daplink's buffer (the number of
packets written but not read) does not exceed the
number supported by the given device.
"""
... | [
"def",
"_send_packet",
"(",
"self",
")",
":",
"cmd",
"=",
"self",
".",
"_crnt_cmd",
"if",
"cmd",
".",
"get_empty",
"(",
")",
":",
"return",
"max_packets",
"=",
"self",
".",
"_interface",
".",
"get_packet_count",
"(",
")",
"if",
"len",
"(",
"self",
".",... | Send a single packet to the interface
This function guarentees that the number of packets
that are stored in daplink's buffer (the number of
packets written but not read) does not exceed the
number supported by the given device. | [
"Send",
"a",
"single",
"packet",
"to",
"the",
"interface"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/pydapaccess/dap_access_cmsis_dap.py#L914-L937 |
220,170 | mbedmicro/pyOCD | pyocd/probe/pydapaccess/dap_access_cmsis_dap.py | DAPAccessCMSISDAP._write | def _write(self, dap_index, transfer_count,
transfer_request, transfer_data):
"""
Write one or more commands
"""
assert dap_index == 0 # dap index currently unsupported
assert isinstance(transfer_count, six.integer_types)
assert isinstance(transfer_request... | python | def _write(self, dap_index, transfer_count,
transfer_request, transfer_data):
"""
Write one or more commands
"""
assert dap_index == 0 # dap index currently unsupported
assert isinstance(transfer_count, six.integer_types)
assert isinstance(transfer_request... | [
"def",
"_write",
"(",
"self",
",",
"dap_index",
",",
"transfer_count",
",",
"transfer_request",
",",
"transfer_data",
")",
":",
"assert",
"dap_index",
"==",
"0",
"# dap index currently unsupported",
"assert",
"isinstance",
"(",
"transfer_count",
",",
"six",
".",
"... | Write one or more commands | [
"Write",
"one",
"or",
"more",
"commands"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/pydapaccess/dap_access_cmsis_dap.py#L939-L992 |
220,171 | mbedmicro/pyOCD | pyocd/probe/pydapaccess/dap_access_cmsis_dap.py | DAPAccessCMSISDAP._jtag_to_swd | def _jtag_to_swd(self):
"""
Send the command to switch from SWD to jtag
"""
data = [0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]
self._protocol.swj_sequence(data)
data = [0x9e, 0xe7]
self._protocol.swj_sequence(data)
data = [0xff, 0xff, 0xff, 0xff, 0xff, 0x... | python | def _jtag_to_swd(self):
"""
Send the command to switch from SWD to jtag
"""
data = [0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]
self._protocol.swj_sequence(data)
data = [0x9e, 0xe7]
self._protocol.swj_sequence(data)
data = [0xff, 0xff, 0xff, 0xff, 0xff, 0x... | [
"def",
"_jtag_to_swd",
"(",
"self",
")",
":",
"data",
"=",
"[",
"0xff",
",",
"0xff",
",",
"0xff",
",",
"0xff",
",",
"0xff",
",",
"0xff",
",",
"0xff",
"]",
"self",
".",
"_protocol",
".",
"swj_sequence",
"(",
"data",
")",
"data",
"=",
"[",
"0x9e",
... | Send the command to switch from SWD to jtag | [
"Send",
"the",
"command",
"to",
"switch",
"from",
"SWD",
"to",
"jtag"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/pydapaccess/dap_access_cmsis_dap.py#L994-L1008 |
220,172 | mbedmicro/pyOCD | pyocd/probe/pydapaccess/dap_access_cmsis_dap.py | DAPAccessCMSISDAP._abort_all_transfers | def _abort_all_transfers(self, exception):
"""
Abort any ongoing transfers and clear all buffers
"""
pending_reads = len(self._commands_to_read)
# invalidate _transfer_list
for transfer in self._transfer_list:
transfer.add_error(exception)
# clear all ... | python | def _abort_all_transfers(self, exception):
"""
Abort any ongoing transfers and clear all buffers
"""
pending_reads = len(self._commands_to_read)
# invalidate _transfer_list
for transfer in self._transfer_list:
transfer.add_error(exception)
# clear all ... | [
"def",
"_abort_all_transfers",
"(",
"self",
",",
"exception",
")",
":",
"pending_reads",
"=",
"len",
"(",
"self",
".",
"_commands_to_read",
")",
"# invalidate _transfer_list",
"for",
"transfer",
"in",
"self",
".",
"_transfer_list",
":",
"transfer",
".",
"add_error... | Abort any ongoing transfers and clear all buffers | [
"Abort",
"any",
"ongoing",
"transfers",
"and",
"clear",
"all",
"buffers"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/pydapaccess/dap_access_cmsis_dap.py#L1010-L1025 |
220,173 | mbedmicro/pyOCD | pyocd/target/builtin/target_nRF51822_xxAA.py | NRF51.resetn | def resetn(self):
"""
reset a core. After a call to this function, the core
is running
"""
#Regular reset will kick NRF out of DBG mode
logging.debug("target_nrf51.reset: enable reset pin")
self.write_memory(RESET, RESET_ENABLE)
#reset
logging.debu... | python | def resetn(self):
"""
reset a core. After a call to this function, the core
is running
"""
#Regular reset will kick NRF out of DBG mode
logging.debug("target_nrf51.reset: enable reset pin")
self.write_memory(RESET, RESET_ENABLE)
#reset
logging.debu... | [
"def",
"resetn",
"(",
"self",
")",
":",
"#Regular reset will kick NRF out of DBG mode",
"logging",
".",
"debug",
"(",
"\"target_nrf51.reset: enable reset pin\"",
")",
"self",
".",
"write_memory",
"(",
"RESET",
",",
"RESET_ENABLE",
")",
"#reset",
"logging",
".",
"debug... | reset a core. After a call to this function, the core
is running | [
"reset",
"a",
"core",
".",
"After",
"a",
"call",
"to",
"this",
"function",
"the",
"core",
"is",
"running"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/target/builtin/target_nRF51822_xxAA.py#L67-L77 |
220,174 | mbedmicro/pyOCD | pyocd/probe/stlink/detect/base.py | StlinkDetectBase.list_mbeds | def list_mbeds(self):
""" List details of connected devices
@return Returns list of structures with detailed info about each mbed
@details Function returns list of dictionaries with mbed attributes
'mount_point', TargetID name etc.
Function returns mbed list with platform names... | python | def list_mbeds(self):
""" List details of connected devices
@return Returns list of structures with detailed info about each mbed
@details Function returns list of dictionaries with mbed attributes
'mount_point', TargetID name etc.
Function returns mbed list with platform names... | [
"def",
"list_mbeds",
"(",
"self",
")",
":",
"platform_count",
"=",
"{",
"}",
"candidates",
"=",
"list",
"(",
"self",
".",
"find_candidates",
"(",
")",
")",
"result",
"=",
"[",
"]",
"for",
"device",
"in",
"candidates",
":",
"if",
"not",
"device",
".",
... | List details of connected devices
@return Returns list of structures with detailed info about each mbed
@details Function returns list of dictionaries with mbed attributes
'mount_point', TargetID name etc.
Function returns mbed list with platform names if possible | [
"List",
"details",
"of",
"connected",
"devices"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/base.py#L52-L69 |
220,175 | mbedmicro/pyOCD | pyocd/probe/stlink/detect/base.py | StlinkDetectBase._update_device_from_fs | def _update_device_from_fs(self, device):
""" Updates the device information based on files from its 'mount_point'
@param device Dictionary containing device information
"""
try:
directory_entries = listdir(device["mount_point"])
# Always try to update using ... | python | def _update_device_from_fs(self, device):
""" Updates the device information based on files from its 'mount_point'
@param device Dictionary containing device information
"""
try:
directory_entries = listdir(device["mount_point"])
# Always try to update using ... | [
"def",
"_update_device_from_fs",
"(",
"self",
",",
"device",
")",
":",
"try",
":",
"directory_entries",
"=",
"listdir",
"(",
"device",
"[",
"\"mount_point\"",
"]",
")",
"# Always try to update using daplink compatible boards processself.",
"# This is done for backwards compat... | Updates the device information based on files from its 'mount_point'
@param device Dictionary containing device information | [
"Updates",
"the",
"device",
"information",
"based",
"on",
"files",
"from",
"its",
"mount_point"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/base.py#L71-L91 |
220,176 | mbedmicro/pyOCD | pyocd/probe/stlink/detect/base.py | StlinkDetectBase._read_htm_ids | def _read_htm_ids(self, mount_point):
"""! Function scans mbed.htm to get information about TargetID.
@param mount_point mbed mount point (disk / drive letter)
@return Function returns targetID, in case of failure returns None.
@details Note: This function should be improved to scan vari... | python | def _read_htm_ids(self, mount_point):
"""! Function scans mbed.htm to get information about TargetID.
@param mount_point mbed mount point (disk / drive letter)
@return Function returns targetID, in case of failure returns None.
@details Note: This function should be improved to scan vari... | [
"def",
"_read_htm_ids",
"(",
"self",
",",
"mount_point",
")",
":",
"result",
"=",
"{",
"}",
"target_id",
"=",
"None",
"for",
"line",
"in",
"self",
".",
"_htm_lines",
"(",
"mount_point",
")",
":",
"target_id",
"=",
"target_id",
"or",
"self",
".",
"_target... | ! Function scans mbed.htm to get information about TargetID.
@param mount_point mbed mount point (disk / drive letter)
@return Function returns targetID, in case of failure returns None.
@details Note: This function should be improved to scan variety of boards'
mbed.htm files | [
"!",
"Function",
"scans",
"mbed",
".",
"htm",
"to",
"get",
"information",
"about",
"TargetID",
"."
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/base.py#L109-L120 |
220,177 | mbedmicro/pyOCD | pyocd/probe/stlink/detect/base.py | StlinkDetectBase._target_id_from_htm | def _target_id_from_htm(self, line):
"""! Extract Target id from htm line.
@return Target id or None
"""
# Detecting modern mbed.htm file format
m = re.search("\\?code=([a-fA-F0-9]+)", line)
if m:
result = m.groups()[0]
return result
# Last... | python | def _target_id_from_htm(self, line):
"""! Extract Target id from htm line.
@return Target id or None
"""
# Detecting modern mbed.htm file format
m = re.search("\\?code=([a-fA-F0-9]+)", line)
if m:
result = m.groups()[0]
return result
# Last... | [
"def",
"_target_id_from_htm",
"(",
"self",
",",
"line",
")",
":",
"# Detecting modern mbed.htm file format",
"m",
"=",
"re",
".",
"search",
"(",
"\"\\\\?code=([a-fA-F0-9]+)\"",
",",
"line",
")",
"if",
"m",
":",
"result",
"=",
"m",
".",
"groups",
"(",
")",
"[... | ! Extract Target id from htm line.
@return Target id or None | [
"!",
"Extract",
"Target",
"id",
"from",
"htm",
"line",
"."
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/base.py#L128-L143 |
220,178 | mbedmicro/pyOCD | pyocd/probe/stlink/detect/base.py | StlinkDetectBase._run_cli_process | def _run_cli_process(cmd, shell=True):
"""! Runs command as a process and return stdout, stderr and ret code
@param cmd Command to execute
@return Tuple of (stdout, stderr, returncode)
"""
from subprocess import Popen, PIPE
p = Popen(cmd, shell=shell, stdout=PIPE, stderr... | python | def _run_cli_process(cmd, shell=True):
"""! Runs command as a process and return stdout, stderr and ret code
@param cmd Command to execute
@return Tuple of (stdout, stderr, returncode)
"""
from subprocess import Popen, PIPE
p = Popen(cmd, shell=shell, stdout=PIPE, stderr... | [
"def",
"_run_cli_process",
"(",
"cmd",
",",
"shell",
"=",
"True",
")",
":",
"from",
"subprocess",
"import",
"Popen",
",",
"PIPE",
"p",
"=",
"Popen",
"(",
"cmd",
",",
"shell",
"=",
"shell",
",",
"stdout",
"=",
"PIPE",
",",
"stderr",
"=",
"PIPE",
")",
... | ! Runs command as a process and return stdout, stderr and ret code
@param cmd Command to execute
@return Tuple of (stdout, stderr, returncode) | [
"!",
"Runs",
"command",
"as",
"a",
"process",
"and",
"return",
"stdout",
"stderr",
"and",
"ret",
"code"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/base.py#L151-L160 |
220,179 | mbedmicro/pyOCD | pyocd/probe/stlink/detect/factory.py | create_mbed_detector | def create_mbed_detector(**kwargs):
"""! Factory used to create host OS specific mbed-lstools object
:param kwargs: keyword arguments to pass along to the constructors
@return Returns MbedLsTools object or None if host OS is not supported
"""
host_os = platform.system()
if host_os == "Windows"... | python | def create_mbed_detector(**kwargs):
"""! Factory used to create host OS specific mbed-lstools object
:param kwargs: keyword arguments to pass along to the constructors
@return Returns MbedLsTools object or None if host OS is not supported
"""
host_os = platform.system()
if host_os == "Windows"... | [
"def",
"create_mbed_detector",
"(",
"*",
"*",
"kwargs",
")",
":",
"host_os",
"=",
"platform",
".",
"system",
"(",
")",
"if",
"host_os",
"==",
"\"Windows\"",
":",
"from",
".",
"windows",
"import",
"StlinkDetectWindows",
"return",
"StlinkDetectWindows",
"(",
"*"... | ! Factory used to create host OS specific mbed-lstools object
:param kwargs: keyword arguments to pass along to the constructors
@return Returns MbedLsTools object or None if host OS is not supported | [
"!",
"Factory",
"used",
"to",
"create",
"host",
"OS",
"specific",
"mbed",
"-",
"lstools",
"object"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/factory.py#L22-L43 |
220,180 | mbedmicro/pyOCD | pyocd/coresight/ap.py | _locked | def _locked(func):
"""! Decorator to automatically lock an AccessPort method."""
def _locking(self, *args, **kwargs):
try:
self.lock()
return func(self, *args, **kwargs)
finally:
self.unlock()
return _locking | python | def _locked(func):
"""! Decorator to automatically lock an AccessPort method."""
def _locking(self, *args, **kwargs):
try:
self.lock()
return func(self, *args, **kwargs)
finally:
self.unlock()
return _locking | [
"def",
"_locked",
"(",
"func",
")",
":",
"def",
"_locking",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"self",
".",
"lock",
"(",
")",
"return",
"func",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
... | ! Decorator to automatically lock an AccessPort method. | [
"!",
"Decorator",
"to",
"automatically",
"lock",
"an",
"AccessPort",
"method",
"."
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/coresight/ap.py#L136-L144 |
220,181 | mbedmicro/pyOCD | pyocd/probe/stlink/detect/linux.py | StlinkDetectLinuxGeneric._dev_by_id | def _dev_by_id(self, device_type):
"""! Get a dict, USBID -> device, for a device class
@param device_type The type of devices to search. For exmaple, "serial"
looks for all serial devices connected to this computer
@return A dict: Device USBID -> device file in /dev
"""
... | python | def _dev_by_id(self, device_type):
"""! Get a dict, USBID -> device, for a device class
@param device_type The type of devices to search. For exmaple, "serial"
looks for all serial devices connected to this computer
@return A dict: Device USBID -> device file in /dev
"""
... | [
"def",
"_dev_by_id",
"(",
"self",
",",
"device_type",
")",
":",
"dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"\"/dev\"",
",",
"device_type",
",",
"\"by-id\"",
")",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"dir",
")",
":",
"to_ret",
"=",
"dic... | ! Get a dict, USBID -> device, for a device class
@param device_type The type of devices to search. For exmaple, "serial"
looks for all serial devices connected to this computer
@return A dict: Device USBID -> device file in /dev | [
"!",
"Get",
"a",
"dict",
"USBID",
"-",
">",
"device",
"for",
"a",
"device",
"class"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/linux.py#L63-L85 |
220,182 | mbedmicro/pyOCD | pyocd/probe/stlink/detect/linux.py | StlinkDetectLinuxGeneric._hex_ids | def _hex_ids(self, dev_list):
"""! Build a USBID map for a device list
@param disk_list List of disks in a system with USBID decoration
@return Returns map USBID -> device file in /dev
@details Uses regular expressions to get a USBID (TargeTIDs) a "by-id"
symbolic link
... | python | def _hex_ids(self, dev_list):
"""! Build a USBID map for a device list
@param disk_list List of disks in a system with USBID decoration
@return Returns map USBID -> device file in /dev
@details Uses regular expressions to get a USBID (TargeTIDs) a "by-id"
symbolic link
... | [
"def",
"_hex_ids",
"(",
"self",
",",
"dev_list",
")",
":",
"for",
"dl",
"in",
"dev_list",
":",
"match",
"=",
"self",
".",
"nlp",
".",
"search",
"(",
"dl",
")",
"if",
"match",
":",
"yield",
"match",
".",
"group",
"(",
"\"usbid\"",
")",
",",
"_readli... | ! Build a USBID map for a device list
@param disk_list List of disks in a system with USBID decoration
@return Returns map USBID -> device file in /dev
@details Uses regular expressions to get a USBID (TargeTIDs) a "by-id"
symbolic link | [
"!",
"Build",
"a",
"USBID",
"map",
"for",
"a",
"device",
"list"
] | 41a174718a9739f3cbe785c2ba21cb7fd1310c6f | https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/probe/stlink/detect/linux.py#L100-L110 |
220,183 | influxdata/influxdb-python | influxdb/line_protocol.py | _get_unicode | def _get_unicode(data, force=False):
"""Try to return a text aka unicode object from the given data."""
if isinstance(data, binary_type):
return data.decode('utf-8')
elif data is None:
return ''
elif force:
if PY2:
return unicode(data)
else:
return... | python | def _get_unicode(data, force=False):
"""Try to return a text aka unicode object from the given data."""
if isinstance(data, binary_type):
return data.decode('utf-8')
elif data is None:
return ''
elif force:
if PY2:
return unicode(data)
else:
return... | [
"def",
"_get_unicode",
"(",
"data",
",",
"force",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"data",
",",
"binary_type",
")",
":",
"return",
"data",
".",
"decode",
"(",
"'utf-8'",
")",
"elif",
"data",
"is",
"None",
":",
"return",
"''",
"elif",
... | Try to return a text aka unicode object from the given data. | [
"Try",
"to",
"return",
"a",
"text",
"aka",
"unicode",
"object",
"from",
"the",
"given",
"data",
"."
] | d5d12499f3755199d5eedd8b363450f1cf4073bd | https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/line_protocol.py#L104-L116 |
220,184 | influxdata/influxdb-python | influxdb/line_protocol.py | make_lines | def make_lines(data, precision=None):
"""Extract points from given dict.
Extracts the points from the given dict and returns a Unicode string
matching the line protocol introduced in InfluxDB 0.9.0.
"""
lines = []
static_tags = data.get('tags')
for point in data['points']:
elements ... | python | def make_lines(data, precision=None):
"""Extract points from given dict.
Extracts the points from the given dict and returns a Unicode string
matching the line protocol introduced in InfluxDB 0.9.0.
"""
lines = []
static_tags = data.get('tags')
for point in data['points']:
elements ... | [
"def",
"make_lines",
"(",
"data",
",",
"precision",
"=",
"None",
")",
":",
"lines",
"=",
"[",
"]",
"static_tags",
"=",
"data",
".",
"get",
"(",
"'tags'",
")",
"for",
"point",
"in",
"data",
"[",
"'points'",
"]",
":",
"elements",
"=",
"[",
"]",
"# ad... | Extract points from given dict.
Extracts the points from the given dict and returns a Unicode string
matching the line protocol introduced in InfluxDB 0.9.0. | [
"Extract",
"points",
"from",
"given",
"dict",
"."
] | d5d12499f3755199d5eedd8b363450f1cf4073bd | https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/line_protocol.py#L119-L172 |
220,185 | influxdata/influxdb-python | examples/tutorial_pandas.py | main | def main(host='localhost', port=8086):
"""Instantiate the connection to the InfluxDB client."""
user = 'root'
password = 'root'
dbname = 'demo'
protocol = 'json'
client = DataFrameClient(host, port, user, password, dbname)
print("Create pandas DataFrame")
df = pd.DataFrame(data=list(ra... | python | def main(host='localhost', port=8086):
"""Instantiate the connection to the InfluxDB client."""
user = 'root'
password = 'root'
dbname = 'demo'
protocol = 'json'
client = DataFrameClient(host, port, user, password, dbname)
print("Create pandas DataFrame")
df = pd.DataFrame(data=list(ra... | [
"def",
"main",
"(",
"host",
"=",
"'localhost'",
",",
"port",
"=",
"8086",
")",
":",
"user",
"=",
"'root'",
"password",
"=",
"'root'",
"dbname",
"=",
"'demo'",
"protocol",
"=",
"'json'",
"client",
"=",
"DataFrameClient",
"(",
"host",
",",
"port",
",",
"... | Instantiate the connection to the InfluxDB client. | [
"Instantiate",
"the",
"connection",
"to",
"the",
"InfluxDB",
"client",
"."
] | d5d12499f3755199d5eedd8b363450f1cf4073bd | https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/examples/tutorial_pandas.py#L10-L38 |
220,186 | influxdata/influxdb-python | influxdb/client.py | _parse_dsn | def _parse_dsn(dsn):
"""Parse data source name.
This is a helper function to split the data source name provided in
the from_dsn classmethod
"""
conn_params = urlparse(dsn)
init_args = {}
scheme_info = conn_params.scheme.split('+')
if len(scheme_info) == 1:
scheme = scheme_info[... | python | def _parse_dsn(dsn):
"""Parse data source name.
This is a helper function to split the data source name provided in
the from_dsn classmethod
"""
conn_params = urlparse(dsn)
init_args = {}
scheme_info = conn_params.scheme.split('+')
if len(scheme_info) == 1:
scheme = scheme_info[... | [
"def",
"_parse_dsn",
"(",
"dsn",
")",
":",
"conn_params",
"=",
"urlparse",
"(",
"dsn",
")",
"init_args",
"=",
"{",
"}",
"scheme_info",
"=",
"conn_params",
".",
"scheme",
".",
"split",
"(",
"'+'",
")",
"if",
"len",
"(",
"scheme_info",
")",
"==",
"1",
... | Parse data source name.
This is a helper function to split the data source name provided in
the from_dsn classmethod | [
"Parse",
"data",
"source",
"name",
"."
] | d5d12499f3755199d5eedd8b363450f1cf4073bd | https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L1059-L1097 |
220,187 | influxdata/influxdb-python | influxdb/client.py | InfluxDBClient.from_dsn | def from_dsn(cls, dsn, **kwargs):
r"""Generate an instance of InfluxDBClient from given data source name.
Return an instance of :class:`~.InfluxDBClient` from the provided
data source name. Supported schemes are "influxdb", "https+influxdb"
and "udp+influxdb". Parameters for the :class:... | python | def from_dsn(cls, dsn, **kwargs):
r"""Generate an instance of InfluxDBClient from given data source name.
Return an instance of :class:`~.InfluxDBClient` from the provided
data source name. Supported schemes are "influxdb", "https+influxdb"
and "udp+influxdb". Parameters for the :class:... | [
"def",
"from_dsn",
"(",
"cls",
",",
"dsn",
",",
"*",
"*",
"kwargs",
")",
":",
"init_args",
"=",
"_parse_dsn",
"(",
"dsn",
")",
"host",
",",
"port",
"=",
"init_args",
".",
"pop",
"(",
"'hosts'",
")",
"[",
"0",
"]",
"init_args",
"[",
"'host'",
"]",
... | r"""Generate an instance of InfluxDBClient from given data source name.
Return an instance of :class:`~.InfluxDBClient` from the provided
data source name. Supported schemes are "influxdb", "https+influxdb"
and "udp+influxdb". Parameters for the :class:`~.InfluxDBClient`
constructor may... | [
"r",
"Generate",
"an",
"instance",
"of",
"InfluxDBClient",
"from",
"given",
"data",
"source",
"name",
"."
] | d5d12499f3755199d5eedd8b363450f1cf4073bd | https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L159-L197 |
220,188 | influxdata/influxdb-python | influxdb/client.py | InfluxDBClient.switch_user | def switch_user(self, username, password):
"""Change the client's username.
:param username: the username to switch to
:type username: str
:param password: the password for the username
:type password: str
"""
self._username = username
self._password = pa... | python | def switch_user(self, username, password):
"""Change the client's username.
:param username: the username to switch to
:type username: str
:param password: the password for the username
:type password: str
"""
self._username = username
self._password = pa... | [
"def",
"switch_user",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"self",
".",
"_username",
"=",
"username",
"self",
".",
"_password",
"=",
"password"
] | Change the client's username.
:param username: the username to switch to
:type username: str
:param password: the password for the username
:type password: str | [
"Change",
"the",
"client",
"s",
"username",
"."
] | d5d12499f3755199d5eedd8b363450f1cf4073bd | https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L207-L216 |
220,189 | influxdata/influxdb-python | influxdb/client.py | InfluxDBClient.request | def request(self, url, method='GET', params=None, data=None,
expected_response_code=200, headers=None):
"""Make a HTTP request to the InfluxDB API.
:param url: the path of the HTTP request, e.g. write, query, etc.
:type url: str
:param method: the HTTP method for the req... | python | def request(self, url, method='GET', params=None, data=None,
expected_response_code=200, headers=None):
"""Make a HTTP request to the InfluxDB API.
:param url: the path of the HTTP request, e.g. write, query, etc.
:type url: str
:param method: the HTTP method for the req... | [
"def",
"request",
"(",
"self",
",",
"url",
",",
"method",
"=",
"'GET'",
",",
"params",
"=",
"None",
",",
"data",
"=",
"None",
",",
"expected_response_code",
"=",
"200",
",",
"headers",
"=",
"None",
")",
":",
"url",
"=",
"\"{0}/{1}\"",
".",
"format",
... | Make a HTTP request to the InfluxDB API.
:param url: the path of the HTTP request, e.g. write, query, etc.
:type url: str
:param method: the HTTP method for the request, defaults to GET
:type method: str
:param params: additional parameters for the request, defaults to None
... | [
"Make",
"a",
"HTTP",
"request",
"to",
"the",
"InfluxDB",
"API",
"."
] | d5d12499f3755199d5eedd8b363450f1cf4073bd | https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L218-L286 |
220,190 | influxdata/influxdb-python | influxdb/client.py | InfluxDBClient.write | def write(self, data, params=None, expected_response_code=204,
protocol='json'):
"""Write data to InfluxDB.
:param data: the data to be written
:type data: (if protocol is 'json') dict
(if protocol is 'line') sequence of line protocol strings
... | python | def write(self, data, params=None, expected_response_code=204,
protocol='json'):
"""Write data to InfluxDB.
:param data: the data to be written
:type data: (if protocol is 'json') dict
(if protocol is 'line') sequence of line protocol strings
... | [
"def",
"write",
"(",
"self",
",",
"data",
",",
"params",
"=",
"None",
",",
"expected_response_code",
"=",
"204",
",",
"protocol",
"=",
"'json'",
")",
":",
"headers",
"=",
"self",
".",
"_headers",
"headers",
"[",
"'Content-Type'",
"]",
"=",
"'application/oc... | Write data to InfluxDB.
:param data: the data to be written
:type data: (if protocol is 'json') dict
(if protocol is 'line') sequence of line protocol strings
or single string
:param params: additional parameters for the request, d... | [
"Write",
"data",
"to",
"InfluxDB",
"."
] | d5d12499f3755199d5eedd8b363450f1cf4073bd | https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L288-L329 |
220,191 | influxdata/influxdb-python | influxdb/client.py | InfluxDBClient.query | def query(self,
query,
params=None,
bind_params=None,
epoch=None,
expected_response_code=200,
database=None,
raise_errors=True,
chunked=False,
chunk_size=0,
method="GET"):
... | python | def query(self,
query,
params=None,
bind_params=None,
epoch=None,
expected_response_code=200,
database=None,
raise_errors=True,
chunked=False,
chunk_size=0,
method="GET"):
... | [
"def",
"query",
"(",
"self",
",",
"query",
",",
"params",
"=",
"None",
",",
"bind_params",
"=",
"None",
",",
"epoch",
"=",
"None",
",",
"expected_response_code",
"=",
"200",
",",
"database",
"=",
"None",
",",
"raise_errors",
"=",
"True",
",",
"chunked",
... | Send a query to InfluxDB.
.. danger::
In order to avoid injection vulnerabilities (similar to `SQL
injection <https://www.owasp.org/index.php/SQL_Injection>`_
vulnerabilities), do not directly include untrusted data into the
``query`` parameter, use ``bind_params... | [
"Send",
"a",
"query",
"to",
"InfluxDB",
"."
] | d5d12499f3755199d5eedd8b363450f1cf4073bd | https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L345-L452 |
220,192 | influxdata/influxdb-python | influxdb/client.py | InfluxDBClient.ping | def ping(self):
"""Check connectivity to InfluxDB.
:returns: The version of the InfluxDB the client is connected to
"""
response = self.request(
url="ping",
method='GET',
expected_response_code=204
)
return response.headers['X-Influxd... | python | def ping(self):
"""Check connectivity to InfluxDB.
:returns: The version of the InfluxDB the client is connected to
"""
response = self.request(
url="ping",
method='GET',
expected_response_code=204
)
return response.headers['X-Influxd... | [
"def",
"ping",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"request",
"(",
"url",
"=",
"\"ping\"",
",",
"method",
"=",
"'GET'",
",",
"expected_response_code",
"=",
"204",
")",
"return",
"response",
".",
"headers",
"[",
"'X-Influxdb-Version'",
"]"
... | Check connectivity to InfluxDB.
:returns: The version of the InfluxDB the client is connected to | [
"Check",
"connectivity",
"to",
"InfluxDB",
"."
] | d5d12499f3755199d5eedd8b363450f1cf4073bd | https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L516-L527 |
220,193 | influxdata/influxdb-python | influxdb/client.py | InfluxDBClient.create_retention_policy | def create_retention_policy(self, name, duration, replication,
database=None,
default=False, shard_duration="0s"):
"""Create a retention policy for a database.
:param name: the name of the new retention policy
:type name: str
... | python | def create_retention_policy(self, name, duration, replication,
database=None,
default=False, shard_duration="0s"):
"""Create a retention policy for a database.
:param name: the name of the new retention policy
:type name: str
... | [
"def",
"create_retention_policy",
"(",
"self",
",",
"name",
",",
"duration",
",",
"replication",
",",
"database",
"=",
"None",
",",
"default",
"=",
"False",
",",
"shard_duration",
"=",
"\"0s\"",
")",
":",
"query_string",
"=",
"\"CREATE RETENTION POLICY {0} ON {1} ... | Create a retention policy for a database.
:param name: the name of the new retention policy
:type name: str
:param duration: the duration of the new retention policy.
Durations such as 1h, 90m, 12h, 7d, and 4w, are all supported
and mean 1 hour, 90 minutes, 12 hours, 7 d... | [
"Create",
"a",
"retention",
"policy",
"for",
"a",
"database",
"."
] | d5d12499f3755199d5eedd8b363450f1cf4073bd | https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L648-L688 |
220,194 | influxdata/influxdb-python | influxdb/client.py | InfluxDBClient.alter_retention_policy | def alter_retention_policy(self, name, database=None,
duration=None, replication=None,
default=None, shard_duration=None):
"""Modify an existing retention policy for a database.
:param name: the name of the retention policy to modify
... | python | def alter_retention_policy(self, name, database=None,
duration=None, replication=None,
default=None, shard_duration=None):
"""Modify an existing retention policy for a database.
:param name: the name of the retention policy to modify
... | [
"def",
"alter_retention_policy",
"(",
"self",
",",
"name",
",",
"database",
"=",
"None",
",",
"duration",
"=",
"None",
",",
"replication",
"=",
"None",
",",
"default",
"=",
"None",
",",
"shard_duration",
"=",
"None",
")",
":",
"query_string",
"=",
"(",
"... | Modify an existing retention policy for a database.
:param name: the name of the retention policy to modify
:type name: str
:param database: the database for which the retention policy is
modified. Defaults to current client's database
:type database: str
:param dura... | [
"Modify",
"an",
"existing",
"retention",
"policy",
"for",
"a",
"database",
"."
] | d5d12499f3755199d5eedd8b363450f1cf4073bd | https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L690-L737 |
220,195 | influxdata/influxdb-python | influxdb/client.py | InfluxDBClient.drop_retention_policy | def drop_retention_policy(self, name, database=None):
"""Drop an existing retention policy for a database.
:param name: the name of the retention policy to drop
:type name: str
:param database: the database for which the retention policy is
dropped. Defaults to current clien... | python | def drop_retention_policy(self, name, database=None):
"""Drop an existing retention policy for a database.
:param name: the name of the retention policy to drop
:type name: str
:param database: the database for which the retention policy is
dropped. Defaults to current clien... | [
"def",
"drop_retention_policy",
"(",
"self",
",",
"name",
",",
"database",
"=",
"None",
")",
":",
"query_string",
"=",
"(",
"\"DROP RETENTION POLICY {0} ON {1}\"",
")",
".",
"format",
"(",
"quote_ident",
"(",
"name",
")",
",",
"quote_ident",
"(",
"database",
"... | Drop an existing retention policy for a database.
:param name: the name of the retention policy to drop
:type name: str
:param database: the database for which the retention policy is
dropped. Defaults to current client's database
:type database: str | [
"Drop",
"an",
"existing",
"retention",
"policy",
"for",
"a",
"database",
"."
] | d5d12499f3755199d5eedd8b363450f1cf4073bd | https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L739-L751 |
220,196 | influxdata/influxdb-python | influxdb/client.py | InfluxDBClient.get_list_retention_policies | def get_list_retention_policies(self, database=None):
"""Get the list of retention policies for a database.
:param database: the name of the database, defaults to the client's
current database
:type database: str
:returns: all retention policies for the database
:rty... | python | def get_list_retention_policies(self, database=None):
"""Get the list of retention policies for a database.
:param database: the name of the database, defaults to the client's
current database
:type database: str
:returns: all retention policies for the database
:rty... | [
"def",
"get_list_retention_policies",
"(",
"self",
",",
"database",
"=",
"None",
")",
":",
"if",
"not",
"(",
"database",
"or",
"self",
".",
"_database",
")",
":",
"raise",
"InfluxDBClientError",
"(",
"\"get_list_retention_policies() requires a database as a \"",
"\"pa... | Get the list of retention policies for a database.
:param database: the name of the database, defaults to the client's
current database
:type database: str
:returns: all retention policies for the database
:rtype: list of dictionaries
:Example:
::
... | [
"Get",
"the",
"list",
"of",
"retention",
"policies",
"for",
"a",
"database",
"."
] | d5d12499f3755199d5eedd8b363450f1cf4073bd | https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L753-L782 |
220,197 | influxdata/influxdb-python | influxdb/client.py | InfluxDBClient.create_user | def create_user(self, username, password, admin=False):
"""Create a new user in InfluxDB.
:param username: the new username to create
:type username: str
:param password: the password for the new user
:type password: str
:param admin: whether the user should have cluster... | python | def create_user(self, username, password, admin=False):
"""Create a new user in InfluxDB.
:param username: the new username to create
:type username: str
:param password: the password for the new user
:type password: str
:param admin: whether the user should have cluster... | [
"def",
"create_user",
"(",
"self",
",",
"username",
",",
"password",
",",
"admin",
"=",
"False",
")",
":",
"text",
"=",
"\"CREATE USER {0} WITH PASSWORD {1}\"",
".",
"format",
"(",
"quote_ident",
"(",
"username",
")",
",",
"quote_literal",
"(",
"password",
")"... | Create a new user in InfluxDB.
:param username: the new username to create
:type username: str
:param password: the password for the new user
:type password: str
:param admin: whether the user should have cluster administration
privileges or not
:type admin: ... | [
"Create",
"a",
"new",
"user",
"in",
"InfluxDB",
"."
] | d5d12499f3755199d5eedd8b363450f1cf4073bd | https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L802-L817 |
220,198 | influxdata/influxdb-python | influxdb/client.py | InfluxDBClient.drop_user | def drop_user(self, username):
"""Drop a user from InfluxDB.
:param username: the username to drop
:type username: str
"""
text = "DROP USER {0}".format(quote_ident(username), method="POST")
self.query(text, method="POST") | python | def drop_user(self, username):
"""Drop a user from InfluxDB.
:param username: the username to drop
:type username: str
"""
text = "DROP USER {0}".format(quote_ident(username), method="POST")
self.query(text, method="POST") | [
"def",
"drop_user",
"(",
"self",
",",
"username",
")",
":",
"text",
"=",
"\"DROP USER {0}\"",
".",
"format",
"(",
"quote_ident",
"(",
"username",
")",
",",
"method",
"=",
"\"POST\"",
")",
"self",
".",
"query",
"(",
"text",
",",
"method",
"=",
"\"POST\"",... | Drop a user from InfluxDB.
:param username: the username to drop
:type username: str | [
"Drop",
"a",
"user",
"from",
"InfluxDB",
"."
] | d5d12499f3755199d5eedd8b363450f1cf4073bd | https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L819-L826 |
220,199 | influxdata/influxdb-python | influxdb/client.py | InfluxDBClient.set_user_password | def set_user_password(self, username, password):
"""Change the password of an existing user.
:param username: the username who's password is being changed
:type username: str
:param password: the new password for the user
:type password: str
"""
text = "SET PASSW... | python | def set_user_password(self, username, password):
"""Change the password of an existing user.
:param username: the username who's password is being changed
:type username: str
:param password: the new password for the user
:type password: str
"""
text = "SET PASSW... | [
"def",
"set_user_password",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"text",
"=",
"\"SET PASSWORD FOR {0} = {1}\"",
".",
"format",
"(",
"quote_ident",
"(",
"username",
")",
",",
"quote_literal",
"(",
"password",
")",
")",
"self",
".",
"query",
... | Change the password of an existing user.
:param username: the username who's password is being changed
:type username: str
:param password: the new password for the user
:type password: str | [
"Change",
"the",
"password",
"of",
"an",
"existing",
"user",
"."
] | d5d12499f3755199d5eedd8b363450f1cf4073bd | https://github.com/influxdata/influxdb-python/blob/d5d12499f3755199d5eedd8b363450f1cf4073bd/influxdb/client.py#L828-L838 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.