diff options
author | Gary Lin <glin@suse.com> | 2018-06-25 18:31:25 +0800 |
---|---|---|
committer | Yonghong Zhu <yonghong.zhu@intel.com> | 2018-06-27 16:31:30 +0800 |
commit | 5b0671c1e514e534c6d5be9604da33bfc2cd0a24 (patch) | |
tree | 7e9dbe54574d43494ef71e57f008074295217c82 /BaseTools/Source/Python/Workspace | |
parent | 00eb12a2c768cae3ca136110baacb5a35e9066a8 (diff) | |
download | edk2-5b0671c1e514e534c6d5be9604da33bfc2cd0a24.tar.gz edk2-5b0671c1e514e534c6d5be9604da33bfc2cd0a24.tar.bz2 edk2-5b0671c1e514e534c6d5be9604da33bfc2cd0a24.zip |
BaseTools: Refactor python except statements
Convert "except ... ," to "except ... as" to be compatible with python3.
Based on "futurize -f lib2to3.fixes.fix_except"
Contributed-under: TianoCore Contribution Agreement 1.1
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Gary Lin <glin@suse.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
Diffstat (limited to 'BaseTools/Source/Python/Workspace')
4 files changed, 16 insertions, 16 deletions
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 1ed7eb1c2c..a001162e8e 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -120,7 +120,7 @@ def GetDependencyList(FileStack,SearchPathList): try:
Fd = open(F, 'r')
FileContent = Fd.read()
- except BaseException, X:
+ except BaseException as X:
EdkLogger.error("build", FILE_OPEN_FAILURE, ExtraData=F + "\n\t" + str(X))
finally:
if "Fd" in dir(locals()):
@@ -887,11 +887,11 @@ class DscBuildData(PlatformBuildClassObject): DatumType = self._DecPcds[PcdCName, TokenSpaceGuid].DatumType
try:
ValueList[Index] = ValueExpressionEx(ValueList[Index], DatumType, self._GuidDict)(True)
- except BadExpression, Value:
+ except BadExpression as Value:
EdkLogger.error('Parser', FORMAT_INVALID, Value, File=self.MetaFile, Line=LineNo,
ExtraData="PCD [%s.%s] Value \"%s\" " % (
TokenSpaceGuid, PcdCName, ValueList[Index]))
- except EvaluationException, Excpt:
+ except EvaluationException as Excpt:
if hasattr(Excpt, 'Pcd'):
if Excpt.Pcd in GlobalData.gPlatformOtherPcds:
EdkLogger.error('Parser', FORMAT_INVALID, "Cannot use this PCD (%s) in an expression as"
@@ -1059,7 +1059,7 @@ class DscBuildData(PlatformBuildClassObject): return PcdValue
try:
PcdValue = ValueExpressionEx(PcdValue[1:], PcdDatumType, GuidDict)(True)
- except BadExpression, Value:
+ except BadExpression as Value:
EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %
(TokenSpaceGuidCName, TokenCName, PcdValue, Value))
elif PcdValue.startswith("L'") or PcdValue.startswith("'"):
@@ -1070,7 +1070,7 @@ class DscBuildData(PlatformBuildClassObject): return PcdValue
try:
PcdValue = ValueExpressionEx(PcdValue, PcdDatumType, GuidDict)(True)
- except BadExpression, Value:
+ except BadExpression as Value:
EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %
(TokenSpaceGuidCName, TokenCName, PcdValue, Value))
elif PcdValue.startswith('L'):
@@ -1082,7 +1082,7 @@ class DscBuildData(PlatformBuildClassObject): return PcdValue
try:
PcdValue = ValueExpressionEx(PcdValue, PcdDatumType, GuidDict)(True)
- except BadExpression, Value:
+ except BadExpression as Value:
EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %
(TokenSpaceGuidCName, TokenCName, PcdValue, Value))
else:
@@ -1109,7 +1109,7 @@ class DscBuildData(PlatformBuildClassObject): return PcdValue
try:
PcdValue = ValueExpressionEx(PcdValue, PcdDatumType, GuidDict)(True)
- except BadExpression, Value:
+ except BadExpression as Value:
EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %
(TokenSpaceGuidCName, TokenCName, PcdValue, Value))
return PcdValue
diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py index 836140759f..165e03f789 100644 --- a/BaseTools/Source/Python/Workspace/InfBuildData.py +++ b/BaseTools/Source/Python/Workspace/InfBuildData.py @@ -1121,7 +1121,7 @@ class InfBuildData(ModuleBuildClassObject): else:
try:
Pcd.DefaultValue = ValueExpressionEx(Pcd.DefaultValue, Pcd.DatumType, _GuidDict)(True)
- except BadExpression, Value:
+ except BadExpression as Value:
EdkLogger.error('Parser', FORMAT_INVALID, 'PCD [%s.%s] Value "%s", %s' %(TokenSpaceGuid, PcdRealName, Pcd.DefaultValue, Value),
File=self.MetaFile, Line=LineNo)
break
diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index 88c7bb374c..f1cfa73fd4 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -1341,7 +1341,7 @@ class DscParser(MetaFileParser): self._InSubsection = False
try:
Processer[self._ItemType]()
- except EvaluationException, Excpt:
+ except EvaluationException as Excpt:
#
# Only catch expression evaluation error here. We need to report
# the precise number of line on which the error occurred
@@ -1363,7 +1363,7 @@ class DscParser(MetaFileParser): EdkLogger.error('Parser', FORMAT_INVALID, "Invalid expression: %s" % str(Excpt),
File=self._FileWithError, ExtraData=' '.join(self._ValueList),
Line=self._LineIndex + 1)
- except MacroException, Excpt:
+ except MacroException as Excpt:
EdkLogger.error('Parser', FORMAT_INVALID, str(Excpt),
File=self._FileWithError, ExtraData=' '.join(self._ValueList),
Line=self._LineIndex + 1)
@@ -1465,10 +1465,10 @@ class DscParser(MetaFileParser): Macros.update(GlobalData.gGlobalDefines)
try:
Result = ValueExpression(self._ValueList[1], Macros)()
- except SymbolNotFound, Exc:
+ except SymbolNotFound as Exc:
EdkLogger.debug(EdkLogger.DEBUG_5, str(Exc), self._ValueList[1])
Result = False
- except WrnExpression, Excpt:
+ except WrnExpression as Excpt:
#
# Catch expression evaluation warning here. We need to report
# the precise number of line and return the evaluation result
@@ -1614,7 +1614,7 @@ class DscParser(MetaFileParser): if PcdValue and "." not in self._ValueList[0]:
try:
ValList[Index] = ValueExpression(PcdValue, self._Macros)(True)
- except WrnExpression, Value:
+ except WrnExpression as Value:
ValList[Index] = Value.result
except:
pass
@@ -2019,7 +2019,7 @@ class DecParser(MetaFileParser): try:
self._GuidDict.update(self._AllPcdDict)
ValueList[0] = ValueExpressionEx(ValueList[0], ValueList[1], self._GuidDict)(True)
- except BadExpression, Value:
+ except BadExpression as Value:
EdkLogger.error('Parser', FORMAT_INVALID, Value, ExtraData=self._CurrentLine, File=self.MetaFile, Line=self._LineIndex + 1)
# check format of default value against the datum type
IsValid, Cause = CheckPcdDatum(ValueList[1], ValueList[0])
diff --git a/BaseTools/Source/Python/Workspace/MetaFileTable.py b/BaseTools/Source/Python/Workspace/MetaFileTable.py index 3c8dae0e62..d17487a440 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileTable.py +++ b/BaseTools/Source/Python/Workspace/MetaFileTable.py @@ -63,7 +63,7 @@ class MetaFileTable(Table): # update the timestamp in database
self._FileIndexTable.SetFileTimeStamp(self.IdBase, TimeStamp)
return False
- except Exception, Exc:
+ except Exception as Exc:
EdkLogger.debug(EdkLogger.DEBUG_5, str(Exc))
return False
return True
@@ -250,7 +250,7 @@ class PackageTable(MetaFileTable): if comment.startswith("@Expression"):
comment = comment.replace("@Expression", "", 1)
expressions.append(comment.split("|")[1].strip())
- except Exception, Exc:
+ except Exception as Exc:
ValidType = ""
if oricomment.startswith("@ValidRange"):
ValidType = "@ValidRange"
|