[py-svn] r7154 - py/dist/py/path/local
hpk at codespeak.net
hpk at codespeak.net
Fri Oct 29 15:58:51 CEST 2004
Author: hpk
Date: Fri Oct 29 15:58:51 2004
New Revision: 7154
Modified:
py/dist/py/path/local/local.py
Log:
- getcodeobj(): use path methods instead of string operations
this makes it easier to inherit from local
and reuse the function
Modified: py/dist/py/path/local/local.py
==============================================================================
--- py/dist/py/path/local/local.py (original)
+++ py/dist/py/path/local/local.py Fri Oct 29 15:58:51 2004
@@ -342,16 +342,16 @@
return self.strpath
def getcodeobj(self):
- dotpy = self.strpath.endswith('.py')
+ dotpy = self.check(ext='.py')
if dotpy:
my_magic = py.std.imp.get_magic()
my_timestamp = int(self.mtime())
if __debug__:
- pycfile = self.strpath + 'c'
+ pycfile = self + 'c'
else:
- pycfile = self.strpath + 'o'
+ pycfile = self + 'o'
try:
- f = open(pycfile, 'rb')
+ f = pycfile.open('rb')
try:
header = f.read(8)
if len(header) == 8:
@@ -363,10 +363,10 @@
except IOError:
pass
s = self.read()
- codeobj = compile(s, self.strpath, 'exec')
+ codeobj = compile(s, str(self), 'exec')
if dotpy:
try:
- f = open(pycfile, 'wb')
+ f = pycfile.open('wb')
f.write(py.std.struct.pack('<4si', 'TEMP', -1)) # fixed below
py.std.marshal.dump(codeobj, f)
f.flush()
More information about the pytest-commit
mailing list