class documentation

class CodeInspection: (source)

View In Hierarchy

Undocumented

Method __init__ init method initializes the Code_Inspection object :param self self: represent the instance of the class :param str path: the file to inspect :param str out_control_flow_path: the output directory to store the control flow information :param str out_json_path: the output directory to store the json file with features extracted from the ast tree...
Method file_json file_json method aggregates all the features previously extracted from a given file such as, functions, classes and dependencies levels into the same dictionary.
Method find_classDef Undocumented
Method inspect_body Undocumented
Method inspect_classes inspect_classes detects all the classes and their methods, and extracts their features. It also calls to _f_definitions method to extract features at method level. The features extracted are name, docstring (this information is further analysed and classified into several categories), extends, start and end of the line and methods...
Method inspect_classes_funcs inspect classes and functions and detects all the functions, classes and their methods, and features. :param self self: represent the instance of the class :return dictionary: a dictionary with the all classes information extracted :return dictionary: a dictionary with the all functions information extracted...
Method inspect_controlflow inspect_controlFlow using CFGBuilder :param self self: represent the instance of the class :param str format: represent the format to save the figure :return dictionary: a dictionary with the all information extracted (at file level)...
Method inspect_dependencies inspect_dependencies method extracts the features at dependencies level. Those features are module , name, and alias. :param self self: represent the instance of the class :return dictionary: a dictionary with the all dependencies information extracted...
Method inspect_file inspect_file method extracts the features at file level. Those features are path, fileNameBase, extension, docstring. The method support several levels of docstrings extraction, such as file's long, short a full descrition...
Method inspect_functions inspect_functions detects all the functions in a AST tree, and calls to _f_definitions method to extracts all the features at function level. :param self self: represent the instance of the class :param classes_info: information about the classes in the program :return dictionary: a dictionary with the all functions information extracted...
Method parser_file parse_file method parsers a file as an AST tree :param self self: represent the instance of the class :return ast.tree: the file as an ast tree
Method re_fill_call_list re fill call list, :param self self: represent the instance of the class :return dictionary: a dictionary with the all classes information extracted
Method walk recursivly traverses through self.tree and return all resultant nodes
Instance Variable abstract_syntax_tree Undocumented
Instance Variable bodyInfo Undocumented
Instance Variable class_init Undocumented
Instance Variable classesInfo Undocumented
Instance Variable controlFlowInfo Undocumented
Instance Variable data_flow Undocumented
Instance Variable depInfo Undocumented
Instance Variable fileInfo Undocumented
Instance Variable fileJson Undocumented
Instance Variable funcsInfo Undocumented
Instance Variable nodes Undocumented
Instance Variable out_control_flow_path Undocumented
Instance Variable out_json_path Undocumented
Instance Variable parser Undocumented
Instance Variable path Undocumented
Instance Variable source_code Undocumented
Instance Variable tree Undocumented
Method _ast_if_main Method for getting if the file has a if __name__ == "__main__" and if it calls a method (e.g. main, version) or not. :param self self: represent the instance of the class :return main_info : dictionary with a flag stored in "main_flag" (1 if the if __name__ == main is found, 0 otherwise) and then "main_function" with the name of the function that is called.
Method _ast_if_test Function that returns True if the file is a test
Method _check_dynamic_calls Undocumented
Method _compute_interval _compute_interval extract the lines (min and max) for a given class, function or method. :param self self: represent the instance of the class :param ast.node node: AST node :return set: min and max lines...
Method _dfs Undocumented
Method _dynamic_calls Undocumented
Method _f_definitions _f_definitions extracts the name, args, docstring returns, raises of a list of functions or a methods. Furthermore, it also extracts automatically several values from a docstring, such as long and short description, arguments' name, description, type, default values and if it they are optional or not...
Method _fill_call_name :param type: 1 represents body, 2 represents re_fill_call, 3 represents nested call
Method _formatFlow _formatFlow reformats the control flow output as a text. :param self self: represent the instance of the class :param cfg_graph s: control flow graph :return str: cfg formated as a text
Method _get_func_name Undocumented
Method _get_ids _get_ids extracts identifiers if present. If not return None :param self self: represent the instance of the class :param ast.node elt: AST node :return list: list of identifiers
Method _skip_dynamic_calls Undocumented
def __init__(self, path, out_control_flow_path, out_json_path, control_flow, abstract_syntax_tree, source_code, data_flow, parser): (source)

init method initializes the Code_Inspection object :param self self: represent the instance of the class :param str path: the file to inspect :param str out_control_flow_path: the output directory to store the control flow information :param str out_json_path: the output directory to store the json file with features extracted from the ast tree. :param bool control_flow: boolean to indicate to generate the control flow :param bool abstract_syntax_tree: boolean to indicate to generate ast in json format :param bool source_code: boolean to indicate to generate source code of each ast node.

def file_json(self): (source)

file_json method aggregates all the features previously extracted from a given file such as, functions, classes and dependencies levels into the same dictionary. It also writes this new dictionary to a json file. :param self self: represent the instance of the class :return dictionary: a dictionary with the all information extracted (at file level)

def find_classDef(self): (source)

Undocumented

def inspect_body(self): (source)

Undocumented

def inspect_classes(self): (source)

inspect_classes detects all the classes and their methods, and extracts their features. It also calls to _f_definitions method to extract features at method level. The features extracted are name, docstring (this information is further analysed and classified into several categories), extends, start and end of the line and methods. :param self self: represent the instance of the class :return dictionary: a dictionary with the all classes information extracted

def inspect_classes_funcs(self): (source)

inspect classes and functions and detects all the functions, classes and their methods, and features. :param self self: represent the instance of the class :return dictionary: a dictionary with the all classes information extracted :return dictionary: a dictionary with the all functions information extracted

def inspect_controlflow(self, format): (source)

inspect_controlFlow using CFGBuilder :param self self: represent the instance of the class :param str format: represent the format to save the figure :return dictionary: a dictionary with the all information extracted (at file level)

def inspect_dependencies(self): (source)

inspect_dependencies method extracts the features at dependencies level. Those features are module , name, and alias. :param self self: represent the instance of the class :return dictionary: a dictionary with the all dependencies information extracted

def inspect_file(self): (source)

inspect_file method extracts the features at file level. Those features are path, fileNameBase, extension, docstring. The method support several levels of docstrings extraction, such as file's long, short a full descrition. :param self self: represent the instance of the class :return dictionary a dictionary with the file information extracted

def inspect_functions(self, classes_info): (source)

inspect_functions detects all the functions in a AST tree, and calls to _f_definitions method to extracts all the features at function level. :param self self: represent the instance of the class :param classes_info: information about the classes in the program :return dictionary: a dictionary with the all functions information extracted

def parser_file(self): (source)

parse_file method parsers a file as an AST tree :param self self: represent the instance of the class :return ast.tree: the file as an ast tree

def re_fill_call_list(self, classes_info, funcs_info): (source)

re fill call list, :param self self: represent the instance of the class :return dictionary: a dictionary with the all classes information extracted

def walk(self): (source)

recursivly traverses through self.tree and return all resultant nodes

abstract_syntax_tree = (source)

Undocumented

bodyInfo = (source)

Undocumented

class_init = (source)

Undocumented

classesInfo = (source)

Undocumented

controlFlowInfo = (source)

Undocumented

data_flow = (source)

Undocumented

Undocumented

fileInfo = (source)

Undocumented

fileJson = (source)

Undocumented

funcsInfo = (source)

Undocumented

Undocumented

out_control_flow_path = (source)

Undocumented

out_json_path = (source)

Undocumented

Undocumented

Undocumented

source_code = (source)

Undocumented

Undocumented

def _ast_if_main(self): (source)

Method for getting if the file has a if __name__ == "__main__" and if it calls a method (e.g. main, version) or not. :param self self: represent the instance of the class :return main_info : dictionary with a flag stored in "main_flag" (1 if the if __name__ == main is found, 0 otherwise) and then "main_function" with the name of the function that is called.

def _ast_if_test(self): (source)

Function that returns True if the file is a test

def _check_dynamic_calls(self, functions_defintions, funcs_info, classes_info, type=1): (source)

Undocumented

def _compute_interval(self, node): (source)

_compute_interval extract the lines (min and max) for a given class, function or method. :param self self: represent the instance of the class :param ast.node node: AST node :return set: min and max lines

def _dfs(self, extend, rest_call_name, renamed, classes_info, renamed_calls): (source)

Undocumented

def _dynamic_calls(self, f_args, f_name_id, funcs_info, classes_info, store_vars={}): (source)

Undocumented

def _f_definitions(self, functions_definitions): (source)

_f_definitions extracts the name, args, docstring returns, raises of a list of functions or a methods. Furthermore, it also extracts automatically several values from a docstring, such as long and short description, arguments' name, description, type, default values and if it they are optional or not. :param self self: represent the instance of the class :param list functions_definitions: represent a list with all functions or methods nodes :return dictionary: a dictionary with the all the information at function/method level

def _fill_call_name(self, function_definition_info, classes_info, class_name='', extend=[], type=0, additional_info={}): (source)

:param type: 1 represents body, 2 represents re_fill_call, 3 represents nested call

def _formatFlow(self, s): (source)

_formatFlow reformats the control flow output as a text. :param self self: represent the instance of the class :param cfg_graph s: control flow graph :return str: cfg formated as a text

def _get_func_name(self, func): (source)

Undocumented

def _get_ids(self, elt): (source)

_get_ids extracts identifiers if present. If not return None :param self self: represent the instance of the class :param ast.node elt: AST node :return list: list of identifiers

def _skip_dynamic_calls(self, funcs_info, classes_info, check_name, name, var_name): (source)

Undocumented