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 copy
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from distutils.version import LooseVersion
|
|
||||||
|
|
||||||
from ansible.plugins.loader import module_loader
|
from ansible.plugins.loader import module_loader
|
||||||
|
from packaging.version import Version
|
||||||
|
|
||||||
from ansiblelater import LOG, utils
|
from ansiblelater import LOG, utils
|
||||||
from ansiblelater.logger import flag_extra
|
from ansiblelater.logger import flag_extra
|
||||||
@ -129,7 +129,7 @@ class Candidate:
|
|||||||
f"{sid}Best practice '{description}' not met:\n{path}:{err}",
|
f"{sid}Best practice '{description}' not met:\n{path}:{err}",
|
||||||
extra=flag_extra(err_labels)
|
extra=flag_extra(err_labels)
|
||||||
)
|
)
|
||||||
elif LooseVersion(standard.version) > LooseVersion(self.version):
|
elif Version(standard.version) > Version(self.version):
|
||||||
LOG.warning(
|
LOG.warning(
|
||||||
f"{sid}Future standard '{description}' not met:\n{path}:{err}",
|
f"{sid}Future standard '{description}' not met:\n{path}:{err}",
|
||||||
extra=flag_extra(err_labels)
|
extra=flag_extra(err_labels)
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from distutils.util import strtobool
|
|
||||||
|
|
||||||
import colorama
|
import colorama
|
||||||
from pythonjsonlogger import jsonlogger
|
from pythonjsonlogger import jsonlogger
|
||||||
@ -12,6 +11,30 @@ CONSOLE_FORMAT = "{}%(levelname)s:{} %(message)s"
|
|||||||
JSON_FORMAT = "%(asctime)s %(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):
|
def to_bool(string):
|
||||||
return bool(strtobool(str(string)))
|
return bool(strtobool(str(string)))
|
||||||
|
|
||||||
|
@ -4,9 +4,9 @@ import contextlib
|
|||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
from contextlib import suppress
|
from contextlib import suppress
|
||||||
from distutils.version import LooseVersion
|
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
from packaging.version import Version
|
||||||
|
|
||||||
from ansiblelater import logger
|
from ansiblelater import logger
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ def count_spaces(c_string):
|
|||||||
|
|
||||||
def standards_latest(standards):
|
def standards_latest(standards):
|
||||||
return max([standard.version for standard in standards if standard.version] or ["0.1"],
|
return max([standard.version for standard in standards if standard.version] or ["0.1"],
|
||||||
key=LooseVersion)
|
key=Version)
|
||||||
|
|
||||||
|
|
||||||
def lines_ranges(lines_spec):
|
def lines_ranges(lines_spec):
|
||||||
|
Loading…
Reference in New Issue
Block a user