mirror of
https://github.com/thegeeklab/ansible-later.git
synced 2024-11-24 22:00:40 +00:00
fix: remove deprecated distutils (#694)
This commit is contained in:
parent
f7592ce839
commit
0ebb855bc5
@ -4,9 +4,9 @@ import codecs
|
||||
import copy
|
||||
import os
|
||||
import re
|
||||
from distutils.version import LooseVersion
|
||||
|
||||
from ansible.plugins.loader import module_loader
|
||||
from packaging.version import Version
|
||||
|
||||
from ansiblelater import LOG, utils
|
||||
from ansiblelater.logger import flag_extra
|
||||
@ -129,7 +129,7 @@ class Candidate:
|
||||
f"{sid}Best practice '{description}' not met:\n{path}:{err}",
|
||||
extra=flag_extra(err_labels)
|
||||
)
|
||||
elif LooseVersion(standard.version) > LooseVersion(self.version):
|
||||
elif Version(standard.version) > Version(self.version):
|
||||
LOG.warning(
|
||||
f"{sid}Future standard '{description}' not met:\n{path}:{err}",
|
||||
extra=flag_extra(err_labels)
|
||||
|
@ -3,7 +3,6 @@
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
from distutils.util import strtobool
|
||||
|
||||
import colorama
|
||||
from pythonjsonlogger import jsonlogger
|
||||
@ -12,6 +11,30 @@ CONSOLE_FORMAT = "{}%(levelname)s:{} %(message)s"
|
||||
JSON_FORMAT = "%(asctime)s %(levelname)s %(message)s"
|
||||
|
||||
|
||||
def strtobool(value):
|
||||
"""Convert a string representation of truth to true or false."""
|
||||
|
||||
_map = {
|
||||
"y": True,
|
||||
"yes": True,
|
||||
"t": True,
|
||||
"true": True,
|
||||
"on": True,
|
||||
"1": True,
|
||||
"n": False,
|
||||
"no": False,
|
||||
"f": False,
|
||||
"false": False,
|
||||
"off": False,
|
||||
"0": False
|
||||
}
|
||||
|
||||
try:
|
||||
return _map[str(value).lower()]
|
||||
except KeyError as err:
|
||||
raise ValueError(f'"{value}" is not a valid bool value') from err
|
||||
|
||||
|
||||
def to_bool(string):
|
||||
return bool(strtobool(str(string)))
|
||||
|
||||
|
@ -4,9 +4,9 @@ import contextlib
|
||||
import re
|
||||
import sys
|
||||
from contextlib import suppress
|
||||
from distutils.version import LooseVersion
|
||||
|
||||
import yaml
|
||||
from packaging.version import Version
|
||||
|
||||
from ansiblelater import logger
|
||||
|
||||
@ -37,7 +37,7 @@ def count_spaces(c_string):
|
||||
|
||||
def standards_latest(standards):
|
||||
return max([standard.version for standard in standards if standard.version] or ["0.1"],
|
||||
key=LooseVersion)
|
||||
key=Version)
|
||||
|
||||
|
||||
def lines_ranges(lines_spec):
|
||||
|
Loading…
Reference in New Issue
Block a user