From 499d60c8ab2015ba7cfcf39b056b61eede603e83 Mon Sep 17 00:00:00 2001 From: hpk Date: Thu, 8 Feb 2007 20:48:31 +0100 Subject: [PATCH] [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 --- py/magic/greenlet.py | 2 +- py/path/common.py | 8 ++++---- py/path/local/local.py | 6 +++--- py/path/testing/fscommon.py | 20 ++++++++++---------- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/py/magic/greenlet.py b/py/magic/greenlet.py index 1a5aa86f8..90d46b134 100644 --- a/py/magic/greenlet.py +++ b/py/magic/greenlet.py @@ -7,4 +7,4 @@ else: import py gdir = py.path.local(py.__file__).dirpath() path = gdir.join('c-extension', 'greenlet', 'greenlet.c') - greenlet = path.getpymodule().greenlet + greenlet = path._getpymodule().greenlet diff --git a/py/path/common.py b/py/path/common.py index 3e9feb014..37ad02c1f 100644 --- a/py/path/common.py +++ b/py/path/common.py @@ -370,14 +370,14 @@ newline will be removed from the end of each line. """ self.copy(target) self.remove() - def getpymodule(self): + def _getpymodule(self): """resolve this path to a module python object. """ modname = str(self) modname = modname.replace('.', self.sep) try: return sys.modules[modname] except KeyError: - co = self.getpycodeobj() + co = self._getpycodeobj() mod = py.std.new.module(modname) mod.__file__ = PathStr(self) if self.basename == '__init__.py': @@ -390,7 +390,7 @@ newline will be removed from the end of each line. """ raise return mod - def getpycodeobj(self): + def _getpycodeobj(self): """ read the path and compile it to a py.code.Code object. """ s = self.read('rU') # 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') if not p.check(): return None # not found - submodule = p.getpymodule() + submodule = p._getpymodule() if parent is not None: setattr(parent, name, submodule) modules.append(submodule) diff --git a/py/path/local/local.py b/py/path/local/local.py index a1c03d9fb..853d194a5 100644 --- a/py/path/local/local.py +++ b/py/path/local/local.py @@ -426,15 +426,15 @@ class LocalPath(common.FSPathBase, PlatformMixin): raise return mod - def getpymodule(self): + def _getpymodule(self): """resolve this path to a module python object. """ if self.ext != '.c': - return super(LocalPath, self).getpymodule() + return super(LocalPath, self)._getpymodule() from py.__.misc.buildcmodule import make_module_from_c mod = make_module_from_c(self) return mod - def getpycodeobj(self): + def _getpycodeobj(self): """ read the path and compile it to a code object. """ dotpy = self.check(ext='.py') if dotpy: diff --git a/py/path/testing/fscommon.py b/py/path/testing/fscommon.py index b9fad8d5f..5edd57295 100644 --- a/py/path/testing/fscommon.py +++ b/py/path/testing/fscommon.py @@ -216,8 +216,8 @@ class CommonFSTests(common.CommonPathTests): assert dest.join('otherfile').check(file=1) assert not source.join('sampledir').check() - def test_getpymodule(self): - obj = self.root.join('execfile').getpymodule() + def test__getpymodule(self): + obj = self.root.join('execfile')._getpymodule() assert obj.x == 42 def test_not_has_resolve(self): @@ -225,22 +225,22 @@ class CommonFSTests(common.CommonPathTests): # py.path.extpy assert not hasattr(self.root, 'resolve') - def test_getpymodule_a(self): + def test__getpymodule_a(self): otherdir = self.root.join('otherdir') - mod = otherdir.join('a.py').getpymodule() + mod = otherdir.join('a.py')._getpymodule() assert mod.result == "got it" - def test_getpymodule_b(self): + def test__getpymodule_b(self): otherdir = self.root.join('otherdir') - mod = otherdir.join('b.py').getpymodule() + mod = otherdir.join('b.py')._getpymodule() assert mod.stuff == "got it" - def test_getpymodule_c(self): + def test__getpymodule_c(self): otherdir = self.root.join('otherdir') - mod = otherdir.join('c.py').getpymodule() + mod = otherdir.join('c.py')._getpymodule() assert mod.value == "got it" - def test_getpymodule_d(self): + def test__getpymodule_d(self): otherdir = self.root.join('otherdir') - mod = otherdir.join('d.py').getpymodule() + mod = otherdir.join('d.py')._getpymodule() assert mod.value2 == "got it"