Skip to content

Commit

Permalink
compatibility: restore timelimit parameter (#96)
Browse files Browse the repository at this point in the history
  • Loading branch information
adbar committed Apr 30, 2024
1 parent 7e84223 commit faabe1c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion courlan/urlstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,16 @@ def get_url(self, domain: str, as_visited: bool = True) -> Optional[str]:
return None

def get_download_urls(
self, max_urls: int = 10000, time_limit: int = 10
self,
time_limit: int = 10,
max_urls: int = 10000,
timelimit: Optional[int] = None,
) -> Optional[List[str]]:
"""Get a list of immediately downloadable URLs according to the given
time limit per domain."""
# TODO: deprecate in later version
time_limit = timelimit if timelimit is not None else time_limit

urls = []
for website, entry in self.urldict.items():
if entry.state != State.OPEN:
Expand Down
2 changes: 1 addition & 1 deletion tests/urlstore_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ def test_urlstore():
test_urls.add_urls(
["https://www.example.org/1", "https://test.org/1", "https://test.org/2"]
)
downloadable_urls = test_urls.get_download_urls(time_limit=0)
downloadable_urls = test_urls.get_download_urls(timelimit=0) # legacy
assert (
len(downloadable_urls) == 2
and downloadable_urls[0].startswith("https://www.example.org")
Expand Down

0 comments on commit faabe1c

Please sign in to comment.