From 0418cae57ab0152b2b045f2bfa1c2c932b82dc4c Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 5 Sep 2021 01:22:21 -0700 Subject: [PATCH] Move truthystring to stringtools. --- .../ycdl_flask/backend/endpoints/channel_endpoints.py | 5 +++-- ycdl/helpers.py | 9 --------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/frontends/ycdl_flask/backend/endpoints/channel_endpoints.py b/frontends/ycdl_flask/backend/endpoints/channel_endpoints.py index c416339..225f0d0 100644 --- a/frontends/ycdl_flask/backend/endpoints/channel_endpoints.py +++ b/frontends/ycdl_flask/backend/endpoints/channel_endpoints.py @@ -3,6 +3,7 @@ import itertools from voussoirkit import flasktools from voussoirkit import pathclass +from voussoirkit import stringtools import ycdl @@ -130,7 +131,7 @@ def post_delete_channel(channel_id): @site.route('/channel//refresh', methods=['POST']) def post_refresh_channel(channel_id): force = request.form.get('force', False) - force = ycdl.helpers.truthystring(force) + force = stringtools.truthystring(force, False) try: channel = common.ycdldb.get_channel(channel_id) except ycdl.exceptions.NoSuchChannel as exc: @@ -142,7 +143,7 @@ def post_refresh_channel(channel_id): @site.route('/refresh_all_channels', methods=['POST']) def post_refresh_all_channels(): force = request.form.get('force', False) - force = ycdl.helpers.truthystring(force) + force = stringtools.truthystring(force, False) common.ycdldb.refresh_all_channels(force=force, skip_failures=True) return flasktools.make_json_response({}) diff --git a/ycdl/helpers.py b/ycdl/helpers.py index 3776d10..e69de29 100644 --- a/ycdl/helpers.py +++ b/ycdl/helpers.py @@ -1,9 +0,0 @@ -def truthystring(s): - if isinstance(s, (bool, int)) or s is None: - return s - s = s.lower() - if s in {'1', 'true', 't', 'yes', 'y', 'on'}: - return True - if s in {'null', 'none'}: - return None - return False