Don't check deleted cards
This commit is contained in:
parent
b23eb084c3
commit
471f82e457
1 changed files with 23 additions and 19 deletions
|
@ -79,28 +79,30 @@ class FindDuplicateContacts:
|
||||||
def compare_cards(self):
|
def compare_cards(self):
|
||||||
'''Compare all vCards'''
|
'''Compare all vCards'''
|
||||||
checked_cards = []
|
checked_cards = []
|
||||||
|
self.removed_cards = []
|
||||||
count = 0
|
count = 0
|
||||||
for card in self.cards:
|
for card in self.cards:
|
||||||
count +=1
|
if card['filename'] not in self.removed_cards:
|
||||||
print(f"Contact {count} of {len(self.cards)}:\b")
|
count +=1
|
||||||
duplicated = False
|
print(f"Contact {count} of {len(self.cards)}:\b")
|
||||||
for checked_card in checked_cards:
|
duplicated = False
|
||||||
if self.are_same_dict(card['content'], checked_card['content']):
|
for checked_card in checked_cards:
|
||||||
duplicated = True
|
if self.are_same_dict(card['content'], checked_card['content']):
|
||||||
self._log.info(
|
|
||||||
"Totally duplicates:\n '%s'\n '%s",
|
|
||||||
card['filename'],
|
|
||||||
checked_card['filename']
|
|
||||||
)
|
|
||||||
shutil.move(
|
|
||||||
card['filename'],
|
|
||||||
os.path.join(self.duplicates_folder, os.path.basename(card['filename']))
|
|
||||||
)
|
|
||||||
if self.are_partially_same_dict(card['content'], checked_card['content'], key='fn'):
|
|
||||||
if self.manual_check_cards(card, checked_card):
|
|
||||||
duplicated = True
|
duplicated = True
|
||||||
if not duplicated:
|
self._log.info(
|
||||||
checked_cards.append(card)
|
"Totally duplicates:\n '%s'\n '%s",
|
||||||
|
card['filename'],
|
||||||
|
checked_card['filename']
|
||||||
|
)
|
||||||
|
shutil.move(
|
||||||
|
card['filename'],
|
||||||
|
os.path.join(self.duplicates_folder, os.path.basename(card['filename']))
|
||||||
|
)
|
||||||
|
if self.are_partially_same_dict(card['content'], checked_card['content'], key='fn'):
|
||||||
|
if self.manual_check_cards(card, checked_card):
|
||||||
|
duplicated = True
|
||||||
|
if not duplicated:
|
||||||
|
checked_cards.append(card)
|
||||||
self._log.info(
|
self._log.info(
|
||||||
"Found %s unique cards",
|
"Found %s unique cards",
|
||||||
len(checked_cards)
|
len(checked_cards)
|
||||||
|
@ -142,12 +144,14 @@ class FindDuplicateContacts:
|
||||||
card2['filename'],
|
card2['filename'],
|
||||||
os.path.join(self.duplicates_folder, os.path.basename(card2['filename']))
|
os.path.join(self.duplicates_folder, os.path.basename(card2['filename']))
|
||||||
)
|
)
|
||||||
|
self.removed_cards.append(card2['filename'])
|
||||||
return True
|
return True
|
||||||
elif option == "2":
|
elif option == "2":
|
||||||
shutil.move(
|
shutil.move(
|
||||||
card1['filename'],
|
card1['filename'],
|
||||||
os.path.join(self.duplicates_folder, os.path.basename(card1['filename']))
|
os.path.join(self.duplicates_folder, os.path.basename(card1['filename']))
|
||||||
)
|
)
|
||||||
|
self.removed_cards.append(card1['filename'])
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
print('Doing nothing.')
|
print('Doing nothing.')
|
||||||
|
|
Loading…
Reference in a new issue