add fallback_locations for via_ip
This commit is contained in:
parent
f2c9715dbc
commit
31981b8f34
3 changed files with 62 additions and 10 deletions
|
@ -7,7 +7,7 @@ REQUIRES = ["git+https://github.com/seanbreckenridge/ipgeocache"]
|
|||
from my.core import __NOT_HPI_MODULE__
|
||||
|
||||
import ipaddress
|
||||
from typing import NamedTuple, Iterator
|
||||
from typing import NamedTuple, Iterator, Tuple
|
||||
from datetime import datetime
|
||||
|
||||
import ipgeocache
|
||||
|
@ -23,6 +23,12 @@ class IP(NamedTuple):
|
|||
def ipgeocache(self) -> Json:
|
||||
return ipgeocache.get(self.addr)
|
||||
|
||||
@property
|
||||
def latlon(self) -> Tuple[float, float]:
|
||||
loc: str = self.ipgeocache()["loc"]
|
||||
lat, _, lon = loc.partition(",")
|
||||
return float(lat), float(lon)
|
||||
|
||||
@property
|
||||
def tzname(self) -> str:
|
||||
tz: str = self.ipgeocache()["timezone"]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue