#NEWLINE# def typed_subtopic_data( fc , subid ) : #NEWLINE# #INDENT# 'Returns typed subtopic data from an FC.' #NEWLINE# ty = subtopic_type ( subid ) #NEWLINE# data = get_unicode_feature ( fc , subid ) #NEWLINE# assert isinstance ( data , unicode ) , ( 'data should be `unicode` but is %r' % type ( data ) ) #NEWLINE# if ( ty == 'image' ) : #NEWLINE# #INDENT# img_data = get_unicode_feature ( fc , ( subid + '|data' ) ) #NEWLINE# img = re . sub ( '^data:image/[a-zA-Z]+;base64,' , '' , img_data ) #NEWLINE# img = base64 . b64decode ( img . encode ( 'utf-8' ) ) #NEWLINE# return ( data , img ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ty in ( 'text' , 'manual' ) ) : #NEWLINE# #INDENT# return data #NEWLINE# #UNINDENT# #UNINDENT# raise ValueError ( ( 'unrecognized subtopic type "%s"' % ty ) )