From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=195.135.221.5; helo=smtp.nue.novell.com; envelope-from=glin@suse.com; receiver=edk2-devel@lists.01.org Received: from smtp.nue.novell.com (smtp.nue.novell.com [195.135.221.5]) (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 7BC7D20336ABD for ; Mon, 9 Jul 2018 20:31:41 -0700 (PDT) Received: from localhost.localdomain (unknown.telstraglobal.net [134.159.103.118]) by smtp.nue.novell.com with ESMTP (NOT encrypted); Tue, 10 Jul 2018 05:31:38 +0200 From: Gary Lin To: edk2-devel@lists.01.org Cc: Yonghong Zhu , Liming Gao Date: Tue, 10 Jul 2018 11:31:02 +0800 Message-Id: <20180710033107.32359-10-glin@suse.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180710033107.32359-1-glin@suse.com> References: <20180710033107.32359-1-glin@suse.com> Subject: [PATCH 09/14] BaseTools: Use absolute import in ECC X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Jul 2018 03:31:42 -0000 Based on "futurize -f libfuturize.fixes.fix_absolute_import Contributed-under: TianoCore Contribution Agreement 1.1 Cc: Yonghong Zhu Cc: Liming Gao Signed-off-by: Gary Lin --- BaseTools/Source/Python/Ecc/CParser.py | 5 ++-- BaseTools/Source/Python/Ecc/Check.py | 9 +++---- BaseTools/Source/Python/Ecc/CodeFragmentCollector.py | 13 +++++----- BaseTools/Source/Python/Ecc/Database.py | 7 +++--- BaseTools/Source/Python/Ecc/Ecc.py | 25 ++++++++++---------- BaseTools/Source/Python/Ecc/Exception.py | 3 ++- BaseTools/Source/Python/Ecc/FileProfile.py | 5 ++-- BaseTools/Source/Python/Ecc/MetaDataParser.py | 5 ++-- BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py | 3 ++- BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py | 5 ++-- BaseTools/Source/Python/Ecc/c.py | 13 +++++----- 11 files changed, 51 insertions(+), 42 deletions(-) diff --git a/BaseTools/Source/Python/Ecc/CParser.py b/BaseTools/Source/Python/Ecc/CParser.py index b66ac2d8d545..0b74b53ae7a5 100644 --- a/BaseTools/Source/Python/Ecc/CParser.py +++ b/BaseTools/Source/Python/Ecc/CParser.py @@ -1,6 +1,7 @@ # $ANTLR 3.0.1 C.g 2010-02-23 09:58:53 from __future__ import print_function +from __future__ import absolute_import from antlr3 import * from antlr3.compat import set, frozenset @@ -23,8 +24,8 @@ from antlr3.compat import set, frozenset # ## -import CodeFragment -import FileProfile +from . import CodeFragment +from . import FileProfile diff --git a/BaseTools/Source/Python/Ecc/Check.py b/BaseTools/Source/Python/Ecc/Check.py index 540d9cb7edc7..0b81013d77e9 100644 --- a/BaseTools/Source/Python/Ecc/Check.py +++ b/BaseTools/Source/Python/Ecc/Check.py @@ -10,14 +10,15 @@ # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. # +from __future__ import absolute_import import Common.LongFilePathOs as os import re from CommonDataClass.DataClass import * import Common.DataType as DT -from EccToolError import * -from MetaDataParser import ParseHeaderCommentSection -import EccGlobalData -import c +from .EccToolError import * +from .MetaDataParser import ParseHeaderCommentSection +from . import EccGlobalData +from . import c from Common.LongFilePathSupport import OpenLongFilePath as open from Common.MultipleWorkspace import MultipleWorkspace as mws diff --git a/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py b/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py index b4f421342f60..28b4e0196f50 100644 --- a/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py +++ b/BaseTools/Source/Python/Ecc/CodeFragmentCollector.py @@ -17,18 +17,19 @@ # from __future__ import print_function +from __future__ import absolute_import import re import Common.LongFilePathOs as os import sys import antlr3 -from CLexer import CLexer -from CParser import CParser +from .CLexer import CLexer +from .CParser import CParser -import FileProfile -from CodeFragment import Comment -from CodeFragment import PP_Directive -from ParserWarning import Warning +from . import FileProfile +from .CodeFragment import Comment +from .CodeFragment import PP_Directive +from .ParserWarning import Warning ##define T_CHAR_SPACE ' ' diff --git a/BaseTools/Source/Python/Ecc/Database.py b/BaseTools/Source/Python/Ecc/Database.py index 204117512452..34f49f3cba8b 100644 --- a/BaseTools/Source/Python/Ecc/Database.py +++ b/BaseTools/Source/Python/Ecc/Database.py @@ -14,6 +14,7 @@ ## # Import Modules # +from __future__ import absolute_import import sqlite3 import Common.LongFilePathOs as os, time @@ -26,9 +27,9 @@ from Table.TableFunction import TableFunction from Table.TablePcd import TablePcd from Table.TableIdentifier import TableIdentifier from Table.TableReport import TableReport -from MetaFileWorkspace.MetaFileTable import ModuleTable -from MetaFileWorkspace.MetaFileTable import PackageTable -from MetaFileWorkspace.MetaFileTable import PlatformTable +from .MetaFileWorkspace.MetaFileTable import ModuleTable +from .MetaFileWorkspace.MetaFileTable import PackageTable +from .MetaFileWorkspace.MetaFileTable import PlatformTable from Table.TableFdf import TableFdf ## diff --git a/BaseTools/Source/Python/Ecc/Ecc.py b/BaseTools/Source/Python/Ecc/Ecc.py index ccd563a4660e..8f96bdf9778c 100644 --- a/BaseTools/Source/Python/Ecc/Ecc.py +++ b/BaseTools/Source/Python/Ecc/Ecc.py @@ -14,14 +14,15 @@ ## # Import Modules # +from __future__ import absolute_import import Common.LongFilePathOs as os, time, glob, sys import Common.EdkLogger as EdkLogger -import Database -import EccGlobalData -from MetaDataParser import * +from . import Database +from . import EccGlobalData +from .MetaDataParser import * from optparse import OptionParser -from Configuration import Configuration -from Check import Check +from .Configuration import Configuration +from .Check import Check import Common.GlobalData as GlobalData from Common.StringUtils import NormPath @@ -29,14 +30,14 @@ from Common.BuildVersion import gBUILD_VERSION from Common import BuildToolError from Common.Misc import PathClass from Common.Misc import DirCache -from MetaFileWorkspace.MetaFileParser import DscParser -from MetaFileWorkspace.MetaFileParser import DecParser -from MetaFileWorkspace.MetaFileParser import InfParser -from MetaFileWorkspace.MetaFileParser import Fdf -from MetaFileWorkspace.MetaFileTable import MetaFileStorage -import c +from .MetaFileWorkspace.MetaFileParser import DscParser +from .MetaFileWorkspace.MetaFileParser import DecParser +from .MetaFileWorkspace.MetaFileParser import InfParser +from .MetaFileWorkspace.MetaFileParser import Fdf +from .MetaFileWorkspace.MetaFileTable import MetaFileStorage +from . import c import re, string -from Exception import * +from .Exception import * from Common.LongFilePathSupport import OpenLongFilePath as open from Common.MultipleWorkspace import MultipleWorkspace as mws diff --git a/BaseTools/Source/Python/Ecc/Exception.py b/BaseTools/Source/Python/Ecc/Exception.py index 0498a503d774..340e0e975207 100644 --- a/BaseTools/Source/Python/Ecc/Exception.py +++ b/BaseTools/Source/Python/Ecc/Exception.py @@ -15,7 +15,8 @@ # Import Modules # from __future__ import print_function -from Xml.XmlRoutines import * +from __future__ import absolute_import +from .Xml.XmlRoutines import * import Common.LongFilePathOs as os # ExceptionXml to parse Exception Node of XML file diff --git a/BaseTools/Source/Python/Ecc/FileProfile.py b/BaseTools/Source/Python/Ecc/FileProfile.py index a071fd020eb4..1d3fbf2d3b79 100644 --- a/BaseTools/Source/Python/Ecc/FileProfile.py +++ b/BaseTools/Source/Python/Ecc/FileProfile.py @@ -16,9 +16,10 @@ # Import Modules # +from __future__ import absolute_import import re import Common.LongFilePathOs as os -from ParserWarning import Warning +from .ParserWarning import Warning from Common.LongFilePathSupport import OpenLongFilePath as open CommentList = [] @@ -54,5 +55,3 @@ class FileProfile : except IOError: raise Warning("Error when opening file %s" % FileName) - - diff --git a/BaseTools/Source/Python/Ecc/MetaDataParser.py b/BaseTools/Source/Python/Ecc/MetaDataParser.py index 6060d67581be..e5744dd5cc48 100644 --- a/BaseTools/Source/Python/Ecc/MetaDataParser.py +++ b/BaseTools/Source/Python/Ecc/MetaDataParser.py @@ -11,11 +11,12 @@ # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. # +from __future__ import absolute_import import Common.LongFilePathOs as os from CommonDataClass.DataClass import * -from EccToolError import * +from .EccToolError import * from Common.MultipleWorkspace import MultipleWorkspace as mws -import EccGlobalData +from . import EccGlobalData import re ## Get the inlcude path list for a source file # diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py index 111a25ed9260..51669815b55f 100644 --- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py @@ -14,6 +14,7 @@ ## # Import Modules # +from __future__ import absolute_import import Common.LongFilePathOs as os import re import time @@ -31,7 +32,7 @@ from Common.Misc import GuidStructureStringToGuidString, CheckPcdDatum, PathClas from Common.Expression import * from CommonDataClass.Exceptions import * -from MetaFileTable import MetaFileStorage +from .MetaFileTable import MetaFileStorage from GenFds.FdfParser import FdfParser from Common.LongFilePathSupport import OpenLongFilePath as open from Common.LongFilePathSupport import CodecOpenLongFilePath diff --git a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py index ad3cf36a1cbd..7e0afd5d70d7 100644 --- a/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py +++ b/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileTable.py @@ -14,13 +14,14 @@ ## # Import Modules # +from __future__ import absolute_import import uuid import Common.EdkLogger as EdkLogger import EccGlobalData -from MetaDataTable import Table -from MetaDataTable import ConvertToSqlString +from .MetaDataTable import Table +from .MetaDataTable import ConvertToSqlString from CommonDataClass.DataClass import MODEL_FILE_DSC, MODEL_FILE_DEC, MODEL_FILE_INF, \ MODEL_FILE_OTHERS diff --git a/BaseTools/Source/Python/Ecc/c.py b/BaseTools/Source/Python/Ecc/c.py index 12dbf664ba9b..5616c108533e 100644 --- a/BaseTools/Source/Python/Ecc/c.py +++ b/BaseTools/Source/Python/Ecc/c.py @@ -12,18 +12,19 @@ # from __future__ import print_function +from __future__ import absolute_import import sys import Common.LongFilePathOs as os import re import string -import CodeFragmentCollector -import FileProfile +from . import CodeFragmentCollector +from . import FileProfile from CommonDataClass import DataClass -import Database +from . import Database from Common import EdkLogger -from EccToolError import * -import EccGlobalData -import MetaDataParser +from .EccToolError import * +from . import EccGlobalData +from . import MetaDataParser IncludeFileListDict = {} AllIncludeFileListDict = {} -- 2.18.0