]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Workspace/MetaDataTable.py
BaseTools: use set instead of list for a variable to be used with in
[mirror_edk2.git] / BaseTools / Source / Python / Workspace / MetaDataTable.py
index 64f0480c37e860d39c9a469c1702d194bde9d12a..0cfec902326186dbda52d23281de47387f9d4a07 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, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2008 - 2014, 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
@@ -14,7 +14,7 @@
 ##\r
 # Import Modules\r
 #\r
-import os\r
+import Common.LongFilePathOs as os\r
 \r
 import Common.EdkLogger as EdkLogger\r
 from CommonDataClass import DataClass\r
@@ -113,7 +113,7 @@ class Table(object):
         SqlCommand = """select max(ID) from %s""" % self.Table\r
         Record = self.Cur.execute(SqlCommand).fetchall()\r
         Id = Record[0][0]\r
-        if Id == None:\r
+        if Id is None:\r
             Id = self.IdBase\r
         return Id\r
 \r
@@ -140,6 +140,10 @@ class Table(object):
 \r
     def SetEndFlag(self):\r
         self.Exec("insert into %s values(%s)" % (self.Table, self._DUMMY_))\r
+        #\r
+        # Need to execution commit for table data changed.\r
+        #\r
+        self.Cur.connection.commit()\r
 \r
     def IsIntegral(self):\r
         Result = self.Exec("select min(ID) from %s" % (self.Table))\r
@@ -147,6 +151,9 @@ class Table(object):
             return False\r
         return True\r
 \r
+    def GetAll(self):\r
+        return self.Exec("select * from %s where ID > 0 order by ID" % (self.Table))\r
+\r
 ## TableFile\r
 #\r
 # This class defined a table used for file\r
@@ -198,19 +205,15 @@ class TableFile(Table):
     #\r
     # @retval FileID:       The ID after record is inserted\r
     #\r
-    def InsertFile(self, FileFullPath, Model):\r
-        (Filepath, Name) = os.path.split(FileFullPath)\r
-        (Root, Ext) = os.path.splitext(FileFullPath)\r
-        TimeStamp = os.stat(FileFullPath)[8]\r
-        File = FileClass(-1, Name, Ext, Filepath, FileFullPath, Model, '', [], [], [])\r
+    def InsertFile(self, File, Model):\r
         return self.Insert(\r
-            Name,\r
-            Ext,\r
-            Filepath,\r
-            FileFullPath,\r
-            Model,\r
-            TimeStamp\r
-            )\r
+                        File.Name,\r
+                        File.Ext,\r
+                        File.Dir,\r
+                        File.Path,\r
+                        Model,\r
+                        File.TimeStamp\r
+                        )\r
 \r
     ## Get ID of a given file\r
     #\r
@@ -218,8 +221,8 @@ class TableFile(Table):
     #\r
     #   @retval ID          ID value of given file in the table\r
     #\r
-    def GetFileId(self, FilePath):\r
-        QueryScript = "select ID from %s where FullPath = '%s'" % (self.Table, FilePath)\r
+    def GetFileId(self, File):\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
@@ -308,7 +311,7 @@ class TableDataModel(Table):
     def InitTable(self):\r
         EdkLogger.verbose("\nInitialize table DataModel started ...")\r
         Count = self.GetCount()\r
-        if Count != None and Count != 0:\r
+        if Count is not None and Count != 0:\r
             return\r
         for Item in DataClass.MODEL_LIST:\r
             CrossIndex = Item[1]\r