#NEWLINE# def _resolve_type_affinity( self , type_ ) : #NEWLINE# #INDENT# "Return a data type from a reflected column, using affinity tules.\n\n        SQLite's goal for universal compatibility introduces some complexity\n        during reflection, as a column's defined type might not actually be a\n        type that SQLite understands - or indeed, my not be defined *at all*.\n        Internally, SQLite handles this with a 'data type affinity' for each\n        column definition, mapping to one of 'TEXT', 'NUMERIC', 'INTEGER',\n        'REAL', or 'NONE' (raw bits). The algorithm that determines this is\n        listed in http://www.sqlite.org/datatype3.html section 2.1.\n\n        This method allows SQLAlchemy to support that algorithm, while still\n        providing access to smarter reflection utilities by regcognizing\n        column definitions that SQLite only supports through affinity (like\n        DATE and DOUBLE).\n\n        " #NEWLINE# match = re . match ( '([\\w ]+)(\\(.*?\\))?' , a ) #NEWLINE# if match : #NEWLINE# #INDENT# coltype = match . group ( 1 ) #NEWLINE# args = match . group ( 2 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# coltype = '' #NEWLINE# args = '' #NEWLINE# #UNINDENT# if ( coltype in self . ischema_names ) : #NEWLINE# #INDENT# coltype = self . ischema_names [ coltype ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'INT' in coltype ) : #NEWLINE# #INDENT# coltype = sqltypes . INTEGER #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( 'CHAR' in coltype ) or ( 'CLOB' in coltype ) or ( 'TEXT' in coltype ) ) : #NEWLINE# #INDENT# coltype = sqltypes . TEXT #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( 'BLOB' in coltype ) or ( not coltype ) ) : #NEWLINE# #INDENT# coltype = sqltypes . NullType #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( 'REAL' in coltype ) or ( 'FLOA' in coltype ) or ( 'DOUB' in coltype ) ) : #NEWLINE# #INDENT# coltype = sqltypes . REAL #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# coltype = sqltypes . NUMERIC #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if ( args is not None ) : #NEWLINE# #INDENT# args = re . findall ( '(\\d+)' , args ) #NEWLINE# try : #NEWLINE# #INDENT# coltype = coltype ( * [ int ( a ) for a in args ] ) #NEWLINE# #UNINDENT# except TypeError : #NEWLINE# #INDENT# util . warn ( ( 'Could not instantiate type %s with reflected arguments %s; using no arguments.' % ( coltype , args ) ) ) #NEWLINE# coltype = coltype ( ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# coltype = coltype ( ) #NEWLINE# #UNINDENT# return coltype