Open Mr0grog opened 3 years ago
This is useful because it provides a more readable way to set timeframes. For example:
# 4 hour window as an integer:
get_memento(url, exact=False, target_window=4 * 60 * 60)
# 4 hour window as a timedelta:
get_memento(url, exact=False, target_window=timedelta(hours=4))
The
WaybackClient.get_memento()
method has atarget_window
parameter, which is used when a memento does not exist at the requested time. If the parameterexact=False
,get_memento()
returns the nearest-in-time memento, but only if it is within the number of seconds specified intarget_window
.https://github.com/edgi-govdata-archiving/wayback/blob/c066e04c1ba11c26febac574b37ee739cc5796e2/wayback/_client.py#L717-L719
Since Python has a built in
datetime.timedelta
type to represent exactly this kind of concept, we should also accept it instead of an integer fortarget_window
. (Really, I’m not sure why we didn’t do this originally!)