diff --git a/.gitignore b/.gitignore index aabd304..ca6e2e4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ venv src/tww/data/.cache.csv __pycache__ .idea +tww.egg-info \ No newline at end of file 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 9d47d43..c133cca 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,6 @@ backcall==0.1.0 chardet==3.0.4 -Click==7.0 +click==7.1.1 dateparser==0.7.2 DateTimeRange==0.6.1 decorator==4.4.1 diff --git a/setup.py b/setup.py index 67a5b1b..8e20596 100644 --- a/setup.py +++ b/setup.py @@ -2,56 +2,56 @@ from setuptools import setup def gen_from_file(): - return [ - 'backcall==0.1.0', - 'chardet==3.0.4', - 'Click==7.0', - 'dateparser==0.7.2', - 'DateTimeRange==0.6.1', - 'decorator==4.4.1', - 'Flask==1.1.1', - 'freezegun==0.3.14', - 'fuzzywuzzy==0.18.0', - 'geographiclib==1.50', - 'geopy==1.21.0', - 'importlib-resources==1.0.2', - 'ipython==7.12.0', - 'ipython-genutils==0.2.0', - 'isodate==0.6.0', - 'itsdangerous==1.1.0', - 'jedi==0.16.0', - 'Jinja2==2.11.1', - 'MarkupSafe==1.1.1', - 'mbstrdecoder==0.8.4', - 'numpy==1.18.1', - 'parso==0.6.1', - 'pexpect==4.8.0', - 'pickleshare==0.7.5', - 'prompt-toolkit==3.0.3', - 'ptyprocess==0.6.0', - 'Pygments==2.5.2', - 'python-dateutil==2.8.1', - 'python-Levenshtein==0.12.0', - 'pytz==2019.3', - 'regex==2020.1.8', - 'six==1.14.0', - 'timezonefinder==4.2.0', - 'traitlets==4.3.3', - 'typepy==0.6.5', - 'tzlocal==2.0.0', - 'wcwidth==0.1.8', - 'Werkzeug==1.0.0', - 'word2number==1.1', - ] - # with open("requirements.txt") as f: - # return [line.strip() for line in f.readlines()] + # return [ + # 'backcall==0.1.0', + # 'chardet==3.0.4', + # 'Click==7.0', + # 'dateparser==0.7.2', + # 'DateTimeRange==0.6.1', + # 'decorator==4.4.1', + # 'Flask==1.1.1', + # 'freezegun==0.3.14', + # 'fuzzywuzzy==0.18.0', + # 'geographiclib==1.50', + # 'geopy==1.21.0', + # 'importlib-resources==1.0.2', + # 'ipython==7.12.0', + # 'ipython-genutils==0.2.0', + # 'isodate==0.6.0', + # 'itsdangerous==1.1.0', + # 'jedi==0.16.0', + # 'Jinja2==2.11.1', + # 'MarkupSafe==1.1.1', + # 'mbstrdecoder==0.8.4', + # 'numpy==1.18.1', + # 'parso==0.6.1', + # 'pexpect==4.8.0', + # 'pickleshare==0.7.5', + # 'prompt-toolkit==3.0.3', + # 'ptyprocess==0.6.0', + # 'Pygments==2.5.2', + # 'python-dateutil==2.8.1', + # 'python-Levenshtein==0.12.0', + # 'pytz==2019.3', + # 'regex==2020.1.8', + # 'six==1.14.0', + # 'timezonefinder==4.2.0', + # 'traitlets==4.3.3', + # 'typepy==0.6.5', + # 'tzlocal==2.0.0', + # 'wcwidth==0.1.8', + # 'Werkzeug==1.0.0', + # 'word2number==1.1', + # ] + with open("requirements.txt") as f: + return [line.strip() for line in f.readlines()] setup(name='tww', version='0.2', description='Time When and Where', url='http://gitlab.com/pisquared/tww', - author='Flying Circus', + author='Daniel Tsvetkov', install_requires=gen_from_file(), author_email='', license='MIT', diff --git a/src/main.py b/src/main.py new file mode 100644 index 0000000..14373da --- /dev/null +++ b/src/main.py @@ -0,0 +1,6 @@ +from tww.tokenizer import parse_args, setup_logging_level, main + +if __name__ == "__main__": + args = parse_args() + setup_logging_level(args.debug) + main(args) 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/localization.py b/src/tww/localization.py index 155d7c8..12c0563 100644 --- a/src/tww/localization.py +++ b/src/tww/localization.py @@ -5,7 +5,7 @@ import os from fuzzywuzzy import fuzz -from tww import basepath +from tww.tww import basepath @contextlib.contextmanager 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..f690c4e 100644 --- a/src/tww/tokenizer.py +++ b/src/tww/tokenizer.py @@ -1,17 +1,18 @@ import argparse import json import locale -import logging import re +import logging from datetime import datetime from pygments import highlight, lexers, formatters from scalpl import Cut -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, \ +from tww.localization import setlocale, resolve_locale +from tww.tww import ISO_FORMAT, time_to_emoji, time_ago, workday_diff, workhours_diff, td_remainders, td_totals, td_iso8601 +from tww.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 tww.common import logger custom_locale = resolve_locale() @@ -314,10 +315,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) @@ -333,9 +330,3 @@ def main(args): if args.full: pretty_print_dict(result) show_magic_results(result, args) - - -if __name__ == "__main__": - args = parse_args() - setup_logging_level(args.debug) - main(args) diff --git a/src/tww/tww.py b/src/tww/tww.py index e61d21c..1bd690b 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 tww.common import logger + FUZZ_THRESHOLD = 70 ISO_FORMAT = '%Y-%m-%dT%H:%M:%S%z' DEFAULT_FORMAT = '%Y-%m-%d %H:%M:%S%z'