mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2025-05-15 07:34:27 -04: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 typing import Optional, List, Iterable
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from django.db.models import QuerySet
|
||||||
|
|
||||||
from ..index.schema import Link
|
from ..index.schema import Link
|
||||||
from ..index import (
|
from ..index import (
|
||||||
|
@ -131,14 +132,14 @@ def archive_link(link: Link, overwrite: bool=False, methods: Optional[Iterable[s
|
||||||
@enforce_types
|
@enforce_types
|
||||||
def archive_links(all_links: any, overwrite: bool=False, methods: Optional[Iterable[str]]=None, out_dir: Optional[str]=None) -> List[Link]:
|
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:
|
if type(all_links) is QuerySet:
|
||||||
num_links: int = len(all_links)
|
|
||||||
get_link = lambda x: x
|
|
||||||
get_iter = lambda x: x
|
|
||||||
else:
|
|
||||||
num_links: int = all_links.count()
|
num_links: int = all_links.count()
|
||||||
get_link = lambda x: x.as_link()
|
get_link = lambda x: x.as_link()
|
||||||
get_iter = lambda x: x.iterator()
|
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:
|
if num_links == 0:
|
||||||
return []
|
return []
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue