mirror of
https://github.com/ArchiveBox/ArchiveBox
synced 2025-02-16 21:38:33 +00:00
refactor: Change archive_links check to focus on queryset, so it allows other iterables and not just lists
This commit is contained in:
parent
fa622d3e14
commit
01fb44fd40
1 changed files with 6 additions and 5 deletions
|
@ -4,6 +4,7 @@ import os
|
|||
|
||||
from typing import Optional, List, Iterable
|
||||
from datetime import datetime
|
||||
from django.db.models import QuerySet
|
||||
|
||||
from ..index.schema import Link
|
||||
from ..index import (
|
||||
|
@ -131,14 +132,14 @@ def archive_link(link: Link, overwrite: bool=False, methods: Optional[Iterable[s
|
|||
@enforce_types
|
||||
def archive_links(all_links: any, overwrite: bool=False, methods: Optional[Iterable[str]]=None, out_dir: Optional[str]=None) -> List[Link]:
|
||||
|
||||
if type(all_links) is list:
|
||||
num_links: int = len(all_links)
|
||||
get_link = lambda x: x
|
||||
get_iter = lambda x: x
|
||||
else:
|
||||
if type(all_links) is QuerySet:
|
||||
num_links: int = all_links.count()
|
||||
get_link = lambda x: x.as_link()
|
||||
get_iter = lambda x: x.iterator()
|
||||
else:
|
||||
num_links: int = len(all_links)
|
||||
get_link = lambda x: x
|
||||
get_iter = lambda x: x
|
||||
|
||||
if num_links == 0:
|
||||
return []
|
||||
|
|
Loading…
Add table
Reference in a new issue