]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Workspace/MetaDataTable.py
BaseTools: refactor to not overcreate ModuleAutoGen objects
[mirror_edk2.git] / BaseTools / Source / Python / Workspace / MetaDataTable.py
index 0cfec902326186dbda52d23281de47387f9d4a07..bd751eadfbc58591750ab28a2426428f538d7bf9 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This file is used to create/update/query/erase table for files\r
 #\r
-# Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -73,7 +73,7 @@ class Table(object):
         self.ID = self.ID + self._ID_STEP_\r
         if self.ID >= (self.IdBase + self._ID_MAX_):\r
             self.ID = self.IdBase + self._ID_STEP_\r
-        Values = ", ".join([str(Arg) for Arg in Args])\r
+        Values = ", ".join(str(Arg) for Arg in Args)\r
         SqlCommand = "insert into %s values(%s, %s)" % (self.Table, self.ID, Values)\r
         EdkLogger.debug(EdkLogger.DEBUG_5, SqlCommand)\r
         self.Cur.execute(SqlCommand)\r
@@ -168,7 +168,8 @@ class TableFile(Table):
         Path VARCHAR,\r
         FullPath VARCHAR NOT NULL,\r
         Model INTEGER DEFAULT 0,\r
-        TimeStamp SINGLE NOT NULL\r
+        TimeStamp SINGLE NOT NULL,\r
+        FromItem REAL NOT NULL\r
         '''\r
     def __init__(self, Cursor):\r
         Table.__init__(self, Cursor, 'File')\r
@@ -184,7 +185,7 @@ class TableFile(Table):
     # @param Model:     Model of a File\r
     # @param TimeStamp: TimeStamp of a File\r
     #\r
-    def Insert(self, Name, ExtName, Path, FullPath, Model, TimeStamp):\r
+    def Insert(self, Name, ExtName, Path, FullPath, Model, TimeStamp, FromItem=0):\r
         (Name, ExtName, Path, FullPath) = ConvertToSqlString((Name, ExtName, Path, FullPath))\r
         return Table.Insert(\r
             self,\r
@@ -193,7 +194,8 @@ class TableFile(Table):
             Path,\r
             FullPath,\r
             Model,\r
-            TimeStamp\r
+            TimeStamp,\r
+            FromItem\r
             )\r
 \r
     ## InsertFile\r
@@ -205,7 +207,17 @@ class TableFile(Table):
     #\r
     # @retval FileID:       The ID after record is inserted\r
     #\r
-    def InsertFile(self, File, Model):\r
+    def InsertFile(self, File, Model, FromItem=''):\r
+        if FromItem:\r
+            return self.Insert(\r
+                        File.Name,\r
+                        File.Ext,\r
+                        File.Dir,\r
+                        File.Path,\r
+                        Model,\r
+                        File.TimeStamp,\r
+                        FromItem\r
+                        )\r
         return self.Insert(\r
                         File.Name,\r
                         File.Ext,\r
@@ -221,8 +233,11 @@ class TableFile(Table):
     #\r
     #   @retval ID          ID value of given file in the table\r
     #\r
-    def GetFileId(self, File):\r
-        QueryScript = "select ID from %s where FullPath = '%s'" % (self.Table, str(File))\r
+    def GetFileId(self, File, FromItem=None):\r
+        if FromItem:\r
+            QueryScript = "select ID from %s where FullPath = '%s' and FromItem = %s" % (self.Table, str(File), str(FromItem))\r
+        else:\r
+            QueryScript = "select ID from %s where FullPath = '%s'" % (self.Table, str(File))\r
         RecordList = self.Exec(QueryScript)\r
         if len(RecordList) == 0:\r
             return None\r