Skip to content

Commit

Permalink
maintenance: deprecate timelimit argument (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
adbar committed May 2, 2024
1 parent 2b11567 commit 720ccbb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions courlan/urlstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,12 +371,12 @@ def get_download_urls(
self,
time_limit: int = 10,
max_urls: int = 10000,
timelimit: Optional[int] = None,
timelimit: Optional[int] = None, # TODO: remove later
) -> 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
if timelimit is not None:
raise ValueError("timelimit is deprecated, use time_limit instead")

urls = []
for website, entry in self.urldict.items():
Expand Down
6 changes: 5 additions & 1 deletion tests/urlstore_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,11 @@ 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(timelimit=0) # legacy

with pytest.raises(ValueError):
test_urls.get_download_urls(timelimit=0)

downloadable_urls = test_urls.get_download_urls(time_limit=0)
assert (
len(downloadable_urls) == 2
and downloadable_urls[0].startswith("https://www.example.org")
Expand Down

0 comments on commit 720ccbb

Please sign in to comment.