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>
OffsetList = _ReOffset.findall(Item)\r
except:\r
pass\r
+ # replace each offset, except errors\r
for Offset in OffsetList:\r
- if Offset in LabelDict.keys():\r
- Re = re.compile('OFFSET_OF\(%s\)' % Offset)\r
- Item = Re.sub(LabelDict[Offset], Item)\r
- else:\r
+ try:\r
+ Item = Item.replace('OFFSET_OF({})'.format(Offset),LabelDict[Offset])\r
+ except:\r
raise BadExpression('%s not defined' % Offset)\r
+\r
NewPcdValueList.append(Item)\r
\r
AllPcdValueList = []\r