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:
@ -14,7 +14,6 @@
|
||||
"""
|
||||
Collect all defined strings in multiple uni files
|
||||
"""
|
||||
from __future__ import print_function
|
||||
|
||||
##
|
||||
# Import Modules
|
||||
@ -247,9 +246,9 @@ def FormatUniEntry(StrTokenName, TokenValueList, ContainerFile):
|
||||
for SubValue in ValueList:
|
||||
if SubValue.strip():
|
||||
SubValueContent += \
|
||||
' ' * (PreFormatLength + len('#language en-US ')) + '\"%s\\n\"' % SubValue.strip() + '\r\n'
|
||||
' ' * (PreFormatLength + len('#language en-US ')) + '\"%s\\n\"' % SubValue.strip() + '\n'
|
||||
SubValueContent = SubValueContent[(PreFormatLength + len('#language en-US ')):SubValueContent.rfind('\\n')] \
|
||||
+ '\"' + '\r\n'
|
||||
+ '\"' + '\n'
|
||||
SubContent += ' '*PreFormatLength + '#language %-5s ' % Lang + SubValueContent
|
||||
if SubContent:
|
||||
SubContent = StrTokenName + ' '*(PreFormatLength - len(StrTokenName)) + SubContent[PreFormatLength:]
|
||||
@ -291,7 +290,7 @@ class StringDefClassObject(object):
|
||||
def UpdateValue(self, Value = None):
|
||||
if Value is not None:
|
||||
if self.StringValue:
|
||||
self.StringValue = self.StringValue + '\r\n' + Value
|
||||
self.StringValue = self.StringValue + '\n' + Value
|
||||
else:
|
||||
self.StringValue = Value
|
||||
self.StringValueByteList = UniToHexList(self.StringValue)
|
||||
@ -465,7 +464,7 @@ class UniFileClassObject(object):
|
||||
if not Line.startswith(DT.TAB_COMMENT_EDK1_SPLIT) and HeaderStart and not HeaderEnd:
|
||||
HeaderEnd = True
|
||||
if Line.startswith(DT.TAB_COMMENT_EDK1_SPLIT) and HeaderStart and not HeaderEnd and FirstGenHeader:
|
||||
self.UniFileHeader += Line + '\r\n'
|
||||
self.UniFileHeader += Line + '\n'
|
||||
continue
|
||||
|
||||
#
|
||||
@ -511,11 +510,11 @@ class UniFileClassObject(object):
|
||||
if FileIn[LineCount].strip().startswith('#language'):
|
||||
Line = Line + FileIn[LineCount]
|
||||
FileIn[LineCount-1] = Line
|
||||
FileIn[LineCount] = '\r\n'
|
||||
FileIn[LineCount] = '\n'
|
||||
LineCount -= 1
|
||||
for Index in xrange (LineCount + 1, len (FileIn) - 1):
|
||||
for Index in range (LineCount + 1, len (FileIn) - 1):
|
||||
if (Index == len(FileIn) -1):
|
||||
FileIn[Index] = '\r\n'
|
||||
FileIn[Index] = '\n'
|
||||
else:
|
||||
FileIn[Index] = FileIn[Index + 1]
|
||||
continue
|
||||
@ -867,12 +866,12 @@ class UniFileClassObject(object):
|
||||
Value = Value + Lines[IndexJ].strip()[1:-1]
|
||||
CombineToken = False
|
||||
else:
|
||||
Value = Value + Lines[IndexJ].strip()[1:-1] + '\r\n'
|
||||
Value = Value + Lines[IndexJ].strip()[1:-1] + '\n'
|
||||
else:
|
||||
IndexI = IndexJ
|
||||
break
|
||||
if Value.endswith('\r\n'):
|
||||
Value = Value[: Value.rfind('\r\n')]
|
||||
if Value.endswith('\n'):
|
||||
Value = Value[: Value.rfind('\n')]
|
||||
Language = GetLanguageCode(Language, self.IsCompatibleMode, self.File)
|
||||
self.AddStringToList(Name, Language, Value)
|
||||
continue
|
||||
|
Reference in New Issue
Block a user