]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Common/Misc.py
BaseTools: Fix old python2 idioms
[mirror_edk2.git] / BaseTools / Source / Python / Common / Misc.py
index fd53b6b046c4442ea066f2c7e4cd3bf3e80d3be5..55e3c6f2281b4d3ede9e4687ee014475e9176d66 100644 (file)
@@ -1291,9 +1291,9 @@ def ParseDevPathValue (Value):
     return '{' + out + '}', Size\r
 \r
 def ParseFieldValue (Value):\r
-    if type(Value) == type(0):\r
+    if isinstance(Value, type(0)):\r
         return Value, (Value.bit_length() + 7) / 8\r
-    if type(Value) != type(''):\r
+    if not isinstance(Value, type('')):\r
         raise BadExpression('Type %s is %s' %(Value, type(Value)))\r
     Value = Value.strip()\r
     if Value.startswith(TAB_UINT8) and Value.endswith(')'):\r
@@ -1584,8 +1584,7 @@ def CheckPcdDatum(Type, Value):
             Printset.add(TAB_PRINTCHAR_BS)\r
             Printset.add(TAB_PRINTCHAR_NUL)\r
             if not set(Value).issubset(Printset):\r
-                PrintList = list(Printset)\r
-                PrintList.sort()\r
+                PrintList = sorted(Printset)\r
                 return False, "Invalid PCD string value of type [%s]; must be printable chars %s." % (Type, PrintList)\r
     elif Type == 'BOOLEAN':\r
         if Value not in ['TRUE', 'True', 'true', '0x1', '0x01', '1', 'FALSE', 'False', 'false', '0x0', '0x00', '0']:\r
@@ -1747,7 +1746,7 @@ class PathClass(object):
     # @retval True  The two PathClass are the same\r
     #\r
     def __eq__(self, Other):\r
-        if type(Other) == type(self):\r
+        if isinstance(Other, type(self)):\r
             return self.Path == Other.Path\r
         else:\r
             return self.Path == str(Other)\r
@@ -1760,7 +1759,7 @@ class PathClass(object):
     # @retval -1    The first PathClass is less than the second PathClass\r
     # @retval 1     The first PathClass is Bigger than the second PathClass\r
     def __cmp__(self, Other):\r
-        if type(Other) == type(self):\r
+        if isinstance(Other, type(self)):\r
             OtherKey = Other.Path\r
         else:\r
             OtherKey = str(Other)\r
@@ -2010,7 +2009,7 @@ class SkuClass():
             return ["DEFAULT"]\r
         skulist = [sku]\r
         nextsku = sku\r
-        while 1:\r
+        while True:\r
             nextsku = self.GetNextSkuId(nextsku)\r
             skulist.append(nextsku)\r
             if nextsku == "DEFAULT":\r