#NEWLINE# @ classmethod #NEWLINE# def from_kind( class_ , kind , itemsize = None , shape = ( ) , dflt = None ) : #NEWLINE# #INDENT# "Create an Atom from a PyTables kind.\n\n        Optional item size, shape and default value may be\n        specified as the itemsize, shape and dflt\n        arguments, respectively. Bear in mind that not all atoms support\n        a default item size::\n\n            >>> Atom.from_kind('int', itemsize=2, shape=(2, 2))\n            Int16Atom(shape=(2, 2), dflt=0)\n            >>> Atom.from_kind('int', shape=(2, 2))\n            Int32Atom(shape=(2, 2), dflt=0)\n            >>> Atom.from_kind('int', shape=1)\n            Int32Atom(shape=(1,), dflt=0)\n            >>> Atom.from_kind('string', dflt=b'hello')\n            Traceback (most recent call last):\n            ...\n            ValueError: no default item size for kind ``string``\n            >>> Atom.from_kind('Float')\n            Traceback (most recent call last):\n            ...\n            ValueError: unknown kind: 'Float'\n\n        Moreover, some kinds with atypical constructor signatures\n        are not supported; you need to use the proper\n        constructor::\n\n            >>> Atom.from_kind('enum') #doctest: +ELLIPSIS\n            Traceback (most recent call last):\n            ...\n            ValueError: the ``enum`` kind is not supported...\n\n        " #NEWLINE# kwargs = { #NEWLINE# #INDENT# 'shape' : shape , #NEWLINE# #UNINDENT# } #NEWLINE# if ( kind not in atom_map ) : #NEWLINE# #INDENT# raise ValueError ( ( 'unknown kind: %r' % ( kind , ) ) ) #NEWLINE# #UNINDENT# if ( kind in [ 'enum' ] ) : #NEWLINE# #INDENT# raise ValueError ( ( 'the ``%s`` kind is not supported; please use the appropriate constructor' % kind ) ) #NEWLINE# #UNINDENT# if ( itemsize is None ) : #NEWLINE# #INDENT# if ( kind not in deftype_from_kind ) : #NEWLINE# #INDENT# raise ValueError ( ( 'no default item size for kind ``%s``' % kind ) ) #NEWLINE# #UNINDENT# type_ = deftype_from_kind [ kind ] #NEWLINE# ( kind , itemsize ) = split_type ( type_ ) #NEWLINE# #UNINDENT# kdata = atom_map [ kind ] #NEWLINE# if hasattr ( kdata , 'kind' ) : #NEWLINE# #INDENT# atomclass = kdata #NEWLINE# kwargs [ 'itemsize' ] = itemsize #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( itemsize not in kdata ) : #NEWLINE# #INDENT# raise _invalid_itemsize_error ( kind , atomclass , kdata ) #NEWLINE# #UNINDENT# atomclass = kdata [ itemsize ] #NEWLINE# #UNINDENT# if ( dflt is not None ) : #NEWLINE# #INDENT# kwargs [ 'dflt' ] = dflt #NEWLINE# #UNINDENT# return atomclass ( ** kwargs )