switch to cachew
This commit is contained in:
parent
8bbcf6aa1d
commit
e1a251d88a
2 changed files with 4 additions and 8 deletions
|
@ -12,7 +12,8 @@ import pytz
|
||||||
|
|
||||||
|
|
||||||
from kython import kompress
|
from kython import kompress
|
||||||
from kython.kcache import make_dbcache, mtime_hash
|
|
||||||
|
from cachew import cachew, mtime_hash
|
||||||
|
|
||||||
|
|
||||||
# pipe install geopy
|
# pipe install geopy
|
||||||
|
@ -38,8 +39,6 @@ class Location(NamedTuple):
|
||||||
alt: Optional[float]
|
alt: Optional[float]
|
||||||
tag: Tag
|
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:
|
def tagger(dt: datetime, point: geopy.Point) -> Tag:
|
||||||
TAGS = [
|
TAGS = [
|
||||||
|
@ -87,8 +86,7 @@ def _iter_locations_fo(fo, start, stop) -> Iterator[Location]:
|
||||||
)
|
)
|
||||||
|
|
||||||
# TODO hope they are sorted...
|
# TODO hope they are sorted...
|
||||||
# TODO that could also serve as basis for tz provider
|
@cachew(CACHE_PATH, hashf=mtime_hash, cls=Location, chunk_by=10000, logger=get_logger())
|
||||||
@dbcache
|
|
||||||
def _iter_locations(path: Path, start=0, stop=None) -> Iterator[Location]:
|
def _iter_locations(path: Path, start=0, stop=None) -> Iterator[Location]:
|
||||||
if path.suffix == '.json':
|
if path.suffix == '.json':
|
||||||
ctx = path.open('r')
|
ctx = path.open('r')
|
||||||
|
|
|
@ -4,13 +4,11 @@ import logging
|
||||||
from location import get_logger, get_locations, iter_locations, get_groups
|
from location import get_logger, get_locations, iter_locations, get_groups
|
||||||
|
|
||||||
from kython.klogging import setup_logzero
|
from kython.klogging import setup_logzero
|
||||||
from kython.kcache import get_kcache_logger
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
logger = get_logger()
|
logger = get_logger()
|
||||||
setup_logzero(logger, level=logging.INFO)
|
setup_logzero(logger, level=logging.DEBUG)
|
||||||
setup_logzero(get_kcache_logger(), level=logging.DEBUG)
|
|
||||||
|
|
||||||
|
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
|
|
Loading…
Add table
Reference in a new issue