[svn r38203] rename getpymodule/getpycodeobj to "_" methods
(which can build C modules on the fly) it's not clear they are still useful this way and they are easy to confuse with pyimport() --HG-- branch : trunk
This commit is contained in:
parent
0a79e56b40
commit
499d60c8ab
|
@ -7,4 +7,4 @@ else:
|
||||||
import py
|
import py
|
||||||
gdir = py.path.local(py.__file__).dirpath()
|
gdir = py.path.local(py.__file__).dirpath()
|
||||||
path = gdir.join('c-extension', 'greenlet', 'greenlet.c')
|
path = gdir.join('c-extension', 'greenlet', 'greenlet.c')
|
||||||
greenlet = path.getpymodule().greenlet
|
greenlet = path._getpymodule().greenlet
|
||||||
|
|
|
@ -370,14 +370,14 @@ newline will be removed from the end of each line. """
|
||||||
self.copy(target)
|
self.copy(target)
|
||||||
self.remove()
|
self.remove()
|
||||||
|
|
||||||
def getpymodule(self):
|
def _getpymodule(self):
|
||||||
"""resolve this path to a module python object. """
|
"""resolve this path to a module python object. """
|
||||||
modname = str(self)
|
modname = str(self)
|
||||||
modname = modname.replace('.', self.sep)
|
modname = modname.replace('.', self.sep)
|
||||||
try:
|
try:
|
||||||
return sys.modules[modname]
|
return sys.modules[modname]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
co = self.getpycodeobj()
|
co = self._getpycodeobj()
|
||||||
mod = py.std.new.module(modname)
|
mod = py.std.new.module(modname)
|
||||||
mod.__file__ = PathStr(self)
|
mod.__file__ = PathStr(self)
|
||||||
if self.basename == '__init__.py':
|
if self.basename == '__init__.py':
|
||||||
|
@ -390,7 +390,7 @@ newline will be removed from the end of each line. """
|
||||||
raise
|
raise
|
||||||
return mod
|
return mod
|
||||||
|
|
||||||
def getpycodeobj(self):
|
def _getpycodeobj(self):
|
||||||
""" read the path and compile it to a py.code.Code object. """
|
""" read the path and compile it to a py.code.Code object. """
|
||||||
s = self.read('rU')
|
s = self.read('rU')
|
||||||
# XXX str(self) should show up somewhere in the code's filename
|
# XXX str(self) should show up somewhere in the code's filename
|
||||||
|
@ -421,7 +421,7 @@ def relativeimport(p, name, parent=None):
|
||||||
p = p.new(basename=name).join('__init__.py')
|
p = p.new(basename=name).join('__init__.py')
|
||||||
if not p.check():
|
if not p.check():
|
||||||
return None # not found
|
return None # not found
|
||||||
submodule = p.getpymodule()
|
submodule = p._getpymodule()
|
||||||
if parent is not None:
|
if parent is not None:
|
||||||
setattr(parent, name, submodule)
|
setattr(parent, name, submodule)
|
||||||
modules.append(submodule)
|
modules.append(submodule)
|
||||||
|
|
|
@ -426,15 +426,15 @@ class LocalPath(common.FSPathBase, PlatformMixin):
|
||||||
raise
|
raise
|
||||||
return mod
|
return mod
|
||||||
|
|
||||||
def getpymodule(self):
|
def _getpymodule(self):
|
||||||
"""resolve this path to a module python object. """
|
"""resolve this path to a module python object. """
|
||||||
if self.ext != '.c':
|
if self.ext != '.c':
|
||||||
return super(LocalPath, self).getpymodule()
|
return super(LocalPath, self)._getpymodule()
|
||||||
from py.__.misc.buildcmodule import make_module_from_c
|
from py.__.misc.buildcmodule import make_module_from_c
|
||||||
mod = make_module_from_c(self)
|
mod = make_module_from_c(self)
|
||||||
return mod
|
return mod
|
||||||
|
|
||||||
def getpycodeobj(self):
|
def _getpycodeobj(self):
|
||||||
""" read the path and compile it to a code object. """
|
""" read the path and compile it to a code object. """
|
||||||
dotpy = self.check(ext='.py')
|
dotpy = self.check(ext='.py')
|
||||||
if dotpy:
|
if dotpy:
|
||||||
|
|
|
@ -216,8 +216,8 @@ class CommonFSTests(common.CommonPathTests):
|
||||||
assert dest.join('otherfile').check(file=1)
|
assert dest.join('otherfile').check(file=1)
|
||||||
assert not source.join('sampledir').check()
|
assert not source.join('sampledir').check()
|
||||||
|
|
||||||
def test_getpymodule(self):
|
def test__getpymodule(self):
|
||||||
obj = self.root.join('execfile').getpymodule()
|
obj = self.root.join('execfile')._getpymodule()
|
||||||
assert obj.x == 42
|
assert obj.x == 42
|
||||||
|
|
||||||
def test_not_has_resolve(self):
|
def test_not_has_resolve(self):
|
||||||
|
@ -225,22 +225,22 @@ class CommonFSTests(common.CommonPathTests):
|
||||||
# py.path.extpy
|
# py.path.extpy
|
||||||
assert not hasattr(self.root, 'resolve')
|
assert not hasattr(self.root, 'resolve')
|
||||||
|
|
||||||
def test_getpymodule_a(self):
|
def test__getpymodule_a(self):
|
||||||
otherdir = self.root.join('otherdir')
|
otherdir = self.root.join('otherdir')
|
||||||
mod = otherdir.join('a.py').getpymodule()
|
mod = otherdir.join('a.py')._getpymodule()
|
||||||
assert mod.result == "got it"
|
assert mod.result == "got it"
|
||||||
|
|
||||||
def test_getpymodule_b(self):
|
def test__getpymodule_b(self):
|
||||||
otherdir = self.root.join('otherdir')
|
otherdir = self.root.join('otherdir')
|
||||||
mod = otherdir.join('b.py').getpymodule()
|
mod = otherdir.join('b.py')._getpymodule()
|
||||||
assert mod.stuff == "got it"
|
assert mod.stuff == "got it"
|
||||||
|
|
||||||
def test_getpymodule_c(self):
|
def test__getpymodule_c(self):
|
||||||
otherdir = self.root.join('otherdir')
|
otherdir = self.root.join('otherdir')
|
||||||
mod = otherdir.join('c.py').getpymodule()
|
mod = otherdir.join('c.py')._getpymodule()
|
||||||
assert mod.value == "got it"
|
assert mod.value == "got it"
|
||||||
|
|
||||||
def test_getpymodule_d(self):
|
def test__getpymodule_d(self):
|
||||||
otherdir = self.root.join('otherdir')
|
otherdir = self.root.join('otherdir')
|
||||||
mod = otherdir.join('d.py').getpymodule()
|
mod = otherdir.join('d.py')._getpymodule()
|
||||||
assert mod.value2 == "got it"
|
assert mod.value2 == "got it"
|
||||||
|
|
Loading…
Reference in New Issue