def makeModuleSource( tree ):
    generator_module = Generator.PythonModuleGenerator(
        module_name = tree.getName(),
    )

    _prepareCodeGeneration( tree )

    source_code = CodeGeneration.generateModuleCode(
        module         = tree,
        module_name    = tree.getName(),
        generator      = generator_module,
        global_context = Contexts.PythonGlobalContext(),
        stand_alone    = True
    )

    return source_code
def makeMainSource( tree ):
    generator_module = Generator.PythonModuleGenerator(
        module_name = "__main__",
    )

    other_modules = TreeBuilding.getOtherModules()

    if tree in other_modules:
        other_modules.remove( tree )

    for module in other_modules:
        _prepareCodeGeneration( module )

    _prepareCodeGeneration( tree )

    source_code = CodeGeneration.generateExecutableCode(
        main_module   = tree,
        other_modules = other_modules,
        generator     = generator_module
    )

    return source_code