/usr/lib/python3/dist-packages/h5py/_hl/datatype.py is in python3-h5py 2.6.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | # This file is part of h5py, a Python interface to the HDF5 library.
#
# http://www.h5py.org
#
# Copyright 2008-2013 Andrew Collette and contributors
#
# License: Standard 3-clause BSD; see "license.txt" for full license terms
# and contributor agreement.
"""
Implements high-level access to committed datatypes in the file.
"""
from __future__ import absolute_import
import posixpath as pp
from ..h5t import TypeID
from .base import HLObject, with_phil
class Datatype(HLObject):
"""
Represents an HDF5 named datatype stored in a file.
To store a datatype, simply assign it to a name in a group:
>>> MyGroup["name"] = numpy.dtype("f")
>>> named_type = MyGroup["name"]
>>> assert named_type.dtype == numpy.dtype("f")
"""
@property
@with_phil
def dtype(self):
"""Numpy dtype equivalent for this datatype"""
return self.id.dtype
@with_phil
def __init__(self, bind):
""" Create a new Datatype object by binding to a low-level TypeID.
"""
if not isinstance(bind, TypeID):
raise ValueError("%s is not a TypeID" % bind)
HLObject.__init__(self, bind)
@with_phil
def __repr__(self):
if not self.id:
return "<Closed HDF5 named type>"
if self.name is None:
namestr = '("anonymous")'
else:
name = pp.basename(pp.normpath(self.name))
namestr = '"%s"' % (name if name != '' else '/')
return '<HDF5 named type %s (dtype %s)>' % \
(namestr, self.dtype.str)
|