use str.replace and try/except.
Cc: Liming Gao <[email protected]>
Cc: Yonghong Zhu <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Jaben Carsey <[email protected]>
---
BaseTools/Source/Python/Common/Expression.py | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/BaseTools/Source/Python/Common/Expression.py
b/BaseTools/Source/Python/Common/Expression.py
index 4f0f377f3788..b7500bff9051 100644
--- a/BaseTools/Source/Python/Common/Expression.py
+++ b/BaseTools/Source/Python/Common/Expression.py
@@ -938,12 +938,13 @@ class ValueExpressionEx(ValueExpression):
OffsetList = ReOffset.findall(Item)
except:
pass
+ # replace each offset, except errors
for Offset in OffsetList:
- if Offset in LabelDict.keys():
- Re = re.compile('OFFSET_OF\(%s\)' % Offset)
- Item = Re.sub(LabelDict[Offset], Item)
- else:
+ try:
+ Item =
Item.replace('OFFSET_OF({})'.format(Offset),LabelDict[Offset])
+ except:
raise BadExpression('%s not defined' %
Offset)
+
NewPcdValueList.append(Item)
AllPcdValueList = []
--
2.16.2.windows.1
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel