Sync EDKII BaseTools to BaseTools project r2065.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10915 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
@ -25,26 +25,26 @@ from DataType import *
|
||||
# @retval 1 Open file failed
|
||||
#
|
||||
def ConvertTextFileToDictionary(FileName, Dictionary, CommentCharacter, KeySplitCharacter, ValueSplitFlag, ValueSplitCharacter):
|
||||
try:
|
||||
F = open(FileName,'r')
|
||||
Keys = []
|
||||
for Line in F:
|
||||
if Line.startswith(CommentCharacter):
|
||||
continue
|
||||
LineList = Line.split(KeySplitCharacter,1)
|
||||
if len(LineList) >= 2:
|
||||
Key = LineList[0].split()
|
||||
if len(Key) == 1 and Key[0][0] != CommentCharacter and Key[0] not in Keys:
|
||||
if ValueSplitFlag:
|
||||
Dictionary[Key[0]] = LineList[1].replace('\\','/').split(ValueSplitCharacter)
|
||||
else:
|
||||
Dictionary[Key[0]] = LineList[1].strip().replace('\\','/')
|
||||
Keys += [Key[0]]
|
||||
F.close()
|
||||
return 0
|
||||
except:
|
||||
EdkLogger.info('Open file failed')
|
||||
return 1
|
||||
try:
|
||||
F = open(FileName,'r')
|
||||
Keys = []
|
||||
for Line in F:
|
||||
if Line.startswith(CommentCharacter):
|
||||
continue
|
||||
LineList = Line.split(KeySplitCharacter,1)
|
||||
if len(LineList) >= 2:
|
||||
Key = LineList[0].split()
|
||||
if len(Key) == 1 and Key[0][0] != CommentCharacter and Key[0] not in Keys:
|
||||
if ValueSplitFlag:
|
||||
Dictionary[Key[0]] = LineList[1].replace('\\','/').split(ValueSplitCharacter)
|
||||
else:
|
||||
Dictionary[Key[0]] = LineList[1].strip().replace('\\','/')
|
||||
Keys += [Key[0]]
|
||||
F.close()
|
||||
return 0
|
||||
except:
|
||||
EdkLogger.info('Open file failed')
|
||||
return 1
|
||||
|
||||
## Print the dictionary
|
||||
#
|
||||
@ -53,11 +53,11 @@ def ConvertTextFileToDictionary(FileName, Dictionary, CommentCharacter, KeySplit
|
||||
# @param Dict: The dictionary to be printed
|
||||
#
|
||||
def printDict(Dict):
|
||||
if Dict != None:
|
||||
KeyList = Dict.keys()
|
||||
for Key in KeyList:
|
||||
if Dict[Key] != '':
|
||||
print Key + ' = ' + str(Dict[Key])
|
||||
if Dict != None:
|
||||
KeyList = Dict.keys()
|
||||
for Key in KeyList:
|
||||
if Dict[Key] != '':
|
||||
print Key + ' = ' + str(Dict[Key])
|
||||
|
||||
## Print the dictionary
|
||||
#
|
||||
@ -67,9 +67,9 @@ def printDict(Dict):
|
||||
# @param key: The key of the item to be printed
|
||||
#
|
||||
def printList(Key, List):
|
||||
if type(List) == type([]):
|
||||
if len(List) > 0:
|
||||
if key.find(TAB_SPLIT) != -1:
|
||||
print "\n" + Key
|
||||
for Item in List:
|
||||
print Item
|
||||
if type(List) == type([]):
|
||||
if len(List) > 0:
|
||||
if Key.find(TAB_SPLIT) != -1:
|
||||
print "\n" + Key
|
||||
for Item in List:
|
||||
print Item
|
||||
|
Reference in New Issue
Block a user