Use future division.

This commit is contained in:
Patrick Zimmermann 2013-06-11 22:27:30 +02:00
parent 4d8b6f669f
commit b172153b15
2 changed files with 4 additions and 3 deletions

View File

@ -29,6 +29,7 @@
""" """
The duplicate song removal logic for OpenLP. The duplicate song removal logic for OpenLP.
""" """
from __future__ import division
import logging import logging
import os import os
@ -161,7 +162,7 @@ class DuplicateSongRemovalForm(OpenLPWizard):
self.notify_no_duplicates() self.notify_no_duplicates()
return return
# With x songs we have x*(x - 1) / 2 comparisons. # With x songs we have x*(x - 1) / 2 comparisons.
max_progress_count = max_songs * (max_songs - 1) / 2 max_progress_count = max_songs * (max_songs - 1) // 2
self.duplicate_search_progress_bar.setMaximum(max_progress_count) self.duplicate_search_progress_bar.setMaximum(max_progress_count)
songs = self.plugin.manager.get_all_objects(Song) songs = self.plugin.manager.get_all_objects(Song)
for outer_song_counter in range(max_songs - 1): for outer_song_counter in range(max_songs - 1):
@ -194,7 +195,6 @@ class DuplicateSongRemovalForm(OpenLPWizard):
translate(u'Wizard', u'No duplicate songs have been found in the database.'), translate(u'Wizard', u'No duplicate songs have been found in the database.'),
QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok)) QtGui.QMessageBox.StandardButtons(QtGui.QMessageBox.Ok))
def add_duplicates_to_song_list(self, search_song, duplicate_song): def add_duplicates_to_song_list(self, search_song, duplicate_song):
""" """
Inserts a song duplicate (two similar songs) to the duplicate song list. Inserts a song duplicate (two similar songs) to the duplicate song list.

View File

@ -43,6 +43,7 @@ Finally two conditions can qualify a song tuple to be a duplicate:
This condition should hit if one of the two songs (or both) is small (smaller This condition should hit if one of the two songs (or both) is small (smaller
than the min_block_size), but most of the song is contained in the other song. than the min_block_size), but most of the song is contained in the other song.
""" """
from __future__ import division
import difflib import difflib
@ -85,7 +86,7 @@ def songs_probably_equal(song1, song2):
for element in diff_no_typos: for element in diff_no_typos:
if element[0] == "equal" and _op_length(element) > length_of_longest_equal_block: if element[0] == "equal" and _op_length(element) > length_of_longest_equal_block:
length_of_longest_equal_block = _op_length(element) length_of_longest_equal_block = _op_length(element)
if length_of_equal_blocks >= MIN_BLOCK_SIZE or length_of_longest_equal_block > len(small) * 2 / 3: if length_of_equal_blocks >= MIN_BLOCK_SIZE or length_of_longest_equal_block > len(small) * 2 // 3:
return True return True
# Both checks failed. We assume the songs are not equal. # Both checks failed. We assume the songs are not equal.
return False return False