Commits

Henrik Vendelbo  committed 93eef1f

pypy_structure_exists(..)

  • Participants
  • Parent commits a4de982

Comments (0)

Files changed (3)

File pypy/module/sys/__init__.py

         'builtin_module_names'  : 'state.w_None',
         'pypy_getudir'          : 'state.pypy_getudir',    # not translated
         'pypy_initial_path'     : 'state.pypy_initial_path',
+        'pypy_structure_exists'  : 'state.pypy_structure_exists', # meshed api addition
 
         '_getframe'             : 'vm._getframe', 
         'setrecursionlimit'     : 'vm.setrecursionlimit', 

File pypy/module/sys/state.py

 
 pypy_initial_path.unwrap_spec = [ObjSpace, str]
 
+def structure_exists(paths):
+    for path in paths:
+        if not os.path.exists(path):
+            return False
+        st = os.stat(path)
+        if path.endswith('/') and not stat.S_ISDIR(st[0]):
+            return False
+    return True
+    
+def pypy_structure_exists(space,paths):
+    found = structure_exists(paths.split(":"))
+    return space.wrap(found)
+    
+pypy_structure_exists.unwrap_spec = [ObjSpace, str]    
+    
 def get(space):
     return space.fromcache(State)
 

File pypy/translator/goal/commands_main.py

         except OSError:
             return None
 
+    # debugging only, meshed addition
+    def pypy_structure_exists(paths):
+        from pypy.module.sys.state import structure_exists
+        try:
+            return structure_exists(paths.split(":"))
+        except OSError:
+            return None
+
     # stick the current sys.path into $PYTHONPATH, so that CPython still
     # finds its own extension modules :-/
     import os
     from pypy.module.sys.version import PYPY_VERSION
     sys.pypy_version_info = PYPY_VERSION
     sys.pypy_initial_path = pypy_initial_path
+    sys.pypy_structure_exists = pypy_structure_exists
     os = nanos.os_module_for_testing
     try:
         sys.exit(int(entry_point(sys.argv[0], sys.argv[1:], os)))