python: Replace distutils.utils.split_quotes with shlex.split

distutils is deprecated and may be removed in python 3.12.
Use shlex.split which has been around since python 2.3.

shlex.split does not split on all the ASCII control characters that
split_quoted will[1], but for edk2 usage I don't think that matters.

[1] https://stackoverflow.com/questions/54999301/what-is-the-difference-between-distutils-util-split-quoted-and-shlex-split

Signed-off-by: Cole Robinson <crobinso@redhat.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
This commit is contained in:
Cole 2021-07-24 04:02:27 +08:00 committed by mergify[bot]
parent 2e1fb41339
commit 0b1b0a9674
2 changed files with 4 additions and 4 deletions

View File

@ -12,7 +12,7 @@
# #
from __future__ import print_function from __future__ import print_function
import Common.LongFilePathOs as os, codecs, re import Common.LongFilePathOs as os, codecs, re
import distutils.util import shlex
import Common.EdkLogger as EdkLogger import Common.EdkLogger as EdkLogger
from io import BytesIO from io import BytesIO
from Common.BuildToolError import * from Common.BuildToolError import *
@ -233,7 +233,7 @@ class UniFileClassObject(object):
# Get Language definition # Get Language definition
# #
def GetLangDef(self, File, Line): def GetLangDef(self, File, Line):
Lang = distutils.util.split_quoted((Line.split(u"//")[0])) Lang = shlex.split(Line.split(u"//")[0])
if len(Lang) != 3: if len(Lang) != 3:
try: try:
FileIn = UniFileClassObject.OpenUniFile(LongFilePath(File.Path)) FileIn = UniFileClassObject.OpenUniFile(LongFilePath(File.Path))

View File

@ -14,7 +14,7 @@ from __future__ import print_function
# Import Modules # Import Modules
# #
import os, codecs, re import os, codecs, re
import distutils.util import shlex
from Logger import ToolError from Logger import ToolError
from Logger import Log as EdkLogger from Logger import Log as EdkLogger
from Logger import StringTable as ST from Logger import StringTable as ST
@ -320,7 +320,7 @@ class UniFileClassObject(object):
# Get Language definition # Get Language definition
# #
def GetLangDef(self, File, Line): def GetLangDef(self, File, Line):
Lang = distutils.util.split_quoted((Line.split(u"//")[0])) Lang = shlex.split(Line.split(u"//")[0])
if len(Lang) != 3: if len(Lang) != 3:
try: try:
FileIn = codecs.open(File.Path, mode='rb', encoding='utf_8').readlines() FileIn = codecs.open(File.Path, mode='rb', encoding='utf_8').readlines()