partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | JNISimProcedure._load_from_native_memory | Load from native memory.
:param addr: Native load address.
:param data_type: Java type of elements.
If set, all loaded elements are casted to this type.
:param data_size: Size of each element.
If not set, siz... | angr/procedures/java_jni/__init__.py | def _load_from_native_memory(self, addr, data_type=None, data_size=None,
no_of_elements=1, return_as_list=False):
"""
Load from native memory.
:param addr: Native load address.
:param data_type: Java type of elements.
... | def _load_from_native_memory(self, addr, data_type=None, data_size=None,
no_of_elements=1, return_as_list=False):
"""
Load from native memory.
:param addr: Native load address.
:param data_type: Java type of elements.
... | [
"Load",
"from",
"native",
"memory",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/procedures/java_jni/__init__.py#L79-L116 | [
"def",
"_load_from_native_memory",
"(",
"self",
",",
"addr",
",",
"data_type",
"=",
"None",
",",
"data_size",
"=",
"None",
",",
"no_of_elements",
"=",
"1",
",",
"return_as_list",
"=",
"False",
")",
":",
"# check if addr is symbolic",
"if",
"addr",
"is",
"not",... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | JNISimProcedure._load_string_from_native_memory | Load zero terminated UTF-8 string from native memory.
:param addr_: Native load address.
:return: Loaded string. | angr/procedures/java_jni/__init__.py | def _load_string_from_native_memory(self, addr_):
"""
Load zero terminated UTF-8 string from native memory.
:param addr_: Native load address.
:return: Loaded string.
"""
# check if addr is symbolic
if self.state.solver.symbolic(addr_):
l.error("... | def _load_string_from_native_memory(self, addr_):
"""
Load zero terminated UTF-8 string from native memory.
:param addr_: Native load address.
:return: Loaded string.
"""
# check if addr is symbolic
if self.state.solver.symbolic(addr_):
l.error("... | [
"Load",
"zero",
"terminated",
"UTF",
"-",
"8",
"string",
"from",
"native",
"memory",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/procedures/java_jni/__init__.py#L118-L144 | [
"def",
"_load_string_from_native_memory",
"(",
"self",
",",
"addr_",
")",
":",
"# check if addr is symbolic",
"if",
"self",
".",
"state",
".",
"solver",
".",
"symbolic",
"(",
"addr_",
")",
":",
"l",
".",
"error",
"(",
"\"Loading strings from symbolic addresses is no... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | JNISimProcedure._store_string_in_native_memory | Store given string UTF-8 encoded and zero terminated in native memory.
:param str string: String
:param addr: Native store address.
If not set, native memory is allocated.
:return: Native address of the string. | angr/procedures/java_jni/__init__.py | def _store_string_in_native_memory(self, string, addr=None):
"""
Store given string UTF-8 encoded and zero terminated in native memory.
:param str string: String
:param addr: Native store address.
If not set, native memory is allocated.
:retur... | def _store_string_in_native_memory(self, string, addr=None):
"""
Store given string UTF-8 encoded and zero terminated in native memory.
:param str string: String
:param addr: Native store address.
If not set, native memory is allocated.
:retur... | [
"Store",
"given",
"string",
"UTF",
"-",
"8",
"encoded",
"and",
"zero",
"terminated",
"in",
"native",
"memory",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/procedures/java_jni/__init__.py#L146-L178 | [
"def",
"_store_string_in_native_memory",
"(",
"self",
",",
"string",
",",
"addr",
"=",
"None",
")",
":",
"if",
"addr",
"is",
"None",
":",
"addr",
"=",
"self",
".",
"_allocate_native_memory",
"(",
"size",
"=",
"len",
"(",
"string",
")",
"+",
"1",
")",
"... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | JNISimProcedure._normalize_array_idx | In Java, all array indices are represented by a 32 bit integer and
consequently we are using in the Soot engine a 32bit bitvector for this.
This function normalize the given index to follow this "convention".
:return: Index as a 32bit bitvector. | angr/procedures/java_jni/__init__.py | def _normalize_array_idx(self, idx):
"""
In Java, all array indices are represented by a 32 bit integer and
consequently we are using in the Soot engine a 32bit bitvector for this.
This function normalize the given index to follow this "convention".
:return: Index as a 32bit bit... | def _normalize_array_idx(self, idx):
"""
In Java, all array indices are represented by a 32 bit integer and
consequently we are using in the Soot engine a 32bit bitvector for this.
This function normalize the given index to follow this "convention".
:return: Index as a 32bit bit... | [
"In",
"Java",
"all",
"array",
"indices",
"are",
"represented",
"by",
"a",
"32",
"bit",
"integer",
"and",
"consequently",
"we",
"are",
"using",
"in",
"the",
"Soot",
"engine",
"a",
"32bit",
"bitvector",
"for",
"this",
".",
"This",
"function",
"normalize",
"t... | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/procedures/java_jni/__init__.py#L184-L197 | [
"def",
"_normalize_array_idx",
"(",
"self",
",",
"idx",
")",
":",
"if",
"isinstance",
"(",
"idx",
",",
"SimActionObject",
")",
":",
"idx",
"=",
"idx",
".",
"to_claripy",
"(",
")",
"if",
"self",
".",
"arch",
".",
"memory_endness",
"==",
"\"Iend_LE\"",
":"... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | HookSet.install_hooks | Given the target `target`, apply the hooks given as keyword arguments to it.
If any targeted method has already been hooked, the hooks will not be overridden but will instead be pushed
into a list of pending hooks. The final behavior should be that all hooks call each other in a nested stack.
:... | angr/misc/hookset.py | def install_hooks(target, **hooks):
"""
Given the target `target`, apply the hooks given as keyword arguments to it.
If any targeted method has already been hooked, the hooks will not be overridden but will instead be pushed
into a list of pending hooks. The final behavior should be that... | def install_hooks(target, **hooks):
"""
Given the target `target`, apply the hooks given as keyword arguments to it.
If any targeted method has already been hooked, the hooks will not be overridden but will instead be pushed
into a list of pending hooks. The final behavior should be that... | [
"Given",
"the",
"target",
"target",
"apply",
"the",
"hooks",
"given",
"as",
"keyword",
"arguments",
"to",
"it",
".",
"If",
"any",
"targeted",
"method",
"has",
"already",
"been",
"hooked",
"the",
"hooks",
"will",
"not",
"be",
"overridden",
"but",
"will",
"i... | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/misc/hookset.py#L11-L26 | [
"def",
"install_hooks",
"(",
"target",
",",
"*",
"*",
"hooks",
")",
":",
"for",
"name",
",",
"hook",
"in",
"hooks",
".",
"items",
"(",
")",
":",
"func",
"=",
"getattr",
"(",
"target",
",",
"name",
")",
"if",
"not",
"isinstance",
"(",
"func",
",",
... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | HookSet.remove_hooks | Remove the given hooks from the given target.
:param target: The object from which to remove hooks. If all hooks are removed from a given method, the
HookedMethod object will be removed and replaced with the original function.
:param hooks: Any keywords will be interpreted as... | angr/misc/hookset.py | def remove_hooks(target, **hooks):
"""
Remove the given hooks from the given target.
:param target: The object from which to remove hooks. If all hooks are removed from a given method, the
HookedMethod object will be removed and replaced with the original function.
... | def remove_hooks(target, **hooks):
"""
Remove the given hooks from the given target.
:param target: The object from which to remove hooks. If all hooks are removed from a given method, the
HookedMethod object will be removed and replaced with the original function.
... | [
"Remove",
"the",
"given",
"hooks",
"from",
"the",
"given",
"target",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/misc/hookset.py#L29-L46 | [
"def",
"remove_hooks",
"(",
"target",
",",
"*",
"*",
"hooks",
")",
":",
"for",
"name",
",",
"hook",
"in",
"hooks",
".",
"items",
"(",
")",
":",
"hooked",
"=",
"getattr",
"(",
"target",
",",
"name",
")",
"if",
"hook",
"in",
"hooked",
".",
"pending",... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | GraphVisitor.reset | Reset the internal node traversal state. Must be called prior to visiting future nodes.
:return: None | angr/analyses/forward_analysis.py | def reset(self):
"""
Reset the internal node traversal state. Must be called prior to visiting future nodes.
:return: None
"""
self._sorted_nodes.clear()
self._node_to_index.clear()
self._reached_fixedpoint.clear()
for i, n in enumerate(self.sort_nodes(... | def reset(self):
"""
Reset the internal node traversal state. Must be called prior to visiting future nodes.
:return: None
"""
self._sorted_nodes.clear()
self._node_to_index.clear()
self._reached_fixedpoint.clear()
for i, n in enumerate(self.sort_nodes(... | [
"Reset",
"the",
"internal",
"node",
"traversal",
"state",
".",
"Must",
"be",
"called",
"prior",
"to",
"visiting",
"future",
"nodes",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/forward_analysis.py#L102-L115 | [
"def",
"reset",
"(",
"self",
")",
":",
"self",
".",
"_sorted_nodes",
".",
"clear",
"(",
")",
"self",
".",
"_node_to_index",
".",
"clear",
"(",
")",
"self",
".",
"_reached_fixedpoint",
".",
"clear",
"(",
")",
"for",
"i",
",",
"n",
"in",
"enumerate",
"... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | GraphVisitor.all_successors | Returns all successors to the specific node.
:param node: A node in the graph.
:return: A set of nodes that are all successors to the given node.
:rtype: set | angr/analyses/forward_analysis.py | def all_successors(self, node, skip_reached_fixedpoint=False):
"""
Returns all successors to the specific node.
:param node: A node in the graph.
:return: A set of nodes that are all successors to the given node.
:rtype: set
"""
successors = set()
... | def all_successors(self, node, skip_reached_fixedpoint=False):
"""
Returns all successors to the specific node.
:param node: A node in the graph.
:return: A set of nodes that are all successors to the given node.
:rtype: set
"""
successors = set()
... | [
"Returns",
"all",
"successors",
"to",
"the",
"specific",
"node",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/forward_analysis.py#L129-L149 | [
"def",
"all_successors",
"(",
"self",
",",
"node",
",",
"skip_reached_fixedpoint",
"=",
"False",
")",
":",
"successors",
"=",
"set",
"(",
")",
"stack",
"=",
"[",
"node",
"]",
"while",
"stack",
":",
"n",
"=",
"stack",
".",
"pop",
"(",
")",
"successors",... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | GraphVisitor.revisit | Revisit a node in the future. As a result, the successors to this node will be revisited as well.
:param node: The node to revisit in the future.
:return: None | angr/analyses/forward_analysis.py | def revisit(self, node, include_self=True):
"""
Revisit a node in the future. As a result, the successors to this node will be revisited as well.
:param node: The node to revisit in the future.
:return: None
"""
successors = self.successors(node) #, skip_reached_fix... | def revisit(self, node, include_self=True):
"""
Revisit a node in the future. As a result, the successors to this node will be revisited as well.
:param node: The node to revisit in the future.
:return: None
"""
successors = self.successors(node) #, skip_reached_fix... | [
"Revisit",
"a",
"node",
"in",
"the",
"future",
".",
"As",
"a",
"result",
"the",
"successors",
"to",
"this",
"node",
"will",
"be",
"revisited",
"as",
"well",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/forward_analysis.py#L151-L168 | [
"def",
"revisit",
"(",
"self",
",",
"node",
",",
"include_self",
"=",
"True",
")",
":",
"successors",
"=",
"self",
".",
"successors",
"(",
"node",
")",
"#, skip_reached_fixedpoint=True)",
"if",
"include_self",
":",
"self",
".",
"_sorted_nodes",
".",
"add",
"... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | JobInfo.add_job | Appended a new job to this JobInfo node.
:param job: The new job to append.
:param bool merged: Whether it is a merged job or not.
:param bool widened: Whether it is a widened job or not. | angr/analyses/forward_analysis.py | def add_job(self, job, merged=False, widened=False):
"""
Appended a new job to this JobInfo node.
:param job: The new job to append.
:param bool merged: Whether it is a merged job or not.
:param bool widened: Whether it is a widened job or not.
"""
job_type = ''
... | def add_job(self, job, merged=False, widened=False):
"""
Appended a new job to this JobInfo node.
:param job: The new job to append.
:param bool merged: Whether it is a merged job or not.
:param bool widened: Whether it is a widened job or not.
"""
job_type = ''
... | [
"Appended",
"a",
"new",
"job",
"to",
"this",
"JobInfo",
"node",
".",
":",
"param",
"job",
":",
"The",
"new",
"job",
"to",
"append",
".",
":",
"param",
"bool",
"merged",
":",
"Whether",
"it",
"is",
"a",
"merged",
"job",
"or",
"not",
".",
":",
"param... | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/forward_analysis.py#L370-L383 | [
"def",
"add_job",
"(",
"self",
",",
"job",
",",
"merged",
"=",
"False",
",",
"widened",
"=",
"False",
")",
":",
"job_type",
"=",
"''",
"if",
"merged",
":",
"job_type",
"=",
"'merged'",
"elif",
"widened",
":",
"job_type",
"=",
"'widened'",
"self",
".",
... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | ForwardAnalysis.has_job | Checks whether there exists another job which has the same job key.
:param job: The job to check.
:return: True if there exists another job with the same key, False otherwise. | angr/analyses/forward_analysis.py | def has_job(self, job):
"""
Checks whether there exists another job which has the same job key.
:param job: The job to check.
:return: True if there exists another job with the same key, False otherwise.
"""
job_key = self._job_key(job)
return job_key in self.... | def has_job(self, job):
"""
Checks whether there exists another job which has the same job key.
:param job: The job to check.
:return: True if there exists another job with the same key, False otherwise.
"""
job_key = self._job_key(job)
return job_key in self.... | [
"Checks",
"whether",
"there",
"exists",
"another",
"job",
"which",
"has",
"the",
"same",
"job",
"key",
".",
":",
"param",
"job",
":",
"The",
"job",
"to",
"check",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/forward_analysis.py#L480-L488 | [
"def",
"has_job",
"(",
"self",
",",
"job",
")",
":",
"job_key",
"=",
"self",
".",
"_job_key",
"(",
"job",
")",
"return",
"job_key",
"in",
"self",
".",
"_job_map"
] | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | ForwardAnalysis._analyze | The main analysis routine.
:return: None | angr/analyses/forward_analysis.py | def _analyze(self):
"""
The main analysis routine.
:return: None
"""
self._pre_analysis()
if self._graph_visitor is None:
# There is no base graph that we can rely on. The analysis itself should generate successors for the
# current job.
... | def _analyze(self):
"""
The main analysis routine.
:return: None
"""
self._pre_analysis()
if self._graph_visitor is None:
# There is no base graph that we can rely on. The analysis itself should generate successors for the
# current job.
... | [
"The",
"main",
"analysis",
"routine",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/forward_analysis.py#L569-L590 | [
"def",
"_analyze",
"(",
"self",
")",
":",
"self",
".",
"_pre_analysis",
"(",
")",
"if",
"self",
".",
"_graph_visitor",
"is",
"None",
":",
"# There is no base graph that we can rely on. The analysis itself should generate successors for the",
"# current job.",
"# An example is... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | ForwardAnalysis._add_input_state | Add the input state to all successors of the given node.
:param node: The node whose successors' input states will be touched.
:param input_state: The state that will be added to successors of the node.
:return: None | angr/analyses/forward_analysis.py | def _add_input_state(self, node, input_state):
"""
Add the input state to all successors of the given node.
:param node: The node whose successors' input states will be touched.
:param input_state: The state that will be added to successors of the node.
:return: ... | def _add_input_state(self, node, input_state):
"""
Add the input state to all successors of the given node.
:param node: The node whose successors' input states will be touched.
:param input_state: The state that will be added to successors of the node.
:return: ... | [
"Add",
"the",
"input",
"state",
"to",
"all",
"successors",
"of",
"the",
"given",
"node",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/forward_analysis.py#L623-L638 | [
"def",
"_add_input_state",
"(",
"self",
",",
"node",
",",
"input_state",
")",
":",
"successors",
"=",
"self",
".",
"_graph_visitor",
".",
"successors",
"(",
"node",
")",
"for",
"succ",
"in",
"successors",
":",
"if",
"succ",
"in",
"self",
".",
"_state_map",... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | ForwardAnalysis._pop_input_state | Get the input abstract state for this node, and remove it from the state map.
:param node: The node in graph.
:return: A merged state, or None if there is no input state for this node available. | angr/analyses/forward_analysis.py | def _pop_input_state(self, node):
"""
Get the input abstract state for this node, and remove it from the state map.
:param node: The node in graph.
:return: A merged state, or None if there is no input state for this node available.
"""
if node in self._state_map:
... | def _pop_input_state(self, node):
"""
Get the input abstract state for this node, and remove it from the state map.
:param node: The node in graph.
:return: A merged state, or None if there is no input state for this node available.
"""
if node in self._state_map:
... | [
"Get",
"the",
"input",
"abstract",
"state",
"for",
"this",
"node",
"and",
"remove",
"it",
"from",
"the",
"state",
"map",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/forward_analysis.py#L640-L650 | [
"def",
"_pop_input_state",
"(",
"self",
",",
"node",
")",
":",
"if",
"node",
"in",
"self",
".",
"_state_map",
":",
"return",
"self",
".",
"_state_map",
".",
"pop",
"(",
"node",
")",
"return",
"None"
] | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | ForwardAnalysis._merge_state_from_predecessors | Get abstract states for all predecessors of the node, merge them, and return the merged state.
:param node: The node in graph.
:return: A merged state, or None if no predecessor is available. | angr/analyses/forward_analysis.py | def _merge_state_from_predecessors(self, node):
"""
Get abstract states for all predecessors of the node, merge them, and return the merged state.
:param node: The node in graph.
:return: A merged state, or None if no predecessor is available.
"""
preds = self._grap... | def _merge_state_from_predecessors(self, node):
"""
Get abstract states for all predecessors of the node, merge them, and return the merged state.
:param node: The node in graph.
:return: A merged state, or None if no predecessor is available.
"""
preds = self._grap... | [
"Get",
"abstract",
"states",
"for",
"all",
"predecessors",
"of",
"the",
"node",
"merge",
"them",
"and",
"return",
"the",
"merged",
"state",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/forward_analysis.py#L652-L667 | [
"def",
"_merge_state_from_predecessors",
"(",
"self",
",",
"node",
")",
":",
"preds",
"=",
"self",
".",
"_graph_visitor",
".",
"predecessors",
"(",
"node",
")",
"states",
"=",
"[",
"self",
".",
"_state_map",
"[",
"n",
"]",
"for",
"n",
"in",
"preds",
"if"... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | ForwardAnalysis._process_job_and_get_successors | Process a job, get all successors of this job, and call _handle_successor() to handle each successor.
:param JobInfo job_info: The JobInfo instance
:return: None | angr/analyses/forward_analysis.py | def _process_job_and_get_successors(self, job_info):
"""
Process a job, get all successors of this job, and call _handle_successor() to handle each successor.
:param JobInfo job_info: The JobInfo instance
:return: None
"""
job = job_info.job
successors = self._... | def _process_job_and_get_successors(self, job_info):
"""
Process a job, get all successors of this job, and call _handle_successor() to handle each successor.
:param JobInfo job_info: The JobInfo instance
:return: None
"""
job = job_info.job
successors = self._... | [
"Process",
"a",
"job",
"get",
"all",
"successors",
"of",
"this",
"job",
"and",
"call",
"_handle_successor",
"()",
"to",
"handle",
"each",
"successor",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/forward_analysis.py#L716-L739 | [
"def",
"_process_job_and_get_successors",
"(",
"self",
",",
"job_info",
")",
":",
"job",
"=",
"job_info",
".",
"job",
"successors",
"=",
"self",
".",
"_get_successors",
"(",
"job",
")",
"all_new_jobs",
"=",
"[",
"]",
"for",
"successor",
"in",
"successors",
"... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | ForwardAnalysis._insert_job | Insert a new job into the job queue. If the job queue is ordered, this job will be inserted at the correct
position.
:param job: The job to insert
:return: None | angr/analyses/forward_analysis.py | def _insert_job(self, job):
"""
Insert a new job into the job queue. If the job queue is ordered, this job will be inserted at the correct
position.
:param job: The job to insert
:return: None
"""
key = self._job_key(job)
if self._allow_merging:
... | def _insert_job(self, job):
"""
Insert a new job into the job queue. If the job queue is ordered, this job will be inserted at the correct
position.
:param job: The job to insert
:return: None
"""
key = self._job_key(job)
if self._allow_merging:
... | [
"Insert",
"a",
"new",
"job",
"into",
"the",
"job",
"queue",
".",
"If",
"the",
"job",
"queue",
"is",
"ordered",
"this",
"job",
"will",
"be",
"inserted",
"at",
"the",
"correct",
"position",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/forward_analysis.py#L741-L798 | [
"def",
"_insert_job",
"(",
"self",
",",
"job",
")",
":",
"key",
"=",
"self",
".",
"_job_key",
"(",
"job",
")",
"if",
"self",
".",
"_allow_merging",
":",
"if",
"key",
"in",
"self",
".",
"_job_map",
":",
"job_info",
"=",
"self",
".",
"_job_map",
"[",
... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | ForwardAnalysis._peek_job | Return the job currently at position `pos`, but still keep it in the job queue. An IndexError will be raised
if that position does not currently exist in the job list.
:param int pos: Position of the job to get.
:return: The job | angr/analyses/forward_analysis.py | def _peek_job(self, pos):
"""
Return the job currently at position `pos`, but still keep it in the job queue. An IndexError will be raised
if that position does not currently exist in the job list.
:param int pos: Position of the job to get.
:return: The job
"""
... | def _peek_job(self, pos):
"""
Return the job currently at position `pos`, but still keep it in the job queue. An IndexError will be raised
if that position does not currently exist in the job list.
:param int pos: Position of the job to get.
:return: The job
"""
... | [
"Return",
"the",
"job",
"currently",
"at",
"position",
"pos",
"but",
"still",
"keep",
"it",
"in",
"the",
"job",
"queue",
".",
"An",
"IndexError",
"will",
"be",
"raised",
"if",
"that",
"position",
"does",
"not",
"currently",
"exist",
"in",
"the",
"job",
"... | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/forward_analysis.py#L800-L812 | [
"def",
"_peek_job",
"(",
"self",
",",
"pos",
")",
":",
"if",
"pos",
"<",
"len",
"(",
"self",
".",
"_job_info_queue",
")",
":",
"return",
"self",
".",
"_job_info_queue",
"[",
"pos",
"]",
".",
"job",
"raise",
"IndexError",
"(",
")"
] | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | ForwardAnalysis._binary_insert | Insert an element into a sorted list, and keep the list sorted.
The major difference from bisect.bisect_left is that this function supports a key method, so user doesn't have
to create the key array for each insertion.
:param list lst: The list. Must be pre-ordered.
:param object eleme... | angr/analyses/forward_analysis.py | def _binary_insert(lst, elem, key, lo=0, hi=None):
"""
Insert an element into a sorted list, and keep the list sorted.
The major difference from bisect.bisect_left is that this function supports a key method, so user doesn't have
to create the key array for each insertion.
:par... | def _binary_insert(lst, elem, key, lo=0, hi=None):
"""
Insert an element into a sorted list, and keep the list sorted.
The major difference from bisect.bisect_left is that this function supports a key method, so user doesn't have
to create the key array for each insertion.
:par... | [
"Insert",
"an",
"element",
"into",
"a",
"sorted",
"list",
"and",
"keep",
"the",
"list",
"sorted",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/analyses/forward_analysis.py#L819-L847 | [
"def",
"_binary_insert",
"(",
"lst",
",",
"elem",
",",
"key",
",",
"lo",
"=",
"0",
",",
"hi",
"=",
"None",
")",
":",
"if",
"lo",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"\"lo must be a non-negative number\"",
")",
"if",
"hi",
"is",
"None",
":",
"h... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | SimSymbolicMemory.merge | Merge this SimMemory with the other SimMemory | angr/state_plugins/symbolic_memory.py | def merge(self, others, merge_conditions, common_ancestor=None): # pylint: disable=unused-argument
"""
Merge this SimMemory with the other SimMemory
"""
changed_bytes = self._changes_to_merge(others)
l.info("Merging %d bytes", len(changed_bytes))
l.info("... %s has chan... | def merge(self, others, merge_conditions, common_ancestor=None): # pylint: disable=unused-argument
"""
Merge this SimMemory with the other SimMemory
"""
changed_bytes = self._changes_to_merge(others)
l.info("Merging %d bytes", len(changed_bytes))
l.info("... %s has chan... | [
"Merge",
"this",
"SimMemory",
"with",
"the",
"other",
"SimMemory"
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/symbolic_memory.py#L96-L114 | [
"def",
"merge",
"(",
"self",
",",
"others",
",",
"merge_conditions",
",",
"common_ancestor",
"=",
"None",
")",
":",
"# pylint: disable=unused-argument",
"changed_bytes",
"=",
"self",
".",
"_changes_to_merge",
"(",
"others",
")",
"l",
".",
"info",
"(",
"\"Merging... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | SimSymbolicMemory.make_symbolic | Replaces `length` bytes starting at `addr` with a symbolic variable named name. Adds a constraint equaling that
symbolic variable to the value previously at `addr`, and returns the variable. | angr/state_plugins/symbolic_memory.py | def make_symbolic(self, name, addr, length=None):
"""
Replaces `length` bytes starting at `addr` with a symbolic variable named name. Adds a constraint equaling that
symbolic variable to the value previously at `addr`, and returns the variable.
"""
l.debug("making %s bytes symbol... | def make_symbolic(self, name, addr, length=None):
"""
Replaces `length` bytes starting at `addr` with a symbolic variable named name. Adds a constraint equaling that
symbolic variable to the value previously at `addr`, and returns the variable.
"""
l.debug("making %s bytes symbol... | [
"Replaces",
"length",
"bytes",
"starting",
"at",
"addr",
"with",
"a",
"symbolic",
"variable",
"named",
"name",
".",
"Adds",
"a",
"constraint",
"equaling",
"that",
"symbolic",
"variable",
"to",
"the",
"value",
"previously",
"at",
"addr",
"and",
"returns",
"the"... | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/symbolic_memory.py#L297-L316 | [
"def",
"make_symbolic",
"(",
"self",
",",
"name",
",",
"addr",
",",
"length",
"=",
"None",
")",
":",
"l",
".",
"debug",
"(",
"\"making %s bytes symbolic\"",
",",
"length",
")",
"if",
"isinstance",
"(",
"addr",
",",
"str",
")",
":",
"addr",
",",
"length... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | SimSymbolicMemory._apply_concretization_strategies | Applies concretization strategies on the address until one of them succeeds. | angr/state_plugins/symbolic_memory.py | def _apply_concretization_strategies(self, addr, strategies, action):
"""
Applies concretization strategies on the address until one of them succeeds.
"""
# we try all the strategies in order
for s in strategies:
# first, we trigger the SimInspect breakpoint and give... | def _apply_concretization_strategies(self, addr, strategies, action):
"""
Applies concretization strategies on the address until one of them succeeds.
"""
# we try all the strategies in order
for s in strategies:
# first, we trigger the SimInspect breakpoint and give... | [
"Applies",
"concretization",
"strategies",
"on",
"the",
"address",
"until",
"one",
"of",
"them",
"succeeds",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/symbolic_memory.py#L352-L393 | [
"def",
"_apply_concretization_strategies",
"(",
"self",
",",
"addr",
",",
"strategies",
",",
"action",
")",
":",
"# we try all the strategies in order",
"for",
"s",
"in",
"strategies",
":",
"# first, we trigger the SimInspect breakpoint and give it a chance to intervene",
"e",
... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | SimSymbolicMemory.concretize_write_addr | Concretizes an address meant for writing.
:param addr: An expression for the address.
:param strategies: A list of concretization strategies (to override the default).
:returns: A list of concrete addresses. | angr/state_plugins/symbolic_memory.py | def concretize_write_addr(self, addr, strategies=None):
"""
Concretizes an address meant for writing.
:param addr: An expression for the address.
:param strategies: A list of concretization strategies (to override the default).
:returns: ... | def concretize_write_addr(self, addr, strategies=None):
"""
Concretizes an address meant for writing.
:param addr: An expression for the address.
:param strategies: A list of concretization strategies (to override the default).
:returns: ... | [
"Concretizes",
"an",
"address",
"meant",
"for",
"writing",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/symbolic_memory.py#L395-L410 | [
"def",
"concretize_write_addr",
"(",
"self",
",",
"addr",
",",
"strategies",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"addr",
",",
"int",
")",
":",
"return",
"[",
"addr",
"]",
"elif",
"not",
"self",
".",
"state",
".",
"solver",
".",
"symbolic",
... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | SimSymbolicMemory.concretize_read_addr | Concretizes an address meant for reading.
:param addr: An expression for the address.
:param strategies: A list of concretization strategies (to override the default).
:returns: A list of concrete addresses. | angr/state_plugins/symbolic_memory.py | def concretize_read_addr(self, addr, strategies=None):
"""
Concretizes an address meant for reading.
:param addr: An expression for the address.
:param strategies: A list of concretization strategies (to override the default).
:returns: ... | def concretize_read_addr(self, addr, strategies=None):
"""
Concretizes an address meant for reading.
:param addr: An expression for the address.
:param strategies: A list of concretization strategies (to override the default).
:returns: ... | [
"Concretizes",
"an",
"address",
"meant",
"for",
"reading",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/symbolic_memory.py#L412-L427 | [
"def",
"concretize_read_addr",
"(",
"self",
",",
"addr",
",",
"strategies",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"addr",
",",
"int",
")",
":",
"return",
"[",
"addr",
"]",
"elif",
"not",
"self",
".",
"state",
".",
"solver",
".",
"symbolic",
... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | SimSymbolicMemory.dbg_print | Print out debugging information. | angr/state_plugins/symbolic_memory.py | def dbg_print(self, indent=0):
"""
Print out debugging information.
"""
lst = []
more_data = False
for i, addr in enumerate(self.mem.keys()):
lst.append(addr)
if i >= 20:
more_data = True
break
for addr in s... | def dbg_print(self, indent=0):
"""
Print out debugging information.
"""
lst = []
more_data = False
for i, addr in enumerate(self.mem.keys()):
lst.append(addr)
if i >= 20:
more_data = True
break
for addr in s... | [
"Print",
"out",
"debugging",
"information",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/symbolic_memory.py#L1134-L1154 | [
"def",
"dbg_print",
"(",
"self",
",",
"indent",
"=",
"0",
")",
":",
"lst",
"=",
"[",
"]",
"more_data",
"=",
"False",
"for",
"i",
",",
"addr",
"in",
"enumerate",
"(",
"self",
".",
"mem",
".",
"keys",
"(",
")",
")",
":",
"lst",
".",
"append",
"("... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | SimSymbolicMemory.permissions | Retrieve the permissions of the page at address `addr`.
:param addr: address to get the page permissions
:param permissions: Integer or BVV to optionally set page permissions to
:return: AST representing the permissions on the page | angr/state_plugins/symbolic_memory.py | def permissions(self, addr, permissions=None):
"""
Retrieve the permissions of the page at address `addr`.
:param addr: address to get the page permissions
:param permissions: Integer or BVV to optionally set page permissions to
:return: AST representing the pe... | def permissions(self, addr, permissions=None):
"""
Retrieve the permissions of the page at address `addr`.
:param addr: address to get the page permissions
:param permissions: Integer or BVV to optionally set page permissions to
:return: AST representing the pe... | [
"Retrieve",
"the",
"permissions",
"of",
"the",
"page",
"at",
"address",
"addr",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/symbolic_memory.py#L1234-L1247 | [
"def",
"permissions",
"(",
"self",
",",
"addr",
",",
"permissions",
"=",
"None",
")",
":",
"out",
"=",
"self",
".",
"mem",
".",
"permissions",
"(",
"addr",
",",
"permissions",
")",
"# if unicorn is in play and we've marked a page writable, it must be uncached",
"if"... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | SimSymbolicMemory.map_region | Map a number of pages at address `addr` with permissions `permissions`.
:param addr: address to map the pages at
:param length: length in bytes of region to map, will be rounded upwards to the page size
:param permissions: AST of permissions to map, will be a bitvalue representing flags
... | angr/state_plugins/symbolic_memory.py | def map_region(self, addr, length, permissions, init_zero=False):
"""
Map a number of pages at address `addr` with permissions `permissions`.
:param addr: address to map the pages at
:param length: length in bytes of region to map, will be rounded upwards to the page size
:param ... | def map_region(self, addr, length, permissions, init_zero=False):
"""
Map a number of pages at address `addr` with permissions `permissions`.
:param addr: address to map the pages at
:param length: length in bytes of region to map, will be rounded upwards to the page size
:param ... | [
"Map",
"a",
"number",
"of",
"pages",
"at",
"address",
"addr",
"with",
"permissions",
"permissions",
".",
":",
"param",
"addr",
":",
"address",
"to",
"map",
"the",
"pages",
"at",
":",
"param",
"length",
":",
"length",
"in",
"bytes",
"of",
"region",
"to",
... | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/symbolic_memory.py#L1249-L1258 | [
"def",
"map_region",
"(",
"self",
",",
"addr",
",",
"length",
",",
"permissions",
",",
"init_zero",
"=",
"False",
")",
":",
"l",
".",
"info",
"(",
"\"Mapping [%#x, %#x] as %s\"",
",",
"addr",
",",
"addr",
"+",
"length",
"-",
"1",
",",
"permissions",
")",... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | AngrObjectFactory.successors | Perform execution using any applicable engine. Enumerate the current engines and use the
first one that works. Return a SimSuccessors object classifying the results of the run.
:param state: The state to analyze
:param addr: optional, an address to execute at instead of the... | angr/factory.py | def successors(self, *args, **kwargs):
"""
Perform execution using any applicable engine. Enumerate the current engines and use the
first one that works. Return a SimSuccessors object classifying the results of the run.
:param state: The state to analyze
:param addr: ... | def successors(self, *args, **kwargs):
"""
Perform execution using any applicable engine. Enumerate the current engines and use the
first one that works. Return a SimSuccessors object classifying the results of the run.
:param state: The state to analyze
:param addr: ... | [
"Perform",
"execution",
"using",
"any",
"applicable",
"engine",
".",
"Enumerate",
"the",
"current",
"engines",
"and",
"use",
"the",
"first",
"one",
"that",
"works",
".",
"Return",
"a",
"SimSuccessors",
"object",
"classifying",
"the",
"results",
"of",
"the",
"r... | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/factory.py#L41-L54 | [
"def",
"successors",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"project",
".",
"engines",
".",
"successors",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | AngrObjectFactory.call_state | Returns a state object initialized to the start of a given function, as if it were called with given parameters.
:param addr: The address the state should start at instead of the entry point.
:param args: Any additional positional arguments will be used as arguments to the functio... | angr/factory.py | def call_state(self, addr, *args, **kwargs):
"""
Returns a state object initialized to the start of a given function, as if it were called with given parameters.
:param addr: The address the state should start at instead of the entry point.
:param args: Any additio... | def call_state(self, addr, *args, **kwargs):
"""
Returns a state object initialized to the start of a given function, as if it were called with given parameters.
:param addr: The address the state should start at instead of the entry point.
:param args: Any additio... | [
"Returns",
"a",
"state",
"object",
"initialized",
"to",
"the",
"start",
"of",
"a",
"given",
"function",
"as",
"if",
"it",
"were",
"called",
"with",
"given",
"parameters",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/factory.py#L118-L160 | [
"def",
"call_state",
"(",
"self",
",",
"addr",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"project",
".",
"simos",
".",
"state_call",
"(",
"addr",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | AngrObjectFactory.simulation_manager | Constructs a new simulation manager.
:param thing: Optional - What to put in the new SimulationManager's active stash (either a SimState or a list of SimStates).
:param kwargs: Any additional keyword arguments will be passed to the SimulationManager constructor
:returns: ... | angr/factory.py | def simulation_manager(self, thing=None, **kwargs):
"""
Constructs a new simulation manager.
:param thing: Optional - What to put in the new SimulationManager's active stash (either a SimState or a list of SimStates).
:param kwargs: Any additional keyword arguments wi... | def simulation_manager(self, thing=None, **kwargs):
"""
Constructs a new simulation manager.
:param thing: Optional - What to put in the new SimulationManager's active stash (either a SimState or a list of SimStates).
:param kwargs: Any additional keyword arguments wi... | [
"Constructs",
"a",
"new",
"simulation",
"manager",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/factory.py#L162-L188 | [
"def",
"simulation_manager",
"(",
"self",
",",
"thing",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"thing",
"is",
"None",
":",
"thing",
"=",
"[",
"self",
".",
"entry_state",
"(",
")",
"]",
"elif",
"isinstance",
"(",
"thing",
",",
"(",
"l... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | AngrObjectFactory.callable | A Callable is a representation of a function in the binary that can be interacted with like a native python
function.
:param addr: The address of the function to use
:param concrete_only: Throw an exception if the execution splits into multiple states
:param perform_merge: ... | angr/factory.py | def callable(self, addr, concrete_only=False, perform_merge=True, base_state=None, toc=None, cc=None):
"""
A Callable is a representation of a function in the binary that can be interacted with like a native python
function.
:param addr: The address of the function to use
... | def callable(self, addr, concrete_only=False, perform_merge=True, base_state=None, toc=None, cc=None):
"""
A Callable is a representation of a function in the binary that can be interacted with like a native python
function.
:param addr: The address of the function to use
... | [
"A",
"Callable",
"is",
"a",
"representation",
"of",
"a",
"function",
"in",
"the",
"binary",
"that",
"can",
"be",
"interacted",
"with",
"like",
"a",
"native",
"python",
"function",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/factory.py#L196-L217 | [
"def",
"callable",
"(",
"self",
",",
"addr",
",",
"concrete_only",
"=",
"False",
",",
"perform_merge",
"=",
"True",
",",
"base_state",
"=",
"None",
",",
"toc",
"=",
"None",
",",
"cc",
"=",
"None",
")",
":",
"return",
"Callable",
"(",
"self",
".",
"pr... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | AngrObjectFactory.cc | Return a SimCC (calling convention) parametrized for this project and, optionally, a given function.
:param args: A list of argument storage locations, as SimFunctionArguments.
:param ret_val: The return value storage location, as a SimFunctionArgument.
:param sp_delta: Does this ... | angr/factory.py | def cc(self, args=None, ret_val=None, sp_delta=None, func_ty=None):
"""
Return a SimCC (calling convention) parametrized for this project and, optionally, a given function.
:param args: A list of argument storage locations, as SimFunctionArguments.
:param ret_val: The return ... | def cc(self, args=None, ret_val=None, sp_delta=None, func_ty=None):
"""
Return a SimCC (calling convention) parametrized for this project and, optionally, a given function.
:param args: A list of argument storage locations, as SimFunctionArguments.
:param ret_val: The return ... | [
"Return",
"a",
"SimCC",
"(",
"calling",
"convention",
")",
"parametrized",
"for",
"this",
"project",
"and",
"optionally",
"a",
"given",
"function",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/factory.py#L219-L244 | [
"def",
"cc",
"(",
"self",
",",
"args",
"=",
"None",
",",
"ret_val",
"=",
"None",
",",
"sp_delta",
"=",
"None",
",",
"func_ty",
"=",
"None",
")",
":",
"return",
"self",
".",
"_default_cc",
"(",
"arch",
"=",
"self",
".",
"project",
".",
"arch",
",",
... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | AngrObjectFactory.cc_from_arg_kinds | Get a SimCC (calling convention) that will extract floating-point/integral args correctly.
:param arch: The Archinfo arch for this CC
:param fp_args: A list, with one entry for each argument the function can take. True if the argument is fp,
false if it is integra... | angr/factory.py | def cc_from_arg_kinds(self, fp_args, ret_fp=None, sizes=None, sp_delta=None, func_ty=None):
"""
Get a SimCC (calling convention) that will extract floating-point/integral args correctly.
:param arch: The Archinfo arch for this CC
:param fp_args: A list, with one entry for eac... | def cc_from_arg_kinds(self, fp_args, ret_fp=None, sizes=None, sp_delta=None, func_ty=None):
"""
Get a SimCC (calling convention) that will extract floating-point/integral args correctly.
:param arch: The Archinfo arch for this CC
:param fp_args: A list, with one entry for eac... | [
"Get",
"a",
"SimCC",
"(",
"calling",
"convention",
")",
"that",
"will",
"extract",
"floating",
"-",
"point",
"/",
"integral",
"args",
"correctly",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/factory.py#L246-L271 | [
"def",
"cc_from_arg_kinds",
"(",
"self",
",",
"fp_args",
",",
"ret_fp",
"=",
"None",
",",
"sizes",
"=",
"None",
",",
"sp_delta",
"=",
"None",
",",
"func_ty",
"=",
"None",
")",
":",
"return",
"self",
".",
"_default_cc",
".",
"from_arg_kinds",
"(",
"arch",... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | Function.blocks | An iterator of all local blocks in the current function.
:return: angr.lifter.Block instances. | angr/knowledge_plugins/functions/function.py | def blocks(self):
"""
An iterator of all local blocks in the current function.
:return: angr.lifter.Block instances.
"""
for block_addr, block in self._local_blocks.items():
try:
yield self._get_block(block_addr, size=block.size,
... | def blocks(self):
"""
An iterator of all local blocks in the current function.
:return: angr.lifter.Block instances.
"""
for block_addr, block in self._local_blocks.items():
try:
yield self._get_block(block_addr, size=block.size,
... | [
"An",
"iterator",
"of",
"all",
"local",
"blocks",
"in",
"the",
"current",
"function",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/knowledge_plugins/functions/function.py#L204-L216 | [
"def",
"blocks",
"(",
"self",
")",
":",
"for",
"block_addr",
",",
"block",
"in",
"self",
".",
"_local_blocks",
".",
"items",
"(",
")",
":",
"try",
":",
"yield",
"self",
".",
"_get_block",
"(",
"block_addr",
",",
"size",
"=",
"block",
".",
"size",
","... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | Function.operations | All of the operations that are done by this functions. | angr/knowledge_plugins/functions/function.py | def operations(self):
"""
All of the operations that are done by this functions.
"""
return [op for block in self.blocks for op in block.vex.operations] | def operations(self):
"""
All of the operations that are done by this functions.
"""
return [op for block in self.blocks for op in block.vex.operations] | [
"All",
"of",
"the",
"operations",
"that",
"are",
"done",
"by",
"this",
"functions",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/knowledge_plugins/functions/function.py#L285-L289 | [
"def",
"operations",
"(",
"self",
")",
":",
"return",
"[",
"op",
"for",
"block",
"in",
"self",
".",
"blocks",
"for",
"op",
"in",
"block",
".",
"vex",
".",
"operations",
"]"
] | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | Function.code_constants | All of the constants that are used by this functions's code. | angr/knowledge_plugins/functions/function.py | def code_constants(self):
"""
All of the constants that are used by this functions's code.
"""
# TODO: remove link register values
return [const.value for block in self.blocks for const in block.vex.constants] | def code_constants(self):
"""
All of the constants that are used by this functions's code.
"""
# TODO: remove link register values
return [const.value for block in self.blocks for const in block.vex.constants] | [
"All",
"of",
"the",
"constants",
"that",
"are",
"used",
"by",
"this",
"functions",
"s",
"code",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/knowledge_plugins/functions/function.py#L292-L297 | [
"def",
"code_constants",
"(",
"self",
")",
":",
"# TODO: remove link register values",
"return",
"[",
"const",
".",
"value",
"for",
"block",
"in",
"self",
".",
"blocks",
"for",
"const",
"in",
"block",
".",
"vex",
".",
"constants",
"]"
] | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | Function.string_references | All of the constant string references used by this function.
:param minimum_length: The minimum length of strings to find (default is 1)
:param vex_only: Only analyze VEX IR, don't interpret the entry state to detect additional constants.
:return: A list of tuples of (add... | angr/knowledge_plugins/functions/function.py | def string_references(self, minimum_length=2, vex_only=False):
"""
All of the constant string references used by this function.
:param minimum_length: The minimum length of strings to find (default is 1)
:param vex_only: Only analyze VEX IR, don't interpret the entry state to de... | def string_references(self, minimum_length=2, vex_only=False):
"""
All of the constant string references used by this function.
:param minimum_length: The minimum length of strings to find (default is 1)
:param vex_only: Only analyze VEX IR, don't interpret the entry state to de... | [
"All",
"of",
"the",
"constant",
"string",
"references",
"used",
"by",
"this",
"function",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/knowledge_plugins/functions/function.py#L435-L477 | [
"def",
"string_references",
"(",
"self",
",",
"minimum_length",
"=",
"2",
",",
"vex_only",
"=",
"False",
")",
":",
"strings",
"=",
"[",
"]",
"memory",
"=",
"self",
".",
"_project",
".",
"loader",
".",
"memory",
"# get known instruction addresses and call targets... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | Function.local_runtime_values | Tries to find all runtime values of this function which do not come from inputs.
These values are generated by starting from a blank state and reanalyzing the basic blocks once each.
Function calls are skipped, and back edges are never taken so these values are often unreliable,
This function is... | angr/knowledge_plugins/functions/function.py | def local_runtime_values(self):
"""
Tries to find all runtime values of this function which do not come from inputs.
These values are generated by starting from a blank state and reanalyzing the basic blocks once each.
Function calls are skipped, and back edges are never taken so these v... | def local_runtime_values(self):
"""
Tries to find all runtime values of this function which do not come from inputs.
These values are generated by starting from a blank state and reanalyzing the basic blocks once each.
Function calls are skipped, and back edges are never taken so these v... | [
"Tries",
"to",
"find",
"all",
"runtime",
"values",
"of",
"this",
"function",
"which",
"do",
"not",
"come",
"from",
"inputs",
".",
"These",
"values",
"are",
"generated",
"by",
"starting",
"from",
"a",
"blank",
"state",
"and",
"reanalyzing",
"the",
"basic",
... | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/knowledge_plugins/functions/function.py#L480-L570 | [
"def",
"local_runtime_values",
"(",
"self",
")",
":",
"constants",
"=",
"set",
"(",
")",
"if",
"not",
"self",
".",
"_project",
".",
"loader",
".",
"main_object",
".",
"contains_addr",
"(",
"self",
".",
"addr",
")",
":",
"return",
"constants",
"# FIXME the ... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | Function.runtime_values | All of the concrete values used by this function at runtime (i.e., including passed-in arguments and global
values). | angr/knowledge_plugins/functions/function.py | def runtime_values(self):
"""
All of the concrete values used by this function at runtime (i.e., including passed-in arguments and global
values).
"""
constants = set()
for b in self.block_addrs:
for sirsb in self._function_manager._cfg.get_all_irsbs(b):
... | def runtime_values(self):
"""
All of the concrete values used by this function at runtime (i.e., including passed-in arguments and global
values).
"""
constants = set()
for b in self.block_addrs:
for sirsb in self._function_manager._cfg.get_all_irsbs(b):
... | [
"All",
"of",
"the",
"concrete",
"values",
"used",
"by",
"this",
"function",
"at",
"runtime",
"(",
"i",
".",
"e",
".",
"including",
"passed",
"-",
"in",
"arguments",
"and",
"global",
"values",
")",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/knowledge_plugins/functions/function.py#L573-L588 | [
"def",
"runtime_values",
"(",
"self",
")",
":",
"constants",
"=",
"set",
"(",
")",
"for",
"b",
"in",
"self",
".",
"block_addrs",
":",
"for",
"sirsb",
"in",
"self",
".",
"_function_manager",
".",
"_cfg",
".",
"get_all_irsbs",
"(",
"b",
")",
":",
"for",
... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | Function.binary | Get the object this function belongs to.
:return: The object this function belongs to. | angr/knowledge_plugins/functions/function.py | def binary(self):
"""
Get the object this function belongs to.
:return: The object this function belongs to.
"""
return self._project.loader.find_object_containing(self.addr, membership_check=False) | def binary(self):
"""
Get the object this function belongs to.
:return: The object this function belongs to.
"""
return self._project.loader.find_object_containing(self.addr, membership_check=False) | [
"Get",
"the",
"object",
"this",
"function",
"belongs",
"to",
".",
":",
"return",
":",
"The",
"object",
"this",
"function",
"belongs",
"to",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/knowledge_plugins/functions/function.py#L647-L653 | [
"def",
"binary",
"(",
"self",
")",
":",
"return",
"self",
".",
"_project",
".",
"loader",
".",
"find_object_containing",
"(",
"self",
".",
"addr",
",",
"membership_check",
"=",
"False",
")"
] | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | Function.add_jumpout_site | Add a custom jumpout site.
:param node: The address of the basic block that control flow leaves during this transition.
:return: None | angr/knowledge_plugins/functions/function.py | def add_jumpout_site(self, node):
"""
Add a custom jumpout site.
:param node: The address of the basic block that control flow leaves during this transition.
:return: None
"""
self._register_nodes(True, node)
self._jumpout_sites.add(node)
self.... | def add_jumpout_site(self, node):
"""
Add a custom jumpout site.
:param node: The address of the basic block that control flow leaves during this transition.
:return: None
"""
self._register_nodes(True, node)
self._jumpout_sites.add(node)
self.... | [
"Add",
"a",
"custom",
"jumpout",
"site",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/knowledge_plugins/functions/function.py#L655-L665 | [
"def",
"add_jumpout_site",
"(",
"self",
",",
"node",
")",
":",
"self",
".",
"_register_nodes",
"(",
"True",
",",
"node",
")",
"self",
".",
"_jumpout_sites",
".",
"add",
"(",
"node",
")",
"self",
".",
"_add_endpoint",
"(",
"node",
",",
"'transition'",
")"... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | Function.add_retout_site | Add a custom retout site.
Retout (returning to outside of the function) sites are very rare. It mostly occurs during CFG recovery when we
incorrectly identify the beginning of a function in the first iteration, and then correctly identify that
function later in the same iteration (function alig... | angr/knowledge_plugins/functions/function.py | def add_retout_site(self, node):
"""
Add a custom retout site.
Retout (returning to outside of the function) sites are very rare. It mostly occurs during CFG recovery when we
incorrectly identify the beginning of a function in the first iteration, and then correctly identify that
... | def add_retout_site(self, node):
"""
Add a custom retout site.
Retout (returning to outside of the function) sites are very rare. It mostly occurs during CFG recovery when we
incorrectly identify the beginning of a function in the first iteration, and then correctly identify that
... | [
"Add",
"a",
"custom",
"retout",
"site",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/knowledge_plugins/functions/function.py#L667-L685 | [
"def",
"add_retout_site",
"(",
"self",
",",
"node",
")",
":",
"self",
".",
"_register_nodes",
"(",
"True",
",",
"node",
")",
"self",
".",
"_retout_sites",
".",
"add",
"(",
"node",
")",
"self",
".",
"_add_endpoint",
"(",
"node",
",",
"'return'",
")"
] | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | Function._get_initial_name | Determine the most suitable name of the function.
:return: The initial function name.
:rtype: string | angr/knowledge_plugins/functions/function.py | def _get_initial_name(self):
"""
Determine the most suitable name of the function.
:return: The initial function name.
:rtype: string
"""
name = None
addr = self.addr
# Try to get a name from existing labels
if self._function_manager is n... | def _get_initial_name(self):
"""
Determine the most suitable name of the function.
:return: The initial function name.
:rtype: string
"""
name = None
addr = self.addr
# Try to get a name from existing labels
if self._function_manager is n... | [
"Determine",
"the",
"most",
"suitable",
"name",
"of",
"the",
"function",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/knowledge_plugins/functions/function.py#L687-L717 | [
"def",
"_get_initial_name",
"(",
"self",
")",
":",
"name",
"=",
"None",
"addr",
"=",
"self",
".",
"addr",
"# Try to get a name from existing labels",
"if",
"self",
".",
"_function_manager",
"is",
"not",
"None",
":",
"if",
"addr",
"in",
"self",
".",
"_function_... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | Function._get_initial_binary_name | Determine the name of the binary where this function is.
:return: None | angr/knowledge_plugins/functions/function.py | def _get_initial_binary_name(self):
"""
Determine the name of the binary where this function is.
:return: None
"""
binary_name = None
# if this function is a simprocedure but not a syscall, use its library name as
# its binary name
# if it is a syscall,... | def _get_initial_binary_name(self):
"""
Determine the name of the binary where this function is.
:return: None
"""
binary_name = None
# if this function is a simprocedure but not a syscall, use its library name as
# its binary name
# if it is a syscall,... | [
"Determine",
"the",
"name",
"of",
"the",
"binary",
"where",
"this",
"function",
"is",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/knowledge_plugins/functions/function.py#L719-L739 | [
"def",
"_get_initial_binary_name",
"(",
"self",
")",
":",
"binary_name",
"=",
"None",
"# if this function is a simprocedure but not a syscall, use its library name as",
"# its binary name",
"# if it is a syscall, fall back to use self.binary.binary which explicitly says cle##kernel",
"if",
... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | Function._get_initial_returning | Determine if this function returns or not *if it is hooked by a SimProcedure or a user hook*.
:return: True if the hooker returns, False otherwise.
:rtype: bool | angr/knowledge_plugins/functions/function.py | def _get_initial_returning(self):
"""
Determine if this function returns or not *if it is hooked by a SimProcedure or a user hook*.
:return: True if the hooker returns, False otherwise.
:rtype: bool
"""
hooker = None
if self.is_syscall:
hooker... | def _get_initial_returning(self):
"""
Determine if this function returns or not *if it is hooked by a SimProcedure or a user hook*.
:return: True if the hooker returns, False otherwise.
:rtype: bool
"""
hooker = None
if self.is_syscall:
hooker... | [
"Determine",
"if",
"this",
"function",
"returns",
"or",
"not",
"*",
"if",
"it",
"is",
"hooked",
"by",
"a",
"SimProcedure",
"or",
"a",
"user",
"hook",
"*",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/knowledge_plugins/functions/function.py#L741-L758 | [
"def",
"_get_initial_returning",
"(",
"self",
")",
":",
"hooker",
"=",
"None",
"if",
"self",
".",
"is_syscall",
":",
"hooker",
"=",
"self",
".",
"project",
".",
"simos",
".",
"syscall_from_addr",
"(",
"self",
".",
"addr",
")",
"elif",
"self",
".",
"is_si... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | Function._transit_to | Registers an edge between basic blocks in this function's transition graph.
Arguments are CodeNode objects.
:param from_node The address of the basic block that control
flow leaves during this transition.
:param to_node The address of ... | angr/knowledge_plugins/functions/function.py | def _transit_to(self, from_node, to_node, outside=False, ins_addr=None, stmt_idx=None):
"""
Registers an edge between basic blocks in this function's transition graph.
Arguments are CodeNode objects.
:param from_node The address of the basic block that control
... | def _transit_to(self, from_node, to_node, outside=False, ins_addr=None, stmt_idx=None):
"""
Registers an edge between basic blocks in this function's transition graph.
Arguments are CodeNode objects.
:param from_node The address of the basic block that control
... | [
"Registers",
"an",
"edge",
"between",
"basic",
"blocks",
"in",
"this",
"function",
"s",
"transition",
"graph",
".",
"Arguments",
"are",
"CodeNode",
"objects",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/knowledge_plugins/functions/function.py#L783-L818 | [
"def",
"_transit_to",
"(",
"self",
",",
"from_node",
",",
"to_node",
",",
"outside",
"=",
"False",
",",
"ins_addr",
"=",
"None",
",",
"stmt_idx",
"=",
"None",
")",
":",
"if",
"outside",
":",
"self",
".",
"_register_nodes",
"(",
"True",
",",
"from_node",
... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | Function._call_to | Registers an edge between the caller basic block and callee function.
:param from_addr: The basic block that control flow leaves during the transition.
:type from_addr: angr.knowledge.CodeNode
:param to_func: The function that we are calling
:type to_func: Function
... | angr/knowledge_plugins/functions/function.py | def _call_to(self, from_node, to_func, ret_node, stmt_idx=None, ins_addr=None, return_to_outside=False):
"""
Registers an edge between the caller basic block and callee function.
:param from_addr: The basic block that control flow leaves during the transition.
:type from_addr: angr... | def _call_to(self, from_node, to_func, ret_node, stmt_idx=None, ins_addr=None, return_to_outside=False):
"""
Registers an edge between the caller basic block and callee function.
:param from_addr: The basic block that control flow leaves during the transition.
:type from_addr: angr... | [
"Registers",
"an",
"edge",
"between",
"the",
"caller",
"basic",
"block",
"and",
"callee",
"function",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/knowledge_plugins/functions/function.py#L820-L846 | [
"def",
"_call_to",
"(",
"self",
",",
"from_node",
",",
"to_func",
",",
"ret_node",
",",
"stmt_idx",
"=",
"None",
",",
"ins_addr",
"=",
"None",
",",
"return_to_outside",
"=",
"False",
")",
":",
"self",
".",
"_register_nodes",
"(",
"True",
",",
"from_node",
... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | Function._add_return_site | Registers a basic block as a site for control flow to return from this function.
:param CodeNode return_site: The block node that ends with a return. | angr/knowledge_plugins/functions/function.py | def _add_return_site(self, return_site):
"""
Registers a basic block as a site for control flow to return from this function.
:param CodeNode return_site: The block node that ends with a return.
"""
self._register_nodes(True, return_site)
self._ret_sites.add(return_... | def _add_return_site(self, return_site):
"""
Registers a basic block as a site for control flow to return from this function.
:param CodeNode return_site: The block node that ends with a return.
"""
self._register_nodes(True, return_site)
self._ret_sites.add(return_... | [
"Registers",
"a",
"basic",
"block",
"as",
"a",
"site",
"for",
"control",
"flow",
"to",
"return",
"from",
"this",
"function",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/knowledge_plugins/functions/function.py#L898-L909 | [
"def",
"_add_return_site",
"(",
"self",
",",
"return_site",
")",
":",
"self",
".",
"_register_nodes",
"(",
"True",
",",
"return_site",
")",
"self",
".",
"_ret_sites",
".",
"add",
"(",
"return_site",
")",
"# A return site must be an endpoint of the function - you canno... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | Function._add_call_site | Registers a basic block as calling a function and returning somewhere.
:param call_site_addr: The address of a basic block that ends in a call.
:param call_target_addr: The address of the target of said call.
:param retn_addr: The address that said call will return to. | angr/knowledge_plugins/functions/function.py | def _add_call_site(self, call_site_addr, call_target_addr, retn_addr):
"""
Registers a basic block as calling a function and returning somewhere.
:param call_site_addr: The address of a basic block that ends in a call.
:param call_target_addr: The address of the target of said... | def _add_call_site(self, call_site_addr, call_target_addr, retn_addr):
"""
Registers a basic block as calling a function and returning somewhere.
:param call_site_addr: The address of a basic block that ends in a call.
:param call_target_addr: The address of the target of said... | [
"Registers",
"a",
"basic",
"block",
"as",
"calling",
"a",
"function",
"and",
"returning",
"somewhere",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/knowledge_plugins/functions/function.py#L911-L919 | [
"def",
"_add_call_site",
"(",
"self",
",",
"call_site_addr",
",",
"call_target_addr",
",",
"retn_addr",
")",
":",
"self",
".",
"_call_sites",
"[",
"call_site_addr",
"]",
"=",
"(",
"call_target_addr",
",",
"retn_addr",
")"
] | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | Function.mark_nonreturning_calls_endpoints | Iterate through all call edges in transition graph. For each call a non-returning function, mark the source
basic block as an endpoint.
This method should only be executed once all functions are recovered and analyzed by CFG recovery, so we know
whether each function returns or not.
:r... | angr/knowledge_plugins/functions/function.py | def mark_nonreturning_calls_endpoints(self):
"""
Iterate through all call edges in transition graph. For each call a non-returning function, mark the source
basic block as an endpoint.
This method should only be executed once all functions are recovered and analyzed by CFG recovery, so ... | def mark_nonreturning_calls_endpoints(self):
"""
Iterate through all call edges in transition graph. For each call a non-returning function, mark the source
basic block as an endpoint.
This method should only be executed once all functions are recovered and analyzed by CFG recovery, so ... | [
"Iterate",
"through",
"all",
"call",
"edges",
"in",
"transition",
"graph",
".",
"For",
"each",
"call",
"a",
"non",
"-",
"returning",
"function",
"mark",
"the",
"source",
"basic",
"block",
"as",
"an",
"endpoint",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/knowledge_plugins/functions/function.py#L972-L992 | [
"def",
"mark_nonreturning_calls_endpoints",
"(",
"self",
")",
":",
"for",
"src",
",",
"dst",
",",
"data",
"in",
"self",
".",
"transition_graph",
".",
"edges",
"(",
"data",
"=",
"True",
")",
":",
"if",
"'type'",
"in",
"data",
"and",
"data",
"[",
"'type'",... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | Function.graph | Return a local transition graph that only contain nodes in current function. | angr/knowledge_plugins/functions/function.py | def graph(self):
"""
Return a local transition graph that only contain nodes in current function.
"""
if self._local_transition_graph is not None:
return self._local_transition_graph
g = networkx.DiGraph()
if self.startpoint is not None:
g.add_no... | def graph(self):
"""
Return a local transition graph that only contain nodes in current function.
"""
if self._local_transition_graph is not None:
return self._local_transition_graph
g = networkx.DiGraph()
if self.startpoint is not None:
g.add_no... | [
"Return",
"a",
"local",
"transition",
"graph",
"that",
"only",
"contain",
"nodes",
"in",
"current",
"function",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/knowledge_plugins/functions/function.py#L1027-L1050 | [
"def",
"graph",
"(",
"self",
")",
":",
"if",
"self",
".",
"_local_transition_graph",
"is",
"not",
"None",
":",
"return",
"self",
".",
"_local_transition_graph",
"g",
"=",
"networkx",
".",
"DiGraph",
"(",
")",
"if",
"self",
".",
"startpoint",
"is",
"not",
... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | Function.subgraph | Generate a sub control flow graph of instruction addresses based on self.graph
:param iterable ins_addrs: A collection of instruction addresses that should be included in the subgraph.
:return: A subgraph.
:rtype: networkx.DiGraph | angr/knowledge_plugins/functions/function.py | def subgraph(self, ins_addrs):
"""
Generate a sub control flow graph of instruction addresses based on self.graph
:param iterable ins_addrs: A collection of instruction addresses that should be included in the subgraph.
:return: A subgraph.
:rtype: networkx.DiGraph
"""
... | def subgraph(self, ins_addrs):
"""
Generate a sub control flow graph of instruction addresses based on self.graph
:param iterable ins_addrs: A collection of instruction addresses that should be included in the subgraph.
:return: A subgraph.
:rtype: networkx.DiGraph
"""
... | [
"Generate",
"a",
"sub",
"control",
"flow",
"graph",
"of",
"instruction",
"addresses",
"based",
"on",
"self",
".",
"graph"
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/knowledge_plugins/functions/function.py#L1052-L1094 | [
"def",
"subgraph",
"(",
"self",
",",
"ins_addrs",
")",
":",
"# find all basic blocks that include those instructions",
"blocks",
"=",
"[",
"]",
"block_addr_to_insns",
"=",
"{",
"}",
"for",
"b",
"in",
"self",
".",
"_local_blocks",
".",
"values",
"(",
")",
":",
... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | Function.instruction_size | Get the size of the instruction specified by `insn_addr`.
:param int insn_addr: Address of the instruction
:return: Size of the instruction in bytes, or None if the instruction is not found.
:rtype: int | angr/knowledge_plugins/functions/function.py | def instruction_size(self, insn_addr):
"""
Get the size of the instruction specified by `insn_addr`.
:param int insn_addr: Address of the instruction
:return: Size of the instruction in bytes, or None if the instruction is not found.
:rtype: int
"""
for b in sel... | def instruction_size(self, insn_addr):
"""
Get the size of the instruction specified by `insn_addr`.
:param int insn_addr: Address of the instruction
:return: Size of the instruction in bytes, or None if the instruction is not found.
:rtype: int
"""
for b in sel... | [
"Get",
"the",
"size",
"of",
"the",
"instruction",
"specified",
"by",
"insn_addr",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/knowledge_plugins/functions/function.py#L1096-L1116 | [
"def",
"instruction_size",
"(",
"self",
",",
"insn_addr",
")",
":",
"for",
"b",
"in",
"self",
".",
"blocks",
":",
"block",
"=",
"self",
".",
"_get_block",
"(",
"b",
".",
"addr",
",",
"size",
"=",
"b",
".",
"size",
",",
"byte_string",
"=",
"b",
".",... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | Function.dbg_draw | Draw the graph and save it to a PNG file. | angr/knowledge_plugins/functions/function.py | def dbg_draw(self, filename):
"""
Draw the graph and save it to a PNG file.
"""
import matplotlib.pyplot as pyplot # pylint: disable=import-error
from networkx.drawing.nx_agraph import graphviz_layout # pylint: disable=import-error
tmp_graph = networkx.DiGraph()
... | def dbg_draw(self, filename):
"""
Draw the graph and save it to a PNG file.
"""
import matplotlib.pyplot as pyplot # pylint: disable=import-error
from networkx.drawing.nx_agraph import graphviz_layout # pylint: disable=import-error
tmp_graph = networkx.DiGraph()
... | [
"Draw",
"the",
"graph",
"and",
"save",
"it",
"to",
"a",
"PNG",
"file",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/knowledge_plugins/functions/function.py#L1124-L1142 | [
"def",
"dbg_draw",
"(",
"self",
",",
"filename",
")",
":",
"import",
"matplotlib",
".",
"pyplot",
"as",
"pyplot",
"# pylint: disable=import-error",
"from",
"networkx",
".",
"drawing",
".",
"nx_agraph",
"import",
"graphviz_layout",
"# pylint: disable=import-error",
"tm... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | Function._add_argument_register | Registers a register offset as being used as an argument to the function.
:param reg_offset: The offset of the register to register. | angr/knowledge_plugins/functions/function.py | def _add_argument_register(self, reg_offset):
"""
Registers a register offset as being used as an argument to the function.
:param reg_offset: The offset of the register to register.
"""
if reg_offset in self._function_manager._arg_registers and \
re... | def _add_argument_register(self, reg_offset):
"""
Registers a register offset as being used as an argument to the function.
:param reg_offset: The offset of the register to register.
"""
if reg_offset in self._function_manager._arg_registers and \
re... | [
"Registers",
"a",
"register",
"offset",
"as",
"being",
"used",
"as",
"an",
"argument",
"to",
"the",
"function",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/knowledge_plugins/functions/function.py#L1144-L1152 | [
"def",
"_add_argument_register",
"(",
"self",
",",
"reg_offset",
")",
":",
"if",
"reg_offset",
"in",
"self",
".",
"_function_manager",
".",
"_arg_registers",
"and",
"reg_offset",
"not",
"in",
"self",
".",
"_argument_registers",
":",
"self",
".",
"_argument_registe... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | Function.normalize | Make sure all basic blocks in the transition graph of this function do not overlap. You will end up with a CFG
that IDA Pro generates.
This method does not touch the CFG result. You may call CFG{Emulated, Fast}.normalize() for that matter.
:return: None | angr/knowledge_plugins/functions/function.py | def normalize(self):
"""
Make sure all basic blocks in the transition graph of this function do not overlap. You will end up with a CFG
that IDA Pro generates.
This method does not touch the CFG result. You may call CFG{Emulated, Fast}.normalize() for that matter.
:return: None... | def normalize(self):
"""
Make sure all basic blocks in the transition graph of this function do not overlap. You will end up with a CFG
that IDA Pro generates.
This method does not touch the CFG result. You may call CFG{Emulated, Fast}.normalize() for that matter.
:return: None... | [
"Make",
"sure",
"all",
"basic",
"blocks",
"in",
"the",
"transition",
"graph",
"of",
"this",
"function",
"do",
"not",
"overlap",
".",
"You",
"will",
"end",
"up",
"with",
"a",
"CFG",
"that",
"IDA",
"Pro",
"generates",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/knowledge_plugins/functions/function.py#L1173-L1294 | [
"def",
"normalize",
"(",
"self",
")",
":",
"# let's put a check here",
"if",
"self",
".",
"startpoint",
"is",
"None",
":",
"# this function is empty",
"l",
".",
"debug",
"(",
"'Unexpected error: %s does not have any blocks. normalize() fails.'",
",",
"repr",
"(",
"self"... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | Function.find_declaration | Find the most likely function declaration from the embedded collection of prototypes, set it to self.prototype,
and update self.calling_convention with the declaration.
:return: None | angr/knowledge_plugins/functions/function.py | def find_declaration(self):
"""
Find the most likely function declaration from the embedded collection of prototypes, set it to self.prototype,
and update self.calling_convention with the declaration.
:return: None
"""
# determine the library name
if not self.i... | def find_declaration(self):
"""
Find the most likely function declaration from the embedded collection of prototypes, set it to self.prototype,
and update self.calling_convention with the declaration.
:return: None
"""
# determine the library name
if not self.i... | [
"Find",
"the",
"most",
"likely",
"function",
"declaration",
"from",
"the",
"embedded",
"collection",
"of",
"prototypes",
"set",
"it",
"to",
"self",
".",
"prototype",
"and",
"update",
"self",
".",
"calling_convention",
"with",
"the",
"declaration",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/knowledge_plugins/functions/function.py#L1296-L1338 | [
"def",
"find_declaration",
"(",
"self",
")",
":",
"# determine the library name",
"if",
"not",
"self",
".",
"is_plt",
":",
"binary_name",
"=",
"self",
".",
"binary_name",
"if",
"binary_name",
"not",
"in",
"SIM_LIBRARIES",
":",
"return",
"else",
":",
"binary_name... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | CallStack._rfind | Reverse look-up.
:param list lst: The list to look up in.
:param item: The item to look for.
:return: Offset of the item if found. A ValueError is raised if the item is not in the list.
:rtype: int | angr/state_plugins/callstack.py | def _rfind(lst, item):
"""
Reverse look-up.
:param list lst: The list to look up in.
:param item: The item to look for.
:return: Offset of the item if found. A ValueError is raised if the item is not in the list.
:rtype: int
"""
try:
return d... | def _rfind(lst, item):
"""
Reverse look-up.
:param list lst: The list to look up in.
:param item: The item to look for.
:return: Offset of the item if found. A ValueError is raised if the item is not in the list.
:rtype: int
"""
try:
return d... | [
"Reverse",
"look",
"-",
"up",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/callstack.py#L203-L217 | [
"def",
"_rfind",
"(",
"lst",
",",
"item",
")",
":",
"try",
":",
"return",
"dropwhile",
"(",
"lambda",
"x",
":",
"lst",
"[",
"x",
"]",
"!=",
"item",
",",
"next",
"(",
"reversed",
"(",
"range",
"(",
"len",
"(",
"lst",
")",
")",
")",
")",
")",
"... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | CallStack.push | Push the frame cf onto the stack. Return the new stack. | angr/state_plugins/callstack.py | def push(self, cf):
"""
Push the frame cf onto the stack. Return the new stack.
"""
cf.next = self
if self.state is not None:
self.state.register_plugin('callstack', cf)
self.state.history.recent_stack_actions.append(CallStackAction(
hash(c... | def push(self, cf):
"""
Push the frame cf onto the stack. Return the new stack.
"""
cf.next = self
if self.state is not None:
self.state.register_plugin('callstack', cf)
self.state.history.recent_stack_actions.append(CallStackAction(
hash(c... | [
"Push",
"the",
"frame",
"cf",
"onto",
"the",
"stack",
".",
"Return",
"the",
"new",
"stack",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/callstack.py#L232-L243 | [
"def",
"push",
"(",
"self",
",",
"cf",
")",
":",
"cf",
".",
"next",
"=",
"self",
"if",
"self",
".",
"state",
"is",
"not",
"None",
":",
"self",
".",
"state",
".",
"register_plugin",
"(",
"'callstack'",
",",
"cf",
")",
"self",
".",
"state",
".",
"h... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | CallStack.pop | Pop the top frame from the stack. Return the new stack. | angr/state_plugins/callstack.py | def pop(self):
"""
Pop the top frame from the stack. Return the new stack.
"""
if self.next is None:
raise SimEmptyCallStackError("Cannot pop a frame from an empty call stack.")
new_list = self.next.copy({})
if self.state is not None:
self.state.r... | def pop(self):
"""
Pop the top frame from the stack. Return the new stack.
"""
if self.next is None:
raise SimEmptyCallStackError("Cannot pop a frame from an empty call stack.")
new_list = self.next.copy({})
if self.state is not None:
self.state.r... | [
"Pop",
"the",
"top",
"frame",
"from",
"the",
"stack",
".",
"Return",
"the",
"new",
"stack",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/callstack.py#L245-L259 | [
"def",
"pop",
"(",
"self",
")",
":",
"if",
"self",
".",
"next",
"is",
"None",
":",
"raise",
"SimEmptyCallStackError",
"(",
"\"Cannot pop a frame from an empty call stack.\"",
")",
"new_list",
"=",
"self",
".",
"next",
".",
"copy",
"(",
"{",
"}",
")",
"if",
... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | CallStack.call | Push a stack frame into the call stack. This method is called when calling a function in CFG recovery.
:param int callsite_addr: Address of the call site
:param int addr: Address of the call target
:param int or None retn_target: Address of the return target
:param int stack_pointer: Va... | angr/state_plugins/callstack.py | def call(self, callsite_addr, addr, retn_target=None, stack_pointer=None):
"""
Push a stack frame into the call stack. This method is called when calling a function in CFG recovery.
:param int callsite_addr: Address of the call site
:param int addr: Address of the call target
:p... | def call(self, callsite_addr, addr, retn_target=None, stack_pointer=None):
"""
Push a stack frame into the call stack. This method is called when calling a function in CFG recovery.
:param int callsite_addr: Address of the call site
:param int addr: Address of the call target
:p... | [
"Push",
"a",
"stack",
"frame",
"into",
"the",
"call",
"stack",
".",
"This",
"method",
"is",
"called",
"when",
"calling",
"a",
"function",
"in",
"CFG",
"recovery",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/callstack.py#L261-L274 | [
"def",
"call",
"(",
"self",
",",
"callsite_addr",
",",
"addr",
",",
"retn_target",
"=",
"None",
",",
"stack_pointer",
"=",
"None",
")",
":",
"frame",
"=",
"CallStack",
"(",
"call_site_addr",
"=",
"callsite_addr",
",",
"func_addr",
"=",
"addr",
",",
"ret_ad... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | CallStack.ret | Pop one or many call frames from the stack. This method is called when returning from a function in CFG
recovery.
:param int retn_target: The target to return to.
:return: None | angr/state_plugins/callstack.py | def ret(self, retn_target=None):
"""
Pop one or many call frames from the stack. This method is called when returning from a function in CFG
recovery.
:param int retn_target: The target to return to.
:return: None
"""
if retn_target is None:
return s... | def ret(self, retn_target=None):
"""
Pop one or many call frames from the stack. This method is called when returning from a function in CFG
recovery.
:param int retn_target: The target to return to.
:return: None
"""
if retn_target is None:
return s... | [
"Pop",
"one",
"or",
"many",
"call",
"frames",
"from",
"the",
"stack",
".",
"This",
"method",
"is",
"called",
"when",
"returning",
"from",
"a",
"function",
"in",
"CFG",
"recovery",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/callstack.py#L276-L301 | [
"def",
"ret",
"(",
"self",
",",
"retn_target",
"=",
"None",
")",
":",
"if",
"retn_target",
"is",
"None",
":",
"return",
"self",
".",
"pop",
"(",
")",
"# We may want to return to several levels up there, not only a",
"# single stack frame",
"return_target_index",
"=",
... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | CallStack.dbg_repr | Debugging representation of this CallStack object.
:return: Details of this CalLStack
:rtype: str | angr/state_plugins/callstack.py | def dbg_repr(self):
"""
Debugging representation of this CallStack object.
:return: Details of this CalLStack
:rtype: str
"""
stack = [ ]
for i, frame in enumerate(self):
s = "%d | %s -> %s, returning to %s" % (
i,
"No... | def dbg_repr(self):
"""
Debugging representation of this CallStack object.
:return: Details of this CalLStack
:rtype: str
"""
stack = [ ]
for i, frame in enumerate(self):
s = "%d | %s -> %s, returning to %s" % (
i,
"No... | [
"Debugging",
"representation",
"of",
"this",
"CallStack",
"object",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/callstack.py#L308-L326 | [
"def",
"dbg_repr",
"(",
"self",
")",
":",
"stack",
"=",
"[",
"]",
"for",
"i",
",",
"frame",
"in",
"enumerate",
"(",
"self",
")",
":",
"s",
"=",
"\"%d | %s -> %s, returning to %s\"",
"%",
"(",
"i",
",",
"\"None\"",
"if",
"frame",
".",
"call_site_addr",
... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | CallStack.stack_suffix | Generate the stack suffix. A stack suffix can be used as the key to a SimRun in CFG recovery.
:param int context_sensitivity_level: Level of context sensitivity.
:return: A tuple of stack suffix.
:rtype: tuple | angr/state_plugins/callstack.py | def stack_suffix(self, context_sensitivity_level):
"""
Generate the stack suffix. A stack suffix can be used as the key to a SimRun in CFG recovery.
:param int context_sensitivity_level: Level of context sensitivity.
:return: A tuple of stack suffix.
:rtype: tuple
"""
... | def stack_suffix(self, context_sensitivity_level):
"""
Generate the stack suffix. A stack suffix can be used as the key to a SimRun in CFG recovery.
:param int context_sensitivity_level: Level of context sensitivity.
:return: A tuple of stack suffix.
:rtype: tuple
"""
... | [
"Generate",
"the",
"stack",
"suffix",
".",
"A",
"stack",
"suffix",
"can",
"be",
"used",
"as",
"the",
"key",
"to",
"a",
"SimRun",
"in",
"CFG",
"recovery",
"."
] | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/callstack.py#L328-L347 | [
"def",
"stack_suffix",
"(",
"self",
",",
"context_sensitivity_level",
")",
":",
"ret",
"=",
"(",
")",
"for",
"frame",
"in",
"self",
":",
"if",
"len",
"(",
"ret",
")",
">=",
"context_sensitivity_level",
"*",
"2",
":",
"break",
"ret",
"=",
"(",
"frame",
... | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | CallStack._find_return_target | Check if the return target exists in the stack, and return the index if exists. We always search from the most
recent call stack frame since the most recent frame has a higher chance to be hit in normal CFG recovery.
:param int target: Target of the return.
:return: The index of the object
... | angr/state_plugins/callstack.py | def _find_return_target(self, target):
"""
Check if the return target exists in the stack, and return the index if exists. We always search from the most
recent call stack frame since the most recent frame has a higher chance to be hit in normal CFG recovery.
:param int target: Target o... | def _find_return_target(self, target):
"""
Check if the return target exists in the stack, and return the index if exists. We always search from the most
recent call stack frame since the most recent frame has a higher chance to be hit in normal CFG recovery.
:param int target: Target o... | [
"Check",
"if",
"the",
"return",
"target",
"exists",
"in",
"the",
"stack",
"and",
"return",
"the",
"index",
"if",
"exists",
".",
"We",
"always",
"search",
"from",
"the",
"most",
"recent",
"call",
"stack",
"frame",
"since",
"the",
"most",
"recent",
"frame",
... | angr/angr | python | https://github.com/angr/angr/blob/4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40/angr/state_plugins/callstack.py#L353-L366 | [
"def",
"_find_return_target",
"(",
"self",
",",
"target",
")",
":",
"for",
"i",
",",
"frame",
"in",
"enumerate",
"(",
"self",
")",
":",
"if",
"frame",
".",
"ret_addr",
"==",
"target",
":",
"return",
"i",
"return",
"None"
] | 4e2f97d56af5419ee73bdb30482c8dd8ff5f3e40 |
train | update_stock_codes | 获取所有股票 ID 到 all_stock_code 目录下 | easyquotation/helpers.py | def update_stock_codes():
"""获取所有股票 ID 到 all_stock_code 目录下"""
all_stock_codes_url = "http://www.shdjt.com/js/lib/astock.js"
grep_stock_codes = re.compile(r"~(\d+)`")
response = requests.get(all_stock_codes_url)
all_stock_codes = grep_stock_codes.findall(response.text)
with open(stock_code_path(... | def update_stock_codes():
"""获取所有股票 ID 到 all_stock_code 目录下"""
all_stock_codes_url = "http://www.shdjt.com/js/lib/astock.js"
grep_stock_codes = re.compile(r"~(\d+)`")
response = requests.get(all_stock_codes_url)
all_stock_codes = grep_stock_codes.findall(response.text)
with open(stock_code_path(... | [
"获取所有股票",
"ID",
"到",
"all_stock_code",
"目录下"
] | shidenggui/easyquotation | python | https://github.com/shidenggui/easyquotation/blob/a75820db4f05f5386e1c1024d05b0bfc1de6cbda/easyquotation/helpers.py#L11-L18 | [
"def",
"update_stock_codes",
"(",
")",
":",
"all_stock_codes_url",
"=",
"\"http://www.shdjt.com/js/lib/astock.js\"",
"grep_stock_codes",
"=",
"re",
".",
"compile",
"(",
"r\"~(\\d+)`\"",
")",
"response",
"=",
"requests",
".",
"get",
"(",
"all_stock_codes_url",
")",
"al... | a75820db4f05f5386e1c1024d05b0bfc1de6cbda |
train | get_stock_codes | 获取所有股票 ID 到 all_stock_code 目录下 | easyquotation/helpers.py | def get_stock_codes(realtime=False):
"""获取所有股票 ID 到 all_stock_code 目录下"""
if realtime:
all_stock_codes_url = "http://www.shdjt.com/js/lib/astock.js"
grep_stock_codes = re.compile(r"~(\d+)`")
response = requests.get(all_stock_codes_url)
stock_codes = grep_stock_codes.findall(respo... | def get_stock_codes(realtime=False):
"""获取所有股票 ID 到 all_stock_code 目录下"""
if realtime:
all_stock_codes_url = "http://www.shdjt.com/js/lib/astock.js"
grep_stock_codes = re.compile(r"~(\d+)`")
response = requests.get(all_stock_codes_url)
stock_codes = grep_stock_codes.findall(respo... | [
"获取所有股票",
"ID",
"到",
"all_stock_code",
"目录下"
] | shidenggui/easyquotation | python | https://github.com/shidenggui/easyquotation/blob/a75820db4f05f5386e1c1024d05b0bfc1de6cbda/easyquotation/helpers.py#L21-L33 | [
"def",
"get_stock_codes",
"(",
"realtime",
"=",
"False",
")",
":",
"if",
"realtime",
":",
"all_stock_codes_url",
"=",
"\"http://www.shdjt.com/js/lib/astock.js\"",
"grep_stock_codes",
"=",
"re",
".",
"compile",
"(",
"r\"~(\\d+)`\"",
")",
"response",
"=",
"requests",
... | a75820db4f05f5386e1c1024d05b0bfc1de6cbda |
train | BaseQuotation.real | return specific stocks real quotation
:param stock_codes: stock code or list of stock code,
when prefix is True, stock code must start with sh/sz
:param prefix: if prefix i True, stock_codes must contain sh/sz market
flag. If prefix is False, index quotation can't return
... | easyquotation/basequotation.py | def real(self, stock_codes, prefix=False):
"""return specific stocks real quotation
:param stock_codes: stock code or list of stock code,
when prefix is True, stock code must start with sh/sz
:param prefix: if prefix i True, stock_codes must contain sh/sz market
flag.... | def real(self, stock_codes, prefix=False):
"""return specific stocks real quotation
:param stock_codes: stock code or list of stock code,
when prefix is True, stock code must start with sh/sz
:param prefix: if prefix i True, stock_codes must contain sh/sz market
flag.... | [
"return",
"specific",
"stocks",
"real",
"quotation",
":",
"param",
"stock_codes",
":",
"stock",
"code",
"or",
"list",
"of",
"stock",
"code",
"when",
"prefix",
"is",
"True",
"stock",
"code",
"must",
"start",
"with",
"sh",
"/",
"sz",
":",
"param",
"prefix",
... | shidenggui/easyquotation | python | https://github.com/shidenggui/easyquotation/blob/a75820db4f05f5386e1c1024d05b0bfc1de6cbda/easyquotation/basequotation.py#L73-L87 | [
"def",
"real",
"(",
"self",
",",
"stock_codes",
",",
"prefix",
"=",
"False",
")",
":",
"if",
"not",
"isinstance",
"(",
"stock_codes",
",",
"list",
")",
":",
"stock_codes",
"=",
"[",
"stock_codes",
"]",
"stock_list",
"=",
"self",
".",
"gen_stock_list",
"(... | a75820db4f05f5386e1c1024d05b0bfc1de6cbda |
train | BaseQuotation.market_snapshot | return all market quotation snapshot
:param prefix: if prefix is True, return quotation dict's stock_code
key start with sh/sz market flag | easyquotation/basequotation.py | def market_snapshot(self, prefix=False):
"""return all market quotation snapshot
:param prefix: if prefix is True, return quotation dict's stock_code
key start with sh/sz market flag
"""
return self.get_stock_data(self.stock_list, prefix=prefix) | def market_snapshot(self, prefix=False):
"""return all market quotation snapshot
:param prefix: if prefix is True, return quotation dict's stock_code
key start with sh/sz market flag
"""
return self.get_stock_data(self.stock_list, prefix=prefix) | [
"return",
"all",
"market",
"quotation",
"snapshot",
":",
"param",
"prefix",
":",
"if",
"prefix",
"is",
"True",
"return",
"quotation",
"dict",
"s",
"stock_code",
"key",
"start",
"with",
"sh",
"/",
"sz",
"market",
"flag"
] | shidenggui/easyquotation | python | https://github.com/shidenggui/easyquotation/blob/a75820db4f05f5386e1c1024d05b0bfc1de6cbda/easyquotation/basequotation.py#L89-L94 | [
"def",
"market_snapshot",
"(",
"self",
",",
"prefix",
"=",
"False",
")",
":",
"return",
"self",
".",
"get_stock_data",
"(",
"self",
".",
"stock_list",
",",
"prefix",
"=",
"prefix",
")"
] | a75820db4f05f5386e1c1024d05b0bfc1de6cbda |
train | BaseQuotation.get_stock_data | 获取并格式化股票信息 | easyquotation/basequotation.py | def get_stock_data(self, stock_list, **kwargs):
"""获取并格式化股票信息"""
res = self._fetch_stock_data(stock_list)
return self.format_response_data(res, **kwargs) | def get_stock_data(self, stock_list, **kwargs):
"""获取并格式化股票信息"""
res = self._fetch_stock_data(stock_list)
return self.format_response_data(res, **kwargs) | [
"获取并格式化股票信息"
] | shidenggui/easyquotation | python | https://github.com/shidenggui/easyquotation/blob/a75820db4f05f5386e1c1024d05b0bfc1de6cbda/easyquotation/basequotation.py#L109-L112 | [
"def",
"get_stock_data",
"(",
"self",
",",
"stock_list",
",",
"*",
"*",
"kwargs",
")",
":",
"res",
"=",
"self",
".",
"_fetch_stock_data",
"(",
"stock_list",
")",
"return",
"self",
".",
"format_response_data",
"(",
"res",
",",
"*",
"*",
"kwargs",
")"
] | a75820db4f05f5386e1c1024d05b0bfc1de6cbda |
train | BaseQuotation._fetch_stock_data | 获取股票信息 | easyquotation/basequotation.py | def _fetch_stock_data(self, stock_list):
"""获取股票信息"""
pool = multiprocessing.pool.ThreadPool(len(stock_list))
try:
res = pool.map(self.get_stocks_by_range, stock_list)
finally:
pool.close()
return [d for d in res if d is not None] | def _fetch_stock_data(self, stock_list):
"""获取股票信息"""
pool = multiprocessing.pool.ThreadPool(len(stock_list))
try:
res = pool.map(self.get_stocks_by_range, stock_list)
finally:
pool.close()
return [d for d in res if d is not None] | [
"获取股票信息"
] | shidenggui/easyquotation | python | https://github.com/shidenggui/easyquotation/blob/a75820db4f05f5386e1c1024d05b0bfc1de6cbda/easyquotation/basequotation.py#L114-L121 | [
"def",
"_fetch_stock_data",
"(",
"self",
",",
"stock_list",
")",
":",
"pool",
"=",
"multiprocessing",
".",
"pool",
".",
"ThreadPool",
"(",
"len",
"(",
"stock_list",
")",
")",
"try",
":",
"res",
"=",
"pool",
".",
"map",
"(",
"self",
".",
"get_stocks_by_ra... | a75820db4f05f5386e1c1024d05b0bfc1de6cbda |
train | TimeKline._fetch_stock_data | 因为 timekline 的返回没有带对应的股票代码,所以要手动带上 | easyquotation/timekline.py | def _fetch_stock_data(self, stock_list):
"""因为 timekline 的返回没有带对应的股票代码,所以要手动带上"""
res = super()._fetch_stock_data(stock_list)
with_stock = []
for stock, resp in zip(stock_list, res):
if resp is not None:
with_stock.append((stock, resp))
return with_st... | def _fetch_stock_data(self, stock_list):
"""因为 timekline 的返回没有带对应的股票代码,所以要手动带上"""
res = super()._fetch_stock_data(stock_list)
with_stock = []
for stock, resp in zip(stock_list, res):
if resp is not None:
with_stock.append((stock, resp))
return with_st... | [
"因为",
"timekline",
"的返回没有带对应的股票代码,所以要手动带上"
] | shidenggui/easyquotation | python | https://github.com/shidenggui/easyquotation/blob/a75820db4f05f5386e1c1024d05b0bfc1de6cbda/easyquotation/timekline.py#L29-L37 | [
"def",
"_fetch_stock_data",
"(",
"self",
",",
"stock_list",
")",
":",
"res",
"=",
"super",
"(",
")",
".",
"_fetch_stock_data",
"(",
"stock_list",
")",
"with_stock",
"=",
"[",
"]",
"for",
"stock",
",",
"resp",
"in",
"zip",
"(",
"stock_list",
",",
"res",
... | a75820db4f05f5386e1c1024d05b0bfc1de6cbda |
train | Jsl.formatfundajson | 格式化集思录返回的json数据,以字典形式保存 | easyquotation/jsl.py | def formatfundajson(fundajson):
"""格式化集思录返回的json数据,以字典形式保存"""
result = {}
for row in fundajson["rows"]:
funda_id = row["id"]
cell = row["cell"]
result[funda_id] = cell
return result | def formatfundajson(fundajson):
"""格式化集思录返回的json数据,以字典形式保存"""
result = {}
for row in fundajson["rows"]:
funda_id = row["id"]
cell = row["cell"]
result[funda_id] = cell
return result | [
"格式化集思录返回的json数据",
"以字典形式保存"
] | shidenggui/easyquotation | python | https://github.com/shidenggui/easyquotation/blob/a75820db4f05f5386e1c1024d05b0bfc1de6cbda/easyquotation/jsl.py#L101-L108 | [
"def",
"formatfundajson",
"(",
"fundajson",
")",
":",
"result",
"=",
"{",
"}",
"for",
"row",
"in",
"fundajson",
"[",
"\"rows\"",
"]",
":",
"funda_id",
"=",
"row",
"[",
"\"id\"",
"]",
"cell",
"=",
"row",
"[",
"\"cell\"",
"]",
"result",
"[",
"funda_id",
... | a75820db4f05f5386e1c1024d05b0bfc1de6cbda |
train | Jsl.formatfundbjson | 格式化集思录返回的json数据,以字典形式保存 | easyquotation/jsl.py | def formatfundbjson(fundbjson):
"""格式化集思录返回的json数据,以字典形式保存"""
result = {}
for row in fundbjson["rows"]:
cell = row["cell"]
fundb_id = cell["fundb_id"]
result[fundb_id] = cell
return result | def formatfundbjson(fundbjson):
"""格式化集思录返回的json数据,以字典形式保存"""
result = {}
for row in fundbjson["rows"]:
cell = row["cell"]
fundb_id = cell["fundb_id"]
result[fundb_id] = cell
return result | [
"格式化集思录返回的json数据",
"以字典形式保存"
] | shidenggui/easyquotation | python | https://github.com/shidenggui/easyquotation/blob/a75820db4f05f5386e1c1024d05b0bfc1de6cbda/easyquotation/jsl.py#L111-L118 | [
"def",
"formatfundbjson",
"(",
"fundbjson",
")",
":",
"result",
"=",
"{",
"}",
"for",
"row",
"in",
"fundbjson",
"[",
"\"rows\"",
"]",
":",
"cell",
"=",
"row",
"[",
"\"cell\"",
"]",
"fundb_id",
"=",
"cell",
"[",
"\"fundb_id\"",
"]",
"result",
"[",
"fund... | a75820db4f05f5386e1c1024d05b0bfc1de6cbda |
train | Jsl.formatetfindexjson | 格式化集思录返回 指数ETF 的json数据,以字典形式保存 | easyquotation/jsl.py | def formatetfindexjson(fundbjson):
"""格式化集思录返回 指数ETF 的json数据,以字典形式保存"""
result = {}
for row in fundbjson["rows"]:
cell = row["cell"]
fundb_id = cell["fund_id"]
result[fundb_id] = cell
return result | def formatetfindexjson(fundbjson):
"""格式化集思录返回 指数ETF 的json数据,以字典形式保存"""
result = {}
for row in fundbjson["rows"]:
cell = row["cell"]
fundb_id = cell["fund_id"]
result[fundb_id] = cell
return result | [
"格式化集思录返回",
"指数ETF",
"的json数据",
"以字典形式保存"
] | shidenggui/easyquotation | python | https://github.com/shidenggui/easyquotation/blob/a75820db4f05f5386e1c1024d05b0bfc1de6cbda/easyquotation/jsl.py#L121-L128 | [
"def",
"formatetfindexjson",
"(",
"fundbjson",
")",
":",
"result",
"=",
"{",
"}",
"for",
"row",
"in",
"fundbjson",
"[",
"\"rows\"",
"]",
":",
"cell",
"=",
"row",
"[",
"\"cell\"",
"]",
"fundb_id",
"=",
"cell",
"[",
"\"fund_id\"",
"]",
"result",
"[",
"fu... | a75820db4f05f5386e1c1024d05b0bfc1de6cbda |
train | Jsl.funda | 以字典形式返回分级A数据
:param fields:利率范围,形如['+3.0%', '6.0%']
:param min_volume:最小交易量,单位万元
:param min_discount:最小折价率, 单位%
:param ignore_nodown:是否忽略无下折品种,默认 False
:param forever: 是否选择永续品种,默认 False | easyquotation/jsl.py | def funda(
self,
fields=None,
min_volume=0,
min_discount=0,
ignore_nodown=False,
forever=False,
):
"""以字典形式返回分级A数据
:param fields:利率范围,形如['+3.0%', '6.0%']
:param min_volume:最小交易量,单位万元
:param min_discount:最小折价率, 单位%
:param ignore_... | def funda(
self,
fields=None,
min_volume=0,
min_discount=0,
ignore_nodown=False,
forever=False,
):
"""以字典形式返回分级A数据
:param fields:利率范围,形如['+3.0%', '6.0%']
:param min_volume:最小交易量,单位万元
:param min_discount:最小折价率, 单位%
:param ignore_... | [
"以字典形式返回分级A数据",
":",
"param",
"fields",
":",
"利率范围,形如",
"[",
"+",
"3",
".",
"0%",
"6",
".",
"0%",
"]",
":",
"param",
"min_volume",
":",
"最小交易量,单位万元",
":",
"param",
"min_discount",
":",
"最小折价率",
"单位%",
":",
"param",
"ignore_nodown",
":",
"是否忽略无下折品种",
"默认"... | shidenggui/easyquotation | python | https://github.com/shidenggui/easyquotation/blob/a75820db4f05f5386e1c1024d05b0bfc1de6cbda/easyquotation/jsl.py#L148-L207 | [
"def",
"funda",
"(",
"self",
",",
"fields",
"=",
"None",
",",
"min_volume",
"=",
"0",
",",
"min_discount",
"=",
"0",
",",
"ignore_nodown",
"=",
"False",
",",
"forever",
"=",
"False",
",",
")",
":",
"if",
"fields",
"is",
"None",
":",
"fields",
"=",
... | a75820db4f05f5386e1c1024d05b0bfc1de6cbda |
train | Jsl.fundm | 以字典形式返回分级母基数据 | easyquotation/jsl.py | def fundm(self):
"""以字典形式返回分级母基数据
"""
# 添加当前的ctime
self.__fundm_url = self.__fundm_url.format(ctime=int(time.time()))
# 请求数据
rep = requests.get(self.__fundm_url)
# 获取返回的json字符串
fundmjson = json.loads(rep.text)
# 格式化返回的json字符串
data = self.fo... | def fundm(self):
"""以字典形式返回分级母基数据
"""
# 添加当前的ctime
self.__fundm_url = self.__fundm_url.format(ctime=int(time.time()))
# 请求数据
rep = requests.get(self.__fundm_url)
# 获取返回的json字符串
fundmjson = json.loads(rep.text)
# 格式化返回的json字符串
data = self.fo... | [
"以字典形式返回分级母基数据"
] | shidenggui/easyquotation | python | https://github.com/shidenggui/easyquotation/blob/a75820db4f05f5386e1c1024d05b0bfc1de6cbda/easyquotation/jsl.py#L209-L221 | [
"def",
"fundm",
"(",
"self",
")",
":",
"# 添加当前的ctime",
"self",
".",
"__fundm_url",
"=",
"self",
".",
"__fundm_url",
".",
"format",
"(",
"ctime",
"=",
"int",
"(",
"time",
".",
"time",
"(",
")",
")",
")",
"# 请求数据",
"rep",
"=",
"requests",
".",
"get",
... | a75820db4f05f5386e1c1024d05b0bfc1de6cbda |
train | Jsl.fundb | 以字典形式返回分级B数据
:param fields:利率范围,形如['+3.0%', '6.0%']
:param min_volume:最小交易量,单位万元
:param min_discount:最小折价率, 单位%
:param forever: 是否选择永续品种,默认 False | easyquotation/jsl.py | def fundb(self, fields=None, min_volume=0, min_discount=0, forever=False):
"""以字典形式返回分级B数据
:param fields:利率范围,形如['+3.0%', '6.0%']
:param min_volume:最小交易量,单位万元
:param min_discount:最小折价率, 单位%
:param forever: 是否选择永续品种,默认 False
"""
if fields is None:
field... | def fundb(self, fields=None, min_volume=0, min_discount=0, forever=False):
"""以字典形式返回分级B数据
:param fields:利率范围,形如['+3.0%', '6.0%']
:param min_volume:最小交易量,单位万元
:param min_discount:最小折价率, 单位%
:param forever: 是否选择永续品种,默认 False
"""
if fields is None:
field... | [
"以字典形式返回分级B数据",
":",
"param",
"fields",
":",
"利率范围,形如",
"[",
"+",
"3",
".",
"0%",
"6",
".",
"0%",
"]",
":",
"param",
"min_volume",
":",
"最小交易量,单位万元",
":",
"param",
"min_discount",
":",
"最小折价率",
"单位%",
":",
"param",
"forever",
":",
"是否选择永续品种",
"默认",
"Fa... | shidenggui/easyquotation | python | https://github.com/shidenggui/easyquotation/blob/a75820db4f05f5386e1c1024d05b0bfc1de6cbda/easyquotation/jsl.py#L223-L266 | [
"def",
"fundb",
"(",
"self",
",",
"fields",
"=",
"None",
",",
"min_volume",
"=",
"0",
",",
"min_discount",
"=",
"0",
",",
"forever",
"=",
"False",
")",
":",
"if",
"fields",
"is",
"None",
":",
"fields",
"=",
"[",
"]",
"# 添加当前的ctime",
"self",
".",
"_... | a75820db4f05f5386e1c1024d05b0bfc1de6cbda |
train | Jsl.fundarb | 以字典形式返回分级A数据
:param jsl_username: 集思录用户名
:param jsl_password: 集思路登录密码
:param avolume: A成交额,单位百万
:param bvolume: B成交额,单位百万
:param ptype: 溢价计算方式,price=现价,buy=买一,sell=卖一 | easyquotation/jsl.py | def fundarb(
self,
jsl_username,
jsl_password,
avolume=100,
bvolume=100,
ptype="price",
):
"""以字典形式返回分级A数据
:param jsl_username: 集思录用户名
:param jsl_password: 集思路登录密码
:param avolume: A成交额,单位百万
:param bvolume: B成交额,单位百万
:par... | def fundarb(
self,
jsl_username,
jsl_password,
avolume=100,
bvolume=100,
ptype="price",
):
"""以字典形式返回分级A数据
:param jsl_username: 集思录用户名
:param jsl_password: 集思路登录密码
:param avolume: A成交额,单位百万
:param bvolume: B成交额,单位百万
:par... | [
"以字典形式返回分级A数据",
":",
"param",
"jsl_username",
":",
"集思录用户名",
":",
"param",
"jsl_password",
":",
"集思路登录密码",
":",
"param",
"avolume",
":",
"A成交额,单位百万",
":",
"param",
"bvolume",
":",
"B成交额,单位百万",
":",
"param",
"ptype",
":",
"溢价计算方式,price",
"=",
"现价,buy",
"=",
"... | shidenggui/easyquotation | python | https://github.com/shidenggui/easyquotation/blob/a75820db4f05f5386e1c1024d05b0bfc1de6cbda/easyquotation/jsl.py#L268-L323 | [
"def",
"fundarb",
"(",
"self",
",",
"jsl_username",
",",
"jsl_password",
",",
"avolume",
"=",
"100",
",",
"bvolume",
"=",
"100",
",",
"ptype",
"=",
"\"price\"",
",",
")",
":",
"session",
"=",
"requests",
".",
"session",
"(",
")",
"headers",
"=",
"{",
... | a75820db4f05f5386e1c1024d05b0bfc1de6cbda |
train | Jsl.etfindex | 以字典形式返回 指数ETF 数据
:param index_id: 获取指定的指数
:param min_volume: 最小成交量
:param min_discount: 最低溢价率, 适用于溢价套利, 格式 "-1.2%", "-1.2", -0.012 三种均可
:param max_discount: 最高溢价率, 适用于折价套利, 格式 "-1.2%", "-1.2", -0.012 三种均可
:return: {"fund_id":{}} | easyquotation/jsl.py | def etfindex(
self, index_id="", min_volume=0, max_discount=None, min_discount=None
):
"""
以字典形式返回 指数ETF 数据
:param index_id: 获取指定的指数
:param min_volume: 最小成交量
:param min_discount: 最低溢价率, 适用于溢价套利, 格式 "-1.2%", "-1.2", -0.012 三种均可
:param max_discount: 最高溢价率, 适用于折价... | def etfindex(
self, index_id="", min_volume=0, max_discount=None, min_discount=None
):
"""
以字典形式返回 指数ETF 数据
:param index_id: 获取指定的指数
:param min_volume: 最小成交量
:param min_discount: 最低溢价率, 适用于溢价套利, 格式 "-1.2%", "-1.2", -0.012 三种均可
:param max_discount: 最高溢价率, 适用于折价... | [
"以字典形式返回",
"指数ETF",
"数据",
":",
"param",
"index_id",
":",
"获取指定的指数",
":",
"param",
"min_volume",
":",
"最小成交量",
":",
"param",
"min_discount",
":",
"最低溢价率",
"适用于溢价套利",
"格式",
"-",
"1",
".",
"2%",
"-",
"1",
".",
"2",
"-",
"0",
".",
"012",
"三种均可",
":",
"... | shidenggui/easyquotation | python | https://github.com/shidenggui/easyquotation/blob/a75820db4f05f5386e1c1024d05b0bfc1de6cbda/easyquotation/jsl.py#L325-L391 | [
"def",
"etfindex",
"(",
"self",
",",
"index_id",
"=",
"\"\"",
",",
"min_volume",
"=",
"0",
",",
"max_discount",
"=",
"None",
",",
"min_discount",
"=",
"None",
")",
":",
"# 添加当前的ctime",
"self",
".",
"__etf_index_url",
"=",
"self",
".",
"__etf_index_url",
".... | a75820db4f05f5386e1c1024d05b0bfc1de6cbda |
train | Jsl.qdii | 以字典形式返回QDII数据
:param min_volume:最小交易量,单位万元 | easyquotation/jsl.py | def qdii(self, min_volume=0):
"""以字典形式返回QDII数据
:param min_volume:最小交易量,单位万元
"""
# 添加当前的ctime
self.__qdii_url = self.__qdii_url.format(ctime=int(time.time()))
# 请求数据
rep = requests.get(self.__qdii_url)
# 获取返回的json字符串
fundjson = json.loads(rep.text)
... | def qdii(self, min_volume=0):
"""以字典形式返回QDII数据
:param min_volume:最小交易量,单位万元
"""
# 添加当前的ctime
self.__qdii_url = self.__qdii_url.format(ctime=int(time.time()))
# 请求数据
rep = requests.get(self.__qdii_url)
# 获取返回的json字符串
fundjson = json.loads(rep.text)
... | [
"以字典形式返回QDII数据",
":",
"param",
"min_volume",
":",
"最小交易量,单位万元"
] | shidenggui/easyquotation | python | https://github.com/shidenggui/easyquotation/blob/a75820db4f05f5386e1c1024d05b0bfc1de6cbda/easyquotation/jsl.py#L393-L415 | [
"def",
"qdii",
"(",
"self",
",",
"min_volume",
"=",
"0",
")",
":",
"# 添加当前的ctime",
"self",
".",
"__qdii_url",
"=",
"self",
".",
"__qdii_url",
".",
"format",
"(",
"ctime",
"=",
"int",
"(",
"time",
".",
"time",
"(",
")",
")",
")",
"# 请求数据",
"rep",
"=... | a75820db4f05f5386e1c1024d05b0bfc1de6cbda |
train | Jsl.cb | 以字典形式返回QDII数据
:param min_volume:最小交易量,单位万元 | easyquotation/jsl.py | def cb(self, min_volume=0):
"""以字典形式返回QDII数据
:param min_volume:最小交易量,单位万元
"""
# 添加当前的ctime
self.__cb_url = self.__cb_url.format(ctime=int(time.time()))
# 请求数据
rep = requests.get(self.__cb_url)
# 获取返回的json字符串
fundjson = json.loads(rep.text)
... | def cb(self, min_volume=0):
"""以字典形式返回QDII数据
:param min_volume:最小交易量,单位万元
"""
# 添加当前的ctime
self.__cb_url = self.__cb_url.format(ctime=int(time.time()))
# 请求数据
rep = requests.get(self.__cb_url)
# 获取返回的json字符串
fundjson = json.loads(rep.text)
... | [
"以字典形式返回QDII数据",
":",
"param",
"min_volume",
":",
"最小交易量,单位万元"
] | shidenggui/easyquotation | python | https://github.com/shidenggui/easyquotation/blob/a75820db4f05f5386e1c1024d05b0bfc1de6cbda/easyquotation/jsl.py#L418-L439 | [
"def",
"cb",
"(",
"self",
",",
"min_volume",
"=",
"0",
")",
":",
"# 添加当前的ctime",
"self",
".",
"__cb_url",
"=",
"self",
".",
"__cb_url",
".",
"format",
"(",
"ctime",
"=",
"int",
"(",
"time",
".",
"time",
"(",
")",
")",
")",
"# 请求数据",
"rep",
"=",
"... | a75820db4f05f5386e1c1024d05b0bfc1de6cbda |
train | Plugin.update | Update current date/time. | glances/plugins/glances_now.py | def update(self):
"""Update current date/time."""
# Had to convert it to string because datetime is not JSON serializable
self.stats = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
# Add the time zone (issue #1249 and issue #1337)
if 'tmzone' in localtime():
self.stats... | def update(self):
"""Update current date/time."""
# Had to convert it to string because datetime is not JSON serializable
self.stats = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
# Add the time zone (issue #1249 and issue #1337)
if 'tmzone' in localtime():
self.stats... | [
"Update",
"current",
"date",
"/",
"time",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_now.py#L48-L58 | [
"def",
"update",
"(",
"self",
")",
":",
"# Had to convert it to string because datetime is not JSON serializable",
"self",
".",
"stats",
"=",
"datetime",
".",
"now",
"(",
")",
".",
"strftime",
"(",
"'%Y-%m-%d %H:%M:%S'",
")",
"# Add the time zone (issue #1249 and issue #133... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.msg_curse | Return the string to display in the curse interface. | glances/plugins/glances_now.py | def msg_curse(self, args=None, max_width=None):
"""Return the string to display in the curse interface."""
# Init the return message
ret = []
# Build the string message
# 23 is the padding for the process list
msg = '{:23}'.format(self.stats)
ret.append(self.curs... | def msg_curse(self, args=None, max_width=None):
"""Return the string to display in the curse interface."""
# Init the return message
ret = []
# Build the string message
# 23 is the padding for the process list
msg = '{:23}'.format(self.stats)
ret.append(self.curs... | [
"Return",
"the",
"string",
"to",
"display",
"in",
"the",
"curse",
"interface",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_now.py#L60-L70 | [
"def",
"msg_curse",
"(",
"self",
",",
"args",
"=",
"None",
",",
"max_width",
"=",
"None",
")",
":",
"# Init the return message",
"ret",
"=",
"[",
"]",
"# Build the string message",
"# 23 is the padding for the process list",
"msg",
"=",
"'{:23}'",
".",
"format",
"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesWebList.load | Load the web list from the configuration file. | glances/web_list.py | def load(self, config):
"""Load the web list from the configuration file."""
web_list = []
if config is None:
logger.debug("No configuration file available. Cannot load ports list.")
elif not config.has_section(self._section):
logger.debug("No [%s] section in the... | def load(self, config):
"""Load the web list from the configuration file."""
web_list = []
if config is None:
logger.debug("No configuration file available. Cannot load ports list.")
elif not config.has_section(self._section):
logger.debug("No [%s] section in the... | [
"Load",
"the",
"web",
"list",
"from",
"the",
"configuration",
"file",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/web_list.py#L43-L127 | [
"def",
"load",
"(",
"self",
",",
"config",
")",
":",
"web_list",
"=",
"[",
"]",
"if",
"config",
"is",
"None",
":",
"logger",
".",
"debug",
"(",
"\"No configuration file available. Cannot load ports list.\"",
")",
"elif",
"not",
"config",
".",
"has_section",
"(... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesWebList.set_server | Set the key to the value for the pos (position in the list). | glances/web_list.py | def set_server(self, pos, key, value):
"""Set the key to the value for the pos (position in the list)."""
self._web_list[pos][key] = value | def set_server(self, pos, key, value):
"""Set the key to the value for the pos (position in the list)."""
self._web_list[pos][key] = value | [
"Set",
"the",
"key",
"to",
"the",
"value",
"for",
"the",
"pos",
"(",
"position",
"in",
"the",
"list",
")",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/web_list.py#L133-L135 | [
"def",
"set_server",
"(",
"self",
",",
"pos",
",",
"key",
",",
"value",
")",
":",
"self",
".",
"_web_list",
"[",
"pos",
"]",
"[",
"key",
"]",
"=",
"value"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.update | Update sensors stats using the input method. | glances/plugins/glances_sensors.py | def update(self):
"""Update sensors stats using the input method."""
# Init new stats
stats = self.get_init_value()
if self.input_method == 'local':
# Update stats using the dedicated lib
stats = []
# Get the temperature
try:
... | def update(self):
"""Update sensors stats using the input method."""
# Init new stats
stats = self.get_init_value()
if self.input_method == 'local':
# Update stats using the dedicated lib
stats = []
# Get the temperature
try:
... | [
"Update",
"sensors",
"stats",
"using",
"the",
"input",
"method",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_sensors.py#L73-L134 | [
"def",
"update",
"(",
"self",
")",
":",
"# Init new stats",
"stats",
"=",
"self",
".",
"get_init_value",
"(",
")",
"if",
"self",
".",
"input_method",
"==",
"'local'",
":",
"# Update stats using the dedicated lib",
"stats",
"=",
"[",
"]",
"# Get the temperature",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.__set_type | Set the plugin type.
4 types of stats is possible in the sensors plugin:
- Core temperature: 'temperature_core'
- Fan speed: 'fan_speed'
- HDD temperature: 'temperature_hdd'
- Battery capacity: 'battery' | glances/plugins/glances_sensors.py | def __set_type(self, stats, sensor_type):
"""Set the plugin type.
4 types of stats is possible in the sensors plugin:
- Core temperature: 'temperature_core'
- Fan speed: 'fan_speed'
- HDD temperature: 'temperature_hdd'
- Battery capacity: 'battery'
"""
fo... | def __set_type(self, stats, sensor_type):
"""Set the plugin type.
4 types of stats is possible in the sensors plugin:
- Core temperature: 'temperature_core'
- Fan speed: 'fan_speed'
- HDD temperature: 'temperature_hdd'
- Battery capacity: 'battery'
"""
fo... | [
"Set",
"the",
"plugin",
"type",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_sensors.py#L136-L151 | [
"def",
"__set_type",
"(",
"self",
",",
"stats",
",",
"sensor_type",
")",
":",
"for",
"i",
"in",
"stats",
":",
"# Set the sensors type",
"i",
".",
"update",
"(",
"{",
"'type'",
":",
"sensor_type",
"}",
")",
"# also add the key name",
"i",
".",
"update",
"("... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Plugin.msg_curse | Return the dict to display in the curse interface. | glances/plugins/glances_sensors.py | def msg_curse(self, args=None, max_width=None):
"""Return the dict to display in the curse interface."""
# Init the return message
ret = []
# Only process if stats exist and display plugin enable...
if not self.stats or self.is_disable():
return ret
# Max si... | def msg_curse(self, args=None, max_width=None):
"""Return the dict to display in the curse interface."""
# Init the return message
ret = []
# Only process if stats exist and display plugin enable...
if not self.stats or self.is_disable():
return ret
# Max si... | [
"Return",
"the",
"dict",
"to",
"display",
"in",
"the",
"curse",
"interface",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_sensors.py#L168-L217 | [
"def",
"msg_curse",
"(",
"self",
",",
"args",
"=",
"None",
",",
"max_width",
"=",
"None",
")",
":",
"# Init the return message",
"ret",
"=",
"[",
"]",
"# Only process if stats exist and display plugin enable...",
"if",
"not",
"self",
".",
"stats",
"or",
"self",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesGrabSensors.build_sensors_list | Build the sensors list depending of the type.
type: SENSOR_TEMP_UNIT or SENSOR_FAN_UNIT
output: a list | glances/plugins/glances_sensors.py | def build_sensors_list(self, type):
"""Build the sensors list depending of the type.
type: SENSOR_TEMP_UNIT or SENSOR_FAN_UNIT
output: a list
"""
ret = []
if type == SENSOR_TEMP_UNIT and self.init_temp:
input_list = self.stemps
self.stemps = psut... | def build_sensors_list(self, type):
"""Build the sensors list depending of the type.
type: SENSOR_TEMP_UNIT or SENSOR_FAN_UNIT
output: a list
"""
ret = []
if type == SENSOR_TEMP_UNIT and self.init_temp:
input_list = self.stemps
self.stemps = psut... | [
"Build",
"the",
"sensors",
"list",
"depending",
"of",
"the",
"type",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_sensors.py#L278-L309 | [
"def",
"build_sensors_list",
"(",
"self",
",",
"type",
")",
":",
"ret",
"=",
"[",
"]",
"if",
"type",
"==",
"SENSOR_TEMP_UNIT",
"and",
"self",
".",
"init_temp",
":",
"input_list",
"=",
"self",
".",
"stemps",
"self",
".",
"stemps",
"=",
"psutil",
".",
"s... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesGrabSensors.get | Get sensors list. | glances/plugins/glances_sensors.py | def get(self, sensor_type='temperature_core'):
"""Get sensors list."""
self.__update__()
if sensor_type == 'temperature_core':
ret = [s for s in self.sensors_list if s['unit'] == SENSOR_TEMP_UNIT]
elif sensor_type == 'fan_speed':
ret = [s for s in self.sensors_lis... | def get(self, sensor_type='temperature_core'):
"""Get sensors list."""
self.__update__()
if sensor_type == 'temperature_core':
ret = [s for s in self.sensors_list if s['unit'] == SENSOR_TEMP_UNIT]
elif sensor_type == 'fan_speed':
ret = [s for s in self.sensors_lis... | [
"Get",
"sensors",
"list",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_sensors.py#L311-L322 | [
"def",
"get",
"(",
"self",
",",
"sensor_type",
"=",
"'temperature_core'",
")",
":",
"self",
".",
"__update__",
"(",
")",
"if",
"sensor_type",
"==",
"'temperature_core'",
":",
"ret",
"=",
"[",
"s",
"for",
"s",
"in",
"self",
".",
"sensors_list",
"if",
"s",... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesServer.add_user | Add an user to the dictionary. | glances/server.py | def add_user(self, username, password):
"""Add an user to the dictionary."""
self.server.user_dict[username] = password
self.server.isAuth = True | def add_user(self, username, password):
"""Add an user to the dictionary."""
self.server.user_dict[username] = password
self.server.isAuth = True | [
"Add",
"an",
"user",
"to",
"the",
"dictionary",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/server.py#L233-L236 | [
"def",
"add_user",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"self",
".",
"server",
".",
"user_dict",
"[",
"username",
"]",
"=",
"password",
"self",
".",
"server",
".",
"isAuth",
"=",
"True"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesServer.serve_forever | Call the main loop. | glances/server.py | def serve_forever(self):
"""Call the main loop."""
# Set the server login/password (if -P/--password tag)
if self.args.password != "":
self.add_user(self.args.username, self.args.password)
# Serve forever
self.server.serve_forever() | def serve_forever(self):
"""Call the main loop."""
# Set the server login/password (if -P/--password tag)
if self.args.password != "":
self.add_user(self.args.username, self.args.password)
# Serve forever
self.server.serve_forever() | [
"Call",
"the",
"main",
"loop",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/server.py#L238-L244 | [
"def",
"serve_forever",
"(",
"self",
")",
":",
"# Set the server login/password (if -P/--password tag)",
"if",
"self",
".",
"args",
".",
"password",
"!=",
"\"\"",
":",
"self",
".",
"add_user",
"(",
"self",
".",
"args",
".",
"username",
",",
"self",
".",
"args"... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesServer.end | End of the Glances server session. | glances/server.py | def end(self):
"""End of the Glances server session."""
if not self.args.disable_autodiscover:
self.autodiscover_client.close()
self.server.end() | def end(self):
"""End of the Glances server session."""
if not self.args.disable_autodiscover:
self.autodiscover_client.close()
self.server.end() | [
"End",
"of",
"the",
"Glances",
"server",
"session",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/server.py#L246-L250 | [
"def",
"end",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"args",
".",
"disable_autodiscover",
":",
"self",
".",
"autodiscover_client",
".",
"close",
"(",
")",
"self",
".",
"server",
".",
"end",
"(",
")"
] | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesThresholds.get | Return the threshold dict.
If stat_name is None, return the threshold for all plugins (dict of Threshold*)
Else return the Threshold* instance for the given plugin | glances/thresholds.py | def get(self, stat_name=None):
"""Return the threshold dict.
If stat_name is None, return the threshold for all plugins (dict of Threshold*)
Else return the Threshold* instance for the given plugin
"""
if stat_name is None:
return self._thresholds
if stat_nam... | def get(self, stat_name=None):
"""Return the threshold dict.
If stat_name is None, return the threshold for all plugins (dict of Threshold*)
Else return the Threshold* instance for the given plugin
"""
if stat_name is None:
return self._thresholds
if stat_nam... | [
"Return",
"the",
"threshold",
"dict",
".",
"If",
"stat_name",
"is",
"None",
"return",
"the",
"threshold",
"for",
"all",
"plugins",
"(",
"dict",
"of",
"Threshold",
"*",
")",
"Else",
"return",
"the",
"Threshold",
"*",
"instance",
"for",
"the",
"given",
"plug... | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/thresholds.py#L40-L51 | [
"def",
"get",
"(",
"self",
",",
"stat_name",
"=",
"None",
")",
":",
"if",
"stat_name",
"is",
"None",
":",
"return",
"self",
".",
"_thresholds",
"if",
"stat_name",
"in",
"self",
".",
"_thresholds",
":",
"return",
"self",
".",
"_thresholds",
"[",
"stat_nam... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | GlancesThresholds.add | Add a new threshold to the dict (key = stat_name) | glances/thresholds.py | def add(self, stat_name, threshold_description):
"""Add a new threshold to the dict (key = stat_name)"""
if threshold_description not in self.threshold_list:
return False
else:
self._thresholds[stat_name] = getattr(self.current_module,
... | def add(self, stat_name, threshold_description):
"""Add a new threshold to the dict (key = stat_name)"""
if threshold_description not in self.threshold_list:
return False
else:
self._thresholds[stat_name] = getattr(self.current_module,
... | [
"Add",
"a",
"new",
"threshold",
"to",
"the",
"dict",
"(",
"key",
"=",
"stat_name",
")"
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/thresholds.py#L53-L60 | [
"def",
"add",
"(",
"self",
",",
"stat_name",
",",
"threshold_description",
")",
":",
"if",
"threshold_description",
"not",
"in",
"self",
".",
"threshold_list",
":",
"return",
"False",
"else",
":",
"self",
".",
"_thresholds",
"[",
"stat_name",
"]",
"=",
"geta... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Export.init | Init the connection to the rabbitmq server. | glances/exports/glances_rabbitmq.py | def init(self):
"""Init the connection to the rabbitmq server."""
if not self.export_enable:
return None
try:
parameters = pika.URLParameters(
'amqp://' + self.user +
':' + self.password +
'@' + self.host +
'... | def init(self):
"""Init the connection to the rabbitmq server."""
if not self.export_enable:
return None
try:
parameters = pika.URLParameters(
'amqp://' + self.user +
':' + self.password +
'@' + self.host +
'... | [
"Init",
"the",
"connection",
"to",
"the",
"rabbitmq",
"server",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_rabbitmq.py#L66-L81 | [
"def",
"init",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"export_enable",
":",
"return",
"None",
"try",
":",
"parameters",
"=",
"pika",
".",
"URLParameters",
"(",
"'amqp://'",
"+",
"self",
".",
"user",
"+",
"':'",
"+",
"self",
".",
"password",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Export.export | Write the points in RabbitMQ. | glances/exports/glances_rabbitmq.py | def export(self, name, columns, points):
"""Write the points in RabbitMQ."""
data = ('hostname=' + self.hostname + ', name=' + name +
', dateinfo=' + datetime.datetime.utcnow().isoformat())
for i in range(len(columns)):
if not isinstance(points[i], Number):
... | def export(self, name, columns, points):
"""Write the points in RabbitMQ."""
data = ('hostname=' + self.hostname + ', name=' + name +
', dateinfo=' + datetime.datetime.utcnow().isoformat())
for i in range(len(columns)):
if not isinstance(points[i], Number):
... | [
"Write",
"the",
"points",
"in",
"RabbitMQ",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_rabbitmq.py#L83-L96 | [
"def",
"export",
"(",
"self",
",",
"name",
",",
"columns",
",",
"points",
")",
":",
"data",
"=",
"(",
"'hostname='",
"+",
"self",
".",
"hostname",
"+",
"', name='",
"+",
"name",
"+",
"', dateinfo='",
"+",
"datetime",
".",
"datetime",
".",
"utcnow",
"("... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | normalize | Normalize name for the Statsd convention | glances/exports/glances_statsd.py | def normalize(name):
"""Normalize name for the Statsd convention"""
# Name should not contain some specials chars (issue #1068)
ret = name.replace(':', '')
ret = ret.replace('%', '')
ret = ret.replace(' ', '_')
return ret | def normalize(name):
"""Normalize name for the Statsd convention"""
# Name should not contain some specials chars (issue #1068)
ret = name.replace(':', '')
ret = ret.replace('%', '')
ret = ret.replace(' ', '_')
return ret | [
"Normalize",
"name",
"for",
"the",
"Statsd",
"convention"
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_statsd.py#L86-L94 | [
"def",
"normalize",
"(",
"name",
")",
":",
"# Name should not contain some specials chars (issue #1068)",
"ret",
"=",
"name",
".",
"replace",
"(",
"':'",
",",
"''",
")",
"ret",
"=",
"ret",
".",
"replace",
"(",
"'%'",
",",
"''",
")",
"ret",
"=",
"ret",
".",... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
train | Export.init | Init the connection to the Statsd server. | glances/exports/glances_statsd.py | def init(self):
"""Init the connection to the Statsd server."""
if not self.export_enable:
return None
logger.info(
"Stats will be exported to StatsD server: {}:{}".format(self.host,
self.port))
r... | def init(self):
"""Init the connection to the Statsd server."""
if not self.export_enable:
return None
logger.info(
"Stats will be exported to StatsD server: {}:{}".format(self.host,
self.port))
r... | [
"Init",
"the",
"connection",
"to",
"the",
"Statsd",
"server",
"."
] | nicolargo/glances | python | https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/exports/glances_statsd.py#L60-L69 | [
"def",
"init",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"export_enable",
":",
"return",
"None",
"logger",
".",
"info",
"(",
"\"Stats will be exported to StatsD server: {}:{}\"",
".",
"format",
"(",
"self",
".",
"host",
",",
"self",
".",
"port",
")",
... | 5bd4d587a736e0d2b03170b56926841d2a3eb7ee |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.