]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Workspace/MetaFileTable.py
MdeModulePkg/PerformanceMeasurement.h: Correct the license
[mirror_edk2.git] / BaseTools / Source / Python / Workspace / MetaFileTable.py
index 3c8dae0e622faf550e8abb72a82eaa55b6e0444c..ee1c7fffca3b36923f72ba37e5995170743a282e 100644 (file)
@@ -31,15 +31,15 @@ class MetaFileTable(Table):
     _ID_MAX_ = 0.99999999\r
 \r
     ## Constructor\r
-    def __init__(self, Cursor, MetaFile, FileType, Temporary):\r
+    def __init__(self, Cursor, MetaFile, FileType, Temporary, FromItem=None):\r
         self.MetaFile = MetaFile\r
 \r
         self._FileIndexTable = TableFile(Cursor)\r
         self._FileIndexTable.Create(False)\r
 \r
-        FileId = self._FileIndexTable.GetFileId(MetaFile)\r
+        FileId = self._FileIndexTable.GetFileId(MetaFile, FromItem)\r
         if not FileId:\r
-            FileId = self._FileIndexTable.InsertFile(MetaFile, FileType)\r
+            FileId = self._FileIndexTable.InsertFile(MetaFile, FileType, FromItem)\r
 \r
         if Temporary:\r
             TableName = "_%s_%s_%s" % (FileType, FileId, uuid.uuid4().hex)\r
@@ -56,14 +56,14 @@ class MetaFileTable(Table):
             Result = self.Cur.execute("select ID from %s where ID<0" % (self.Table)).fetchall()\r
             if not Result:\r
                 # update the timestamp in database\r
-                self._FileIndexTable.SetFileTimeStamp(self.IdBase, TimeStamp)                \r
+                self._FileIndexTable.SetFileTimeStamp(self.IdBase, TimeStamp)\r
                 return False\r
 \r
             if TimeStamp != self._FileIndexTable.GetFileTimeStamp(self.IdBase):\r
                 # update the timestamp in database\r
                 self._FileIndexTable.SetFileTimeStamp(self.IdBase, TimeStamp)\r
                 return False\r
-        except Exception, Exc:\r
+        except Exception as Exc:\r
             EdkLogger.debug(EdkLogger.DEBUG_5, str(Exc))\r
             return False\r
         return True\r
@@ -113,28 +113,28 @@ class ModuleTable(MetaFileTable):
                BelongsToItem=-1, StartLine=-1, StartColumn=-1, EndLine=-1, EndColumn=-1, Enabled=0):\r
         (Value1, Value2, Value3, Scope1, Scope2) = ConvertToSqlString((Value1, Value2, Value3, Scope1, Scope2))\r
         return Table.Insert(\r
-                        self, \r
-                        Model, \r
-                        Value1, \r
-                        Value2, \r
-                        Value3, \r
-                        Scope1, \r
+                        self,\r
+                        Model,\r
+                        Value1,\r
+                        Value2,\r
+                        Value3,\r
+                        Scope1,\r
                         Scope2,\r
-                        BelongsToItem, \r
-                        StartLine, \r
-                        StartColumn, \r
-                        EndLine, \r
-                        EndColumn, \r
+                        BelongsToItem,\r
+                        StartLine,\r
+                        StartColumn,\r
+                        EndLine,\r
+                        EndColumn,\r
                         Enabled\r
                         )\r
 \r
     ## Query table\r
     #\r
-    # @param    Model:      The Model of Record \r
-    # @param    Arch:       The Arch attribute of Record \r
-    # @param    Platform    The Platform attribute of Record \r
+    # @param    Model:      The Model of Record\r
+    # @param    Arch:       The Arch attribute of Record\r
+    # @param    Platform    The Platform attribute of Record\r
     #\r
-    # @retval:       A recordSet of all found records \r
+    # @retval:       A recordSet of all found records\r
     #\r
     def Query(self, Model, Arch=None, Platform=None, BelongsToItem=None):\r
         ConditionString = "Model=%s AND Enabled>=0" % Model\r
@@ -195,27 +195,27 @@ class PackageTable(MetaFileTable):
                BelongsToItem=-1, StartLine=-1, StartColumn=-1, EndLine=-1, EndColumn=-1, Enabled=0):\r
         (Value1, Value2, Value3, Scope1, Scope2) = ConvertToSqlString((Value1, Value2, Value3, Scope1, Scope2))\r
         return Table.Insert(\r
-                        self, \r
-                        Model, \r
-                        Value1, \r
-                        Value2, \r
-                        Value3, \r
-                        Scope1, \r
+                        self,\r
+                        Model,\r
+                        Value1,\r
+                        Value2,\r
+                        Value3,\r
+                        Scope1,\r
                         Scope2,\r
-                        BelongsToItem, \r
-                        StartLine, \r
-                        StartColumn, \r
-                        EndLine, \r
-                        EndColumn, \r
+                        BelongsToItem,\r
+                        StartLine,\r
+                        StartColumn,\r
+                        EndLine,\r
+                        EndColumn,\r
                         Enabled\r
                         )\r
 \r
     ## Query table\r
     #\r
-    # @param    Model:  The Model of Record \r
-    # @param    Arch:   The Arch attribute of Record \r
+    # @param    Model:  The Model of Record\r
+    # @param    Arch:   The Arch attribute of Record\r
     #\r
-    # @retval:       A recordSet of all found records \r
+    # @retval:       A recordSet of all found records\r
     #\r
     def Query(self, Model, Arch=None):\r
         ConditionString = "Model=%s AND Enabled>=0" % Model\r
@@ -236,7 +236,7 @@ class PackageTable(MetaFileTable):
         try:\r
             for row in self.Cur:\r
                 comment = row[0]\r
-                \r
+\r
                 LineNum = row[1]\r
                 comment = comment.strip("#")\r
                 comment = comment.strip()\r
@@ -250,7 +250,7 @@ class PackageTable(MetaFileTable):
                 if comment.startswith("@Expression"):\r
                     comment = comment.replace("@Expression", "", 1)\r
                     expressions.append(comment.split("|")[1].strip())\r
-        except Exception, Exc:\r
+        except Exception as Exc:\r
             ValidType = ""\r
             if oricomment.startswith("@ValidRange"):\r
                 ValidType = "@ValidRange"\r
@@ -258,8 +258,8 @@ class PackageTable(MetaFileTable):
                 ValidType = "@ValidList"\r
             if oricomment.startswith("@Expression"):\r
                 ValidType = "@Expression"\r
-            EdkLogger.error('Parser', FORMAT_INVALID, "The syntax for %s of PCD %s.%s is incorrect" % (ValidType,TokenSpaceGuid, PcdCName),\r
-                            ExtraData=oricomment,File=self.MetaFile, Line=LineNum)\r
+            EdkLogger.error('Parser', FORMAT_INVALID, "The syntax for %s of PCD %s.%s is incorrect" % (ValidType, TokenSpaceGuid, PcdCName),\r
+                            ExtraData=oricomment, File=self.MetaFile, Line=LineNum)\r
             return set(), set(), set()\r
         return set(validateranges), set(validlists), set(expressions)\r
 ## Python class representation of table storing platform data\r
@@ -285,8 +285,8 @@ class PlatformTable(MetaFileTable):
     _DUMMY_ = "-1, -1, '====', '====', '====', '====', '====','====', -1, -1, -1, -1, -1, -1, -1"\r
 \r
     ## Constructor\r
-    def __init__(self, Cursor, MetaFile, Temporary):\r
-        MetaFileTable.__init__(self, Cursor, MetaFile, MODEL_FILE_DSC, Temporary)\r
+    def __init__(self, Cursor, MetaFile, Temporary, FromItem=0):\r
+        MetaFileTable.__init__(self, Cursor, MetaFile, MODEL_FILE_DSC, Temporary, FromItem)\r
 \r
     ## Insert table\r
     #\r
@@ -308,34 +308,34 @@ class PlatformTable(MetaFileTable):
     #\r
     def Insert(self, Model, Value1, Value2, Value3, Scope1=TAB_ARCH_COMMON, Scope2=TAB_COMMON, Scope3=TAB_DEFAULT_STORES_DEFAULT,BelongsToItem=-1,\r
                FromItem=-1, StartLine=-1, StartColumn=-1, EndLine=-1, EndColumn=-1, Enabled=1):\r
-        (Value1, Value2, Value3, Scope1, Scope2,Scope3) = ConvertToSqlString((Value1, Value2, Value3, Scope1, Scope2,Scope3))\r
+        (Value1, Value2, Value3, Scope1, Scope2, Scope3) = ConvertToSqlString((Value1, Value2, Value3, Scope1, Scope2, Scope3))\r
         return Table.Insert(\r
-                        self, \r
-                        Model, \r
-                        Value1, \r
-                        Value2, \r
-                        Value3, \r
-                        Scope1, \r
+                        self,\r
+                        Model,\r
+                        Value1,\r
+                        Value2,\r
+                        Value3,\r
+                        Scope1,\r
                         Scope2,\r
                         Scope3,\r
-                        BelongsToItem, \r
+                        BelongsToItem,\r
                         FromItem,\r
-                        StartLine, \r
-                        StartColumn, \r
-                        EndLine, \r
-                        EndColumn, \r
+                        StartLine,\r
+                        StartColumn,\r
+                        EndLine,\r
+                        EndColumn,\r
                         Enabled\r
                         )\r
 \r
     ## Query table\r
     #\r
-    # @param Model:          The Model of Record \r
+    # @param Model:          The Model of Record\r
     # @param Scope1:         Arch of a Dsc item\r
     # @param Scope2:         Module type of a Dsc item\r
     # @param BelongsToItem:  The item belongs to which another item\r
     # @param FromItem:       The item belongs to which dsc file\r
     #\r
-    # @retval:       A recordSet of all found records \r
+    # @retval:       A recordSet of all found records\r
     #\r
     def Query(self, Model, Scope1=None, Scope2=None, BelongsToItem=None, FromItem=None):\r
         ConditionString = "Model=%s AND Enabled>0" % Model\r
@@ -379,7 +379,7 @@ class MetaFileStorage(object):
     }\r
 \r
     ## Constructor\r
-    def __new__(Class, Cursor, MetaFile, FileType=None, Temporary=False):\r
+    def __new__(Class, Cursor, MetaFile, FileType=None, Temporary=False, FromItem=None):\r
         # no type given, try to find one\r
         if not FileType:\r
             if MetaFile.Type in self._FILE_TYPE_:\r
@@ -392,6 +392,8 @@ class MetaFileStorage(object):
             Args = (Cursor, MetaFile, FileType, Temporary)\r
         else:\r
             Args = (Cursor, MetaFile, Temporary)\r
+        if FromItem:\r
+            Args = Args + (FromItem,)\r
 \r
         # create the storage object and return it to caller\r
         return Class._FILE_TABLE_[FileType](*Args)\r