]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/UPT/Core/IpiDb.py
BaseTools: Remove equality operator with None
[mirror_edk2.git] / BaseTools / Source / Python / UPT / Core / IpiDb.py
index 2c444f903c0f569e3cceeb575d77594dbf37187a..78d67ab31e1eaba543cb9ee1f6199b07fab9283e 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # This file is for installed package information database operations\r
 #\r
-# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>\r
 #\r
 # This program and the accompanying materials are licensed and made available \r
 # under the terms and conditions of the BSD License which accompanies this \r
@@ -44,7 +44,7 @@ class IpiDatabase(object):
         Dir = os.path.dirname(DbPath)\r
         if not os.path.isdir(Dir):\r
             os.mkdir(Dir)\r
-        self.Conn = sqlite3.connect(DbPath, isolation_level='DEFERRED')\r
+        self.Conn = sqlite3.connect(unicode(DbPath), isolation_level='DEFERRED')\r
         self.Conn.execute("PRAGMA page_size=4096")\r
         self.Conn.execute("PRAGMA synchronous=OFF")\r
         self.Cur = self.Conn.cursor()\r
@@ -247,13 +247,13 @@ class IpiDatabase(object):
     def _AddDp(self, Guid, Version, NewDpFileName, DistributionFileName, \\r
                RePackage):\r
         \r
-        if Version == None or len(Version.strip()) == 0:\r
+        if Version is None or len(Version.strip()) == 0:\r
             Version = 'N/A'\r
         \r
         #\r
         # Add newly installed DP information to DB.\r
         #\r
-        if NewDpFileName == None or len(NewDpFileName.strip()) == 0:\r
+        if NewDpFileName is None or len(NewDpFileName.strip()) == 0:\r
             PkgFileName = 'N/A'\r
         else:\r
             PkgFileName = NewDpFileName\r
@@ -295,13 +295,13 @@ class IpiDatabase(object):
     #\r
     def _AddPackage(self, Guid, Version, DpGuid=None, DpVersion=None, Path=''):\r
         \r
-        if Version == None or len(Version.strip()) == 0:\r
+        if Version is None or len(Version.strip()) == 0:\r
             Version = 'N/A'\r
         \r
-        if DpGuid == None or len(DpGuid.strip()) == 0:\r
+        if DpGuid is None or len(DpGuid.strip()) == 0:\r
             DpGuid = 'N/A'\r
         \r
-        if DpVersion == None or len(DpVersion.strip()) == 0:\r
+        if DpVersion is None or len(DpVersion.strip()) == 0:\r
             DpVersion = 'N/A'\r
         \r
         #\r
@@ -325,13 +325,13 @@ class IpiDatabase(object):
     def _AddModuleInPackage(self, Guid, Version, Name, PkgGuid=None, \\r
                             PkgVersion=None, Path=''):\r
         \r
-        if Version == None or len(Version.strip()) == 0:\r
+        if Version is None or len(Version.strip()) == 0:\r
             Version = 'N/A'\r
         \r
-        if PkgGuid == None or len(PkgGuid.strip()) == 0:\r
+        if PkgGuid is None or len(PkgGuid.strip()) == 0:\r
             PkgGuid = 'N/A'\r
         \r
-        if PkgVersion == None or len(PkgVersion.strip()) == 0:\r
+        if PkgVersion is None or len(PkgVersion.strip()) == 0:\r
             PkgVersion = 'N/A'\r
             \r
         if os.name == 'posix':\r
@@ -361,13 +361,13 @@ class IpiDatabase(object):
     def _AddStandaloneModule(self, Guid, Version, Name, DpGuid=None, \\r
                              DpVersion=None, Path=''):\r
         \r
-        if Version == None or len(Version.strip()) == 0:\r
+        if Version is None or len(Version.strip()) == 0:\r
             Version = 'N/A'\r
         \r
-        if DpGuid == None or len(DpGuid.strip()) == 0:\r
+        if DpGuid is None or len(DpGuid.strip()) == 0:\r
             DpGuid = 'N/A'\r
         \r
-        if DpVersion == None or len(DpVersion.strip()) == 0:\r
+        if DpVersion is None or len(DpVersion.strip()) == 0:\r
             DpVersion = 'N/A'\r
         \r
         #\r
@@ -391,10 +391,10 @@ class IpiDatabase(object):
     def _AddModuleDepex(self, Guid, Version, Name, Path, DepexGuid=None, \\r
                         DepexVersion=None):\r
                 \r
-        if DepexGuid == None or len(DepexGuid.strip()) == 0:\r
+        if DepexGuid is None or len(DepexGuid.strip()) == 0:\r
             DepexGuid = 'N/A'\r
         \r
-        if DepexVersion == None or len(DepexVersion.strip()) == 0:\r
+        if DepexVersion is None or len(DepexVersion.strip()) == 0:\r
             DepexVersion = 'N/A'\r
             \r
         if os.name == 'posix':\r
@@ -510,7 +510,7 @@ class IpiDatabase(object):
     #\r
     def GetDp(self, Guid, Version):\r
         \r
-        if Version == None or len(Version.strip()) == 0:\r
+        if Version is None or len(Version.strip()) == 0:\r
             Version = 'N/A'\r
             Logger.Verbose(ST.MSG_GET_DP_INSTALL_LIST)\r
             (DpGuid, DpVersion) = (Guid, Version)\r
@@ -614,8 +614,8 @@ class IpiDatabase(object):
     # @param DistributionFile: Distribution File  \r
     #\r
     def GetDpByName(self, DistributionFile):\r
-        SqlCommand = """select * from %s where NewPkgFileName like '%s'""" % \\r
-        (self.DpTable, '%' + DistributionFile)\r
+        SqlCommand = """select * from %s where NewPkgFileName = '%s'""" % \\r
+        (self.DpTable, DistributionFile)\r
         self.Cur.execute(SqlCommand)\r
 \r
         for Result in self.Cur:\r
@@ -642,7 +642,7 @@ class IpiDatabase(object):
                                             PackageVersion)\r
             self.Cur.execute(SqlCommand)\r
         \r
-        elif Version == None or len(Version.strip()) == 0:\r
+        elif Version is None or len(Version.strip()) == 0:\r
             \r
             SqlCommand = """select * from %s where PackageGuid ='%s'""" % \\r
             (self.PkgTable, Guid)\r