class CodeInspection: (source)
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 |
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_class |
Undocumented |
Method | inspect |
Undocumented |
Method | inspect |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
Undocumented |
Instance Variable | body |
Undocumented |
Instance Variable | class |
Undocumented |
Instance Variable | classes |
Undocumented |
Instance Variable | control |
Undocumented |
Instance Variable | data |
Undocumented |
Instance Variable | dep |
Undocumented |
Instance Variable | file |
Undocumented |
Instance Variable | file |
Undocumented |
Instance Variable | funcs |
Undocumented |
Instance Variable | nodes |
Undocumented |
Instance Variable | out |
Undocumented |
Instance Variable | out |
Undocumented |
Instance Variable | parser |
Undocumented |
Instance Variable | path |
Undocumented |
Instance Variable | source |
Undocumented |
Instance Variable | tree |
Undocumented |
Method | _ast |
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 |
Function that returns True if the file is a test |
Method | _check |
Undocumented |
Method | _compute |
_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 |
Undocumented |
Method | _f |
_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 |
:param type: 1 represents body, 2 represents re_fill_call, 3 represents nested call |
Method | _format |
_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 |
Undocumented |
Method | _get |
_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 |
Undocumented |
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.
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)
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
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
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)
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
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
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
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
re fill call list, :param self self: represent the instance of the class :return dictionary: a dictionary with the all classes information extracted
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.
_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
_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
:param type: 1 represents body, 2 represents re_fill_call, 3 represents nested call
_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