Fixing len() bug (#32)
* added class functionality * Update wrapper.py * style edits * fixed bug with len() of url() * fixing len() bug * fixing len() bug * squashing bug * removed test notebook
This commit is contained in:
parent
d465454019
commit
91e7f65617
@ -3,7 +3,7 @@
|
|||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import json
|
import json
|
||||||
from datetime import datetime
|
from datetime import datetime, timedelta
|
||||||
from waybackpy.exceptions import WaybackError
|
from waybackpy.exceptions import WaybackError
|
||||||
from waybackpy.__version__ import __version__
|
from waybackpy.__version__ import __version__
|
||||||
|
|
||||||
@ -80,6 +80,14 @@ class Url:
|
|||||||
return "%s" % self.archive_url
|
return "%s" % self.archive_url
|
||||||
|
|
||||||
def __len__(self):
|
def __len__(self):
|
||||||
|
td_max = timedelta(days=999999999,
|
||||||
|
hours=23,
|
||||||
|
minutes=59,
|
||||||
|
seconds=59,
|
||||||
|
microseconds=999999)
|
||||||
|
if self.timestamp == datetime.max:
|
||||||
|
return td_max.days
|
||||||
|
else:
|
||||||
diff = datetime.utcnow() - self.timestamp
|
diff = datetime.utcnow() - self.timestamp
|
||||||
return diff.days
|
return diff.days
|
||||||
|
|
||||||
@ -122,7 +130,8 @@ class Url:
|
|||||||
data = self.JSON
|
data = self.JSON
|
||||||
|
|
||||||
if not data["archived_snapshots"]:
|
if not data["archived_snapshots"]:
|
||||||
time = None
|
time = datetime.max
|
||||||
|
|
||||||
else:
|
else:
|
||||||
time = datetime.strptime(data["archived_snapshots"]
|
time = datetime.strptime(data["archived_snapshots"]
|
||||||
["closest"]
|
["closest"]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user