Skip to content

Commit

Permalink
general: switch from deprecated utcnow and utcfromtimestamp methods
Browse files Browse the repository at this point in the history
  • Loading branch information
karlicoss committed Aug 10, 2024
1 parent 97575f4 commit 17f2399
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions scripts/browser_history.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
DEPRECATION = 'NOTE: this is DEPRECATED! Please use https://github.com/seanbreckenridge/browserexport instead'

from datetime import datetime
from datetime import datetime, timezone
from pathlib import Path
from subprocess import check_output
import filecmp
Expand Down Expand Up @@ -70,7 +70,7 @@ def backup_history(browser: Browser, to: Path, profile: str='*', pattern=None) -
assert to.is_dir()
logger = get_logger()

now = format_dt(datetime.utcnow())
now = format_dt(datetime.now(tz=timezone.utc))

path = get_path(browser, profile=profile)

Expand Down Expand Up @@ -99,7 +99,7 @@ def guess_db_date(db: Path) -> str:
'-csv',
db,
'SELECT max(datetime(((visits.visit_time/1000000)-11644473600), "unixepoch")) FROM visits;'
]).decode('utf8').strip().strip('"');
]).decode('utf8').strip().strip('"')
return format_dt(datetime.strptime(maxvisit, "%Y-%m-%d %H:%M:%S"))


Expand Down
2 changes: 1 addition & 1 deletion src/promnesia/sources/takeout_legacy.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def read_browser_history_json(takeout: TakeoutPath) -> Iterable[Visit]:
hist = j['Browser History']
for item in hist:
url = item['url']
time = datetime.utcfromtimestamp(item['time_usec'] / 10 ** 6).replace(tzinfo=pytz.utc)
time = datetime.fromtimestamp(item['time_usec'] / 10 ** 6, tz=pytz.utc)
# TODO any more interesitng info?
yield Visit(
url=url,
Expand Down
6 changes: 3 additions & 3 deletions src/promnesia/tests/test_extract.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from datetime import datetime
from datetime import datetime, timezone

from ..common import Visit, DbVisit, Loc, Source
from ..extract import extract_visits
Expand All @@ -14,9 +14,9 @@ class ExtractionError(Exception):
pass

def indexer():
yield Visit(url='http://test1', dt=datetime.utcfromtimestamp(0), locator=Loc.make('whatever'))
yield Visit(url='http://test1', dt=datetime.fromtimestamp(0, tz=timezone.utc), locator=Loc.make('whatever'))
yield ExtractionError()
yield Visit(url='http://test2', dt=datetime.utcfromtimestamp(0), locator=Loc.make('whatever'))
yield Visit(url='http://test2', dt=datetime.fromtimestamp(0, tz=timezone.utc), locator=Loc.make('whatever'))

[v1, e, v2] = extract_visits(source=Source(indexer), src='whatever')
assert isinstance(v1, DbVisit)
Expand Down

0 comments on commit 17f2399

Please sign in to comment.