[h5py] 31/38: Fix lint issues with _hl/group
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Thu Jul 2 18:21:40 UTC 2015
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to branch master
in repository h5py.
commit cbbee064f6f4a9271e19c6d91c76920dff127611
Author: Andrew Collette <andrew.collette at gmail.com>
Date: Sat May 30 18:56:38 2015 -0600
Fix lint issues with _hl/group
---
h5py/_hl/group.py | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/h5py/_hl/group.py b/h5py/_hl/group.py
index bc13c18..33e363a 100644
--- a/h5py/_hl/group.py
+++ b/h5py/_hl/group.py
@@ -7,14 +7,16 @@
# License: Standard 3-clause BSD; see "license.txt" for full license terms
# and contributor agreement.
+"""
+ Implements support for high-level access to HDF5 groups.
+"""
+
from __future__ import absolute_import
import posixpath as pp
-
import six
-
import numpy
-import collections
+import sys
from .. import h5g, h5i, h5o, h5r, h5t, h5l, h5p
from . import base
@@ -197,6 +199,8 @@ class Group(HLObject, MutableMappingHDF5):
>>> if cls == SoftLink:
... print '"foo" is a soft link!'
"""
+ # pylint: disable=arguments-differ
+
with phil:
if not (getclass or getlink):
try:
@@ -225,15 +229,20 @@ class Group(HLObject, MutableMappingHDF5):
return SoftLink
linkbytes = self.id.links.get_val(self._e(name))
return SoftLink(self._d(linkbytes))
+
elif typecode == h5l.TYPE_EXTERNAL:
if getclass:
return ExternalLink
filebytes, linkbytes = self.id.links.get_val(self._e(name))
- # TODO: I think this is wrong,
- # we should use filesystem decoding on the filename
- return ExternalLink(self._d(filebytes), self._d(linkbytes))
+ try:
+ filetext = filebytes.decode(sys.getfilesystemencoding())
+ except (UnicodeError, LookupError):
+ filetext = filebytes
+ return ExternalLink(filetext, self._d(linkbytes))
+
elif typecode == h5l.TYPE_HARD:
return HardLink if getclass else HardLink()
+
else:
raise TypeError("Unknown link type")
@@ -419,6 +428,7 @@ class Group(HLObject, MutableMappingHDF5):
"""
with phil:
def proxy(name):
+ """ Call the function with the text name, not bytes """
return func(self._d(name))
return h5o.visit(self.id, proxy)
@@ -448,6 +458,7 @@ class Group(HLObject, MutableMappingHDF5):
"""
with phil:
def proxy(name):
+ """ Use the text name of the object, not bytes """
name = self._d(name)
return func(name, self[name])
return h5o.visit(self.id, proxy)
@@ -477,7 +488,6 @@ class HardLink(object):
pass
-#TODO: implement equality testing for these
class SoftLink(object):
"""
@@ -488,6 +498,7 @@ class SoftLink(object):
@property
def path(self):
+ """ Soft link value. Not guaranteed to be a valid path. """
return self._path
def __init__(self, path):
@@ -506,10 +517,12 @@ class ExternalLink(object):
@property
def path(self):
+ """ Soft link path, i.e. the part inside the HDF5 file. """
return self._path
@property
def filename(self):
+ """ Path to the external HDF5 file in the filesystem. """
return self._filename
def __init__(self, filename, path):
--
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