How to use the astor.code_to_ast function in astor

To help you get started, we’ve selected a few astor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github fake-name / ChromeController / test_dump_ast.py View on Github external
def docstring_dbg():
	print(astor.dump_tree(astor.code_to_ast(func)))
github bsc-wdc / compss / compss / programming_model / bindings / tmp / python / src / pycompss / util / translators / py2pycompss / translator_py2pycompss.py View on Github external
:param par_py_files: List of files containing the Python parallelization of each for block in the func_source
        :param output: PyCOMPSs file path
        :param taskify_loop_level: Loop depth to perform taskification (default None)
        :raise Py2PyCOMPSsException:
        """

        if __debug__:
            logger.debug("[Py2PyCOMPSs] Initialize translation")
            logger.debug("[Py2PyCOMPSs]  - Function: " + str(func))
            for par_f in par_py_files:
                logger.debug("[Py2PyCOMPSs]  - File: " + str(par_f))
            logger.debug("[Py2PyCOMPSs]  - Output: " + str(output))

        # Load user function code
        import astor
        func_ast = astor.code_to_ast(func)

        # Initialize output content
        output_imports = []
        task2headers = {}
        task2func_code = {}
        output_loops_code = []
        task_counter_id = 0

        # Process each par_py file
        for par_py in par_py_files:
            # Retrieve file AST
            par_py_ast = astor.code_to_ast.parse_file(par_py)

            # Process ast
            output_code = []
            task2new_name = {}