[h5py] 193/455: Fix copying glitch where destination is a group

Ghislain Vaillant ghisvail-guest at moszumanska.debian.org
Thu Jul 2 18:19:32 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 6e11eb08957d7dc0a147c9a06edca5547c5e69e3
Author: andrewcollette <andrew.collette at gmail.com>
Date:   Fri Jan 23 00:54:52 2009 +0000

    Fix copying glitch where destination is a group
---
 h5py/highlevel.py | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/h5py/highlevel.py b/h5py/highlevel.py
index f157e37..e90f03c 100644
--- a/h5py/highlevel.py
+++ b/h5py/highlevel.py
@@ -58,6 +58,7 @@ from utils_hl import slice_select, hbasename, guess_chunk
 from utils_hl import CoordsList
 from browse import _H5Browser
 import h5py.selections as sel
+import posixpath as pp
 
 config = h5.get_config()
 if config.API_18:
@@ -362,13 +363,17 @@ class Group(HLObject, _DictCompat):
 
     # New 1.8.X methods
 
-    def copy(self, source, dest):
+    def copy(self, source, dest, name=None):
         """ Copy an object or group.
 
         The source can be a path, Group, Dataset, or Datatype object.  The
         destination can be either a path or a Group object.  The source and
         destinations need not be in the same file.
 
+        When the destination is a Group object, by default the target will
+        be created in that group with its current name (basename of obj.name).
+        You can override that by setting "name" to a string.
+
         Example:
 
         >>> f = File('myfile.hdf5')
@@ -392,7 +397,11 @@ class Group(HLObject, _DictCompat):
                 source = self
 
             if isinstance(dest, Group):
-                dest_path = '.'
+                if name is not None:
+                    dest_path = name
+                else:
+                    dest_path = pp.basename(h5i.get_name(source[source_path].id))
+
             elif isinstance(dest, HLObject):
                 raise TypeError("Destination must be path or Group object")
             else:

-- 
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