Added validate function to serviceitem

This commit is contained in:
Philip Ridout 2012-11-02 18:54:42 +00:00
parent d35d4f4f79
commit 443ad478c1
2 changed files with 19 additions and 7 deletions

View File

@ -508,3 +508,20 @@ class ServiceItem(object):
self._new_item()
self.render()
def remove_invalid_frames(self, invalid_paths=None):
"""
Remove invalid frames, such as ones where the file no longer exists.
"""
if self.uses_file():
for frame in self.get_frames():
if self.get_frame_path(frame=frame) in invalid_paths:
self.remove_frame(frame)
def validate(self):
"""
Validates this service item
"""
if not self._raw_frames:
self.is_valid = False
return self.is_valid

View File

@ -520,13 +520,8 @@ class ServiceManager(QtGui.QWidget):
# Check if item contains a missing file.
for item in list(self.serviceItems):
self.mainwindow.incrementProgressBar()
if item[u'service_item'].uses_file():
for frame in item[u'service_item'].get_frames():
path_from = item[u'service_item'].get_frame_path(
frame=frame)
if path_from in missing_list:
item[u'service_item'].remove_frame(frame)
if not item[u'service_item'].get_frames():
item[u'service_item'].remove_invalid_frames(missing_list)
if not item[u'service_item'].validate():
self.serviceItems.remove(item)
else:
service_item = item[u'service_item'].get_service_repr()