method: path.local.pyimport

 return path as an imported python module.
            if modname is None, look for the containing package
            and construct an according module name.
            The module will be put/looked up in sys.modules.
        
    def pyimport(self, modname=None, ensuresyspath=True):

origin: path.local

where:

exceptions that might appear during execution:

function source:

def pyimport(self, modname=None, ensuresyspath=True):
    """ return path as an imported python module.
            if modname is None, look for the containing package
            and construct an according module name.
            The module will be put/looked up in sys.modules.
        """
    if not self.check():
        raise py.error.ENOENT(self)
    #print "trying to import", self
    pkgpath = None
    if modname is None:
        #try:
        #    return self._module
        #except AttributeError:
        #    pass
        pkgpath = self.pypkgpath()
        if pkgpath is not None:
            if ensuresyspath:
                self._prependsyspath(pkgpath.dirpath())
            pkg = __import__(pkgpath.basename, None, None, [])
                
            if hasattr(pkg, '__package__'):
                modname = pkg.__package__.getimportname(self)
                assert modname is not None, "package %s doesn't know %s" % (
                                            pkg.__name__, self)
                
            else:
                names = self.new(ext='').relto(pkgpath.dirpath())
                names = names.split(self.sep)
                modname = ".".join(names)
        else:
            # no package scope, still make it possible
            if ensuresyspath:
                self._prependsyspath(self.dirpath())
            modname = self.purebasename
        mod = __import__(modname, None, None, ['__doc__'])
        #self._module = mod
        return mod
    else:
        try:
            return sys.modules[modname]
        except KeyError:
            # we have a custom modname, do a pseudo-import
            mod = py.std.new.module(modname)
            mod.__file__ = str(self)
            sys.modules[modname] = mod
            try:
                execfile(str(self), mod.__dict__)
            except:
                del sys.modules[modname]
                raise
            return mod

call sites:

called in /home/johnny/projects/merlinux/py/dist/py/test/config.py

traceback path.local.pyimport.0

called in /home/johnny/projects/merlinux/py/dist/py/apigen/source/browser.py

traceback path.local.pyimport.1

called in /home/johnny/projects/merlinux/py/dist/py/path/local/testing/test_local.py

traceback path.local.pyimport.2

called in /home/johnny/projects/merlinux/py/dist/py/test/config.py

traceback path.local.pyimport.3

called in /home/johnny/projects/merlinux/py/dist/py/path/local/testing/test_local.py

traceback path.local.pyimport.4

called in /home/johnny/projects/merlinux/py/dist/py/test/config.py

traceback path.local.pyimport.5

called in /home/johnny/projects/merlinux/py/dist/py/apigen/source/browser.py

traceback path.local.pyimport.6

called in /home/johnny/projects/merlinux/py/dist/py/test/config.py

traceback path.local.pyimport.7

called in /home/johnny/projects/merlinux/py/dist/py/apigen/source/browser.py

traceback path.local.pyimport.8

called in /home/johnny/projects/merlinux/py/dist/py/test/collect.py

traceback path.local.pyimport.9

called in /home/johnny/projects/merlinux/py/dist/py/path/local/testing/test_local.py

traceback path.local.pyimport.10

called in /home/johnny/projects/merlinux/py/dist/py/test/config.py

traceback path.local.pyimport.11

called in /home/johnny/projects/merlinux/py/dist/py/test/config.py

traceback path.local.pyimport.12

called in /home/johnny/projects/merlinux/py/dist/py/test/config.py

traceback path.local.pyimport.13

called in /home/johnny/projects/merlinux/py/dist/py/test/config.py

traceback path.local.pyimport.14

called in /home/johnny/projects/merlinux/py/dist/py/path/local/testing/test_local.py

traceback path.local.pyimport.15

called in /home/johnny/projects/merlinux/py/dist/py/test/config.py

traceback path.local.pyimport.16

called in /home/johnny/projects/merlinux/py/dist/py/path/local/testing/test_local.py

traceback path.local.pyimport.17

called in /home/johnny/projects/merlinux/py/dist/py/test/config.py

traceback path.local.pyimport.18

called in /home/johnny/projects/merlinux/py/dist/py/path/local/testing/test_local.py

traceback path.local.pyimport.19

called in /home/johnny/projects/merlinux/py/dist/py/path/local/testing/test_local.py

traceback path.local.pyimport.20