location fallback (#263)

see https://github.com/karlicoss/HPI/issues/262

* move home to fallback/via_home.py
* move via_ip to fallback
* add fallback model
* add stub via_ip file
* add fallback_locations for via_ip
* use protocol for locations
* estimate_from helper, via_home estimator, all.py
* via_home: add accuracy, cache history
* add datasources to gpslogger/google_takeout
* tz/via_location.py: update import to fallback
* denylist docs/installation instructions
* tz.via_location: let user customize cachew refresh time
* add via_ip.estimate_location using binary search
* use estimate_location in via_home.get_location
* tests: add gpslogger to location config stub
* tests: install tz related libs in test env
* tz: add regression test for broken windows dates

* vendorize bisect_left from python src
doesnt have a 'key' parameter till python3.10
This commit is contained in:
seanbreckenridge 2023-02-27 20:30:06 -08:00 committed by GitHub
parent 6dc5e7575f
commit 98b086f746
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 1166 additions and 190 deletions

View file

@ -1,7 +1,5 @@
from pathlib import Path
from more_itertools import one
import pytest # type: ignore
@ -20,26 +18,11 @@ def test() -> None:
@pytest.fixture(autouse=True)
def prepare(tmp_path: Path):
from .common import reset_modules
reset_modules()
user_config = _prepare_google_config(tmp_path)
from .shared_config import temp_config
user_config = temp_config(tmp_path)
import my.core.cfg as C
with C.tmp_config() as config:
config.google = user_config # type: ignore
config.google = user_config.google
yield
def _prepare_google_config(tmp_path: Path):
from .common import testdata
track = one(testdata().rglob('italy-slovenia-2017-07-29.json'))
# todo ugh. unnecessary zipping, but at the moment takeout provider doesn't support plain dirs
import zipfile
with zipfile.ZipFile(tmp_path / 'takeout.zip', 'w') as zf:
zf.writestr('Takeout/Location History/Location History.json', track.read_bytes())
class google_config:
takeout_path = tmp_path
return google_config