#NEWLINE# def merge_syncs( self , sync_points , incoming = True ) : #NEWLINE# #INDENT# "\n        Merge a list of sync points with the incoming sync table.\n\n        :param sync_points: list of sync points where a sync point is a dict of\n                            {'sync_point', 'remote_id'}\n        :param incoming: if True, get the last incoming sync, otherwise get\n                         the last outgoing sync\n        " #NEWLINE# with self . get ( ) as conn : #NEWLINE# #INDENT# for rec in rec : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# conn . execute ( ( '\n                        INSERT INTO %s_sync (sync_point, remote_id)\n                        VALUES (?, ?)\n                    ' % ( 'incoming' if incoming else 'outgoing' ) ) , ( rec [ 'sync_point' ] , rec [ 'remote_id' ] ) ) #NEWLINE# #UNINDENT# except sqlite3 . IntegrityError : #NEWLINE# #INDENT# conn . execute ( ( '\n                        UPDATE %s_sync SET sync_point=max(?, sync_point)\n                        WHERE remote_id=?\n                    ' % ( 'incoming' if incoming else 'outgoing' ) ) , ( rec [ 'sync_point' ] , rec [ 'remote_id' ] ) ) #NEWLINE# #UNINDENT# #UNINDENT# conn . commit ( )