Merge branch 'master' of gitlab.com:pisquared/tww

This commit is contained in:
Daniel Tsvetkov 2020-04-23 11:24:14 +02:00
commit 361904c9b7
10 changed files with 66 additions and 61 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@ venv
src/tww/data/.cache.csv
__pycache__
.idea
tww.egg-info

1
data/.cache.csv Normal file
View File

@ -0,0 +1 @@
zurich,47.3666667,8.5500002
1 zurich 47.3666667 8.5500002

View File

@ -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

View File

@ -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',

6
src/main.py Normal file
View File

@ -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)

4
src/tww/common.py Normal file
View File

@ -0,0 +1,4 @@
import logging
logging.basicConfig()
logger = logging.getLogger()

View File

@ -5,7 +5,7 @@ import os
from fuzzywuzzy import fuzz
from tww import basepath
from tww.tww import basepath
@contextlib.contextmanager

View File

@ -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}}");
</script>

View File

@ -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)

View File

@ -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'