From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.151; helo=mga17.intel.com; envelope-from=bob.c.feng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 67F25211A6D56 for ; Sun, 27 Jan 2019 19:45:37 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Jan 2019 19:45:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,532,1539673200"; d="scan'208";a="110267301" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga007.jf.intel.com with ESMTP; 27 Jan 2019 19:45:36 -0800 Received: from fmsmsx157.amr.corp.intel.com (10.18.116.73) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.408.0; Sun, 27 Jan 2019 19:45:36 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX157.amr.corp.intel.com (10.18.116.73) with Microsoft SMTP Server (TLS) id 14.3.408.0; Sun, 27 Jan 2019 19:45:36 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.110]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.194]) with mapi id 14.03.0415.000; Mon, 28 Jan 2019 11:45:33 +0800 From: "Feng, Bob C" To: "Carsey, Jaben" , "edk2-devel@lists.01.org" CC: "Gao, Liming" Thread-Topic: [Patch v1 3/4] BaseTools/Common/Misc: Cleanup the imports Thread-Index: AQHUs//mc89evQ+tdEmcxMausGQsO6XED9Pw Date: Mon, 28 Jan 2019 03:45:33 +0000 Message-ID: <08650203BA1BD64D8AD9B6D5D74A85D16007611E@SHSMSX101.ccr.corp.intel.com> References: In-Reply-To: Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch v1 3/4] BaseTools/Common/Misc: Cleanup the imports X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Jan 2019 03:45:37 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Bob Feng -----Original Message----- From: Carsey, Jaben=20 Sent: Friday, January 25, 2019 12:14 AM To: edk2-devel@lists.01.org Cc: Feng, Bob C ; Gao, Liming Subject: [Patch v1 3/4] BaseTools/Common/Misc: Cleanup the imports Refactor to 'dict' from 'IterableUserDict' which was only required for old python interpreter. Sort imports according to PEP8 Remove those we dont need. Cc: Bob Feng Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jaben Carsey --- BaseTools/Source/Python/Common/Misc.py | 34 ++++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Pyth= on/Common/Misc.py index 65ccba36b2e9..e8be8f866511 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -15,7 +15,7 @@ # Import Modules # from __future__ import absolute_import -import Common.LongFilePathOs as os + import sys import string import threading @@ -26,22 +26,22 @@ import array import shutil from random import sample from struct import pack -from UserDict import IterableUserDict -from UserList import UserList +import uuid +import subprocess +from collections import OrderedDict =20 +import Common.LongFilePathOs as os from Common import EdkLogger as EdkLogger from Common import GlobalData a= s GlobalData -from .DataType import * -from .BuildToolError import * +from Common.DataType import * +from Common.BuildToolError import * from CommonDataClass.DataClass import * -from .Parsing import GetSplitValu= eList +from Common.Parsing import GetSplitValueList from Common.LongFilePathSupport import OpenLongFilePath as open from Comm= on.MultipleWorkspace import MultipleWorkspace as mws -import uuid from Com= monDataClass.Exceptions import BadExpression from Common.caching import ca= ched_property -import subprocess -from collections import OrderedDict + ## Regular expression used to find out place holders in string template g= PlaceholderPattern =3D re.compile("\$\{([^$()\s]+)\}", re.MULTILINE | re.UN= ICODE) =20 @@ -831,22 +831,22 @@ class Progressor: # accessed in the order they are added into the dict. It guarantees the o= rder # by making use of an internal list to keep a copy of keys. # -class sdict(IterableUserDict): +class sdict(dict): ## Constructor def __init__(self): - IterableUserDict.__init__(self) + dict.__init__(self) self._key_list =3D [] =20 ## [] operator def __setitem__(self, key, value): if key not in self._key_list: self._key_list.append(key) - IterableUserDict.__setitem__(self, key, value) + dict.__setitem__(self, key, value) =20 ## del operator def __delitem__(self, key): self._key_list.remove(key) - IterableUserDict.__delitem__(self, key) + dict.__delitem__(self, key) =20 ## used in "for k in dict" loop to ensure the correct order def __iter__(self): @@ -869,17 +869,17 @@ class sdict(IterableUserDict): index =3D self._key_list.index(key) if order =3D=3D 'BEFORE': self._key_list.insert(index, newkey) - IterableUserDict.__setitem__(self, newkey, newvalue) + dict.__setitem__(self, newkey, newvalue) elif order =3D=3D 'AFTER': self._key_list.insert(index + 1, newkey) - IterableUserDict.__setitem__(self, newkey, newvalue) + dict.__setitem__(self, newkey, newvalue) =20 ## append support def append(self, sdict): for key in sdict: if key not in self._key_list: self._key_list.append(key) - IterableUserDict.__setitem__(self, key, sdict[key]) + dict.__setitem__(self, key, sdict[key]) =20 def has_key(self, key): return key in self._key_list @@ -887,7 +887,7 @@ class sdict(IterableUserDict): ## Empty the dict def clear(self): self._key_list =3D [] - IterableUserDict.clear(self) + dict.clear(self) =20 ## Return a copy of keys def keys(self): -- 2.16.2.windows.1