Build a PythonFile given a dotted module name like a.b.c

def from_modulename(cls, module_name):
        """
        Build a PythonFile given a dotted module name like a.b.c
        """
        # XXX make this more robust (pyc files? zip archives? etc)
        slug = module_name.replace('.', '/')
        paths = [slug + '.py', slug + '/__init__.py']

        # always search from current directory
        for base in [''] + sys.path:
            for path in paths:
                fullpath = os.path.join(base, path)
                if os.path.exists(fullpath):
                    return cls(fullpath, prefix=module_name)
        else:
            raise ValueError("Module not found: %s" % module_name)