]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/AutoGen/IdfClassObject.py
BaseTools: AutoGen - refactor function to remove extra variables
[mirror_edk2.git] / BaseTools / Source / Python / AutoGen / IdfClassObject.py
index a028aceee927af6d2a4edf040e44d96864817351..82396d3744d56f66c4b7a589bf09dd707f44bc45 100644 (file)
@@ -22,6 +22,7 @@ from Common.LongFilePathSupport import LongFilePath
 import re\r
 import os\r
 from Common.GlobalData import gIdentifierPattern\r
+from UniClassObject import StripComments\r
 \r
 IMAGE_TOKEN = re.compile('IMAGE_TOKEN *\(([A-Z0-9_]+) *\)', re.MULTILINE | re.UNICODE)\r
 \r
@@ -91,7 +92,7 @@ class IdfFileClassObject(object):
         ImageFileList = []\r
         for Line in FileIn.splitlines():\r
             Line = Line.strip()\r
-            Line = self.StripComments(Line)\r
+            Line = StripComments(Line)\r
             if len(Line) == 0:\r
                 continue\r
 \r
@@ -107,7 +108,7 @@ class IdfFileClassObject(object):
                 if Len == 4 and LineDetails[2] != 'TRANSPARENT':\r
                     EdkLogger.error("Image Definition File Parser", PARSER_ERROR, 'Please use the keyword "TRANSPARENT" to describe the transparency setting in Line %s of File %s.' % (LineNo, File.Path))\r
                 MatchString = gIdentifierPattern.match(LineDetails[1])\r
-                if MatchString is None or MatchString.end(0) != len(LineDetails[1]):\r
+                if MatchString is None:\r
                     EdkLogger.error('Image Definition  File Parser', FORMAT_INVALID, 'The Image token name %s defined in Idf file %s contains the invalid character.' % (LineDetails[1], File.Path))\r
                 if LineDetails[1] not in self.ImageIDList:\r
                     self.ImageIDList.append(LineDetails[1])\r
@@ -121,22 +122,6 @@ class IdfFileClassObject(object):
         if ImageFileList:\r
             self.ImageFilesDict[File] = ImageFileList\r
 \r
-    def StripComments(self, Line):\r
-        Comment = '//'\r
-        CommentPos = Line.find(Comment)\r
-        while CommentPos >= 0:\r
-        # if there are non matched quotes before the comment header\r
-        # then we are in the middle of a string\r
-        # but we need to ignore the escaped quotes and backslashes.\r
-            if ((Line.count('"', 0, CommentPos) - Line.count('\\"', 0, CommentPos)) & 1) == 1:\r
-                CommentPos = Line.find (Comment, CommentPos + 1)\r
-            else:\r
-                return Line[:CommentPos].strip()\r
-        return Line.strip()\r
-\r
-    def ImageDecoder(self, File):\r
-        pass\r
-\r
 def SearchImageID(ImageFileObject, FileList):\r
     if FileList == []:\r
         return ImageFileObject\r