Skip to content
This repository has been archived by the owner on Jan 14, 2024. It is now read-only.

Commit

Permalink
style fix
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianriese committed Jul 4, 2017
1 parent 434b9ea commit a6ef8d5
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions aioxmpp/bookmarks/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,26 +387,28 @@ def discard_bookmark(self, bookmark_to_remove, *, max_retries=3):
occurences = bookmarks.count(bookmark_to_remove)

try:
if occurences:
if not occurences:
return

modified_bookmarks = list(bookmarks)
modified_bookmarks.remove(bookmark_to_remove)
yield from self._set_bookmarks(modified_bookmarks)

retries = 0
bookmarks = yield from self._get_bookmarks()
new_occurences = bookmarks.count(bookmark_to_remove)
while retries < max_retries:
if new_occurences < occurences:
break
modified_bookmarks = list(bookmarks)
modified_bookmarks.remove(bookmark_to_remove)
yield from self._set_bookmarks(modified_bookmarks)

retries = 0
bookmarks = yield from self._get_bookmarks()
new_occurences = bookmarks.count(bookmark_to_remove)
while retries < max_retries:
if new_occurences < occurences:
break
modified_bookmarks = list(bookmarks)
modified_bookmarks.remove(bookmark_to_remove)
yield from self._set_bookmarks(modified_bookmarks)
bookmarks = yield from self._get_bookmarks()
new_occurences = bookmarks.count(bookmark_to_remove)
retries += 1

if new_occurences >= occurences:
raise RuntimeError("Could not remove bookmark")
retries += 1

if new_occurences >= occurences:
raise RuntimeError("Could not remove bookmark")
finally:
self._diff_emit_update(bookmarks)

Expand Down

0 comments on commit a6ef8d5

Please sign in to comment.