Skip to content

Commit

Permalink
Merge pull request #592 from Relkci/replace-distutils-strtobool
Browse files Browse the repository at this point in the history
strtoboolreplace - replace deprecated distutils
  • Loading branch information
ChrisTruncer authored Nov 7, 2022
2 parents 46e3c02 + 82a4714 commit 4574110
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
3 changes: 1 addition & 2 deletions Python/MiktoList.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
import sys
import webbrowser

from distutils.util import strtobool
from modules.helpers import strtobool
from modules.db_manager import DB_Manager


def open_file_input(cli_parsed):
files = glob.glob(os.path.join(cli_parsed.d, 'report.html'))
if len(files) > 0:
Expand Down
2 changes: 1 addition & 1 deletion Python/Recategorize.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import sys
import webbrowser

from distutils.util import strtobool
from modules.helpers import strtobool
from modules.db_manager import DB_Manager
from modules.reporting import sort_data_and_write

Expand Down
2 changes: 1 addition & 1 deletion Python/Search.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import sys
import webbrowser

from distutils.util import strtobool
from modules.helpers import strtobool
from modules.db_manager import DB_Manager
from modules.reporting import search_report

Expand Down
18 changes: 17 additions & 1 deletion Python/modules/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import sys
import time
import xml.sax
from distutils.util import strtobool
import glob
import socket
from netaddr import IPAddress
Expand Down Expand Up @@ -836,6 +835,23 @@ def open_file_input(cli_parsed):
print('[*] No report files found to open, perhaps no hosts were successful')
return False


def strtobool(value, raise_exc=False):

str2b_true = {'yes', 'true', 't', 'y', '1'}
str2b_false = {'no', 'false', 'f', 'n', '0'}

if isinstance(value, str) or sys.version_info[0] < 3 and isinstance(value, basestring):
value = value.lower()
if value in str2b_true:
return True
if value in str2b_false:
return False

if raise_exc:
raise ValueError('Expected "%s"' % '", "'.join(str2b_true | str2b_false))
return None

def class_info():
class_image = '''MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM
M M
Expand Down

0 comments on commit 4574110

Please sign in to comment.