linted
This commit is contained in:
parent
fae628b534
commit
17ca8f8b33
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
venv
|
venv
|
||||||
data/.cache.csv
|
data/.cache.csv
|
||||||
__pycache__
|
__pycache__
|
||||||
|
.idea
|
||||||
|
12
tww.py
12
tww.py
@ -3,10 +3,9 @@
|
|||||||
Find time now, in the past or future in any timezone or location.
|
Find time now, in the past or future in any timezone or location.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
|
||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
import sys
|
import os
|
||||||
|
|
||||||
import dateparser
|
import dateparser
|
||||||
from pytz.exceptions import UnknownTimeZoneError
|
from pytz.exceptions import UnknownTimeZoneError
|
||||||
@ -20,6 +19,7 @@ basepath = os.path.dirname(os.path.abspath(__file__))
|
|||||||
logging.basicConfig()
|
logging.basicConfig()
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
|
||||||
def parse_args():
|
def parse_args():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument('query', nargs='*', default="now", help="<datetime-like> to <timezone-like or location string>")
|
parser.add_argument('query', nargs='*', default="now", help="<datetime-like> to <timezone-like or location string>")
|
||||||
@ -36,12 +36,12 @@ def setup_logging_level(debug=False):
|
|||||||
logger.debug("Debugging enabled")
|
logger.debug("Debugging enabled")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Location:
|
class Location:
|
||||||
"""
|
"""
|
||||||
Represents a location with name, latitude and longitude
|
Represents a location with name, latitude and longitude
|
||||||
"""
|
"""
|
||||||
def __init__(self, name:str, latitude: float, longitude: float):
|
|
||||||
|
def __init__(self, name: str, latitude: float, longitude: float):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.latitude = latitude
|
self.latitude = latitude
|
||||||
self.longitude = longitude
|
self.longitude = longitude
|
||||||
@ -100,7 +100,7 @@ def write_to_cache(query, location):
|
|||||||
import csv
|
import csv
|
||||||
|
|
||||||
logger.debug("Writing location to cache")
|
logger.debug("Writing location to cache")
|
||||||
with open(os.path.join(basepath, "data",".cache.csv"), 'a+') as wf:
|
with open(os.path.join(basepath, "data", ".cache.csv"), 'a+') as wf:
|
||||||
cachewriter = csv.writer(wf)
|
cachewriter = csv.writer(wf)
|
||||||
cachewriter.writerow([query,
|
cachewriter.writerow([query,
|
||||||
location.latitude,
|
location.latitude,
|
||||||
@ -124,7 +124,7 @@ def resolve_location_local(query):
|
|||||||
from fuzzywuzzy import fuzz
|
from fuzzywuzzy import fuzz
|
||||||
|
|
||||||
query = query.lower()
|
query = query.lower()
|
||||||
create_if_not_exists(os.path.join(basepath, "data",".cache.csv"))
|
create_if_not_exists(os.path.join(basepath, "data", ".cache.csv"))
|
||||||
|
|
||||||
# location hypothesis heap
|
# location hypothesis heap
|
||||||
heap = []
|
heap = []
|
||||||
|
Loading…
Reference in New Issue
Block a user