[h5py] 118/455: Initial H5L design

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Thu Jul 2 18:19:24 UTC 2015


This is an automated email from the git hooks/post-receive script.

ghisvail-guest pushed a commit to annotated tag 1.3.0
in repository h5py.

commit 1b6825dfa68127f3cf5b6e7e1cf9aa4321e0efbe
Author: andrewcollette <andrew.collette at gmail.com>
Date:   Tue Sep 16 23:32:03 2008 +0000

    Initial H5L design
---
 h5py/h5g.pxd      |   3 ++
 h5py/h5g.pyx      |  11 +++++
 h5py/h5l.pxd      | 118 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 h5py/h5l.pyx      |  46 +++++++++++++++++++++
 h5py/h5o.pxd      |   2 +-
 h5py/std_defs.pxi |  10 +++++
 6 files changed, 187 insertions(+), 3 deletions(-)

diff --git a/h5py/h5g.pxd b/h5py/h5g.pxd
index dc1af0c..dc2c758 100644
--- a/h5py/h5g.pxd
+++ b/h5py/h5g.pxd
@@ -19,6 +19,9 @@ include "std_defs.pxi"
 from h5 cimport class ObjectID
 
 cdef class GroupID(ObjectID):
+
+    IF H5PY_18API:
+        cdef readonly object links
     pass
 
 cdef extern from "hdf5.h":
diff --git a/h5py/h5g.pyx b/h5py/h5g.pyx
index b3739f0..5d05b35 100644
--- a/h5py/h5g.pyx
+++ b/h5py/h5g.pyx
@@ -19,6 +19,8 @@ include "conditions.pxi"
 from utils cimport emalloc, efree
 from h5 cimport standard_richcmp
 from h5p cimport H5P_DEFAULT
+IF H5PY_18API:
+    from h5l cimport LinkProxy
 
 # Runtime imports
 import h5
@@ -217,8 +219,17 @@ cdef class GroupID(ObjectID):
         __contains__(name)   Test for group member ("if name in grpid")
         __iter__             Get an iterator over member names
         __len__              Number of members in this group; len(grpid) = N
+
+        If HDF5 1.8.X is used, the attribute "links" contains a proxy object
+        providing access to the H5L family of routines.  See the docs
+        for h5py.h5l.LinkProxy for more information.
+
     """
 
+    IF H5PY_18API:
+        def __init__(self, hid_t id_):
+            self.links = LinkProxy(id_)
+
     def _close(self):
         """ ()
 
diff --git a/h5py/h5l.pxd b/h5py/h5l.pxd
index 0321a47..b49666a 100644
--- a/h5py/h5l.pxd
+++ b/h5py/h5l.pxd
@@ -2,10 +2,124 @@
 # 
 # This file is part of h5py, a low-level Python interface to the HDF5 library.
 # 
-# Copyright (C) 2008 Andrew Collette
+# Copyright (C) except * 2008 Andrew Collette
 # http://h5py.alfven.org
-# License: BSD  (See LICENSE.txt for full license)
+# License: BSD  (See LICENSE.txt for full license) except *
 # 
 # $Date$
 # 
 #-
+
+include "std_defs.pxi"
+
+from h5 cimport ObjectID
+
+# Public classes
+cdef class LinkProxy(ObjectID):
+  pass
+
+cdef extern from "hdf5.h":
+
+  # TODO: put both versions in h5t.pxd
+  ctypedef enum H5T_cset_t:
+    H5T_CSET_ERROR       = -1,  #
+    H5T_CSET_ASCII       = 0,   # US ASCII
+    H5T_CSET_UTF8        = 1,   # UTF-8 Unicode encoding
+
+  unsigned int H5L_MAX_LINK_NAME_LEN #  ((uint32_t) (-1)) (4GB - 1)
+
+  # Link class types.
+  # * Values less than 64 are reserved for the HDF5 library's internal use.
+  # * Values 64 to 255 are for "user-defined" link class types; these types are
+  # * defined by HDF5 but their behavior can be overridden by users.
+  # * Users who want to create new classes of links should contact the HDF5
+  # * development team at hdfhelp at ncsa.uiuc.edu .
+  # * These values can never change because they appear in HDF5 files. 
+  # 
+  ctypedef enum H5L_type_t:
+    H5L_TYPE_ERROR = (-1),      #  Invalid link type id         
+    H5L_TYPE_HARD = 0,          #  Hard link id                 
+    H5L_TYPE_SOFT = 1,          #  Soft link id                 
+    H5L_TYPE_EXTERNAL = 64,     #  External link id             
+    H5L_TYPE_MAX = 255          #  Maximum link type id         
+
+  #  Information struct for link (for H5Lget_info/H5Lget_info_by_idx)
+  cdef union _add_u:
+    haddr_t address   #  Address hard link points to    
+    size_t val_size   #  Size of a soft link or UD link value 
+
+  ctypedef struct H5L_info_t:
+    H5L_type_t  type            #  Type of link                   
+    hbool_t     corder_valid    #  Indicate if creation order is valid 
+    int64_t     corder          #  Creation order                 
+    H5T_cset_t  cset            #  Character set of link name     
+    _add_u u
+
+  #  Prototype for H5Literate/H5Literate_by_name() operator 
+  ctypedef herr_t (*H5L_iterate_t) (hid_t group, char *name, H5L_info_t *info,
+                    void *op_data)
+
+  ctypedef enum H5_index_t:
+    H5_INDEX_NAME,
+    H5_INDEX_CRT_ORDER
+
+  ctypedef enum H5_iter_order_t:
+     H5_ITER_INC,      # Increasing order
+     H5_ITER_DEC,     # Decreasing order
+     H5_ITER_NATIVE  # Fastest available order
+
+ # API
+
+  herr_t H5Lmove(hid_t src_loc, char *src_name, hid_t dst_loc,
+    char *dst_name, hid_t lcpl_id, hid_t lapl_id) except *
+
+  herr_t H5Lcopy(hid_t src_loc, char *src_name, hid_t dst_loc,
+    char *dst_name, hid_t lcpl_id, hid_t lapl_id) except *
+
+  herr_t H5Lcreate_hard(hid_t cur_loc, char *cur_name,
+    hid_t dst_loc, char *dst_name, hid_t lcpl_id, hid_t lapl_id) except *
+
+  herr_t H5Lcreate_soft(char *link_target, hid_t link_loc_id,
+    char *link_name, hid_t lcpl_id, hid_t lapl_id) except *
+
+  herr_t H5Ldelete(hid_t loc_id, char *name, hid_t lapl_id) except *
+
+  herr_t H5Ldelete_by_idx(hid_t loc_id, char *group_name,
+    H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id) except *
+
+  herr_t H5Lget_val(hid_t loc_id, char *name, void *bufout,
+    size_t size, hid_t lapl_id) except *
+
+  herr_t H5Lget_val_by_idx(hid_t loc_id, char *group_name,
+    H5_index_t idx_type, H5_iter_order_t order, hsize_t n,
+    void *bufout, size_t size, hid_t lapl_id) except *
+
+  htri_t H5Lexists(hid_t loc_id, char *name, hid_t lapl_id) except *
+
+  herr_t H5Lget_info(hid_t loc_id, char *name,
+    H5L_info_t *linfo, hid_t lapl_id) except *
+
+  herr_t H5Lget_info_by_idx(hid_t loc_id, char *group_name,
+    H5_index_t idx_type, H5_iter_order_t order, hsize_t n,
+    H5L_info_t *linfo, hid_t lapl_id) except *
+
+  ssize_t H5Lget_name_by_idx(hid_t loc_id, char *group_name,
+    H5_index_t idx_type, H5_iter_order_t order, hsize_t n,
+    char *name, size_t size, hid_t lapl_id) except *
+
+  herr_t H5Literate(hid_t grp_id, H5_index_t idx_type,
+    H5_iter_order_t order, hsize_t *idx, H5L_iterate_t op, void *op_data) except *
+
+  herr_t H5Literate_by_name(hid_t loc_id, char *group_name,
+    H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx,
+    H5L_iterate_t op, void *op_data, hid_t lapl_id) except *
+
+  herr_t H5Lvisit(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order,
+    H5L_iterate_t op, void *op_data) except *
+
+  herr_t H5Lvisit_by_name(hid_t loc_id, char *group_name,
+    H5_index_t idx_type, H5_iter_order_t order, H5L_iterate_t op,
+    void *op_data, hid_t lapl_id) except *
+
+
+
diff --git a/h5py/h5l.pyx b/h5py/h5l.pyx
index 0321a47..a93f674 100644
--- a/h5py/h5l.pyx
+++ b/h5py/h5l.pyx
@@ -9,3 +9,49 @@
 # $Date$
 # 
 #-
+from utils cimport pybool
+
+"""
+    API for the "H5L" family of link-related operations
+"""
+
+
+cdef extern from "hdf5.h":
+
+  int   H5Iinc_ref(hid_t obj_id) except *    
+  int   H5P_DEFAULT
+
+cdef class LinkProxy(ObjectID):
+
+    """
+        Proxy class which provides access to the HDF5 "H5L" API.
+
+        These come attached to GroupID objects as "obj.links".  Since every
+        H5L function operates on at least one group, the methods provided
+        operate on their parent group operator.  For example:
+
+        >>> g = h5g.open(fid, '/')
+        >>> g.links.exists("MyGroup")
+        True
+        >>> g.links.exists("FooBar")
+        False
+
+    """
+
+    def __cinit__(self, hid_t id_):
+        # At this point the ObjectID constructor has already been called.
+
+        # We need to manually incref the identifier because it's now
+        # shared by both this object and its parent GroupID object.
+        H5Iinc_ref(self.id)
+
+    def exists(self, char* name):
+        """ (STRING name) => BOOL
+
+            Check if a link of the specified name exists in this group.
+        """
+        return pybool(H5Lexists(self.id, name, H5P_DEFAULT))
+
+
+
+
diff --git a/h5py/h5o.pxd b/h5py/h5o.pxd
index 375fcba..2aadac2 100644
--- a/h5py/h5o.pxd
+++ b/h5py/h5o.pxd
@@ -80,7 +80,7 @@ cdef extern from "hdf5.h":
   herr_t H5Ovisit(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order,
                     H5O_iterate_t op, void *op_data) except *
 
-  herr_t H5Oget_info(hid_t loc_id, H5O_info_t *oinfo)
+  herr_t H5Oget_info(hid_t loc_id, H5O_info_t *oinfo) except *
 
 
 
diff --git a/h5py/std_defs.pxi b/h5py/std_defs.pxi
index c15c179..ac4dc91 100644
--- a/h5py/std_defs.pxi
+++ b/h5py/std_defs.pxi
@@ -19,3 +19,13 @@ from h5 cimport hid_t, hbool_t, herr_t, htri_t, hsize_t, \
                 hssize_t, haddr_t, hvl_t
 
 from defs_c cimport size_t, time_t, ssize_t
+
+cdef extern from "stdint.h":
+  ctypedef signed char int8_t
+  ctypedef unsigned char uint8_t
+  ctypedef signed int int16_t
+  ctypedef unsigned int uint16_t
+  ctypedef signed long int int32_t
+  ctypedef unsigned long int uint32_t
+  ctypedef signed long long int int64_t
+  ctypedef signed long long int uint64_t 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/h5py.git



More information about the debian-science-commits mailing list