linted
This commit is contained in:
parent
fae628b534
commit
17ca8f8b33
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
venv
|
||||
data/.cache.csv
|
||||
__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.
|
||||
"""
|
||||
|
||||
import os
|
||||
import argparse
|
||||
import logging
|
||||
import sys
|
||||
import os
|
||||
|
||||
import dateparser
|
||||
from pytz.exceptions import UnknownTimeZoneError
|
||||
@ -20,6 +19,7 @@ basepath = os.path.dirname(os.path.abspath(__file__))
|
||||
logging.basicConfig()
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
||||
def parse_args():
|
||||
parser = argparse.ArgumentParser()
|
||||
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")
|
||||
|
||||
|
||||
|
||||
class Location:
|
||||
"""
|
||||
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.latitude = latitude
|
||||
self.longitude = longitude
|
||||
@ -100,7 +100,7 @@ def write_to_cache(query, location):
|
||||
import csv
|
||||
|
||||
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.writerow([query,
|
||||
location.latitude,
|
||||
@ -124,7 +124,7 @@ def resolve_location_local(query):
|
||||
from fuzzywuzzy import fuzz
|
||||
|
||||
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
|
||||
heap = []
|
||||
|
Loading…
Reference in New Issue
Block a user