BaseTools: refactor repeated RegExp when no special searching is needed.
use str.replace and try/except. Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
This commit is contained in:
committed by
Yonghong Zhu
parent
e52aed0d85
commit
cc0321f22a
@ -936,12 +936,13 @@ class ValueExpressionEx(ValueExpression):
|
|||||||
OffsetList = _ReOffset.findall(Item)
|
OffsetList = _ReOffset.findall(Item)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
# replace each offset, except errors
|
||||||
for Offset in OffsetList:
|
for Offset in OffsetList:
|
||||||
if Offset in LabelDict.keys():
|
try:
|
||||||
Re = re.compile('OFFSET_OF\(%s\)' % Offset)
|
Item = Item.replace('OFFSET_OF({})'.format(Offset),LabelDict[Offset])
|
||||||
Item = Re.sub(LabelDict[Offset], Item)
|
except:
|
||||||
else:
|
|
||||||
raise BadExpression('%s not defined' % Offset)
|
raise BadExpression('%s not defined' % Offset)
|
||||||
|
|
||||||
NewPcdValueList.append(Item)
|
NewPcdValueList.append(Item)
|
||||||
|
|
||||||
AllPcdValueList = []
|
AllPcdValueList = []
|
||||||
|
Reference in New Issue
Block a user