mirror of https://github.com/acidanthera/audk.git
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:
parent
e52aed0d85
commit
cc0321f22a
|
@ -936,12 +936,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 = []
|
||||
|
|
Loading…
Reference in New Issue