[pypy-svn] r43638 - pypy/dist/pypy/translator/jvm

afa at codespeak.net afa at codespeak.net
Fri May 25 16:22:33 CEST 2007


Author: afa
Date: Fri May 25 16:22:33 2007
New Revision: 43638

Modified:
   pypy/dist/pypy/translator/jvm/generator.py
   pypy/dist/pypy/translator/jvm/genjvm.py
Log:
Use py.path to manipulate file names:
code is simpler and more portable


Modified: pypy/dist/pypy/translator/jvm/generator.py
==============================================================================
--- pypy/dist/pypy/translator/jvm/generator.py	(original)
+++ pypy/dist/pypy/translator/jvm/generator.py	Fri May 25 16:22:33 2007
@@ -1,4 +1,3 @@
-import os # 
 from pypy.objspace.flow import model as flowmodel
 from pypy.translator.oosupport.metavm import Generator
 from pypy.rpython.ootypesystem import ootype
@@ -1246,14 +1245,11 @@
         iclassnm = self.current_type().descriptor.int_class_name()
         isuper = self.curclass.superclass_type.descriptor.int_class_name()
         
-        jfile = "%s/%s.j" % (self.outdir, iclassnm)
+        jfile = self.outdir.join("%s.j" % iclassnm)
 
-        try:
-            jdir = jfile[:jfile.rindex('/')]
-            os.makedirs(jdir)
-        except OSError: pass
-        self.curclass.file = open(jfile, 'w')
-        self.db.add_jasmin_file(jfile)
+        jfile.dirpath().ensure(dir=True)
+        self.curclass.file = jfile.open('w')
+        self.db.add_jasmin_file(str(jfile))
 
         # Determine the "declaration string"
         if interface: decl_str = "interface"

Modified: pypy/dist/pypy/translator/jvm/genjvm.py
==============================================================================
--- pypy/dist/pypy/translator/jvm/genjvm.py	(original)
+++ pypy/dist/pypy/translator/jvm/genjvm.py	Fri May 25 16:22:33 2007
@@ -2,7 +2,7 @@
 Backend for the JVM.
 """
 
-import os, os.path, sys
+import sys
 
 import py
 from py.compat import subprocess
@@ -106,11 +106,11 @@
         tocompile = []
         for clsnm in clsnms:
             pypycls = self.classdir.join(clsnm + '.class')
-            if not os.path.exists(str(pypycls)):
+            if not pypycls.check():
                 tocompile.append(clsnm)
         if tocompile:
-            sl = __file__.rindex(os.path.sep)
-            javasrcs = [__file__[:sl]+("/src/pypy/%s.java" % clsnm) for
+            thisdir = py.magic.autopath().dirpath()
+            javasrcs = [str(thisdir.join('src/pypy', clsnm + '.java')) for
                         clsnm in tocompile]
             self._invoke([getoption('javac'),
                           '-nowarn',



More information about the Pypy-commit mailing list