Move function

This commit is contained in:
croneter 2018-12-25 18:26:13 +01:00
parent 6076da724b
commit 4ee828dfe9
2 changed files with 21 additions and 21 deletions

View file

@ -28,3 +28,23 @@ def update_kodi_library(video=True, music=True):
xbmc.executebuiltin('UpdateLibrary(video)')
if music:
xbmc.executebuiltin('UpdateLibrary(music)')
def tag_last(iterable):
"""
Given some iterable, returns (last, item), where last is only True if you
are on the final iteration.
"""
iterator = iter(iterable)
gotone = False
try:
lookback = next(iterator)
gotone = True
while True:
cur = next(iterator)
yield False, lookback
lookback = cur
except StopIteration:
if gotone:
yield True, lookback
raise StopIteration()

View file

@ -29,26 +29,6 @@ UPDATED_AT_SAFETY = 60 * 5
LAST_VIEWED_AT_SAFETY = 60 * 5
def tag_last(iterable):
"""
Given some iterable, returns (last, item), where last is only True if you
are on the final iteration.
"""
iterator = iter(iterable)
gotone = False
try:
lookback = next(iterator)
gotone = True
while True:
cur = next(iterator)
yield False, lookback
lookback = cur
except StopIteration:
if gotone:
yield True, lookback
raise StopIteration()
class InitNewSection(object):
"""
Throw this into the queue used for ProcessMetadata to tell it which
@ -201,7 +181,7 @@ class FullSync(common.fullsync_mixin):
self.current = 0
# Initialize only once to avoid loosing the last value before
# we're breaking the for loop
loop = tag_last(iterator)
loop = common.tag_last(iterator)
while True:
# Check Plex DB to see what we need to add/update
with PlexDB() as self.plexdb: