[python-hdf5storage] 16/152: Added a function to get an Attribute.
Ghislain Vaillant
ghisvail-guest at moszumanska.debian.org
Mon Feb 29 08:24:30 UTC 2016
This is an automated email from the git hooks/post-receive script.
ghisvail-guest pushed a commit to annotated tag 0.1
in repository python-hdf5storage.
commit 00d15ff4569205b15b0a7b9080d60f08889e3534
Author: Freja Nordsiek <fnordsie at gmail.com>
Date: Sun Jan 12 03:13:55 2014 -0500
Added a function to get an Attribute.
---
hdf5storage/utilities.py | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/hdf5storage/utilities.py b/hdf5storage/utilities.py
index c2c1609..cd2acd3 100644
--- a/hdf5storage/utilities.py
+++ b/hdf5storage/utilities.py
@@ -31,6 +31,31 @@ import numpy as np
import h5py
+def get_attribute(target, name):
+ """ Gets an attribute from a Dataset or Group.
+
+ Gets the value of an Attribute if it is present (get ``None`` if
+ not).
+
+ Parameters
+ ----------
+ target : Dataset or Group
+ :py:class:`h5py.Dataset` or :py:class:`h5py.Group` to get the
+ attribute of.
+ name : str
+ Name of the attribute to get.
+
+ Returns
+ -------
+ The value of the attribute if it is present, or ``None`` if it
+ isn't.
+
+ """
+ if name not in target.attrs:
+ return None
+ else:
+ return target.attrs[name]
+
def set_attribute(target, name, value):
""" Sets an attribute on a Dataset or Group.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/python-hdf5storage.git
More information about the debian-science-commits
mailing list