Skip to content
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
Cannot retrieve contributors at this time
from astmonkey.transformers import ParentNodeTransformer
from inliner.searcher import InlineMethodLocator
from inliner.transformer import FunctionInliner
import sys
import imp
import ast
class InlineLoader(object):
def __init__(self, module):
self.module = module
def load_module(self, fullname):
return self.module
class InlineImporter(object):
def find_module(self, fullname, path):
file, pathname, description = imp.find_module(
fullname.split(".")[-1], path)
src =
tree = ast.parse(src)
tree = ParentNodeTransformer().visit(tree)
function_disoverer = InlineMethodLocator()
print "found funcs: %s" % function_disoverer.functions
tree = FunctionInliner(function_disoverer.functions).visit(tree)
module = sys.modules.setdefault(fullname,
module.__package__ = fullname.rpartition('.')[0]
module.__file__ =
tree = ast.fix_missing_locations(tree)
code = compile(tree,, "exec")
exec code in module.__dict__
return InlineLoader(module)