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
47 lines
1.1 KiB
Python
47 lines
1.1 KiB
Python
"""
|
|
Merges location data from multiple sources
|
|
"""
|
|
|
|
from typing import Iterator
|
|
|
|
from my.core import Stats, LazyLogger
|
|
from my.core.source import import_source
|
|
|
|
from .common import Location
|
|
|
|
|
|
logger = LazyLogger(__name__, level="warning")
|
|
|
|
|
|
def locations() -> Iterator[Location]:
|
|
# can add/comment out sources here to disable them, or use core.disabled_modules
|
|
yield from _takeout_locations()
|
|
yield from _gpslogger_locations()
|
|
yield from _ip_locations()
|
|
|
|
|
|
@import_source(module_name="my.location.google_takeout")
|
|
def _takeout_locations() -> Iterator[Location]:
|
|
from . import google_takeout
|
|
yield from google_takeout.locations()
|
|
|
|
|
|
@import_source(module_name="my.location.gpslogger")
|
|
def _gpslogger_locations() -> Iterator[Location]:
|
|
from . import gpslogger
|
|
yield from gpslogger.locations()
|
|
|
|
|
|
# TODO: remove, user should use fallback.estimate_location or fallback.fallback_locations instead
|
|
@import_source(module_name="my.location.via_ip")
|
|
def _ip_locations() -> Iterator[Location]:
|
|
from . import via_ip
|
|
yield from via_ip.locations()
|
|
|
|
|
|
def stats() -> Stats:
|
|
from my.core import stat
|
|
|
|
return {
|
|
**stat(locations),
|
|
}
|