diff --git a/krawl/config.py b/krawl/config.py index 66de5e6..eb2f5b8 100644 --- a/krawl/config.py +++ b/krawl/config.py @@ -15,26 +15,10 @@ from collections.abc import Mapping, MutableMapping from copy import deepcopy from datetime import datetime -# from str_to_bool import str_to_bool +from str_to_bool import str_to_bool from pathlib import Path from typing import Any -"""Implementation of str_to_bool from Python 3.8.2.""" # HACK Copied from library python-strtobool, because it does not support python < 3.9 -def str_to_bool(val: str) -> bool: - """Convert a string representation of truth to `True` or `False`. - - True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values - are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if - 'val' is anything else. - """ - val = val.lower() - if val in ('y', 'yes', 't', 'true', 'on', '1'): - return True - if val in ('n', 'no', 'f', 'false', 'off', '0'): - return False - msg = f'Invalid truth value "{val}"' - raise ValueError(msg) - import yaml from cerberus import TypeDefinition, Validator from cerberus.errors import REQUIRED_FIELD, BasicErrorHandler, ValidationError diff --git a/poetry.lock b/poetry.lock index 072fdc4..ef25d64 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1162,6 +1162,17 @@ files = [ [package.dependencies] six = ">=1.5" +[[package]] +name = "python-strtobool" +version = "1.0.3" +description = "str_to_bool function for Python" +optional = false +python-versions = ">=3.0" +files = [ + {file = "python_strtobool-1.0.3-py3-none-any.whl", hash = "sha256:a9f6988be13660fbb451023fe2966aae423b48c8f67bd5948f7dc315184575d2"}, + {file = "python_strtobool-1.0.3.tar.gz", hash = "sha256:b05e8a732025907e0ab900693cf574bb275d0ef3473e3255dbb2958e0db32e1b"}, +] + [[package]] name = "pyyaml" version = "6.0.1" @@ -1687,4 +1698,4 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more [metadata] lock-version = "2.0" python-versions = ">=3.7,<4.0" -content-hash = "da9546efb89359693a9312f0c2cd4752756aea8a23973699be512d47de6bd408" +content-hash = "42ee98b71141b2a3987b04ebf264e23df1ea66beb69113cfcc0b482b12453685" diff --git a/pyproject.toml b/pyproject.toml index 0f81b77..f3e8828 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,7 @@ pathvalidate = "^2.3.2" langdetect = "^1.0.8" PyYAML = "^6.0" requests-oauthlib = "^1.3.0" -# python-strtobool = "^1.0.0" +python-strtobool = "^1.0.3" requests = "^2.26.0" python-dateutil = "^2.8.2" validators = "^0.18.2"