From efb60782e91a93a9cc2cb33485e0cf1fc223702b Mon Sep 17 00:00:00 2001 From: Daniel Tsvetkov Date: Tue, 17 Mar 2020 18:43:35 +0100 Subject: [PATCH] fixes with logging --- data/.cache.csv | 1 + requirements.txt | 1 + src/tww/common.py | 4 ++++ src/tww/templates/dt.html | 2 +- src/tww/tokenizer.py | 6 +----- src/tww/tww.py | 2 ++ 6 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 data/.cache.csv create mode 100644 src/tww/common.py diff --git a/data/.cache.csv b/data/.cache.csv new file mode 100644 index 0000000..9d4be2f --- /dev/null +++ b/data/.cache.csv @@ -0,0 +1 @@ +zurich,47.3666667,8.5500002 diff --git a/requirements.txt b/requirements.txt index 041f24d..0fd3d9d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -29,6 +29,7 @@ python-dateutil==2.8.1 python-Levenshtein==0.12.0 pytz==2019.3 regex==2020.1.8 +scalpl==0.3.0 six==1.14.0 timezonefinder==4.2.0 traitlets==4.3.3 diff --git a/src/tww/common.py b/src/tww/common.py new file mode 100644 index 0000000..63ed784 --- /dev/null +++ b/src/tww/common.py @@ -0,0 +1,4 @@ +import logging + +logging.basicConfig() +logger = logging.getLogger() diff --git a/src/tww/templates/dt.html b/src/tww/templates/dt.html index 1ee2cd8..8208f44 100644 --- a/src/tww/templates/dt.html +++ b/src/tww/templates/dt.html @@ -21,5 +21,5 @@ var radius = canvas.height / 2; ctx.translate(radius, radius); radius = radius * 0.90; - drawClock(ctx, radius, "{{dst_dt.iso8601_time}}"); + drawClock(ctx, radius, "{{dt.iso8601_time}}"); \ No newline at end of file diff --git a/src/tww/tokenizer.py b/src/tww/tokenizer.py index f7f8d8d..12768a6 100644 --- a/src/tww/tokenizer.py +++ b/src/tww/tokenizer.py @@ -1,7 +1,6 @@ import argparse import json import locale -import logging import re from datetime import datetime @@ -12,6 +11,7 @@ from localization import setlocale, resolve_locale from tww import ISO_FORMAT, time_to_emoji, time_ago, workday_diff, workhours_diff, td_remainders, td_totals, td_iso8601 from tww import resolve_timezone, dateparser_parse_dt, get_utcnow, get_s_since_epoch, get_ms_since_epoch, \ dt_tz_translation, get_local_now, query_to_format_result +from common import logger custom_locale = resolve_locale() @@ -314,10 +314,6 @@ def parse_args(): return args -logging.basicConfig() -logger = logging.getLogger() - - def setup_logging_level(debug=False): log_level = logging.DEBUG if debug else logging.ERROR logger.setLevel(log_level) diff --git a/src/tww/tww.py b/src/tww/tww.py index e61d21c..d9707c1 100644 --- a/src/tww/tww.py +++ b/src/tww/tww.py @@ -29,6 +29,8 @@ from pytz.exceptions import UnknownTimeZoneError from timezonefinder import TimezoneFinder from word2number import w2n +from common import logger + FUZZ_THRESHOLD = 70 ISO_FORMAT = '%Y-%m-%dT%H:%M:%S%z' DEFAULT_FORMAT = '%Y-%m-%d %H:%M:%S%z'