Commits

drudd  committed bfee9fc

Changed to class based wrapper.

  • Participants
  • Parent commits 7857d97

Comments (0)

Files changed (3)

File yt/frontends/artio/__config__.py

-# This file is generated by /Users/sleitner/repos/ytsnlupdate/setup.py
+# This file is generated by /home/drudd/Programs/yt-3.0-artio/setup.py
 # It contains system_info results at the time of building this package.
 __all__ = ["get_info","show"]
 

File yt/frontends/artio2/_artio_reader.pyx

 # warning: this may not be portable
+from cpython.cobject cimport PyCObject_FromVoidPtr, PyCObject_AsVoidPtr
+
 from libc.stdint cimport int32_t, int64_t
 
 cdef extern from "artio.h" :
 
     artio_file artio_fileset_open(char *file_prefix, int type, artio_context context )
     int artio_fileset_close( artio_file handle )
+    int artio_fileset_open_grid( artio_file )
+    int artio_fileset_open_particle( artio_file )
 
     # parameter functions
-    cdef int artio_parameter_iterate( artio_file handle, char *key, int *type, int *length )
-    cdef int artio_parameter_get_array_length(artio_file handle, char * key, int *length)
+    int artio_parameter_iterate( artio_file handle, char *key, int *type, int *length )
+    int artio_parameter_get_array_length(artio_file handle, char * key, int *length)
 
-    cdef int artio_parameter_get_int(artio_file handle, char * key, int32_t * value)
-    cdef int artio_parameter_get_int_array(artio_file handle, char * key, int length,
+    int artio_parameter_get_int(artio_file handle, char * key, int32_t * value)
+    int artio_parameter_get_int_array(artio_file handle, char * key, int length,
             int32_t *values)
 
-cpdef artio_is_valid( char *file_prefix ) :
-    cdef artio_file handle = artio_fileset_open( file_prefix, 
-                ARTIO_OPEN_HEADER, artio_context_global )
-    if handle == NULL :
-        print "Handle is null"
+class artio_fileset :
+    def __init__(self, char *file_prefix) :
+        self.handle = PyCObject_FromVoidPtr(artio_fileset_open( file_prefix,
+                ARTIO_OPEN_HEADER, artio_context_global ),NULL)
+
+def artio_is_valid( char *file_prefix ) :
+    cdef artio_file local_handle = artio_fileset_open( file_prefix, 
+            ARTIO_OPEN_HEADER, artio_context_global )
+    if local_handle == NULL :
         return False;
     else :
-        artio_fileset_close(handle) 
+        artio_fileset_close(local_handle) 
     return True

File yt/frontends/artio2/data_structures.py

 #from _artio_reader import artio_is_valid
-import _artio_reader
+from _artio_reader import artio_is_valid, artio_fileset
 
 from yt.data_objects.static_output import \
     StaticOutput
     _handle = None
 
     def __init__(self, filename, data_style='artio2'):
-        if self._handle is not None; return
+        if self._handle is not None : return
         self.fileset_prefix = filename[:-4]
-        self._handle = _artio_reader.artio_open_fileset( prefix, ARTIO_OPEN_HEADER, artio_context_global )
+        self._fileset = artio_fileset(self.fileset_prefix)
         StaticOutput.__init__(self, filename, data_style)
 
-    def _parse_parameter_file(self) :
-        self.parameters = _artio_reader.artio_read_parameters( self._handle )
+    #def _parse_parameter_file(self) :
+        #self.parameters = _artio_reader.artio_read_parameters( self._handle )
 
     @classmethod
     def _is_valid(self, *args, **kwargs) :
         # a valid artio header file starts with a prefix and ends with .art
         if not args[0].endswith(".art"): return False
-        return _artio_reader.artio_is_valid(args[0][:-4])
-
-
+        return artio_is_valid(args[0][:-4])