_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 31 13.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q30800 | ZK.restart | train | def restart(self):
"""
restart the device
:return: bool
"""
command = const.CMD_RESTART
cmd_response = self.__send_command(command)
if cmd_response.get('status'):
self.is_connect = False
| python | {
"resource": ""
} |
q30801 | ZK.poweroff | train | def poweroff(self):
"""
shutdown the machine
"""
command = const.CMD_POWEROFF
command_string = b''
response_size = 1032
cmd_response = self.__send_command(command, command_string, response_size)
if cmd_response.get('status'):
| python | {
"resource": ""
} |
q30802 | ZK.set_user | train | def set_user(self, uid=None, name='', privilege=0, password='', group_id='', user_id='', card=0):
"""
create or update user by uid
:param name: name ot the user
:param privilege: check the const.py for reference
:param password: int password
:param group_id: group ID
... | python | {
"resource": ""
} |
q30803 | ZK.save_user_template | train | def save_user_template(self, user, fingers=[]):
"""
save user and template
:param user: user
:param fingers: list of finger. (The maximum index 0-9)
"""
if not isinstance(user, User):
users = self.get_users()
tusers = list(filter(lambda x: x.uid==... | python | {
"resource": ""
} |
q30804 | ZK.delete_user_template | train | def delete_user_template(self, uid=0, temp_id=0, user_id=''):
"""
Delete specific template
:param uid: user ID that are generated from device
:param user_id: your own user ID
:return: bool
"""
if self.tcp and user_id:
command = 134
command... | python | {
"resource": ""
} |
q30805 | ZK.delete_user | train | def delete_user(self, uid=0, user_id=''):
"""
delete specific user by uid or user_id
:param uid: user ID that are generated from device
:param user_id: your own user ID
:return: bool
"""
if not uid:
users = self.get_users()
users = list(fi... | python | {
"resource": ""
} |
q30806 | ZK.cancel_capture | train | def cancel_capture(self):
"""
cancel capturing finger
:return: bool
"""
command = const.CMD_CANCELCAPTURE
| python | {
"resource": ""
} |
q30807 | ZK.__recieve_tcp_data | train | def __recieve_tcp_data(self, data_recv, size):
""" data_recv, raw tcp packet
must analyze tcp_length
must return data, broken
"""
data = []
tcp_length = self.__test_tcp_top(data_recv)
if self.verbose: print ("tcp_length {}, size {}".format(tcp_length, size))
... | python | {
"resource": ""
} |
q30808 | ZK.__recieve_raw_data | train | def __recieve_raw_data(self, size):
""" partial data ? """
data = []
if self.verbose: print ("expecting {} bytes raw data".format(size))
while size > 0:
data_recv = self.__sock.recv(size)
recieved = len(data_recv)
if self.verbose: print ("partial recv ... | python | {
"resource": ""
} |
q30809 | ZK.__read_chunk | train | def __read_chunk(self, start, size):
"""
read a chunk from buffer
"""
for _retries in range(3):
command = 1504
command_string = pack('<ii', start, size)
if self.tcp:
response_size | python | {
"resource": ""
} |
q30810 | ZK.clear_attendance | train | def clear_attendance(self):
"""
clear all attendance record
:return: bool
"""
command = const.CMD_CLEAR_ATTLOG
cmd_response = self.__send_command(command)
| python | {
"resource": ""
} |
q30811 | _connect_control_flow_node | train | def _connect_control_flow_node(control_flow_node, next_node):
"""Connect a ControlFlowNode properly to the next_node."""
for last in control_flow_node.last_nodes:
if isinstance(next_node, ControlFlowNode):
last.connect(next_node.test) # connect to next if test case
elif isinstance(n... | python | {
"resource": ""
} |
q30812 | connect_nodes | train | def connect_nodes(nodes):
"""Connect the nodes in a list linearly."""
for n, next_node in zip(nodes, nodes[1:]):
if isinstance(n, ControlFlowNode):
_connect_control_flow_node(n, next_node)
| python | {
"resource": ""
} |
q30813 | _get_names | train | def _get_names(node, result):
"""Recursively finds all names."""
if isinstance(node, ast.Name):
return node.id + result
elif isinstance(node, ast.Subscript):
return result
elif isinstance(node, | python | {
"resource": ""
} |
q30814 | extract_left_hand_side | train | def extract_left_hand_side(target):
"""Extract the left hand side variable from a target.
Removes list indexes, stars and other left hand side elements.
"""
left_hand_side = _get_names(target, '')
| python | {
"resource": ""
} |
q30815 | get_first_node | train | def get_first_node(
node,
node_not_to_step_past
):
"""
This is a super hacky way of getting the first node after a statement.
We do this because we visit a statement and keep on visiting and get something in return that is rarely the first node.
So we loop and loop backwards until we... | python | {
"resource": ""
} |
q30816 | StmtVisitor.handle_or_else | train | def handle_or_else(self, orelse, test):
"""Handle the orelse part of an if or try node.
Args:
orelse(list[Node])
test(Node)
Returns:
The last nodes of the orelse branch.
"""
if isinstance(orelse[0], ast.If):
control_flow_node = se... | python | {
"resource": ""
} |
q30817 | StmtVisitor.assignment_call_node | train | def assignment_call_node(self, left_hand_label, ast_node):
"""Handle assignments that contain a function call on its right side."""
self.undecided = True # Used for handling functions in assignments
call = self.visit(ast_node.value)
call_label = call.left_hand_side
call_assign... | python | {
"resource": ""
} |
q30818 | StmtVisitor.loop_node_skeleton | train | def loop_node_skeleton(self, test, node):
"""Common handling of looped structures, while and for."""
body_connect_stmts = self.stmt_star_handler(
node.body,
prev_node_to_avoid=self.nodes[-1]
)
test.connect(body_connect_stmts.first_statement)
test.connect_... | python | {
"resource": ""
} |
q30819 | StmtVisitor.process_loop_funcs | train | def process_loop_funcs(self, comp_n, loop_node):
"""
If the loop test node contains function calls, it connects the loop node to the nodes of
those function calls.
:param comp_n: The test node of a loop that may contain functions.
:param loop_node: The loop node itself to connec... | python | {
"resource": ""
} |
q30820 | StmtVisitor.from_directory_import | train | def from_directory_import(
self,
module,
real_names,
local_names,
import_alias_mapping,
skip_init=False
):
"""
Directories don't need to be packages.
"""
module_path = module[1]
init_file_location = os.path.join(module_path... | python | {
"resource": ""
} |
q30821 | StmtVisitor.handle_relative_import | train | def handle_relative_import(self, node):
"""
from A means node.level == 0
from . import B means node.level == 1
from .A means node.level == 1
"""
no_file = os.path.abspath(os.path.join(self.filenames[-1], os.pardir))
skip_init = False
if node.l... | python | {
"resource": ""
} |
q30822 | ExprVisitor.save_local_scope | train | def save_local_scope(
self,
line_number,
saved_function_call_index
):
"""Save the local scope before entering a function call by saving all the LHS's of assignments so far.
Args:
line_number(int): Of the def of the function call about to be entered into.
... | python | {
"resource": ""
} |
q30823 | ExprVisitor.save_def_args_in_temp | train | def save_def_args_in_temp(
self,
call_args,
def_args,
line_number,
saved_function_call_index,
first_node
):
"""Save the arguments of the definition being called. Visit the arguments if they're calls.
Args:
call_args(list[ast.Name]): Of the... | python | {
"resource": ""
} |
q30824 | ExprVisitor.create_local_scope_from_def_args | train | def create_local_scope_from_def_args(
self,
call_args,
def_args,
line_number,
saved_function_call_index
):
"""Create the local scope before entering the body of a function call.
Args:
call_args(list[ast.Name]): Of the call being made.
... | python | {
"resource": ""
} |
q30825 | ExprVisitor.visit_and_get_function_nodes | train | def visit_and_get_function_nodes(
self,
definition,
first_node
):
"""Visits the nodes of a user defined function.
Args:
definition(LocalModuleDefinition): Definition of the function being added.
first_node(EntryOrExitNode or None or RestoreNode): Used... | python | {
"resource": ""
} |
q30826 | ExprVisitor.restore_saved_local_scope | train | def restore_saved_local_scope(
self,
saved_variables,
args_mapping,
line_number
):
"""Restore the previously saved variables to their original values.
Args:
saved_variables(list[SavedVariable])
args_mapping(dict): A mapping of call argument to d... | python | {
"resource": ""
} |
q30827 | ExprVisitor.return_handler | train | def return_handler(
self,
call_node,
function_nodes,
saved_function_call_index,
first_node
):
"""Handle the return from a function during a function call.
Args:
call_node(ast.Call) : The node that calls the definition.
function_nodes(l... | python | {
"resource": ""
} |
q30828 | ExprVisitor.process_function | train | def process_function(self, call_node, definition):
"""Processes a user defined function when it is called.
Increments self.function_call_index each time it is called, we can refer to it as N in the comments.
Make e.g. save_N_LHS = assignment.LHS for each AssignmentNode. (save_local_scope)
... | python | {
"resource": ""
} |
q30829 | report | train | def report(
vulnerabilities,
fileobj,
print_sanitised,
):
"""
Prints issues in color-coded text format.
Args:
vulnerabilities: list of vulnerabilities to report
fileobj: The output file object, which may be sys.stdout
"""
n_vulnerabilities = len(vulnerabilities)
unsa... | python | {
"resource": ""
} |
q30830 | FixedPointAnalysis.fixpoint_runner | train | def fixpoint_runner(self):
"""Work list algorithm that runs the fixpoint algorithm."""
q = self.cfg.nodes
while q != []:
x_i = constraint_table[q[0]] # x_i = q[0].old_constraint
self.analysis.fixpointmethod(q[0]) # y = | python | {
"resource": ""
} |
q30831 | parse | train | def parse(trigger_word_file):
"""Parse the file for source and sink definitions.
Returns:
A definitions tuple with sources and sinks.
"""
with open(trigger_word_file) as fd:
triggers_dict = json.load(fd)
sources = [Source(s) for s in triggers_dict['sources']]
sinks = [
| python | {
"resource": ""
} |
q30832 | Node.connect | train | def connect(self, successor):
"""Connect this node to its successor node by
setting its outgoing and the successors ingoing."""
if | python | {
"resource": ""
} |
q30833 | Node.connect_predecessors | train | def connect_predecessors(self, predecessors):
"""Connect all nodes in predecessors to this node."""
for n in predecessors:
| python | {
"resource": ""
} |
q30834 | ModuleDefinitions.append_if_local_or_in_imports | train | def append_if_local_or_in_imports(self, definition):
"""Add definition to list.
Handles local definitions and adds to project_definitions.
"""
if isinstance(definition, LocalModuleDefinition):
self.definitions.append(definition)
elif self.import_names == ["*"]:
... | python | {
"resource": ""
} |
q30835 | ModuleDefinitions.get_definition | train | def get_definition(self, name):
"""Get definitions by name."""
for definition in self.definitions:
| python | {
"resource": ""
} |
q30836 | ModuleDefinitions.set_definition_node | train | def set_definition_node(self, node, name):
"""Set definition by name."""
definition | python | {
"resource": ""
} |
q30837 | ReachingDefinitionsTaintAnalysis.fixpointmethod | train | def fixpointmethod(self, cfg_node):
"""The most important part of PyT, where we perform
the variant of reaching definitions to find where sources reach.
"""
JOIN = self.join(cfg_node)
# Assignment check
if isinstance(cfg_node, AssignmentNode):
arrow_result = J... | python | {
"resource": ""
} |
q30838 | ReachingDefinitionsTaintAnalysis.arrow | train | def arrow(self, JOIN, _id):
"""Removes all previous assignments from JOIN that have the same left hand side.
This represents the arrow id definition from Schwartzbach."""
r = JOIN
| python | {
"resource": ""
} |
q30839 | identify_triggers | train | def identify_triggers(
cfg,
sources,
sinks,
lattice,
nosec_lines
):
"""Identify sources, sinks and sanitisers in a CFG.
Args:
cfg(CFG): CFG to find sources, sinks and sanitisers in.
sources(tuple): list of sources, a source is a (source, sanitiser) tuple.
sinks(tuple... | python | {
"resource": ""
} |
q30840 | find_secondary_sources | train | def find_secondary_sources(
assignment_nodes,
sources,
lattice
):
"""
Sets the secondary_nodes attribute of each source in the sources list.
Args:
assignment_nodes([AssignmentNode])
sources([tuple])
| python | {
"resource": ""
} |
q30841 | find_triggers | train | def find_triggers(
nodes,
trigger_words,
nosec_lines
):
"""Find triggers from the trigger_word_list in the nodes.
Args:
nodes(list[Node]): the nodes to find triggers in.
trigger_word_list(list[Union[Sink, Source]]): list of trigger words to look for.
nosec_lines(set): lines ... | python | {
"resource": ""
} |
q30842 | label_contains | train | def label_contains(
node,
triggers
):
"""Determine if node contains any of the trigger_words provided.
Args:
node(Node): CFG node to check.
trigger_words(list[Union[Sink, Source]]): list of trigger words to look for.
Returns:
Iterable of TriggerNodes found. Can be multiple ... | python | {
"resource": ""
} |
q30843 | build_sanitiser_node_dict | train | def build_sanitiser_node_dict(
cfg,
sinks_in_file
):
"""Build a dict of string -> TriggerNode pairs, where the string
is the sanitiser and the TriggerNode is a TriggerNode of the sanitiser.
Args:
cfg(CFG): cfg to traverse.
sinks_in_file(list[TriggerNode]): list of TriggerNodes co... | python | {
"resource": ""
} |
q30844 | find_sanitiser_nodes | train | def find_sanitiser_nodes(
sanitiser,
sanitisers_in_file
):
"""Find nodes containing a particular sanitiser.
Args:
sanitiser(string): sanitiser to look for.
sanitisers_in_file(list[Node]): list of CFG nodes with the sanitiser.
Returns:
Iterable of sanitiser nodes.
"""
| python | {
"resource": ""
} |
q30845 | get_vulnerability_chains | train | def get_vulnerability_chains(
current_node,
sink,
def_use,
chain=[]
):
"""Traverses the def-use graph to find all paths from source to sink that cause a vulnerability.
Args:
current_node()
sink()
def_use(dict):
chain(list(Node)): A path | python | {
"resource": ""
} |
q30846 | how_vulnerable | train | def how_vulnerable(
chain,
blackbox_mapping,
sanitiser_nodes,
potential_sanitiser,
blackbox_assignments,
interactive,
vuln_deets
):
"""Iterates through the chain of nodes and checks the blackbox nodes against the blackbox mapping and sanitiser dictionary.
Note: potential_sanitiser i... | python | {
"resource": ""
} |
q30847 | get_vulnerability | train | def get_vulnerability(
source,
sink,
triggers,
lattice,
cfg,
interactive,
blackbox_mapping
):
"""Get vulnerability between source and sink if it exists.
Uses triggers to find sanitisers.
Note: When a secondary node is in_constraint with the sink
but not the source... | python | {
"resource": ""
} |
q30848 | find_vulnerabilities_in_cfg | train | def find_vulnerabilities_in_cfg(
cfg,
definitions,
lattice,
blackbox_mapping,
vulnerabilities_list,
interactive,
nosec_lines
):
"""Find vulnerabilities in a cfg.
Args:
cfg(CFG): The CFG to find vulnerabilities in.
definitions(trigger_definitions_parser.Definitions): ... | python | {
"resource": ""
} |
q30849 | find_vulnerabilities | train | def find_vulnerabilities(
cfg_list,
blackbox_mapping_file,
sources_and_sinks_file,
interactive=False,
nosec_lines=defaultdict(set)
):
"""Find vulnerabilities in a list of CFGs from a trigger_word_file.
Args:
cfg_list(list[CFG]): the list of CFGs to scan.
blackbox_mapping_fil... | python | {
"resource": ""
} |
q30850 | _get_func_nodes | train | def _get_func_nodes():
"""Get all function nodes."""
return [definition | python | {
"resource": ""
} |
q30851 | FrameworkAdaptor.get_func_cfg_with_tainted_args | train | def get_func_cfg_with_tainted_args(self, definition):
"""Build a function cfg and return it, with all arguments tainted."""
log.debug("Getting CFG for %s", definition.name)
func_cfg = make_cfg(
definition.node,
self.project_modules,
self.local_modules,
... | python | {
"resource": ""
} |
q30852 | FrameworkAdaptor.find_route_functions_taint_args | train | def find_route_functions_taint_args(self):
"""Find all route functions and taint all of their arguments.
Yields:
CFG of each route function, with args marked as tainted.
"""
for definition in _get_func_nodes():
| python | {
"resource": ""
} |
q30853 | FrameworkAdaptor.run | train | def run(self):
"""Run find_route_functions_taint_args on each CFG."""
function_cfgs = list()
for _ in self.cfg_list:
| python | {
"resource": ""
} |
q30854 | initialize_constraint_table | train | def initialize_constraint_table(cfg_list):
"""Collects all given cfg nodes and initializes the table with value 0."""
| python | {
"resource": ""
} |
q30855 | constraint_join | train | def constraint_join(cfg_nodes):
"""Looks up all cfg_nodes and joins the bitvectors by using logical or."""
r = 0
for e in | python | {
"resource": ""
} |
q30856 | store_uploaded_file | train | def store_uploaded_file(title, uploaded_file):
""" Stores a temporary uploaded file on disk """
upload_dir_path = '%s/static/taskManager/uploads' % (
os.path.dirname(os.path.realpath(__file__)))
if not os.path.exists(upload_dir_path):
os.makedirs(upload_dir_path)
# A1: Injection (shell)... | python | {
"resource": ""
} |
q30857 | return_connection_handler | train | def return_connection_handler(nodes, exit_node):
"""Connect all return statements to the Exit node."""
for function_body_node in nodes:
if isinstance(function_body_node, ConnectToExitNode):
| python | {
"resource": ""
} |
q30858 | get_my_choices_users | train | def get_my_choices_users():
""" Retrieves a list of all users in the system
for the user management page
"""
user_list = User.objects.order_by('date_joined')
user_tuple = []
counter = 1
| python | {
"resource": ""
} |
q30859 | get_my_choices_tasks | train | def get_my_choices_tasks(current_proj):
""" Retrieves all tasks in the system
for the task management page
"""
task_list = []
tasks = Task.objects.all()
for task in tasks:
if task.project == current_proj:
task_list.append(task)
| python | {
"resource": ""
} |
q30860 | get_my_choices_projects | train | def get_my_choices_projects():
""" Retrieves all projects in the system
for the project management page
"""
proj_list = Project.objects.all()
proj_tuple = []
counter = 1
| python | {
"resource": ""
} |
q30861 | as_alias_handler | train | def as_alias_handler(alias_list):
"""Returns a list of all the names that will be called."""
list_ = list()
for alias in alias_list:
if alias.asname: | python | {
"resource": ""
} |
q30862 | handle_fdid_aliases | train | def handle_fdid_aliases(module_or_package_name, import_alias_mapping):
"""Returns either None or the handled alias.
Used in add_module.
fdid means from directory import directory.
"""
| python | {
"resource": ""
} |
q30863 | not_as_alias_handler | train | def not_as_alias_handler(names_list):
"""Returns a list of names ignoring any | python | {
"resource": ""
} |
q30864 | retrieve_import_alias_mapping | train | def retrieve_import_alias_mapping(names_list):
"""Creates a dictionary mapping aliases to their respective name.
import_alias_names is used in module_definitions.py and visit_Call"""
import_alias_names = dict()
for alias | python | {
"resource": ""
} |
q30865 | fully_qualify_alias_labels | train | def fully_qualify_alias_labels(label, aliases):
"""Replace any aliases in label with the fully qualified name.
Args:
label -- A label : str representing a name (e.g. myos.system)
aliases -- A dict of {alias: real_name} (e.g. {'myos': 'os'})
>>> fully_qualify_alias_labels('myos.mycall', {'m... | python | {
"resource": ""
} |
q30866 | _convert_to_3 | train | def _convert_to_3(path): # pragma: no cover
"""Convert python 2 file to python 3."""
try:
log.warn('##### Trying to convert %s to Python 3. #####', path)
subprocess.call(['2to3', '-w', path])
| python | {
"resource": ""
} |
q30867 | generate_ast | train | def generate_ast(path):
"""Generate an Abstract Syntax Tree using the ast module.
Args:
path(str): The path to the file e.g. example/foo/bar.py
"""
if os.path.isfile(path):
with open(path, 'r') as f:
try:
tree = ast.parse(f.read())
ret... | python | {
"resource": ""
} |
q30868 | _get_call_names_helper | train | def _get_call_names_helper(node):
"""Recursively finds all function names."""
if isinstance(node, ast.Name):
if node.id not in BLACK_LISTED_CALL_NAMES:
yield node.id
elif isinstance(node, ast.Subscript):
yield from _get_call_names_helper(node.value) | python | {
"resource": ""
} |
q30869 | is_flask_route_function | train | def is_flask_route_function(ast_node):
"""Check whether function uses a route decorator."""
for decorator in ast_node.decorator_list:
if isinstance(decorator, ast.Call):
| python | {
"resource": ""
} |
q30870 | _cache_normalize_path | train | def _cache_normalize_path(path):
"""abspath with caching"""
# _module_file calls abspath on every path in sys.path every time it's
# called; on a larger codebase this easily adds up to half a second just
# assembling path components. This cache alleviates that.
try:
return _NORM_PATH_CACHE[p... | python | {
"resource": ""
} |
q30871 | load_module_from_name | train | def load_module_from_name(dotted_name, path=None, use_sys=True):
"""Load a Python module from its name.
:type dotted_name: str
:param dotted_name: python name of a module or package
:type path: list or None
:param path:
optional list of path where the module or package should be
search... | python | {
"resource": ""
} |
q30872 | load_module_from_modpath | train | def load_module_from_modpath(parts, path=None, use_sys=1):
"""Load a python module from its split name.
:type parts: list(str) or tuple(str)
:param parts:
python name of a module or package split on '.'
:type path: list or None
:param path:
optional list of path where the module or pac... | python | {
"resource": ""
} |
q30873 | load_module_from_file | train | def load_module_from_file(filepath, path=None, use_sys=True, extrapath=None):
"""Load a Python module from it's path.
:type filepath: str
:param filepath: path to the python module or package
:type path: list or None
:param path:
optional list of path where the module or package should be
... | python | {
"resource": ""
} |
q30874 | _get_relative_base_path | train | def _get_relative_base_path(filename, path_to_check):
"""Extracts the relative mod path of the file to import from
Check if a file is within the passed in path and if so, returns the
relative mod path from the one passed in.
If the filename is no in path_to_check, returns None
Note this function ... | python | {
"resource": ""
} |
q30875 | get_module_files | train | def get_module_files(src_directory, blacklist, list_all=False):
"""given a package directory return a list of all available python
module's files in the package and its subpackages
:type src_directory: str
:param src_directory:
path of the directory corresponding to the package
:type blackli... | python | {
"resource": ""
} |
q30876 | is_relative | train | def is_relative(modname, from_file):
"""return true if the given module name is relative to the given
file name
:type modname: str
:param modname: name of the module we are interested in
:type from_file: str
:param from_file:
path of the module from which modname has been imported
:... | python | {
"resource": ""
} |
q30877 | BaseInstance._wrap_attr | train | def _wrap_attr(self, attrs, context=None):
"""wrap bound methods of attrs in a InstanceMethod proxies"""
for attr in attrs:
if isinstance(attr, UnboundMethod):
if _is_property(attr):
yield from attr.infer_call_result(self, context)
else:
... | python | {
"resource": ""
} |
q30878 | BaseInstance.infer_call_result | train | def infer_call_result(self, caller, context=None):
"""infer what a class instance is returning when called"""
context = contextmod.bind_context_to_node(context, self)
inferred = False
for node in self._proxied.igetattr("__call__", context):
if node is util.Uninferable or not ... | python | {
"resource": ""
} |
q30879 | Instance.bool_value | train | def bool_value(self):
"""Infer the truth value for an Instance
The truth value of an instance is determined by these conditions:
* if it implements __bool__ on Python 3 or __nonzero__
on Python 2, then its bool value will be determined by
calling this special metho... | python | {
"resource": ""
} |
q30880 | ObjectModel.attributes | train | def attributes(self):
"""Get the attributes which are exported by this object model."""
return [
| python | {
"resource": ""
} |
q30881 | infer_func_form | train | def infer_func_form(node, base_type, context=None, enum=False):
"""Specific inference function for namedtuple or Python 3 enum. """
# node is a Call node, class name as first argument and generated class
# attributes as second argument
# namedtuple or enums list of attributes can be a list of strings o... | python | {
"resource": ""
} |
q30882 | infer_enum | train | def infer_enum(node, context=None):
""" Specific inference function for enum Call node. """
enum_meta = extract_node(
"""
class EnumMeta(object):
'docstring'
def __call__(self, node):
class EnumAttribute(object):
name = ''
value = 0
... | python | {
"resource": ""
} |
q30883 | infer_typing_namedtuple_class | train | def infer_typing_namedtuple_class(class_node, context=None):
"""Infer a subclass of typing.NamedTuple"""
# Check if it has the corresponding bases
annassigns_fields = [
annassign.target.name
for annassign in class_node.body
if isinstance(annassign, nodes.AnnAssign)
]
code = d... | python | {
"resource": ""
} |
q30884 | _visit_or_none | train | def _visit_or_none(node, attr, visitor, parent, visit="visit", **kws):
"""If the given node has an attribute, visits the attribute, and
otherwise returns None.
"""
| python | {
"resource": ""
} |
q30885 | TreeRebuilder.visit_module | train | def visit_module(self, node, modname, modpath, package):
"""visit a Module node by returning a fresh instance of it"""
node, doc = self._get_doc(node)
newnode = nodes.Module(
| python | {
"resource": ""
} |
q30886 | TreeRebuilder._save_assignment | train | def _save_assignment(self, node, name=None):
"""save assignement situation since node.parent is not available yet"""
if self._global_names and node.name in self._global_names[-1]:
| python | {
"resource": ""
} |
q30887 | TreeRebuilder.visit_arguments | train | def visit_arguments(self, node, parent):
"""visit an Arguments node by returning a fresh instance of it"""
vararg, kwarg = node.vararg, node.kwarg
if PY34:
newnode = nodes.Arguments(
vararg.arg if vararg else None, kwarg.arg if kwarg else None, parent
)
... | python | {
"resource": ""
} |
q30888 | TreeRebuilder.visit_assert | train | def visit_assert(self, node, parent):
"""visit a Assert node by returning a fresh instance of it"""
newnode = nodes.Assert(node.lineno, node.col_offset, parent)
if node.msg:
msg = self.visit(node.msg, newnode)
| python | {
"resource": ""
} |
q30889 | TreeRebuilder.visit_assign | train | def visit_assign(self, node, parent):
"""visit a Assign node by returning a fresh instance of it"""
type_annotation = self.check_type_comment(node)
newnode = nodes.Assign(node.lineno, node.col_offset, parent)
newnode.postinit(
| python | {
"resource": ""
} |
q30890 | TreeRebuilder.visit_assignname | train | def visit_assignname(self, node, parent, node_name=None):
"""visit a node and return a AssignName node"""
newnode = nodes.AssignName(
node_name,
getattr(node, "lineno", None),
| python | {
"resource": ""
} |
q30891 | TreeRebuilder.visit_augassign | train | def visit_augassign(self, node, parent):
"""visit a AugAssign node by returning a fresh instance of it"""
newnode = nodes.AugAssign(
self._bin_op_classes[type(node.op)] + "=",
node.lineno,
node.col_offset,
| python | {
"resource": ""
} |
q30892 | TreeRebuilder.visit_repr | train | def visit_repr(self, node, parent):
"""visit a Backquote node by returning a fresh instance of it"""
newnode = nodes.Repr(node.lineno, node.col_offset, parent)
| python | {
"resource": ""
} |
q30893 | TreeRebuilder.visit_binop | train | def visit_binop(self, node, parent):
"""visit a BinOp node by returning a fresh instance of it"""
newnode = nodes.BinOp(
self._bin_op_classes[type(node.op)], node.lineno, node.col_offset, parent
)
| python | {
"resource": ""
} |
q30894 | TreeRebuilder.visit_boolop | train | def visit_boolop(self, node, parent):
"""visit a BoolOp node by returning a fresh instance of it"""
newnode = nodes.BoolOp(
self._bool_op_classes[type(node.op)], node.lineno, node.col_offset, parent
| python | {
"resource": ""
} |
q30895 | TreeRebuilder.visit_break | train | def visit_break(self, node, parent):
"""visit a Break node by returning a fresh instance of it"""
return nodes.Break(
| python | {
"resource": ""
} |
q30896 | TreeRebuilder.visit_call | train | def visit_call(self, node, parent):
"""visit a CallFunc node by returning a fresh instance of it"""
newnode = nodes.Call(node.lineno, node.col_offset, parent)
starargs = _visit_or_none(node, "starargs", self, newnode)
kwargs = _visit_or_none(node, "kwargs", self, newnode)
args = ... | python | {
"resource": ""
} |
q30897 | TreeRebuilder.visit_classdef | train | def visit_classdef(self, node, parent, newstyle=None):
"""visit a ClassDef node to become astroid"""
node, doc = self._get_doc(node)
newnode = nodes.ClassDef(node.name, doc, node.lineno, node.col_offset, parent)
metaclass = None
if PY3:
for keyword in node.keywords:
... | python | {
"resource": ""
} |
q30898 | TreeRebuilder.visit_const | train | def visit_const(self, node, parent):
"""visit a Const node by returning a fresh instance of it"""
| python | {
"resource": ""
} |
q30899 | TreeRebuilder.visit_continue | train | def visit_continue(self, node, parent):
"""visit a Continue node by returning a fresh instance of it"""
return nodes.Continue(
| python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.