summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python/Common
diff options
context:
space:
mode:
authorYonghong Zhu <yonghong.zhu@intel.com>2015-12-18 06:43:57 +0000
committervanjeff <vanjeff@Edk2>2015-12-18 06:43:57 +0000
commit253a4b8ccbb4a984189eb29c48c25f6ef266ca80 (patch)
treea2207b2a3a2e6f9a42a5d9262cf616dfa369b727 /BaseTools/Source/Python/Common
parent818e60d95106bd68679bf4be1cef67f0d0af4b6c (diff)
downloadedk2-platforms-253a4b8ccbb4a984189eb29c48c25f6ef266ca80.tar.xz
BaseTools: Clean some coding style issues
This patch clean some coding style issues, majorly for space character. (Sync patch r19080 from main trunk.) Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/branches/UDK2015@19369 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'BaseTools/Source/Python/Common')
-rw-r--r--BaseTools/Source/Python/Common/Dictionary.py8
-rw-r--r--BaseTools/Source/Python/Common/EdkIIWorkspace.py24
-rw-r--r--BaseTools/Source/Python/Common/FdfParserLite.py8
-rw-r--r--BaseTools/Source/Python/Common/MigrationUtilities.py4
-rw-r--r--BaseTools/Source/Python/Common/Misc.py62
-rw-r--r--BaseTools/Source/Python/Common/ToolDefClassObject.py6
6 files changed, 56 insertions, 56 deletions
diff --git a/BaseTools/Source/Python/Common/Dictionary.py b/BaseTools/Source/Python/Common/Dictionary.py
index 5300a5456c..1c33fefabf 100644
--- a/BaseTools/Source/Python/Common/Dictionary.py
+++ b/BaseTools/Source/Python/Common/Dictionary.py
@@ -27,19 +27,19 @@ from Common.LongFilePathSupport import OpenLongFilePath as open
#
def ConvertTextFileToDictionary(FileName, Dictionary, CommentCharacter, KeySplitCharacter, ValueSplitFlag, ValueSplitCharacter):
try:
- F = open(FileName,'r')
+ F = open(FileName, 'r')
Keys = []
for Line in F:
if Line.startswith(CommentCharacter):
continue
- LineList = Line.split(KeySplitCharacter,1)
+ 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)
+ Dictionary[Key[0]] = LineList[1].replace('\\', '/').split(ValueSplitCharacter)
else:
- Dictionary[Key[0]] = LineList[1].strip().replace('\\','/')
+ Dictionary[Key[0]] = LineList[1].strip().replace('\\', '/')
Keys += [Key[0]]
F.close()
return 0
diff --git a/BaseTools/Source/Python/Common/EdkIIWorkspace.py b/BaseTools/Source/Python/Common/EdkIIWorkspace.py
index 401efeef3c..f22a545b77 100644
--- a/BaseTools/Source/Python/Common/EdkIIWorkspace.py
+++ b/BaseTools/Source/Python/Common/EdkIIWorkspace.py
@@ -59,7 +59,7 @@ class EdkIIWorkspace:
#
# Load TianoCoreOrgLogo, used for GUI tool
#
- self.Icon = wx.Icon(self.WorkspaceFile('tools/Python/TianoCoreOrgLogo.gif'),wx.BITMAP_TYPE_GIF)
+ self.Icon = wx.Icon(self.WorkspaceFile('tools/Python/TianoCoreOrgLogo.gif'), wx.BITMAP_TYPE_GIF)
except:
self.Icon = None
@@ -151,7 +151,7 @@ class EdkIIWorkspace:
def XmlParseFileSection (self, FileName, SectionTag):
if self.Verbose:
print FileName
- return XmlParseFileSection (self.WorkspaceFile(FileName), SectionTag)
+ return XmlParseFileSection (self.WorkspaceFile(FileName), SectionTag)
## Save a XML file
#
@@ -219,19 +219,19 @@ class EdkIIWorkspace:
#
def ConvertTextFileToDictionary(FileName, Dictionary, CommentCharacter, KeySplitCharacter, ValueSplitFlag, ValueSplitCharacter):
try:
- F = open(FileName,'r')
+ F = open(FileName, 'r')
except:
return False
Keys = []
for Line in F:
- LineList = Line.split(KeySplitCharacter,1)
+ 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 len(Key) == 1 and Key[0][0] != CommentCharacter and Key[0] not in Keys:
if ValueSplitFlag:
- Dictionary[Key[0]] = LineList[1].replace('\\','/').split(ValueSplitCharacter)
+ Dictionary[Key[0]] = LineList[1].replace('\\', '/').split(ValueSplitCharacter)
else:
- Dictionary[Key[0]] = LineList[1].strip().replace('\\','/')
+ Dictionary[Key[0]] = LineList[1].strip().replace('\\', '/')
Keys += [Key[0]]
F.close()
return True
@@ -252,7 +252,7 @@ def ConvertTextFileToDictionary(FileName, Dictionary, CommentCharacter, KeySplit
#
def ConvertDictionaryToTextFile(FileName, Dictionary, CommentCharacter, KeySplitCharacter, ValueSplitFlag, ValueSplitCharacter):
try:
- F = open(FileName,'r')
+ F = open(FileName, 'r')
Lines = []
Lines = F.readlines()
F.close()
@@ -265,7 +265,7 @@ def ConvertDictionaryToTextFile(FileName, Dictionary, CommentCharacter, KeySplit
MaxLength = len(Key)
Index = 0
for Line in Lines:
- LineList = Line.split(KeySplitCharacter,1)
+ 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] in Dictionary:
@@ -275,17 +275,17 @@ def ConvertDictionaryToTextFile(FileName, Dictionary, CommentCharacter, KeySplit
Line = '%-*s %c %s\n' % (MaxLength, Key[0], KeySplitCharacter, Dictionary[Key[0]])
Lines.pop(Index)
if Key[0] in Keys:
- Lines.insert(Index,Line)
+ Lines.insert(Index, Line)
Keys.remove(Key[0])
Index += 1
for RemainingKey in Keys:
if ValueSplitFlag:
- Line = '%-*s %c %s\n' % (MaxLength, RemainingKey, KeySplitCharacter,' '.join(Dictionary[RemainingKey]))
+ Line = '%-*s %c %s\n' % (MaxLength, RemainingKey, KeySplitCharacter, ' '.join(Dictionary[RemainingKey]))
else:
Line = '%-*s %c %s\n' % (MaxLength, RemainingKey, KeySplitCharacter, Dictionary[RemainingKey])
Lines.append(Line)
try:
- F = open(FileName,'w')
+ F = open(FileName, 'w')
except:
return False
F.writelines(Lines)
diff --git a/BaseTools/Source/Python/Common/FdfParserLite.py b/BaseTools/Source/Python/Common/FdfParserLite.py
index a0ee249748..a8cce26120 100644
--- a/BaseTools/Source/Python/Common/FdfParserLite.py
+++ b/BaseTools/Source/Python/Common/FdfParserLite.py
@@ -69,8 +69,8 @@ class Warning (Exception):
# @param File The FDF name
# @param Line The Line number that error occurs
#
- def __init__(self, Str, File = None, Line = None):
-
+ def __init__(self, Str, File=None, Line=None):
+
FileLineTuple = GetRealFileLine(File, Line)
self.FileName = FileLineTuple[0]
self.LineNumber = FileLineTuple[1]
@@ -359,8 +359,8 @@ class FdfParser(object):
else:
raise Warning("Macro not complete At Line ", self.FileName, self.CurrentLineNumber)
return Str
-
- def __ReplaceFragment(self, StartPos, EndPos, Value = ' '):
+
+ def __ReplaceFragment(self, StartPos, EndPos, Value=' '):
if StartPos[0] == EndPos[0]:
Offset = StartPos[1]
while Offset <= EndPos[1]:
diff --git a/BaseTools/Source/Python/Common/MigrationUtilities.py b/BaseTools/Source/Python/Common/MigrationUtilities.py
index 6d6669d7ae..e9f1cabcb7 100644
--- a/BaseTools/Source/Python/Common/MigrationUtilities.py
+++ b/BaseTools/Source/Python/Common/MigrationUtilities.py
@@ -423,7 +423,7 @@ def StoreHeader(TextFile, CommonHeader):
Description = CommonHeader.Description
License = CommonHeader.License
- Header = "#/** @file\n#\n"
+ Header = "#/** @file\n#\n"
Header += "# " + Abstract + "\n#\n"
Header += "# " + Description.strip().replace("\n", "\n# ") + "\n"
Header += "# " + CopyRight + "\n#\n"
@@ -519,7 +519,7 @@ def GetXmlFileInfo(FileName, TagTuple):
# @retval Options A optparse object containing the parsed options.
# @retval InputFile Path of an source file to be migrated.
#
-def MigrationOptionParser(Source, Destinate, ToolName, VersionNumber = 1.0):
+def MigrationOptionParser(Source, Destinate, ToolName, VersionNumber=1.0):
# use clearer usage to override default usage message
UsageString = "%s [-a] [-v|-q] [-o <output_file>] <input_file>" % ToolName
Version = "%s Version %.2f" % (ToolName, VersionNumber)
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index 0eedddc861..777450d818 100644
--- a/BaseTools/Source/Python/Common/Misc.py
+++ b/BaseTools/Source/Python/Common/Misc.py
@@ -38,7 +38,7 @@ from Common.LongFilePathSupport import OpenLongFilePath as open
from Common.MultipleWorkspace import MultipleWorkspace as mws
## Regular expression used to find out place holders in string template
-gPlaceholderPattern = re.compile("\$\{([^$()\s]+)\}", re.MULTILINE|re.UNICODE)
+gPlaceholderPattern = re.compile("\$\{([^$()\s]+)\}", re.MULTILINE | re.UNICODE)
## Dictionary used to store file time stamp for quick re-access
gFileTimeStampCache = {} # {file path : file time stamp}
@@ -293,11 +293,11 @@ def ProcessVariableArgument(Option, OptionString, Value, Parser):
def GuidStringToGuidStructureString(Guid):
GuidList = Guid.split('-')
Result = '{'
- for Index in range(0,3,1):
+ for Index in range(0, 3, 1):
Result = Result + '0x' + GuidList[Index] + ', '
Result = Result + '{0x' + GuidList[3][0:2] + ', 0x' + GuidList[3][2:4]
- for Index in range(0,12,2):
- Result = Result + ', 0x' + GuidList[4][Index:Index+2]
+ for Index in range(0, 12, 2):
+ Result = Result + ', 0x' + GuidList[4][Index:Index + 2]
Result += '}}'
return Result
@@ -494,7 +494,7 @@ def SaveFileOnChange(File, Content, IsBinaryFile=True):
Fd.write(Content)
Fd.close()
except IOError, X:
- EdkLogger.error(None, FILE_CREATE_FAILURE, ExtraData='IOError %s'%X)
+ EdkLogger.error(None, FILE_CREATE_FAILURE, ExtraData='IOError %s' % X)
return True
@@ -613,7 +613,7 @@ class DirCache:
#
# @retval A list of all files
#
-def GetFiles(Root, SkipList=None, FullPath = True):
+def GetFiles(Root, SkipList=None, FullPath=True):
OriPath = Root
FileList = []
for Root, Dirs, Files in os.walk(Root):
@@ -663,7 +663,7 @@ def RealPath2(File, Dir='', OverrideDir=''):
if OverrideDir[-1] == os.path.sep:
return NewFile[len(OverrideDir):], NewFile[0:len(OverrideDir)]
else:
- return NewFile[len(OverrideDir)+1:], NewFile[0:len(OverrideDir)]
+ return NewFile[len(OverrideDir) + 1:], NewFile[0:len(OverrideDir)]
if GlobalData.gAllFiles:
NewFile = GlobalData.gAllFiles[os.path.normpath(os.path.join(Dir, File))]
if not NewFile:
@@ -675,7 +675,7 @@ def RealPath2(File, Dir='', OverrideDir=''):
if Dir[-1] == os.path.sep:
return NewFile[len(Dir):], NewFile[0:len(Dir)]
else:
- return NewFile[len(Dir)+1:], NewFile[0:len(Dir)]
+ return NewFile[len(Dir) + 1:], NewFile[0:len(Dir)]
else:
return NewFile, ''
@@ -701,7 +701,7 @@ def ValidFile2(AllFiles, File, Ext=None, Workspace='', EfiSource='', EdkSource='
# Replace the default dir to current dir
if Dir == '.':
Dir = os.getcwd()
- Dir = Dir[len(Workspace)+1:]
+ Dir = Dir[len(Workspace) + 1:]
# First check if File has Edk definition itself
if File.find('$(EFI_SOURCE)') > -1 or File.find('$(EDK_SOURCE)') > -1:
@@ -740,7 +740,7 @@ def ValidFile3(AllFiles, File, Workspace='', EfiSource='', EdkSource='', Dir='.'
# Dir is current module dir related to workspace
if Dir == '.':
Dir = os.getcwd()
- Dir = Dir[len(Workspace)+1:]
+ Dir = Dir[len(Workspace) + 1:]
NewFile = File
RelaPath = AllFiles[os.path.normpath(Dir)]
@@ -865,7 +865,7 @@ class TemplateString(object):
#
# PlaceHolderName, PlaceHolderStartPoint, PlaceHolderEndPoint
#
- for PlaceHolder,Start,End in PlaceHolderList:
+ for PlaceHolder, Start, End in PlaceHolderList:
self._SubSectionList.append(TemplateSection[SubSectionStart:Start])
self._SubSectionList.append(TemplateSection[Start:End])
self._PlaceHolderList.append(PlaceHolder)
@@ -1251,11 +1251,11 @@ class tdict:
if len(key) > 1:
RestKeys = key[1:]
elif self._Level_ > 1:
- RestKeys = [self._Wildcard for i in range(0, self._Level_-1)]
+ RestKeys = [self._Wildcard for i in range(0, self._Level_ - 1)]
else:
FirstKey = key
if self._Level_ > 1:
- RestKeys = [self._Wildcard for i in range(0, self._Level_-1)]
+ RestKeys = [self._Wildcard for i in range(0, self._Level_ - 1)]
if FirstKey == None or str(FirstKey).upper() in self._ValidWildcardList:
FirstKey = self._Wildcard
@@ -1328,11 +1328,11 @@ class tdict:
if len(key) > 1:
RestKeys = key[1:]
else:
- RestKeys = [self._Wildcard for i in range(0, self._Level_-1)]
+ RestKeys = [self._Wildcard for i in range(0, self._Level_ - 1)]
else:
FirstKey = key
if self._Level_ > 1:
- RestKeys = [self._Wildcard for i in range(0, self._Level_-1)]
+ RestKeys = [self._Wildcard for i in range(0, self._Level_ - 1)]
if FirstKey in self._ValidWildcardList:
FirstKey = self._Wildcard
@@ -1437,7 +1437,7 @@ def AnalyzeDscPcd(Setting, PcdType, DataType=''):
Pair += 1
elif ch == ')' and not InStr:
Pair -= 1
-
+
if (Pair > 0 or InStr) and ch == TAB_VALUE_SPLIT:
NewStr += '-'
else:
@@ -1491,7 +1491,7 @@ def AnalyzeDscPcd(Setting, PcdType, DataType=''):
IsValid = (len(FieldList) <= 3)
else:
IsValid = (len(FieldList) <= 1)
- return [Value, Type, Size], IsValid, 0
+ return [Value, Type, Size], IsValid, 0
elif PcdType in (MODEL_PCD_DYNAMIC_VPD, MODEL_PCD_DYNAMIC_EX_VPD):
VpdOffset = FieldList[0]
Value = Size = ''
@@ -1532,17 +1532,17 @@ def AnalyzeDscPcd(Setting, PcdType, DataType=''):
#
# @retval ValueList: A List contain value, datum type and toke number.
#
-def AnalyzePcdData(Setting):
- ValueList = ['', '', '']
-
- ValueRe = re.compile(r'^\s*L?\".*\|.*\"')
+def AnalyzePcdData(Setting):
+ ValueList = ['', '', '']
+
+ ValueRe = re.compile(r'^\s*L?\".*\|.*\"')
PtrValue = ValueRe.findall(Setting)
ValueUpdateFlag = False
if len(PtrValue) >= 1:
Setting = re.sub(ValueRe, '', Setting)
- ValueUpdateFlag = True
+ ValueUpdateFlag = True
TokenList = Setting.split(TAB_VALUE_SPLIT)
ValueList[0:len(TokenList)] = TokenList
@@ -1578,17 +1578,17 @@ def AnalyzeHiiPcdData(Setting):
#
# @retval ValueList: A List contain VpdOffset, MaxDatumSize and InitialValue.
#
-def AnalyzeVpdPcdData(Setting):
- ValueList = ['', '', '']
-
- ValueRe = re.compile(r'\s*L?\".*\|.*\"\s*$')
+def AnalyzeVpdPcdData(Setting):
+ ValueList = ['', '', '']
+
+ ValueRe = re.compile(r'\s*L?\".*\|.*\"\s*$')
PtrValue = ValueRe.findall(Setting)
ValueUpdateFlag = False
if len(PtrValue) >= 1:
Setting = re.sub(ValueRe, '', Setting)
- ValueUpdateFlag = True
+ ValueUpdateFlag = True
TokenList = Setting.split(TAB_VALUE_SPLIT)
ValueList[0:len(TokenList)] = TokenList
@@ -1604,12 +1604,12 @@ def AnalyzeVpdPcdData(Setting):
#
def CheckPcdDatum(Type, Value):
if Type == "VOID*":
- ValueRe = re.compile(r'\s*L?\".*\"\s*$')
+ ValueRe = re.compile(r'\s*L?\".*\"\s*$')
if not (((Value.startswith('L"') or Value.startswith('"')) and Value.endswith('"'))
or (Value.startswith('{') and Value.endswith('}'))
):
return False, "Invalid value [%s] of type [%s]; must be in the form of {...} for array"\
- ", or \"...\" for string, or L\"...\" for unicode string" % (Value, Type)
+ ", or \"...\" for string, or L\"...\" for unicode string" % (Value, Type)
elif ValueRe.match(Value):
# Check the chars in UnicodeString or CString is printable
if Value.startswith("L"):
@@ -1662,7 +1662,7 @@ def SplitOption(OptionString):
if CurrentChar in ["/", "-"] and LastChar in [" ", "\t", "\r", "\n"]:
if Index > OptionStart:
- OptionList.append(OptionString[OptionStart:Index-1])
+ OptionList.append(OptionString[OptionStart:Index - 1])
OptionStart = Index
LastChar = CurrentChar
OptionList.append(OptionString[OptionStart:])
@@ -1739,7 +1739,7 @@ class PathClass(object):
if self.Root[-1] == os.path.sep:
self.File = self.Path[len(self.Root):]
else:
- self.File = self.Path[len(self.Root)+1:]
+ self.File = self.Path[len(self.Root) + 1:]
else:
self.Path = os.path.normpath(self.File)
diff --git a/BaseTools/Source/Python/Common/ToolDefClassObject.py b/BaseTools/Source/Python/Common/ToolDefClassObject.py
index 4fefbd91e0..4d54027820 100644
--- a/BaseTools/Source/Python/Common/ToolDefClassObject.py
+++ b/BaseTools/Source/Python/Common/ToolDefClassObject.py
@@ -42,7 +42,7 @@ gDefaultToolsDefFile = "tools_def.txt"
# @var MacroDictionary: To store keys and values defined in DEFINE statement
#
class ToolDefClassObject(object):
- def __init__(self, FileName = None):
+ def __init__(self, FileName=None):
self.ToolsDefTxtDictionary = {}
self.MacroDictionary = {}
for Env in os.environ:
@@ -61,7 +61,7 @@ class ToolDefClassObject(object):
FileContent = []
if os.path.isfile(FileName):
try:
- F = open(FileName,'r')
+ F = open(FileName, 'r')
FileContent = F.readlines()
except:
EdkLogger.error("tools_def.txt parser", FILE_OPEN_FAILURE, ExtraData=FileName)
@@ -155,7 +155,7 @@ class ToolDefClassObject(object):
self.ToolsDefTxtDatabase[TAB_TOD_DEFINES_COMMAND_TYPE].sort()
KeyList = [TAB_TOD_DEFINES_TARGET, TAB_TOD_DEFINES_TOOL_CHAIN_TAG, TAB_TOD_DEFINES_TARGET_ARCH, TAB_TOD_DEFINES_COMMAND_TYPE]
- for Index in range(3,-1,-1):
+ for Index in range(3, -1, -1):
for Key in dict(self.ToolsDefTxtDictionary):
List = Key.split('_')
if List[Index] == '*':