\r
from Common.Misc import tdict\r
\r
-import re\r
import Common.LongFilePathOs as os\r
from Common.LongFilePathSupport import OpenLongFilePath as open\r
\r
if Profile.IsLineInFile(Line):\r
return Profile.GetLineInFile(Line)\r
elif Line >= Profile.InsertStartLineNumber and Profile.Level == 1:\r
- InsertedLines += Profile.GetTotalLines()\r
+ InsertedLines += Profile.GetTotalLines()\r
\r
return (File, Line - InsertedLines)\r
\r
TotalLines = self.InsertAdjust + len(self.FileLinesList)\r
\r
for Profile in self.IncludeFileList:\r
- TotalLines += Profile.GetTotalLines()\r
+ TotalLines += Profile.GetTotalLines()\r
\r
return TotalLines\r
\r
% (FileLineTuple[1], self.CurrentOffsetWithinLine + 1, self.Profile.FileLinesList[self.CurrentLineNumber - 1][self.CurrentOffsetWithinLine :].rstrip('\n').rstrip('\r'))\r
raise\r
\r
+ ## SectionParser() method\r
+ #\r
+ # Parse the file section info\r
+ # Exception will be raised if syntax error found\r
+ #\r
+ # @param self The object pointer\r
+ # @param section The section string\r
+\r
+ def SectionParser(self, section):\r
+ S = section.upper()\r
+ if not S.startswith("[DEFINES") and not S.startswith("[FD.") and not S.startswith("[FV.") and not S.startswith("[CAPSULE.") \\r
+ and not S.startswith("[VTF.") and not S.startswith("[RULE.") and not S.startswith("[OPTIONROM.") and not S.startswith('[FMPPAYLOAD.'):\r
+ raise Warning("Unknown section or section appear sequence error (The correct sequence should be [DEFINES], [FD.], [FV.], [Capsule.], [VTF.], [Rule.], [OptionRom.], [FMPPAYLOAD.])", self.FileName, self.CurrentLineNumber)\r
+\r
## __GetDefines() method\r
#\r
# Get Defines section contents and store its data into AllMacrosList\r
\r
S = self.__Token.upper()\r
if S.startswith("[") and not S.startswith("[DEFINES"):\r
- if not S.startswith("[FD.") and not S.startswith("[FV.") and not S.startswith("[CAPSULE.") \\r
- and not S.startswith("[VTF.") and not S.startswith("[RULE.") and not S.startswith("[OPTIONROM."):\r
- raise Warning("Unknown section or section appear sequence error (The correct sequence should be [DEFINES], [FD.], [FV.], [Capsule.], [VTF.], [Rule.], [OptionRom.])", self.FileName, self.CurrentLineNumber)\r
+ self.SectionParser(S)\r
self.__UndoToken()\r
return False\r
\r
\r
S = self.__Token.upper()\r
if S.startswith("[") and not S.startswith("[FV."):\r
- if not S.startswith('[FMPPAYLOAD.') and not S.startswith("[CAPSULE.") \\r
- and not S.startswith("[VTF.") and not S.startswith("[RULE.") and not S.startswith("[OPTIONROM."):\r
- raise Warning("Unknown section or section appear sequence error (The correct sequence should be [FD.], [FV.], [Capsule.], [VTF.], [Rule.], [OptionRom.])", self.FileName, self.CurrentLineNumber)\r
+ self.SectionParser(S)\r
self.__UndoToken()\r
return False\r
\r
if not self.__GetNextToken():\r
return False\r
S = self.__Token.upper()\r
- if not S.startswith("[FMPPAYLOAD."):\r
- if not S.startswith("[CAPSULE.") and not S.startswith("[VTF.") and not S.startswith("[RULE.") and not S.startswith("[OPTIONROM."):\r
- raise Warning("Unknown section or section appear sequence error (The correct sequence should be [FD.], [FV.], [FmpPayload.], [Capsule.], [VTF.], [Rule.], [OptionRom.])", self.FileName, self.CurrentLineNumber)\r
+ if S.startswith("[") and not S.startswith("[FMPPAYLOAD."):\r
+ self.SectionParser(S)\r
self.__UndoToken()\r
return False\r
\r
\r
S = self.__Token.upper()\r
if S.startswith("[") and not S.startswith("[CAPSULE."):\r
- if not S.startswith("[VTF.") and not S.startswith("[RULE.") and not S.startswith("[OPTIONROM."):\r
- raise Warning("Unknown section or section appear sequence error (The correct sequence should be [FD.], [FV.], [Capsule.], [VTF.], [Rule.], [OptionRom.])", self.FileName, self.CurrentLineNumber)\r
+ self.SectionParser(S)\r
self.__UndoToken()\r
return False\r
\r
return True\r
\r
def __GetFmpStatement(self, CapsuleObj):\r
- if not self.__IsKeyword("FMP"):\r
- return False\r
+ if not self.__IsKeyword("FMP_PAYLOAD"):\r
+ if not self.__IsKeyword("FMP"):\r
+ return False\r
\r
- if not self.__IsKeyword("PAYLOAD"):\r
- self.__UndoToken()\r
- return False\r
+ if not self.__IsKeyword("PAYLOAD"):\r
+ self.__UndoToken()\r
+ return False\r
\r
if not self.__IsToken("="):\r
raise Warning("expected '='", self.FileName, self.CurrentLineNumber)\r
\r
if not self.__GetNextToken():\r
- raise Warning("expected payload name after FMP PAYLOAD =", self.FileName, self.CurrentLineNumber)\r
+ raise Warning("expected payload name after FMP_PAYLOAD =", self.FileName, self.CurrentLineNumber)\r
Payload = self.__Token.upper()\r
if Payload not in self.Profile.FmpPayloadDict:\r
raise Warning("This FMP Payload does not exist: %s" % self.__Token, self.FileName, self.CurrentLineNumber)\r
\r
S = self.__Token.upper()\r
if S.startswith("[") and not S.startswith("[RULE."):\r
- if not S.startswith("[OPTIONROM."):\r
- raise Warning("Unknown section or section appear sequence error (The correct sequence should be [FD.], [FV.], [Capsule.], [VTF.], [Rule.], [OptionRom.])", self.FileName, self.CurrentLineNumber)\r
+ self.SectionParser(S)\r
self.__UndoToken()\r
return False\r
self.__UndoToken()\r
#\r
def __GetFileExtension(self):\r
if not self.__IsToken("."):\r
- raise Warning("expected '.'", self.FileName, self.CurrentLineNumber)\r
+ raise Warning("expected '.'", self.FileName, self.CurrentLineNumber)\r
\r
Ext = ""\r
if self.__GetNextToken():\r
\r
S = self.__Token.upper()\r
if S.startswith("[") and not S.startswith("[VTF."):\r
- if not S.startswith("[RULE.") and not S.startswith("[OPTIONROM."):\r
- raise Warning("Unknown section or section appear sequence error (The correct sequence should be [FD.], [FV.], [Capsule.], [VTF.], [Rule.], [OptionRom.])", self.FileName, self.CurrentLineNumber)\r
+ self.SectionParser(S)\r
self.__UndoToken()\r
return False\r
\r
\r
S = self.__Token.upper()\r
if S.startswith("[") and not S.startswith("[OPTIONROM."):\r
- raise Warning("Unknown section or section appear sequence error (The correct sequence should be [FD.], [FV.], [Capsule.], [VTF.], [Rule.], [OptionRom.])", self.FileName, self.CurrentLineNumber)\r
+ self.SectionParser(S)\r
+ self.__UndoToken()\r
+ return False\r
\r
self.__UndoToken()\r
if not self.__IsToken("[OptionRom.", True):\r