Ejemplo n.º 1
0
    def test_python_ast_conversion_lots_of_code(self):
        modules = allSubmodules(ufora)
        filenames = []
        for m in modules:
            if '__file__' in dir(m):
                filename = m.__file__
                if filename.endswith(".pyc"):
                    filename = filename[:-4] + ".py"

                if filename.endswith(".py"):
                    filenames.append(filename)
        filenames = sorted(filenames)

        for filename in filenames:
            print filename
            with open(filename, "r") as f:
                txt = f.read()
                if txt:
                    PythonAstConverter.parseStringToPythonAst(txt)
Ejemplo n.º 2
0
    def test_python_ast_conversion_lots_of_code(self):
        modules = allSubmodules(ufora)
        filenames = []
        for m in modules:
            if '__file__' in dir(m):
                filename = m.__file__
                if filename.endswith(".pyc"):
                    filename = filename[:-4] + ".py"

                if filename.endswith(".py"):
                    filenames.append(filename)
        filenames = sorted(filenames)

        for filename in filenames:
            print filename
            with open(filename, "r") as f:
                txt = f.read()
                if txt:
                    PythonAstConverter.parseStringToPythonAst(txt)
Ejemplo n.º 3
0
    def _convertClassOrFunctionDefinitionToNativePyAst(classOrFunctionDefinition,
                                                      objectIdToObjectDefinition):
        sourceText = objectIdToObjectDefinition[classOrFunctionDefinition.sourceFileId].text

        pyAst = PythonAstConverter.parseStringToPythonAst(sourceText)

        assert pyAst is not None

        pyAst = pyAst.functionClassOrLambdaDefAtLine(classOrFunctionDefinition.lineNumber)

        assert pyAst is not None, (sourceText, classOrFunctionDefinition.lineNumber)

        return pyAst