#NEWLINE# def parse_colspecstr( colspecstr , default = unicode ) : #NEWLINE# #INDENT# '\n\n    Args:\n        colspecstr (str): e.g. "0,1,2,3" or "0,1,4::int"\n\n    Keyword Arguments:\n        default (callable): type casting callable\n\n    Yields:\n        tuple: (colkey, coltypefunc)\n\n    .. code::\n\n        \' \'\n        0\n        0,1,2\n        2, 1, 0\n        2:int\n        0:str, 1:int, 2:int\n        0:int, 1:int, 2:int  # raises\n        0, 1, 2:int\n        2::int, 2::xsd:integer  #\n        #0:"xsd:string", 2:xsd:integer #\n        attr:"xsd:string", attr2:"xsd:integer" #\n\n        # - [ ] ENH: [rdflib] RDFa default context\n        # - [ ] ENH: shlex quote parsing after the split\n\n    ' #NEWLINE# if ( ( not colspecstr ) or ( not colspecstr . strip ( ) ) ) : #NEWLINE# #INDENT# return #NEWLINE# #UNINDENT# for ( n , colspecstr_col_n ) in enumerate ( colspecstr . split ( ',' ) ) : #NEWLINE# #INDENT# colkeystr = None #NEWLINE# coltypefunc = default #NEWLINE# colspecstrrgx_split = COLSPECSTRRGX . split ( colspecstr_col_n , maxsplit = 1 ) #NEWLINE# if ( len ( colspecstrrgx_split ) == 2 ) : #NEWLINE# #INDENT# ( colkeystr , coltypestr ) = colspecstrrgx_split #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( colspecstrrgx_split ) == 1 ) : #NEWLINE# #INDENT# colkeystr = colspecstrrgx_split [ 0 ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise ValueError ( colspecstrrgx_split ) #NEWLINE# #UNINDENT# #UNINDENT# colkey = parse_field ( colkeystr ) . strip ( ) #NEWLINE# coltypestr = parse_field ( coltypestr ) . strip ( ) #NEWLINE# coltypefunc = typestr_func_map . get ( coltypefunc , default ) #NEWLINE# ( yield ( colkey , coltypefunc ) )