fix linter

This commit is contained in:
Jesse Bannon 2022-09-12 22:05:04 -07:00
parent a16fca5fde
commit 1446720e8d
2 changed files with 13 additions and 15 deletions

View file

@ -142,7 +142,7 @@ class CollectionDownloader(Downloader[CollectionDownloadOptions, Entry]):
for leaf_child in leaf_children:
leaf_child.add_variables(
parent._get_children_entry_variables_to_add(parent.child_entries)
parent.get_children_entry_variables_to_add(parent.child_entries)
)
leaf_child.add_variables(collection_url.variables)
@ -179,13 +179,11 @@ class CollectionDownloader(Downloader[CollectionDownloadOptions, Entry]):
Separate download archive writing between collection urls. This is so break_on_existing
does not break when downloading from subset urls.
"""
archive_path = self._enhanced_download_archive._archive_working_file_path
archive_path = self._ytdl_options_builder.to_dict().get("download_archive", "")
backup_archive_path = f"{archive_path}.backup"
archive_file_exists = False
# If archive path exists, maintain download archive is enable
if os.path.isfile(archive_path):
if archive_file_exists := archive_path and os.path.isfile(archive_path):
archive_file_exists = True
# If a backup exists, it's the one prior to any downloading, use that.
@ -198,8 +196,11 @@ class CollectionDownloader(Downloader[CollectionDownloadOptions, Entry]):
yield
# If an archive path did not exist at first, but now exists, delete it
if not archive_file_exists:
if not archive_file_exists and os.path.isfile(archive_path):
FileHandler.delete(file_path=archive_path)
# If the archive file did exist, restore the backup
elif archive_file_exists:
FileHandler.copy(src_file_path=backup_archive_path, dst_file_path=archive_path)
def _download_leaf_entry(self, entry: Entry) -> Entry:
download_logger.info("Downloading entry %s", entry.title)

View file

@ -19,18 +19,16 @@ class EntryParent(BaseEntry):
self._entry_parent = entry_parent
# pylint: disable=no-self-use
def _get_children_entry_variables_to_add(
self, child_entries: List[TChildEntry]
) -> Dict[str, str | int]:
def get_children_entry_variables_to_add(self) -> Dict[str, str | int]:
"""
Adds source variables to the child entry derived from the parent entry.
"""
if not child_entries:
if not self.child_entries:
return {}
return {
"playlist_max_upload_year": max(
entry.upload_year for entry in child_entries if isinstance(entry, Entry)
entry.upload_year for entry in self.child_entries if isinstance(entry, Entry)
)
}
@ -77,13 +75,12 @@ class EntryParent(BaseEntry):
child_class(entry_dict=entry_dict, working_directory=self.working_directory())
)
child_variables_to_add = self._get_children_entry_variables_to_add(child_entries)
for child_entry in child_entries:
child_entry.add_variables(variables_to_add=child_variables_to_add)
self._child_entries = sorted(
child_entries, key=lambda entry: entry.kwargs("playlist_index")
)
for child_entry in self._child_entries:
child_entry.add_variables(variables_to_add=self.get_children_entry_variables_to_add())
return self
@property