[py-svn] r38203 - in py/trunk/py: magic path path/local path/testing

hpk at codespeak.net hpk at codespeak.net
Thu Feb 8 20:48:34 CET 2007


Author: hpk
Date: Thu Feb  8 20:48:31 2007
New Revision: 38203

Modified:
   py/trunk/py/magic/greenlet.py
   py/trunk/py/path/common.py
   py/trunk/py/path/local/local.py
   py/trunk/py/path/testing/fscommon.py
Log:
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()


Modified: py/trunk/py/magic/greenlet.py
==============================================================================
--- py/trunk/py/magic/greenlet.py	(original)
+++ py/trunk/py/magic/greenlet.py	Thu Feb  8 20:48:31 2007
@@ -7,4 +7,4 @@
     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 

Modified: py/trunk/py/path/common.py
==============================================================================
--- py/trunk/py/path/common.py	(original)
+++ py/trunk/py/path/common.py	Thu Feb  8 20:48:31 2007
@@ -370,14 +370,14 @@
             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 @@
                 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 @@
                 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)

Modified: py/trunk/py/path/local/local.py
==============================================================================
--- py/trunk/py/path/local/local.py	(original)
+++ py/trunk/py/path/local/local.py	Thu Feb  8 20:48:31 2007
@@ -426,15 +426,15 @@
                     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:

Modified: py/trunk/py/path/testing/fscommon.py
==============================================================================
--- py/trunk/py/path/testing/fscommon.py	(original)
+++ py/trunk/py/path/testing/fscommon.py	Thu Feb  8 20:48:31 2007
@@ -216,8 +216,8 @@
         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 @@
         # 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"



More information about the pytest-commit mailing list