BaseTools/UPT: Porting UPT Tool from Python2 to Python3
Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
@ -585,17 +585,17 @@ def GenPackageUNIEncodeFile(PackageObject, UniFileHeader = '', Encoding=TAB_ENCO
|
||||
|
||||
ContainerFile = GetUniFileName(os.path.dirname(PackageObject.GetFullPath()), PackageObject.GetBaseName())
|
||||
|
||||
Content = UniFileHeader + '\r\n'
|
||||
Content += '\r\n'
|
||||
Content = UniFileHeader + '\n'
|
||||
Content += '\n'
|
||||
|
||||
Content += FormatUniEntry('#string ' + TAB_DEC_PACKAGE_ABSTRACT, PackageObject.GetAbstract(), ContainerFile) + '\r\n'
|
||||
Content += FormatUniEntry('#string ' + TAB_DEC_PACKAGE_ABSTRACT, PackageObject.GetAbstract(), ContainerFile) + '\n'
|
||||
|
||||
Content += FormatUniEntry('#string ' + TAB_DEC_PACKAGE_DESCRIPTION, PackageObject.GetDescription(), ContainerFile) \
|
||||
+ '\r\n'
|
||||
+ '\n'
|
||||
|
||||
Content += FormatUniEntry('#string ' + TAB_DEC_BINARY_ABSTRACT, BinaryAbstract, ContainerFile) + '\r\n'
|
||||
Content += FormatUniEntry('#string ' + TAB_DEC_BINARY_ABSTRACT, BinaryAbstract, ContainerFile) + '\n'
|
||||
|
||||
Content += FormatUniEntry('#string ' + TAB_DEC_BINARY_DESCRIPTION, BinaryDescription, ContainerFile) + '\r\n'
|
||||
Content += FormatUniEntry('#string ' + TAB_DEC_BINARY_DESCRIPTION, BinaryDescription, ContainerFile) + '\n'
|
||||
|
||||
PromptGenList = []
|
||||
HelpTextGenList = []
|
||||
@ -612,7 +612,7 @@ def GenPackageUNIEncodeFile(PackageObject, UniFileHeader = '', Encoding=TAB_ENCO
|
||||
if (PcdPromptStrName, Lang) not in PromptGenList:
|
||||
TokenValueList.append((Lang, PromptStr))
|
||||
PromptGenList.append((PcdPromptStrName, Lang))
|
||||
PromptString = FormatUniEntry(PcdPromptStrName, TokenValueList, ContainerFile) + '\r\n'
|
||||
PromptString = FormatUniEntry(PcdPromptStrName, TokenValueList, ContainerFile) + '\n'
|
||||
if PromptString not in Content:
|
||||
Content += PromptString
|
||||
|
||||
@ -628,7 +628,7 @@ def GenPackageUNIEncodeFile(PackageObject, UniFileHeader = '', Encoding=TAB_ENCO
|
||||
if (PcdHelpStrName, Lang) not in HelpTextGenList:
|
||||
TokenValueList.append((Lang, HelpStr))
|
||||
HelpTextGenList.append((PcdHelpStrName, Lang))
|
||||
HelpTextString = FormatUniEntry(PcdHelpStrName, TokenValueList, ContainerFile) + '\r\n'
|
||||
HelpTextString = FormatUniEntry(PcdHelpStrName, TokenValueList, ContainerFile) + '\n'
|
||||
if HelpTextString not in Content:
|
||||
Content += HelpTextString
|
||||
|
||||
@ -639,7 +639,7 @@ def GenPackageUNIEncodeFile(PackageObject, UniFileHeader = '', Encoding=TAB_ENCO
|
||||
PcdErrStrName = '#string ' + TAB_STR_TOKENCNAME + TAB_UNDERLINE_SPLIT + Pcd.GetTokenSpaceGuidCName() \
|
||||
+ TAB_UNDERLINE_SPLIT + TAB_STR_TOKENERR \
|
||||
+ TAB_UNDERLINE_SPLIT + ErrorNo[2:]
|
||||
PcdErrString = FormatUniEntry(PcdErrStrName, PcdError.GetErrorMessageList(), ContainerFile) + '\r\n'
|
||||
PcdErrString = FormatUniEntry(PcdErrStrName, PcdError.GetErrorMessageList(), ContainerFile) + '\n'
|
||||
if PcdErrString not in Content:
|
||||
Content += PcdErrString
|
||||
|
||||
|
@ -234,22 +234,22 @@ def GenModuleUNIEncodeFile(ModuleObject, UniFileHeader='', Encoding=DT.TAB_ENCOD
|
||||
if not os.path.exists(os.path.dirname(ModuleObject.GetFullPath())):
|
||||
os.makedirs(os.path.dirname(ModuleObject.GetFullPath()))
|
||||
|
||||
Content = UniFileHeader + '\r\n'
|
||||
Content += '\r\n'
|
||||
Content = UniFileHeader + '\n'
|
||||
Content += '\n'
|
||||
|
||||
Content += FormatUniEntry('#string ' + DT.TAB_INF_ABSTRACT, ModuleObject.GetAbstract(), ContainerFile) + '\r\n'
|
||||
Content += FormatUniEntry('#string ' + DT.TAB_INF_ABSTRACT, ModuleObject.GetAbstract(), ContainerFile) + '\n'
|
||||
|
||||
Content += FormatUniEntry('#string ' + DT.TAB_INF_DESCRIPTION, ModuleObject.GetDescription(), ContainerFile) \
|
||||
+ '\r\n'
|
||||
+ '\n'
|
||||
|
||||
BinaryAbstractString = FormatUniEntry('#string ' + DT.TAB_INF_BINARY_ABSTRACT, BinaryAbstract, ContainerFile)
|
||||
if BinaryAbstractString:
|
||||
Content += BinaryAbstractString + '\r\n'
|
||||
Content += BinaryAbstractString + '\n'
|
||||
|
||||
BinaryDescriptionString = FormatUniEntry('#string ' + DT.TAB_INF_BINARY_DESCRIPTION, BinaryDescription, \
|
||||
ContainerFile)
|
||||
if BinaryDescriptionString:
|
||||
Content += BinaryDescriptionString + '\r\n'
|
||||
Content += BinaryDescriptionString + '\n'
|
||||
|
||||
if not os.path.exists(ContainerFile):
|
||||
File = codecs.open(ContainerFile, 'wb', Encoding)
|
||||
@ -274,7 +274,7 @@ def GenDefines(ModuleObject):
|
||||
if not DefinesDict:
|
||||
continue
|
||||
for Statement in DefinesDict:
|
||||
if Statement.split(DT.TAB_EQUAL_SPLIT) > 1:
|
||||
if len(Statement.split(DT.TAB_EQUAL_SPLIT)) > 1:
|
||||
Statement = (u'%s ' % Statement.split(DT.TAB_EQUAL_SPLIT, 1)[0]).ljust(LeftOffset) \
|
||||
+ u'= %s' % Statement.split(DT.TAB_EQUAL_SPLIT, 1)[1].lstrip()
|
||||
SortedArch = DT.TAB_ARCH_COMMON
|
||||
@ -409,7 +409,7 @@ def GenLibraryClasses(ModuleObject):
|
||||
Statement += '|' + FFE
|
||||
ModuleList = LibraryClass.GetSupModuleList()
|
||||
ArchList = LibraryClass.GetSupArchList()
|
||||
for Index in xrange(0, len(ArchList)):
|
||||
for Index in range(0, len(ArchList)):
|
||||
ArchList[Index] = ConvertArchForInstall(ArchList[Index])
|
||||
ArchList.sort()
|
||||
SortedArch = ' '.join(ArchList)
|
||||
@ -572,7 +572,7 @@ def GenUserExtensions(ModuleObject):
|
||||
# if not Statement:
|
||||
# continue
|
||||
ArchList = UserExtension.GetSupArchList()
|
||||
for Index in xrange(0, len(ArchList)):
|
||||
for Index in range(0, len(ArchList)):
|
||||
ArchList[Index] = ConvertArchForInstall(ArchList[Index])
|
||||
ArchList.sort()
|
||||
KeyList = []
|
||||
|
Reference in New Issue
Block a user