## @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
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
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
# @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
Path,\r
FullPath,\r
Model,\r
- TimeStamp\r
+ TimeStamp,\r
+ FromItem\r
)\r
\r
## InsertFile\r
#\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
#\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