diff --git a/location/__init__.py b/location/__init__.py index b20d500..35c3c7a 100644 --- a/location/__init__.py +++ b/location/__init__.py @@ -12,7 +12,8 @@ import pytz from kython import kompress -from kython.kcache import make_dbcache, mtime_hash + +from cachew import cachew, mtime_hash # pipe install geopy @@ -38,8 +39,6 @@ class Location(NamedTuple): alt: Optional[float] tag: Tag -dbcache = make_dbcache(CACHE_PATH, hashf=mtime_hash, type_=Location, chunk_by=10000, logger=get_logger()) - def tagger(dt: datetime, point: geopy.Point) -> Tag: TAGS = [ @@ -87,8 +86,7 @@ def _iter_locations_fo(fo, start, stop) -> Iterator[Location]: ) # TODO hope they are sorted... -# TODO that could also serve as basis for tz provider -@dbcache +@cachew(CACHE_PATH, hashf=mtime_hash, cls=Location, chunk_by=10000, logger=get_logger()) def _iter_locations(path: Path, start=0, stop=None) -> Iterator[Location]: if path.suffix == '.json': ctx = path.open('r') diff --git a/location/__main__.py b/location/__main__.py index a796ea6..442d4df 100644 --- a/location/__main__.py +++ b/location/__main__.py @@ -4,13 +4,11 @@ import logging from location import get_logger, get_locations, iter_locations, get_groups from kython.klogging import setup_logzero -from kython.kcache import get_kcache_logger def main(): logger = get_logger() - setup_logzero(logger, level=logging.INFO) - setup_logzero(get_kcache_logger(), level=logging.DEBUG) + setup_logzero(logger, level=logging.DEBUG) if len(sys.argv) > 1: