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 0B7C920988478 for ; Fri, 13 Jul 2018 03:19:30 -0700 (PDT) Received: from localhost.localdomain (unknown.telstraglobal.net [134.159.103.118]) by smtp.nue.novell.com with ESMTP (NOT encrypted); Fri, 13 Jul 2018 12:19:27 +0200 From: Gary Lin To: edk2-devel@lists.01.org Cc: Yonghong Zhu , Liming Gao Date: Fri, 13 Jul 2018 18:18:43 +0800 Message-Id: <20180713101847.7485-13-glin@suse.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180713101847.7485-1-glin@suse.com> References: <20180713101847.7485-1-glin@suse.com> Subject: [PATCH v2 12/16] BaseTools: Use absolute import in Eot 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: Fri, 13 Jul 2018 10:19:31 -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/Eot/CParser.py | 5 +++-- BaseTools/Source/Python/Eot/CodeFragmentCollector.py | 11 +++++----- BaseTools/Source/Python/Eot/Eot.py | 21 ++++++++++---------- BaseTools/Source/Python/Eot/FileProfile.py | 3 ++- BaseTools/Source/Python/Eot/InfParserLite.py | 5 +++-- BaseTools/Source/Python/Eot/Parser.py | 3 ++- BaseTools/Source/Python/Eot/Report.py | 3 ++- BaseTools/Source/Python/Eot/c.py | 9 +++++---- 8 files changed, 34 insertions(+), 26 deletions(-) diff --git a/BaseTools/Source/Python/Eot/CParser.py b/BaseTools/Source/Python/Eot/CParser.py index b66ac2d8d545..0b74b53ae7a5 100644 --- a/BaseTools/Source/Python/Eot/CParser.py +++ b/BaseTools/Source/Python/Eot/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/Eot/CodeFragmentCollector.py b/BaseTools/Source/Python/Eot/CodeFragmentCollector.py index 1e30e2ce62e2..8a5e5df17e5a 100644 --- a/BaseTools/Source/Python/Eot/CodeFragmentCollector.py +++ b/BaseTools/Source/Python/Eot/CodeFragmentCollector.py @@ -16,17 +16,18 @@ # Import Modules # 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 PP_Directive -from ParserWarning import Warning +from . import FileProfile +from .CodeFragment import PP_Directive +from .ParserWarning import Warning ##define T_CHAR_SPACE ' ' diff --git a/BaseTools/Source/Python/Eot/Eot.py b/BaseTools/Source/Python/Eot/Eot.py index 297847cdab91..6fb882642bff 100644 --- a/BaseTools/Source/Python/Eot/Eot.py +++ b/BaseTools/Source/Python/Eot/Eot.py @@ -14,20 +14,21 @@ ## # Import Modules # +from __future__ import absolute_import import Common.LongFilePathOs as os, time, glob import Common.EdkLogger as EdkLogger -import EotGlobalData +from . import EotGlobalData from optparse import OptionParser from Common.StringUtils import NormPath from Common import BuildToolError from Common.Misc import GuidStructureStringToGuidString, sdict -from InfParserLite import * -import c -import Database +from .InfParserLite import * +from . import c +from . import Database from array import array -from Report import Report +from .Report import Report from Common.BuildVersion import gBUILD_VERSION -from Parser import ConvertGuid +from .Parser import ConvertGuid from Common.LongFilePathSupport import OpenLongFilePath as open import struct import uuid @@ -153,7 +154,7 @@ class CompressedImage(Image): def _GetSections(m): try: - import EfiCompressor + from . import EfiCompressor TmpData = EfiCompressor.FrameworkDecompress( m[m._HEADER_SIZE_:], len(m) - m._HEADER_SIZE_ @@ -161,7 +162,7 @@ class CompressedImage(Image): DecData = array('B') DecData.fromstring(TmpData) except: - import EfiCompressor + from . import EfiCompressor TmpData = EfiCompressor.UefiDecompress( m[m._HEADER_SIZE_:], len(m) - m._HEADER_SIZE_ @@ -748,7 +749,7 @@ class GuidDefinedImage(Image): SectionList.append(Sec) elif Guid == m.TIANO_COMPRESS_GUID: try: - import EfiCompressor + from . import EfiCompressor # skip the header Offset = m.DataOffset - 4 TmpData = EfiCompressor.FrameworkDecompress(m[Offset:], len(m)-Offset) @@ -769,7 +770,7 @@ class GuidDefinedImage(Image): pass elif Guid == m.LZMA_COMPRESS_GUID: try: - import LzmaCompressor + from . import LzmaCompressor # skip the header Offset = m.DataOffset - 4 TmpData = LzmaCompressor.LzmaDecompress(m[Offset:], len(m)-Offset) diff --git a/BaseTools/Source/Python/Eot/FileProfile.py b/BaseTools/Source/Python/Eot/FileProfile.py index 0544c0d55b44..3846279cad4c 100644 --- a/BaseTools/Source/Python/Eot/FileProfile.py +++ b/BaseTools/Source/Python/Eot/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 # Profile contents of a file diff --git a/BaseTools/Source/Python/Eot/InfParserLite.py b/BaseTools/Source/Python/Eot/InfParserLite.py index 24f0d50246e5..88d7e7d58e0b 100644 --- a/BaseTools/Source/Python/Eot/InfParserLite.py +++ b/BaseTools/Source/Python/Eot/InfParserLite.py @@ -15,14 +15,15 @@ # Import Modules # from __future__ import print_function +from __future__ import absolute_import import Common.LongFilePathOs as os import Common.EdkLogger as EdkLogger from Common.DataType import * from CommonDataClass.DataClass import * from Common.Identification import * from Common.StringUtils import * -from Parser import * -import Database +from .Parser import * +from . import Database ## EdkInfParser() class # diff --git a/BaseTools/Source/Python/Eot/Parser.py b/BaseTools/Source/Python/Eot/Parser.py index 0b720d5b2187..e01a9770befb 100644 --- a/BaseTools/Source/Python/Eot/Parser.py +++ b/BaseTools/Source/Python/Eot/Parser.py @@ -15,12 +15,13 @@ ## # Import Modules # +from __future__ import absolute_import import Common.LongFilePathOs as os, re import Common.EdkLogger as EdkLogger from Common.DataType import * from CommonDataClass.DataClass import * from Common.StringUtils import CleanString, GetSplitValueList, ReplaceMacro -import EotGlobalData +from . import EotGlobalData from Common.StringUtils import GetSplitList from Common.LongFilePathSupport import OpenLongFilePath as open diff --git a/BaseTools/Source/Python/Eot/Report.py b/BaseTools/Source/Python/Eot/Report.py index e9716c988c8b..4ddddb103401 100644 --- a/BaseTools/Source/Python/Eot/Report.py +++ b/BaseTools/Source/Python/Eot/Report.py @@ -14,8 +14,9 @@ ## # Import Modules # +from __future__ import absolute_import import Common.LongFilePathOs as os -import EotGlobalData +from . import EotGlobalData from Common.LongFilePathSupport import OpenLongFilePath as open ## Report() class diff --git a/BaseTools/Source/Python/Eot/c.py b/BaseTools/Source/Python/Eot/c.py index ceefc952237f..4f0b58a52c79 100644 --- a/BaseTools/Source/Python/Eot/c.py +++ b/BaseTools/Source/Python/Eot/c.py @@ -16,15 +16,16 @@ # Import Modules # from __future__ import print_function +from __future__ import absolute_import import sys import Common.LongFilePathOs as os import re -import CodeFragmentCollector -import FileProfile +from . import CodeFragmentCollector +from . import FileProfile from CommonDataClass import DataClass from Common import EdkLogger -from EotToolError import * -import EotGlobalData +from .EotToolError import * +from . import EotGlobalData # Global Dicts IncludeFileListDict = {} -- 2.18.0