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 421F121E0BA06 for ; Thu, 1 Feb 2018 00:31:37 -0800 (PST) Received: from localhost.localdomain (unknown.telstraglobal.net [134.159.103.118]) by smtp.nue.novell.com with ESMTP (NOT encrypted); Thu, 01 Feb 2018 09:37:11 +0100 From: Gary Lin To: edk2-devel@lists.01.org Cc: Yonghong Zhu , Liming Gao Date: Thu, 1 Feb 2018 16:36:05 +0800 Message-Id: <20180201083608.16036-18-glin@suse.com> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180201083608.16036-1-glin@suse.com> References: <20180201083608.16036-1-glin@suse.com> Subject: [PATCH v2 17/20] BaseTools: Adopt absolute import for python scripts X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Feb 2018 08:31:38 -0000 Based on "futurize -f libfuturize.fixes.fix_absolute_import" Since circular import is not allowed in python 3, the following changes are applied to break the circles. * BaseTools/Source/Python/GenFds/Capsule.py - Delay "from .GenFds import GenFds" until GenCapsule() - Delay "from .GenFds import FindExtendTool" until GenFmpCapsule() To break the circle: AutoGen.AutoGen => GenFds.FdfParser => GenFds.Capsule => GenFds.GenFds => GenFds.FdfParser * BaseTools/Source/Python/GenFds/Fd.py - Delay "from .GenFds import GenFds" until GenFd() To break the circle: AutoGen.AutoGen => GenFds.FdfParser => GenFds.Fd => GenFds.GenFds => GenFds.FdfParser * BaseTools/Source/Python/GenFds/Fv.py - Delay "from .GenFds import GenFds" until AddToBuffer() To break the circle: AutoGen.AutoGen => GenFds.FdfParser => GenFds.Fd => GenFds.Fv => GenFds.GenFds => GenFds.FdfParser * BaseTools/Source/Python/GenFds/GuidSection.py - Delay "from .GenFds import FindExtendTool" until GuidSection() To break the circle: AutoGen.AutoGen => GenFds.FdfParser => GenFds.Fd => GenFds.Fv => GenFds.AprioriSection => GenFds.FfsFileStatement => GenFds.GuidSection => GenFds.GenFds => GenFds.FdfParser * BaseTools/Source/Python/GenFds/OptRomInfStatement.py - Delay "from . import OptionRom" until __GetOptRomParams() To break the circle: AutoGen.AutoGen => GenFds.FdfParser => GenFds.OptionRom => GenFds.OptRomInfStatement => GenFds.OptionRom * BaseTools/Source/Python/GenFds/OptionRom.py - Remove the unused "from .GenFds import GenFds" To break the circle: AutoGen.AutoGen => GenFds.FdfParser => GenFds.OptionRom => GenFds.GenFds => GenFds.FdfParser Contributed-under: TianoCore Contribution Agreement 1.1 Cc: Yonghong Zhu Cc: Liming Gao Signed-off-by: Gary Lin --- BaseTools/Source/Python/AutoGen/AutoGen.py | 17 +++--- BaseTools/Source/Python/AutoGen/GenC.py | 7 +-- BaseTools/Source/Python/AutoGen/GenMake.py | 3 +- BaseTools/Source/Python/AutoGen/GenPcdDb.py | 7 +-- BaseTools/Source/Python/AutoGen/StrGather.py | 3 +- BaseTools/Source/Python/BPDG/BPDG.py | 5 +- BaseTools/Source/Python/BPDG/GenVpd.py | 3 +- BaseTools/Source/Python/Common/Database.py | 8 +-- BaseTools/Source/Python/Common/DecClassObject.py | 17 +++--- BaseTools/Source/Python/Common/Dictionary.py | 5 +- BaseTools/Source/Python/Common/DscClassObject.py | 21 ++++---- BaseTools/Source/Python/Common/EdkIIWorkspace.py | 3 +- BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py | 19 +++---- BaseTools/Source/Python/Common/EdkLogger.py | 3 +- BaseTools/Source/Python/Common/Expression.py | 3 +- BaseTools/Source/Python/Common/FdfClassObject.py | 5 +- BaseTools/Source/Python/Common/InfClassObject.py | 21 ++++---- BaseTools/Source/Python/Common/LongFilePathOs.py | 3 +- BaseTools/Source/Python/Common/MigrationUtilities.py | 3 +- BaseTools/Source/Python/Common/Misc.py | 9 ++-- BaseTools/Source/Python/Common/Parsing.py | 5 +- BaseTools/Source/Python/Common/String.py | 9 ++-- BaseTools/Source/Python/Common/TargetTxtClassObject.py | 9 ++-- BaseTools/Source/Python/Common/ToolDefClassObject.py | 9 ++-- BaseTools/Source/Python/CommonDataClass/ModuleClass.py | 3 +- BaseTools/Source/Python/CommonDataClass/PackageClass.py | 3 +- BaseTools/Source/Python/CommonDataClass/PlatformClass.py | 3 +- 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 ++--- BaseTools/Source/Python/Eot/CParser.py | 5 +- BaseTools/Source/Python/Eot/CodeFragmentCollector.py | 11 ++-- BaseTools/Source/Python/Eot/Eot.py | 15 +++--- BaseTools/Source/Python/Eot/FileProfile.py | 3 +- BaseTools/Source/Python/Eot/FvImage.py | 11 ++-- 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 ++-- BaseTools/Source/Python/GenFds/AprioriSection.py | 5 +- BaseTools/Source/Python/GenFds/Capsule.py | 7 +-- BaseTools/Source/Python/GenFds/CapsuleData.py | 5 +- BaseTools/Source/Python/GenFds/CompressSection.py | 7 +-- BaseTools/Source/Python/GenFds/DataSection.py | 7 +-- BaseTools/Source/Python/GenFds/DepexSection.py | 7 +-- BaseTools/Source/Python/GenFds/EfiSection.py | 7 +-- BaseTools/Source/Python/GenFds/Fd.py | 9 ++-- BaseTools/Source/Python/GenFds/FdfParser.py | 55 ++++++++++---------- BaseTools/Source/Python/GenFds/FfsFileStatement.py | 11 ++-- BaseTools/Source/Python/GenFds/FfsInfStatement.py | 19 +++---- BaseTools/Source/Python/GenFds/Fv.py | 12 ++--- BaseTools/Source/Python/GenFds/FvImageSection.py | 7 +-- BaseTools/Source/Python/GenFds/GenFds.py | 11 ++-- BaseTools/Source/Python/GenFds/GuidSection.py | 11 ++-- BaseTools/Source/Python/GenFds/OptRomFileStatement.py | 3 +- BaseTools/Source/Python/GenFds/OptRomInfStatement.py | 16 +++--- BaseTools/Source/Python/GenFds/OptionRom.py | 6 +-- BaseTools/Source/Python/GenFds/Region.py | 3 +- BaseTools/Source/Python/GenFds/RuleComplexFile.py | 3 +- BaseTools/Source/Python/GenFds/RuleSimpleFile.py | 3 +- BaseTools/Source/Python/GenFds/Section.py | 3 +- BaseTools/Source/Python/GenFds/UiSection.py | 7 +-- BaseTools/Source/Python/GenFds/VerSection.py | 7 +-- BaseTools/Source/Python/GenFds/Vtf.py | 3 +- BaseTools/Source/Python/Table/TableDataModel.py | 3 +- BaseTools/Source/Python/Table/TableDec.py | 3 +- BaseTools/Source/Python/Table/TableDsc.py | 3 +- BaseTools/Source/Python/Table/TableEotReport.py | 5 +- BaseTools/Source/Python/Table/TableFdf.py | 3 +- BaseTools/Source/Python/Table/TableFile.py | 3 +- BaseTools/Source/Python/Table/TableFunction.py | 3 +- BaseTools/Source/Python/Table/TableIdentifier.py | 5 +- BaseTools/Source/Python/Table/TableInf.py | 3 +- BaseTools/Source/Python/Table/TablePcd.py | 5 +- BaseTools/Source/Python/Table/TableQuery.py | 3 +- BaseTools/Source/Python/Table/TableReport.py | 3 +- BaseTools/Source/Python/UPT/Library/Parsing.py | 3 +- BaseTools/Source/Python/Workspace/DscBuildData.py | 9 ++-- BaseTools/Source/Python/Workspace/InfBuildData.py | 3 +- BaseTools/Source/Python/Workspace/MetaFileParser.py | 5 +- BaseTools/Source/Python/Workspace/MetaFileTable.py | 5 +- BaseTools/Source/Python/Workspace/WorkspaceCommon.py | 3 +- BaseTools/Source/Python/Workspace/WorkspaceDatabase.py | 7 +-- BaseTools/Source/Python/build/build.py | 3 +- 92 files changed, 381 insertions(+), 297 deletions(-) diff --git a/BaseTools/Source/Python/AutoGen/AutoGen.py b/BaseTools/Source/Python/AutoGen/AutoGen.py index 2bc925aa1e08..6e8c3cc10c1e 100644 --- a/BaseTools/Source/Python/AutoGen/AutoGen.py +++ b/BaseTools/Source/Python/AutoGen/AutoGen.py @@ -14,6 +14,7 @@ ## Import Modules # from __future__ import print_function +from __future__ import absolute_import from builtins import range import Common.LongFilePathOs as os import re @@ -21,13 +22,13 @@ import os.path as path import copy import uuid -import GenC -import GenMake -import GenDepex +from . import GenC +from . import GenMake +from . import GenDepex from io import BytesIO -from StrGather import * -from BuildEngine import BuildRule +from .StrGather import * +from .BuildEngine import BuildRule from Common.LongFilePathSupport import CopyLongFilePath from Common.BuildToolError import * @@ -40,13 +41,13 @@ from CommonDataClass.CommonClass import SkuInfoClass from Workspace.BuildClassObject import * from GenPatchPcdTable.GenPatchPcdTable import parsePcdInfoFromMapFile import Common.VpdInfoFile as VpdInfoFile -from GenPcdDb import CreatePcdDatabaseCode +from .GenPcdDb import CreatePcdDatabaseCode from Workspace.MetaFileCommentParser import UsageList from Common.MultipleWorkspace import MultipleWorkspace as mws -import InfSectionParser +from . import InfSectionParser import datetime import hashlib -from GenVar import VariableMgr, var_info +from .GenVar import VariableMgr, var_info ## Regular expression for splitting Dependency Expression string into tokens gDepexTokenPattern = re.compile("(\(|\)|\w+| \S+\.inf)") diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py index d68160deb4a1..adf00d9a9514 100644 --- a/BaseTools/Source/Python/AutoGen/GenC.py +++ b/BaseTools/Source/Python/AutoGen/GenC.py @@ -13,6 +13,7 @@ ## Import Modules # +from __future__ import absolute_import from builtins import range import string import collections @@ -23,9 +24,9 @@ from Common.BuildToolError import * from Common.DataType import * from Common.Misc import * from Common.String import StringToArray -from StrGather import * -from GenPcdDb import CreatePcdDatabaseCode -from IdfClassObject import * +from .StrGather import * +from .GenPcdDb import CreatePcdDatabaseCode +from .IdfClassObject import * ## PCD type string gItemTypeStringDatabase = { diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py b/BaseTools/Source/Python/AutoGen/GenMake.py index eb56d0e7c5a3..a2a6cb2ac224 100644 --- a/BaseTools/Source/Python/AutoGen/GenMake.py +++ b/BaseTools/Source/Python/AutoGen/GenMake.py @@ -13,6 +13,7 @@ ## Import Modules # +from __future__ import absolute_import import Common.LongFilePathOs as os import sys import string @@ -23,7 +24,7 @@ from Common.MultipleWorkspace import MultipleWorkspace as mws from Common.BuildToolError import * from Common.Misc import * from Common.String import * -from BuildEngine import * +from .BuildEngine import * import Common.GlobalData as GlobalData ## Regular expression for finding header file inclusions diff --git a/BaseTools/Source/Python/AutoGen/GenPcdDb.py b/BaseTools/Source/Python/AutoGen/GenPcdDb.py index 716ec8ca3f52..476f5391ffdc 100644 --- a/BaseTools/Source/Python/AutoGen/GenPcdDb.py +++ b/BaseTools/Source/Python/AutoGen/GenPcdDb.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 from builtins import range from io import BytesIO from Common.Misc import * from Common.String import StringToArray from struct import pack -from ValidCheckingInfoObject import VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER -from ValidCheckingInfoObject import VAR_CHECK_PCD_VARIABLE_TAB -from ValidCheckingInfoObject import VAR_VALID_OBJECT_FACTORY +from .ValidCheckingInfoObject import VAR_CHECK_PCD_VARIABLE_TAB_CONTAINER +from .ValidCheckingInfoObject import VAR_CHECK_PCD_VARIABLE_TAB +from .ValidCheckingInfoObject import VAR_VALID_OBJECT_FACTORY from Common.VariableAttributes import VariableAttributes import copy from struct import unpack diff --git a/BaseTools/Source/Python/AutoGen/StrGather.py b/BaseTools/Source/Python/AutoGen/StrGather.py index b61450c02831..f1773d99e4dd 100644 --- a/BaseTools/Source/Python/AutoGen/StrGather.py +++ b/BaseTools/Source/Python/AutoGen/StrGather.py @@ -14,11 +14,12 @@ ## # Import Modules # +from __future__ import absolute_import from builtins import range import re import Common.EdkLogger as EdkLogger from Common.BuildToolError import * -from UniClassObject import * +from .UniClassObject import * from io import BytesIO from struct import pack, unpack from Common.LongFilePathSupport import OpenLongFilePath as open diff --git a/BaseTools/Source/Python/BPDG/BPDG.py b/BaseTools/Source/Python/BPDG/BPDG.py index 9ab13a39e8bf..8388915d8637 100644 --- a/BaseTools/Source/Python/BPDG/BPDG.py +++ b/BaseTools/Source/Python/BPDG/BPDG.py @@ -21,6 +21,7 @@ # Import Modules # from __future__ import print_function +from __future__ import absolute_import import Common.LongFilePathOs as os import sys import encodings.ascii @@ -30,8 +31,8 @@ from Common import EdkLogger from Common.BuildToolError import * from Common.BuildVersion import gBUILD_VERSION -import StringTable as st -import GenVpd +from . import StringTable as st +from . import GenVpd PROJECT_NAME = st.LBL_BPDG_LONG_UNI VERSION = (st.LBL_BPDG_VERSION + " Build " + gBUILD_VERSION) diff --git a/BaseTools/Source/Python/BPDG/GenVpd.py b/BaseTools/Source/Python/BPDG/GenVpd.py index 54b2cc54f578..bbccdc780fb3 100644 --- a/BaseTools/Source/Python/BPDG/GenVpd.py +++ b/BaseTools/Source/Python/BPDG/GenVpd.py @@ -13,10 +13,11 @@ # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. # +from __future__ import absolute_import from builtins import range import Common.LongFilePathOs as os from io import BytesIO -import StringTable as st +from . import StringTable as st import array import re from Common.LongFilePathSupport import OpenLongFilePath as open diff --git a/BaseTools/Source/Python/Common/Database.py b/BaseTools/Source/Python/Common/Database.py index a81a44731f03..c281c199effd 100644 --- a/BaseTools/Source/Python/Common/Database.py +++ b/BaseTools/Source/Python/Common/Database.py @@ -14,13 +14,14 @@ ## # Import Modules # +from __future__ import absolute_import import sqlite3 import Common.LongFilePathOs as os -import EdkLogger as EdkLogger +from . import EdkLogger as EdkLogger from CommonDataClass.DataClass import * -from String import * -from DataType import * +from .String import * +from .DataType import * from Table.TableDataModel import TableDataModel from Table.TableFile import TableFile @@ -117,4 +118,3 @@ if __name__ == '__main__': Db.QueryTable(Db.TblFile) Db.QueryTable(Db.TblDsc) Db.Close() - \ No newline at end of file diff --git a/BaseTools/Source/Python/Common/DecClassObject.py b/BaseTools/Source/Python/Common/DecClassObject.py index 970e644318d0..71cd2d33000e 100644 --- a/BaseTools/Source/Python/Common/DecClassObject.py +++ b/BaseTools/Source/Python/Common/DecClassObject.py @@ -15,18 +15,19 @@ # Import Modules # from __future__ import print_function +from __future__ import absolute_import import Common.LongFilePathOs as os -from String import * -from DataType import * -from Identification import * -from Dictionary import * +from .String import * +from .DataType import * +from .Identification import * +from .Dictionary import * from CommonDataClass.PackageClass import * from CommonDataClass.CommonClass import PcdClass -from BuildToolError import * +from .BuildToolError import * from Table.TableDec import TableDec -import Database -from Parsing import * -import GlobalData +from . import Database +from .Parsing import * +from . import GlobalData from Common.LongFilePathSupport import OpenLongFilePath as open # diff --git a/BaseTools/Source/Python/Common/Dictionary.py b/BaseTools/Source/Python/Common/Dictionary.py index c381995f97ff..149081be2831 100644 --- a/BaseTools/Source/Python/Common/Dictionary.py +++ b/BaseTools/Source/Python/Common/Dictionary.py @@ -15,8 +15,9 @@ # Import Modules # from __future__ import print_function -import EdkLogger -from DataType import * +from __future__ import absolute_import +from . import EdkLogger +from .DataType import * from Common.LongFilePathSupport import OpenLongFilePath as open ## Convert a text file to a dictionary diff --git a/BaseTools/Source/Python/Common/DscClassObject.py b/BaseTools/Source/Python/Common/DscClassObject.py index e6abc1f036ac..d4ebddadc74a 100644 --- a/BaseTools/Source/Python/Common/DscClassObject.py +++ b/BaseTools/Source/Python/Common/DscClassObject.py @@ -15,20 +15,21 @@ # Import Modules # from __future__ import print_function +from __future__ import absolute_import from builtins import range import Common.LongFilePathOs as os -import EdkLogger as EdkLogger -import Database -from String import * -from Parsing import * -from DataType import * -from Identification import * -from Dictionary import * +from . import EdkLogger as EdkLogger +from . import Database +from .String import * +from .Parsing import * +from .DataType import * +from .Identification import * +from .Dictionary import * from CommonDataClass.PlatformClass import * from CommonDataClass.CommonClass import SkuInfoClass -from BuildToolError import * -from Misc import sdict -import GlobalData +from .BuildToolError import * +from .Misc import sdict +from . import GlobalData from Table.TableDsc import TableDsc from Common.LongFilePathSupport import OpenLongFilePath as open diff --git a/BaseTools/Source/Python/Common/EdkIIWorkspace.py b/BaseTools/Source/Python/Common/EdkIIWorkspace.py index 52f63ae53df8..4f7e69ca5ef2 100644 --- a/BaseTools/Source/Python/Common/EdkIIWorkspace.py +++ b/BaseTools/Source/Python/Common/EdkIIWorkspace.py @@ -15,8 +15,9 @@ # Import Modules # from __future__ import print_function +from __future__ import absolute_import import Common.LongFilePathOs as os, sys, time -from DataType import * +from .DataType import * from Common.LongFilePathSupport import OpenLongFilePath as open from Common.MultipleWorkspace import MultipleWorkspace as mws diff --git a/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py b/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py index a2f7c94c1ca7..2b4dc720cea9 100644 --- a/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py +++ b/BaseTools/Source/Python/Common/EdkIIWorkspaceBuild.py @@ -15,16 +15,17 @@ # Import Modules # from __future__ import print_function +from __future__ import absolute_import import Common.LongFilePathOs as os, string, copy, pdb, copy -import EdkLogger -import DataType -from InfClassObject import * -from DecClassObject import * -from DscClassObject import * -from String import * -from BuildToolError import * -from Misc import sdict -import Database as Database +from . import EdkLogger +from . import DataType +from .InfClassObject import * +from .DecClassObject import * +from .DscClassObject import * +from .String import * +from .BuildToolError import * +from .Misc import sdict +from . import Database as Database import time as time ## PcdClassObject diff --git a/BaseTools/Source/Python/Common/EdkLogger.py b/BaseTools/Source/Python/Common/EdkLogger.py index ac1c8edc4fe2..636ac908c320 100644 --- a/BaseTools/Source/Python/Common/EdkLogger.py +++ b/BaseTools/Source/Python/Common/EdkLogger.py @@ -12,9 +12,10 @@ # ## Import modules +from __future__ import absolute_import import Common.LongFilePathOs as os, sys, logging import traceback -from BuildToolError import * +from .BuildToolError import * ## Log level constants DEBUG_0 = 1 diff --git a/BaseTools/Source/Python/Common/Expression.py b/BaseTools/Source/Python/Common/Expression.py index 3b5afdc9ab06..afe80e690877 100644 --- a/BaseTools/Source/Python/Common/Expression.py +++ b/BaseTools/Source/Python/Common/Expression.py @@ -13,11 +13,12 @@ ## Import Modules # from __future__ import print_function +from __future__ import absolute_import from builtins import range from Common.GlobalData import * from CommonDataClass.Exceptions import BadExpression from CommonDataClass.Exceptions import WrnExpression -from Misc import GuidStringToGuidStructureString, ParseFieldValue +from .Misc import GuidStringToGuidStructureString, ParseFieldValue import Common.EdkLogger as EdkLogger import copy diff --git a/BaseTools/Source/Python/Common/FdfClassObject.py b/BaseTools/Source/Python/Common/FdfClassObject.py index 7ec0235967b2..b0ab8010343a 100644 --- a/BaseTools/Source/Python/Common/FdfClassObject.py +++ b/BaseTools/Source/Python/Common/FdfClassObject.py @@ -14,11 +14,12 @@ ## # Import Modules # +from __future__ import absolute_import from builtins import range -from FdfParserLite import FdfParser +from .FdfParserLite import FdfParser from Table.TableFdf import TableFdf from CommonDataClass.DataClass import MODEL_FILE_FDF, MODEL_PCD, MODEL_META_DATA_COMPONENT -from String import NormPath +from .String import NormPath ## FdfObject # diff --git a/BaseTools/Source/Python/Common/InfClassObject.py b/BaseTools/Source/Python/Common/InfClassObject.py index fe82ffd8eb4e..54f99c83910e 100644 --- a/BaseTools/Source/Python/Common/InfClassObject.py +++ b/BaseTools/Source/Python/Common/InfClassObject.py @@ -15,21 +15,22 @@ # Import Modules # from __future__ import print_function +from __future__ import absolute_import import Common.LongFilePathOs as os import re -import EdkLogger +from . import EdkLogger from CommonDataClass.CommonClass import LibraryClassClass from CommonDataClass.ModuleClass import * -from String import * -from DataType import * -from Identification import * -from Dictionary import * -from BuildToolError import * -from Misc import sdict -import GlobalData +from .String import * +from .DataType import * +from .Identification import * +from .Dictionary import * +from .BuildToolError import * +from .Misc import sdict +from . import GlobalData from Table.TableInf import TableInf -import Database -from Parsing import * +from . import Database +from .Parsing import * from Common.LongFilePathSupport import OpenLongFilePath as open # diff --git a/BaseTools/Source/Python/Common/LongFilePathOs.py b/BaseTools/Source/Python/Common/LongFilePathOs.py index 47d63faeb995..a32205545368 100644 --- a/BaseTools/Source/Python/Common/LongFilePathOs.py +++ b/BaseTools/Source/Python/Common/LongFilePathOs.py @@ -11,8 +11,9 @@ # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. # +from __future__ import absolute_import import os -import LongFilePathOsPath +from . import LongFilePathOsPath from Common.LongFilePathSupport import LongFilePath from Common.LongFilePathSupport import UniToStr diff --git a/BaseTools/Source/Python/Common/MigrationUtilities.py b/BaseTools/Source/Python/Common/MigrationUtilities.py index 2385988247d4..88038046835a 100644 --- a/BaseTools/Source/Python/Common/MigrationUtilities.py +++ b/BaseTools/Source/Python/Common/MigrationUtilities.py @@ -14,10 +14,11 @@ ## # Import Modules # +from __future__ import absolute_import from builtins import range import Common.LongFilePathOs as os import re -import EdkLogger +from . import EdkLogger from optparse import OptionParser from Common.BuildToolError import * from XmlRoutines import * diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py index 1a7418734cf8..5d7b0cf9ddc5 100644 --- a/BaseTools/Source/Python/Common/Misc.py +++ b/BaseTools/Source/Python/Common/Misc.py @@ -14,6 +14,7 @@ ## # Import Modules # +from __future__ import absolute_import from builtins import range import Common.LongFilePathOs as os import sys @@ -31,10 +32,10 @@ from UserList import UserList from Common import EdkLogger as EdkLogger from Common import GlobalData as GlobalData -from DataType import * -from BuildToolError import * +from .DataType import * +from .BuildToolError import * from CommonDataClass.DataClass import * -from Parsing import GetSplitValueList +from .Parsing import GetSplitValueList from Common.LongFilePathSupport import OpenLongFilePath as open from Common.MultipleWorkspace import MultipleWorkspace as mws import uuid @@ -512,7 +513,7 @@ def SaveFileOnChange(File, Content, IsBinaryFile=True): try: if GlobalData.gIsWindows: try: - from PyUtility import SaveFileToDisk + from .PyUtility import SaveFileToDisk if not SaveFileToDisk(File, Content): EdkLogger.error(None, FILE_CREATE_FAILURE, ExtraData=File) except: diff --git a/BaseTools/Source/Python/Common/Parsing.py b/BaseTools/Source/Python/Common/Parsing.py index 9caa9424d8ed..ebbb9f564320 100644 --- a/BaseTools/Source/Python/Common/Parsing.py +++ b/BaseTools/Source/Python/Common/Parsing.py @@ -14,10 +14,11 @@ ## # Import Modules # +from __future__ import absolute_import from builtins import range -from String import * +from .String import * from CommonDataClass.DataClass import * -from DataType import * +from .DataType import * ## ParseDefineMacro # diff --git a/BaseTools/Source/Python/Common/String.py b/BaseTools/Source/Python/Common/String.py index d2ec46d84eb8..d5932b367d69 100644 --- a/BaseTools/Source/Python/Common/String.py +++ b/BaseTools/Source/Python/Common/String.py @@ -14,15 +14,16 @@ ## # Import Modules # +from __future__ import absolute_import from builtins import range import re -import DataType +from . import DataType import Common.LongFilePathOs as os import string -import EdkLogger as EdkLogger +from . import EdkLogger as EdkLogger -import GlobalData -from BuildToolError import * +from . import GlobalData +from .BuildToolError import * from CommonDataClass.Exceptions import * from Common.LongFilePathSupport import OpenLongFilePath as open from Common.MultipleWorkspace import MultipleWorkspace as mws diff --git a/BaseTools/Source/Python/Common/TargetTxtClassObject.py b/BaseTools/Source/Python/Common/TargetTxtClassObject.py index 9c1e6b407356..b4ad4f1d290a 100644 --- a/BaseTools/Source/Python/Common/TargetTxtClassObject.py +++ b/BaseTools/Source/Python/Common/TargetTxtClassObject.py @@ -15,11 +15,12 @@ # Import Modules # from __future__ import print_function +from __future__ import absolute_import import Common.LongFilePathOs as os -import EdkLogger -import DataType -from BuildToolError import * -import GlobalData +from . import EdkLogger +from . import DataType +from .BuildToolError import * +from . import GlobalData from Common.LongFilePathSupport import OpenLongFilePath as open gDefaultTargetTxtFile = "target.txt" diff --git a/BaseTools/Source/Python/Common/ToolDefClassObject.py b/BaseTools/Source/Python/Common/ToolDefClassObject.py index d3587b171192..639ca176695c 100644 --- a/BaseTools/Source/Python/Common/ToolDefClassObject.py +++ b/BaseTools/Source/Python/Common/ToolDefClassObject.py @@ -14,14 +14,15 @@ ## # Import Modules # +from __future__ import absolute_import from builtins import range import Common.LongFilePathOs as os import re -import EdkLogger +from . import EdkLogger -from Dictionary import * -from BuildToolError import * -from TargetTxtClassObject import * +from .Dictionary import * +from .BuildToolError import * +from .TargetTxtClassObject import * from Common.LongFilePathSupport import OpenLongFilePath as open from Common.Misc import PathClass from Common.String import NormPath diff --git a/BaseTools/Source/Python/CommonDataClass/ModuleClass.py b/BaseTools/Source/Python/CommonDataClass/ModuleClass.py index c5ea15af5b97..54cc3e92e108 100644 --- a/BaseTools/Source/Python/CommonDataClass/ModuleClass.py +++ b/BaseTools/Source/Python/CommonDataClass/ModuleClass.py @@ -13,7 +13,8 @@ ## # Import Modules # -from CommonClass import * +from __future__ import absolute_import +from .CommonClass import * ## ModuleHeaderClass # diff --git a/BaseTools/Source/Python/CommonDataClass/PackageClass.py b/BaseTools/Source/Python/CommonDataClass/PackageClass.py index 89d4d0797fe1..d2ef29aea312 100644 --- a/BaseTools/Source/Python/CommonDataClass/PackageClass.py +++ b/BaseTools/Source/Python/CommonDataClass/PackageClass.py @@ -13,7 +13,8 @@ ## # Import Modules # -from CommonClass import * +from __future__ import absolute_import +from .CommonClass import * from Common.Misc import sdict ## PackageHeaderClass diff --git a/BaseTools/Source/Python/CommonDataClass/PlatformClass.py b/BaseTools/Source/Python/CommonDataClass/PlatformClass.py index a93d1ce2a1db..ee656e4d55e2 100644 --- a/BaseTools/Source/Python/CommonDataClass/PlatformClass.py +++ b/BaseTools/Source/Python/CommonDataClass/PlatformClass.py @@ -13,7 +13,8 @@ ## # Import Modules # -from CommonClass import * +from __future__ import absolute_import +from .CommonClass import * ## SkuInfoListClass # diff --git a/BaseTools/Source/Python/Ecc/CParser.py b/BaseTools/Source/Python/Ecc/CParser.py index bd4f10e1edff..02d70e73cbb8 100644 --- a/BaseTools/Source/Python/Ecc/CParser.py +++ b/BaseTools/Source/Python/Ecc/CParser.py @@ -1,4 +1,5 @@ from __future__ import print_function +from __future__ import absolute_import # $ANTLR 3.0.1 C.g 2010-02-23 09:58:53 from antlr3 import * @@ -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 92259999853c..339a6ddca471 100644 --- a/BaseTools/Source/Python/Ecc/Check.py +++ b/BaseTools/Source/Python/Ecc/Check.py @@ -10,15 +10,16 @@ # 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 from builtins import range 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 7bdb3cc3aea5..f96ea2fec6d2 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 94f9a427e370..46c79f169334 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.String 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 bde41c3a4b57..ba43ebe03fdb 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 f31d37ff9683..6f93cbf60479 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) - - \ No newline at end of file diff --git a/BaseTools/Source/Python/Ecc/MetaDataParser.py b/BaseTools/Source/Python/Ecc/MetaDataParser.py index 9b8b96aa4b43..545a9c3b20b4 100644 --- a/BaseTools/Source/Python/Ecc/MetaDataParser.py +++ b/BaseTools/Source/Python/Ecc/MetaDataParser.py @@ -11,12 +11,13 @@ # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. # +from __future__ import absolute_import from builtins import range 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 605a1d847c61..83676422692b 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 from builtins import range import Common.LongFilePathOs as os import re @@ -32,7 +33,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 54a3016948b1..f70a2f238334 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 7f83387c08c8..56eb21ead519 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 = {} diff --git a/BaseTools/Source/Python/Eot/CParser.py b/BaseTools/Source/Python/Eot/CParser.py index bd4f10e1edff..02d70e73cbb8 100644 --- a/BaseTools/Source/Python/Eot/CParser.py +++ b/BaseTools/Source/Python/Eot/CParser.py @@ -1,4 +1,5 @@ from __future__ import print_function +from __future__ import absolute_import # $ANTLR 3.0.1 C.g 2010-02-23 09:58:53 from antlr3 import * @@ -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 5d5336bee463..b92f81ad514d 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 5029f7369d4a..1905b06aefab 100644 --- a/BaseTools/Source/Python/Eot/Eot.py +++ b/BaseTools/Source/Python/Eot/Eot.py @@ -14,22 +14,23 @@ ## # 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.String import NormPath from Common import BuildToolError from Common.Misc import GuidStructureStringToGuidString -from InfParserLite import * -import c -import Database -from FvImage import * +from .InfParserLite import * +from . import c +from . import Database +from .FvImage import * from array import array -from Report import Report +from .Report import Report from Common.Misc import ParseConsoleLog from Common.BuildVersion import gBUILD_VERSION -from Parser import ConvertGuid +from .Parser import ConvertGuid from Common.LongFilePathSupport import OpenLongFilePath as open ## Class Eot 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/FvImage.py b/BaseTools/Source/Python/Eot/FvImage.py index 0a1eca1ed86f..085698557efe 100644 --- a/BaseTools/Source/Python/Eot/FvImage.py +++ b/BaseTools/Source/Python/Eot/FvImage.py @@ -14,6 +14,7 @@ ## Import Modules # from __future__ import print_function +from __future__ import absolute_import from builtins import range import Common.LongFilePathOs as os import re @@ -31,7 +32,7 @@ from Common.Misc import sdict, GuidStructureStringToGuidString import Common.EdkLogger as EdkLogger -import EotGlobalData +from . import EotGlobalData # Global definiton gFfsPrintTitle = "%-36s %-21s %8s %8s %8s %-4s %-36s" % ("GUID", "TYPE", "OFFSET", "SIZE", "FREE", "ALIGN", "NAME") @@ -557,7 +558,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_ @@ -565,7 +566,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_ @@ -665,7 +666,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) @@ -686,7 +687,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/InfParserLite.py b/BaseTools/Source/Python/Eot/InfParserLite.py index 4bdd60a6f71c..4080dc852008 100644 --- a/BaseTools/Source/Python/Eot/InfParserLite.py +++ b/BaseTools/Source/Python/Eot/InfParserLite.py @@ -15,6 +15,7 @@ # Import Modules # from __future__ import print_function +from __future__ import absolute_import from builtins import range import Common.LongFilePathOs as os import Common.EdkLogger as EdkLogger @@ -22,8 +23,8 @@ from Common.DataType import * from CommonDataClass.DataClass import * from Common.Identification import * from Common.String 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 951fe7e3be2e..8703e2d55552 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.String import CleanString, GetSplitValueList, ReplaceMacro -import EotGlobalData +from . import EotGlobalData from Common.Misc import sdict from Common.String 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 386e3eb8ec05..6440ede6bce3 100644 --- a/BaseTools/Source/Python/Eot/Report.py +++ b/BaseTools/Source/Python/Eot/Report.py @@ -1,3 +1,4 @@ +from __future__ import absolute_import ## @file # This file is used to create report for Eot tool # @@ -15,7 +16,7 @@ # Import Modules # 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 = {} diff --git a/BaseTools/Source/Python/GenFds/AprioriSection.py b/BaseTools/Source/Python/GenFds/AprioriSection.py index 65919270af15..983c89e82970 100644 --- a/BaseTools/Source/Python/GenFds/AprioriSection.py +++ b/BaseTools/Source/Python/GenFds/AprioriSection.py @@ -15,12 +15,13 @@ ## # Import Modules # +from __future__ import absolute_import from builtins import range from struct import * import Common.LongFilePathOs as os from io import BytesIO -import FfsFileStatement -from GenFdsGlobalVariable import GenFdsGlobalVariable +from . import FfsFileStatement +from .GenFdsGlobalVariable import GenFdsGlobalVariable from CommonDataClass.FdfClass import AprioriSectionClassObject from Common.String import * from Common.Misc import SaveFileOnChange, PathClass diff --git a/BaseTools/Source/Python/GenFds/Capsule.py b/BaseTools/Source/Python/GenFds/Capsule.py index 60019195df27..fb929065634e 100644 --- a/BaseTools/Source/Python/GenFds/Capsule.py +++ b/BaseTools/Source/Python/GenFds/Capsule.py @@ -15,17 +15,16 @@ ## # Import Modules # -from GenFdsGlobalVariable import GenFdsGlobalVariable +from __future__ import absolute_import +from .GenFdsGlobalVariable import GenFdsGlobalVariable from CommonDataClass.FdfClass import CapsuleClassObject import Common.LongFilePathOs as os import subprocess from io import BytesIO from Common.Misc import SaveFileOnChange -from GenFds import GenFds from Common.Misc import PackRegistryFormatGuid import uuid from struct import pack -from GenFds import FindExtendTool from Common import EdkLogger from Common.BuildToolError import * @@ -57,6 +56,7 @@ class Capsule (CapsuleClassObject) : # @retval string Generated Capsule file path # def GenFmpCapsule(self): + from .GenFds import FindExtendTool # # Generate capsule header # typedef struct { @@ -201,6 +201,7 @@ class Capsule (CapsuleClassObject) : # @retval string Generated Capsule file path # def GenCapsule(self): + from .GenFds import GenFds if self.UiCapsuleName.upper() + 'cap' in GenFds.ImageBinDict.keys(): return GenFds.ImageBinDict[self.UiCapsuleName.upper() + 'cap'] diff --git a/BaseTools/Source/Python/GenFds/CapsuleData.py b/BaseTools/Source/Python/GenFds/CapsuleData.py index f0a55d81120b..d7208deea1e3 100644 --- a/BaseTools/Source/Python/GenFds/CapsuleData.py +++ b/BaseTools/Source/Python/GenFds/CapsuleData.py @@ -15,8 +15,9 @@ ## # Import Modules # -import Ffs -from GenFdsGlobalVariable import GenFdsGlobalVariable +from __future__ import absolute_import +from . import Ffs +from .GenFdsGlobalVariable import GenFdsGlobalVariable from io import BytesIO from struct import pack import os diff --git a/BaseTools/Source/Python/GenFds/CompressSection.py b/BaseTools/Source/Python/GenFds/CompressSection.py index 64ad275d832e..ae4866661de6 100644 --- a/BaseTools/Source/Python/GenFds/CompressSection.py +++ b/BaseTools/Source/Python/GenFds/CompressSection.py @@ -15,11 +15,12 @@ ## # Import Modules # -from Ffs import Ffs -import Section +from __future__ import absolute_import +from .Ffs import Ffs +from . import Section import subprocess import Common.LongFilePathOs as os -from GenFdsGlobalVariable import GenFdsGlobalVariable +from .GenFdsGlobalVariable import GenFdsGlobalVariable from CommonDataClass.FdfClass import CompressSectionClassObject ## generate compress section diff --git a/BaseTools/Source/Python/GenFds/DataSection.py b/BaseTools/Source/Python/GenFds/DataSection.py index 2d2975f75c0f..cf0d27d83e08 100644 --- a/BaseTools/Source/Python/GenFds/DataSection.py +++ b/BaseTools/Source/Python/GenFds/DataSection.py @@ -15,10 +15,11 @@ ## # Import Modules # -import Section -from GenFdsGlobalVariable import GenFdsGlobalVariable +from __future__ import absolute_import +from . import Section +from .GenFdsGlobalVariable import GenFdsGlobalVariable import subprocess -from Ffs import Ffs +from .Ffs import Ffs import Common.LongFilePathOs as os from CommonDataClass.FdfClass import DataSectionClassObject from Common.Misc import PeImageClass diff --git a/BaseTools/Source/Python/GenFds/DepexSection.py b/BaseTools/Source/Python/GenFds/DepexSection.py index 1992d2abd807..d67321473268 100644 --- a/BaseTools/Source/Python/GenFds/DepexSection.py +++ b/BaseTools/Source/Python/GenFds/DepexSection.py @@ -15,10 +15,11 @@ ## # Import Modules # -import Section -from GenFdsGlobalVariable import GenFdsGlobalVariable +from __future__ import absolute_import +from . import Section +from .GenFdsGlobalVariable import GenFdsGlobalVariable import subprocess -from Ffs import Ffs +from .Ffs import Ffs import Common.LongFilePathOs as os from CommonDataClass.FdfClass import DepexSectionClassObject from AutoGen.GenDepex import DependencyExpression diff --git a/BaseTools/Source/Python/GenFds/EfiSection.py b/BaseTools/Source/Python/GenFds/EfiSection.py index d24df30cb734..7bce56ed55db 100644 --- a/BaseTools/Source/Python/GenFds/EfiSection.py +++ b/BaseTools/Source/Python/GenFds/EfiSection.py @@ -15,11 +15,12 @@ ## # Import Modules # +from __future__ import absolute_import from struct import * -import Section -from GenFdsGlobalVariable import GenFdsGlobalVariable +from . import Section +from .GenFdsGlobalVariable import GenFdsGlobalVariable import subprocess -from Ffs import Ffs +from .Ffs import Ffs import Common.LongFilePathOs as os from CommonDataClass.FdfClass import EfiSectionClassObject from Common import EdkLogger diff --git a/BaseTools/Source/Python/GenFds/Fd.py b/BaseTools/Source/Python/GenFds/Fd.py index acd73f6449f6..86a0d9a47bfc 100644 --- a/BaseTools/Source/Python/GenFds/Fd.py +++ b/BaseTools/Source/Python/GenFds/Fd.py @@ -15,18 +15,18 @@ ## # Import Modules # -import Region -import Fv +from __future__ import absolute_import +from . import Region +from . import Fv import Common.LongFilePathOs as os from io import BytesIO import sys from struct import * -from GenFdsGlobalVariable import GenFdsGlobalVariable +from .GenFdsGlobalVariable import GenFdsGlobalVariable from CommonDataClass.FdfClass import FDClassObject from Common import EdkLogger from Common.BuildToolError import * from Common.Misc import SaveFileOnChange -from GenFds import GenFds ## generate FD # @@ -46,6 +46,7 @@ class FD(FDClassObject): # @retval string Generated FD file name # def GenFd (self, Flag = False): + from .GenFds import GenFds if self.FdUiName.upper() + 'fd' in GenFds.ImageBinDict.keys(): return GenFds.ImageBinDict[self.FdUiName.upper() + 'fd'] diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py index 43f849b07172..4e07d04c08df 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -17,34 +17,35 @@ # Import Modules # from __future__ import print_function +from __future__ import absolute_import import re -import Fd -import Region -import Fv -import AprioriSection -import FfsInfStatement -import FfsFileStatement -import VerSection -import UiSection -import FvImageSection -import DataSection -import DepexSection -import CompressSection -import GuidSection -import Capsule -import CapsuleData -import Rule -import RuleComplexFile -import RuleSimpleFile -import EfiSection -import Vtf -import ComponentStatement -import OptionRom -import OptRomInfStatement -import OptRomFileStatement +from . import Fd +from . import Region +from . import Fv +from . import AprioriSection +from . import FfsInfStatement +from . import FfsFileStatement +from . import VerSection +from . import UiSection +from . import FvImageSection +from . import DataSection +from . import DepexSection +from . import CompressSection +from . import GuidSection +from . import Capsule +from . import CapsuleData +from . import Rule +from . import RuleComplexFile +from . import RuleSimpleFile +from . import EfiSection +from . import Vtf +from . import ComponentStatement +from . import OptionRom +from . import OptRomInfStatement +from . import OptRomFileStatement -from GenFdsGlobalVariable import GenFdsGlobalVariable +from .GenFdsGlobalVariable import GenFdsGlobalVariable from Common.BuildToolError import * from Common import EdkLogger from Common.Misc import PathClass @@ -58,8 +59,8 @@ from Common.Misc import tdict from Common.MultipleWorkspace import MultipleWorkspace as mws import Common.LongFilePathOs as os from Common.LongFilePathSupport import OpenLongFilePath as open -from Capsule import EFI_CERT_TYPE_PKCS7_GUID -from Capsule import EFI_CERT_TYPE_RSA2048_SHA256_GUID +from .Capsule import EFI_CERT_TYPE_PKCS7_GUID +from .Capsule import EFI_CERT_TYPE_RSA2048_SHA256_GUID ##define T_CHAR_SPACE ' ' ##define T_CHAR_NULL '\0' diff --git a/BaseTools/Source/Python/GenFds/FfsFileStatement.py b/BaseTools/Source/Python/GenFds/FfsFileStatement.py index 1293c8a107f0..1b9b4deef9ae 100644 --- a/BaseTools/Source/Python/GenFds/FfsFileStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsFileStatement.py @@ -15,20 +15,21 @@ ## # Import Modules # +from __future__ import absolute_import from builtins import range -import Ffs -import Rule +from . import Ffs +from . import Rule import Common.LongFilePathOs as os from io import BytesIO import subprocess -from GenFdsGlobalVariable import GenFdsGlobalVariable +from .GenFdsGlobalVariable import GenFdsGlobalVariable from CommonDataClass.FdfClass import FileStatementClassObject from Common import EdkLogger from Common.BuildToolError import * from Common.Misc import GuidStructureByteArrayToGuidString -from GuidSection import GuidSection -from FvImageSection import FvImageSection +from .GuidSection import GuidSection +from .FvImageSection import FvImageSection from Common.Misc import SaveFileOnChange from struct import * diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py index d6edd1f0971e..d1f3604a7fc9 100644 --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py @@ -16,17 +16,18 @@ ## # Import Modules # -import Rule +from __future__ import absolute_import +from . import Rule import Common.LongFilePathOs as os from io import BytesIO from struct import * -from GenFdsGlobalVariable import GenFdsGlobalVariable -import Ffs +from .GenFdsGlobalVariable import GenFdsGlobalVariable +from . import Ffs import subprocess import sys -import Section -import RuleSimpleFile -import RuleComplexFile +from . import Section +from . import RuleSimpleFile +from . import RuleComplexFile from CommonDataClass.FdfClass import FfsInfStatementClassObject from Common.MultipleWorkspace import MultipleWorkspace as mws from Common.String import * @@ -36,15 +37,15 @@ from Common.Misc import ProcessDuplicatedInf from Common.Misc import GetVariableOffset from Common import EdkLogger from Common.BuildToolError import * -from GuidSection import GuidSection -from FvImageSection import FvImageSection +from .GuidSection import GuidSection +from .FvImageSection import FvImageSection from Common.Misc import PeImageClass from AutoGen.GenDepex import DependencyExpression from PatchPcdValue.PatchPcdValue import PatchBinaryFile from Common.LongFilePathSupport import CopyLongFilePath from Common.LongFilePathSupport import OpenLongFilePath as open import Common.GlobalData as GlobalData -from DepexSection import DepexSection +from .DepexSection import DepexSection from Common.Misc import SaveFileOnChange ## generate FFS from INF diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python/GenFds/Fv.py index 88a520998eae..bff661e43e7e 100644 --- a/BaseTools/Source/Python/GenFds/Fv.py +++ b/BaseTools/Source/Python/GenFds/Fv.py @@ -15,17 +15,17 @@ ## # Import Modules # +from __future__ import absolute_import from builtins import range import Common.LongFilePathOs as os import subprocess from io import BytesIO from struct import * -import Ffs -import AprioriSection -import FfsFileStatement -from GenFdsGlobalVariable import GenFdsGlobalVariable -from GenFds import GenFds +from . import Ffs +from . import AprioriSection +from . import FfsFileStatement +from .GenFdsGlobalVariable import GenFdsGlobalVariable from CommonDataClass.FdfClass import FvClassObject from Common.Misc import SaveFileOnChange from Common.LongFilePathSupport import CopyLongFilePath @@ -70,7 +70,7 @@ class FV (FvClassObject): # @retval string Generated FV file path # def AddToBuffer (self, Buffer, BaseAddress=None, BlockSize= None, BlockNum=None, ErasePloarity='1', VtfDict=None, MacroDict = {}, Flag=False) : - + from .GenFds import GenFds if BaseAddress == None and self.UiFvName.upper() + 'fv' in GenFds.ImageBinDict.keys(): return GenFds.ImageBinDict[self.UiFvName.upper() + 'fv'] diff --git a/BaseTools/Source/Python/GenFds/FvImageSection.py b/BaseTools/Source/Python/GenFds/FvImageSection.py index 7416ce1b7d8a..2352e8962e94 100644 --- a/BaseTools/Source/Python/GenFds/FvImageSection.py +++ b/BaseTools/Source/Python/GenFds/FvImageSection.py @@ -15,11 +15,12 @@ ## # Import Modules # -import Section +from __future__ import absolute_import +from . import Section from io import BytesIO -from Ffs import Ffs +from .Ffs import Ffs import subprocess -from GenFdsGlobalVariable import GenFdsGlobalVariable +from .GenFdsGlobalVariable import GenFdsGlobalVariable import Common.LongFilePathOs as os from CommonDataClass.FdfClass import FvImageSectionClassObject from Common import EdkLogger diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py index ebebcd7980e4..7c1df37778fb 100644 --- a/BaseTools/Source/Python/GenFds/GenFds.py +++ b/BaseTools/Source/Python/GenFds/GenFds.py @@ -16,19 +16,20 @@ # Import Modules # from __future__ import print_function +from __future__ import absolute_import from builtins import range from optparse import OptionParser import sys import Common.LongFilePathOs as os import linecache -import FdfParser +from . import FdfParser import Common.BuildToolError as BuildToolError -from GenFdsGlobalVariable import GenFdsGlobalVariable +from .GenFdsGlobalVariable import GenFdsGlobalVariable from Workspace.WorkspaceDatabase import WorkspaceDatabase from Workspace.BuildClassObject import PcdClassObject from Workspace.BuildClassObject import ModuleBuildClassObject -import RuleComplexFile -from EfiSection import EfiSection +from . import RuleComplexFile +from .EfiSection import EfiSection from io import BytesIO import Common.TargetTxtClassObject as TargetTxtClassObject import Common.ToolDefClassObject as ToolDefClassObject @@ -44,7 +45,7 @@ from Common.Misc import CheckPcdDatum from Common.Misc import BuildOptionPcdValueFormat from Common.BuildVersion import gBUILD_VERSION from Common.MultipleWorkspace import MultipleWorkspace as mws -import FfsFileStatement +from . import FfsFileStatement import glob from struct import unpack diff --git a/BaseTools/Source/Python/GenFds/GuidSection.py b/BaseTools/Source/Python/GenFds/GuidSection.py index ea737bb9a7ea..877dabc196e1 100644 --- a/BaseTools/Source/Python/GenFds/GuidSection.py +++ b/BaseTools/Source/Python/GenFds/GuidSection.py @@ -15,19 +15,19 @@ ## # Import Modules # -import Section +from __future__ import absolute_import +from . import Section import subprocess -from Ffs import Ffs +from .Ffs import Ffs import Common.LongFilePathOs as os -from GenFdsGlobalVariable import GenFdsGlobalVariable +from .GenFdsGlobalVariable import GenFdsGlobalVariable from CommonDataClass.FdfClass import GuidSectionClassObject from Common import ToolDefClassObject import sys from Common import EdkLogger from Common.BuildToolError import * -from FvImageSection import FvImageSection +from .FvImageSection import FvImageSection from Common.LongFilePathSupport import OpenLongFilePath as open -from GenFds import FindExtendTool ## generate GUIDed section # @@ -129,6 +129,7 @@ class GuidSection(GuidSectionClassObject) : ExternalTool = None ExternalOption = None if self.NameGuid != None: + from .GenFds import FindExtendTool ExternalTool, ExternalOption = FindExtendTool(self.KeyStringList, self.CurrentArchList, self.NameGuid) # diff --git a/BaseTools/Source/Python/GenFds/OptRomFileStatement.py b/BaseTools/Source/Python/GenFds/OptRomFileStatement.py index ab4fae611e33..f33d6606ca96 100644 --- a/BaseTools/Source/Python/GenFds/OptRomFileStatement.py +++ b/BaseTools/Source/Python/GenFds/OptRomFileStatement.py @@ -15,9 +15,10 @@ ## # Import Modules # +from __future__ import absolute_import import Common.LongFilePathOs as os -from GenFdsGlobalVariable import GenFdsGlobalVariable +from .GenFdsGlobalVariable import GenFdsGlobalVariable ## # # diff --git a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py b/BaseTools/Source/Python/GenFds/OptRomInfStatement.py index 80c4bbab6eff..5de0cac2a374 100644 --- a/BaseTools/Source/Python/GenFds/OptRomInfStatement.py +++ b/BaseTools/Source/Python/GenFds/OptRomInfStatement.py @@ -15,16 +15,16 @@ ## # Import Modules # -import RuleSimpleFile -import RuleComplexFile -import Section -import OptionRom +from __future__ import absolute_import +from . import RuleSimpleFile +from . import RuleComplexFile +from . import Section import Common.GlobalData as GlobalData from Common.DataType import * from Common.String import * -from FfsInfStatement import FfsInfStatement -from GenFdsGlobalVariable import GenFdsGlobalVariable +from .FfsInfStatement import FfsInfStatement +from .GenFdsGlobalVariable import GenFdsGlobalVariable ## # @@ -45,7 +45,7 @@ class OptRomInfStatement (FfsInfStatement): # @param self The object pointer # def __GetOptRomParams(self): - + from . import OptionRom if self.OverrideAttribs == None: self.OverrideAttribs = OptionRom.OverrideAttribs() @@ -151,5 +151,3 @@ class OptRomInfStatement (FfsInfStatement): OutputFileList.extend(FileList) return OutputFileList - - \ No newline at end of file diff --git a/BaseTools/Source/Python/GenFds/OptionRom.py b/BaseTools/Source/Python/GenFds/OptionRom.py index 946cdf812a24..a7a63e80845c 100644 --- a/BaseTools/Source/Python/GenFds/OptionRom.py +++ b/BaseTools/Source/Python/GenFds/OptionRom.py @@ -15,12 +15,12 @@ ## # Import Modules # +from __future__ import absolute_import import Common.LongFilePathOs as os import subprocess -import OptRomInfStatement -from GenFdsGlobalVariable import GenFdsGlobalVariable -from GenFds import GenFds +from . import OptRomInfStatement +from .GenFdsGlobalVariable import GenFdsGlobalVariable from CommonDataClass.FdfClass import OptionRomClassObject from Common.Misc import SaveFileOnChange from Common import EdkLogger diff --git a/BaseTools/Source/Python/GenFds/Region.py b/BaseTools/Source/Python/GenFds/Region.py index 6ace73abe904..0debd579bec5 100644 --- a/BaseTools/Source/Python/GenFds/Region.py +++ b/BaseTools/Source/Python/GenFds/Region.py @@ -15,9 +15,10 @@ ## # Import Modules # +from __future__ import absolute_import from builtins import range from struct import * -from GenFdsGlobalVariable import GenFdsGlobalVariable +from .GenFdsGlobalVariable import GenFdsGlobalVariable from io import BytesIO import string from CommonDataClass.FdfClass import RegionClassObject diff --git a/BaseTools/Source/Python/GenFds/RuleComplexFile.py b/BaseTools/Source/Python/GenFds/RuleComplexFile.py index 36c483fbb207..c357fedbd3be 100644 --- a/BaseTools/Source/Python/GenFds/RuleComplexFile.py +++ b/BaseTools/Source/Python/GenFds/RuleComplexFile.py @@ -15,7 +15,8 @@ ## # Import Modules # -import Rule +from __future__ import absolute_import +from . import Rule from CommonDataClass.FdfClass import RuleComplexFileClassObject ## complex rule diff --git a/BaseTools/Source/Python/GenFds/RuleSimpleFile.py b/BaseTools/Source/Python/GenFds/RuleSimpleFile.py index 061f984e6af4..7aa184e7d8bb 100644 --- a/BaseTools/Source/Python/GenFds/RuleSimpleFile.py +++ b/BaseTools/Source/Python/GenFds/RuleSimpleFile.py @@ -15,7 +15,8 @@ ## # Import Modules # -import Rule +from __future__ import absolute_import +from . import Rule from CommonDataClass.FdfClass import RuleSimpleFileClassObject ## simple rule diff --git a/BaseTools/Source/Python/GenFds/Section.py b/BaseTools/Source/Python/GenFds/Section.py index 463faa378165..4650afe27114 100644 --- a/BaseTools/Source/Python/GenFds/Section.py +++ b/BaseTools/Source/Python/GenFds/Section.py @@ -15,8 +15,9 @@ ## # Import Modules # +from __future__ import absolute_import from CommonDataClass.FdfClass import SectionClassObject -from GenFdsGlobalVariable import GenFdsGlobalVariable +from .GenFdsGlobalVariable import GenFdsGlobalVariable import Common.LongFilePathOs as os, glob from Common import EdkLogger from Common.BuildToolError import * diff --git a/BaseTools/Source/Python/GenFds/UiSection.py b/BaseTools/Source/Python/GenFds/UiSection.py index 4f6926f7cae4..a92bebc65cf8 100644 --- a/BaseTools/Source/Python/GenFds/UiSection.py +++ b/BaseTools/Source/Python/GenFds/UiSection.py @@ -15,11 +15,12 @@ ## # Import Modules # -import Section -from Ffs import Ffs +from __future__ import absolute_import +from . import Section +from .Ffs import Ffs import subprocess import Common.LongFilePathOs as os -from GenFdsGlobalVariable import GenFdsGlobalVariable +from .GenFdsGlobalVariable import GenFdsGlobalVariable from CommonDataClass.FdfClass import UiSectionClassObject from Common.LongFilePathSupport import OpenLongFilePath as open diff --git a/BaseTools/Source/Python/GenFds/VerSection.py b/BaseTools/Source/Python/GenFds/VerSection.py index e29029980fad..c8186fe7477e 100644 --- a/BaseTools/Source/Python/GenFds/VerSection.py +++ b/BaseTools/Source/Python/GenFds/VerSection.py @@ -15,11 +15,12 @@ ## # Import Modules # -from Ffs import Ffs -import Section +from __future__ import absolute_import +from .Ffs import Ffs +from . import Section import Common.LongFilePathOs as os import subprocess -from GenFdsGlobalVariable import GenFdsGlobalVariable +from .GenFdsGlobalVariable import GenFdsGlobalVariable from CommonDataClass.FdfClass import VerSectionClassObject from Common.LongFilePathSupport import OpenLongFilePath as open diff --git a/BaseTools/Source/Python/GenFds/Vtf.py b/BaseTools/Source/Python/GenFds/Vtf.py index 06e3d275c381..a0898b2f639b 100644 --- a/BaseTools/Source/Python/GenFds/Vtf.py +++ b/BaseTools/Source/Python/GenFds/Vtf.py @@ -15,7 +15,8 @@ ## # Import Modules # -from GenFdsGlobalVariable import GenFdsGlobalVariable +from __future__ import absolute_import +from .GenFdsGlobalVariable import GenFdsGlobalVariable import Common.LongFilePathOs as os from CommonDataClass.FdfClass import VtfClassObject from Common.LongFilePathSupport import OpenLongFilePath as open diff --git a/BaseTools/Source/Python/Table/TableDataModel.py b/BaseTools/Source/Python/Table/TableDataModel.py index 9c3d7bd9345f..74df04a8200a 100644 --- a/BaseTools/Source/Python/Table/TableDataModel.py +++ b/BaseTools/Source/Python/Table/TableDataModel.py @@ -14,9 +14,10 @@ ## # Import Modules # +from __future__ import absolute_import import Common.EdkLogger as EdkLogger import CommonDataClass.DataClass as DataClass -from Table import Table +from .Table import Table from Common.String import ConvertToSqlString ## TableDataModel diff --git a/BaseTools/Source/Python/Table/TableDec.py b/BaseTools/Source/Python/Table/TableDec.py index 6b7d22c9384c..b33230f437b6 100644 --- a/BaseTools/Source/Python/Table/TableDec.py +++ b/BaseTools/Source/Python/Table/TableDec.py @@ -14,9 +14,10 @@ ## # Import Modules # +from __future__ import absolute_import import Common.EdkLogger as EdkLogger import CommonDataClass.DataClass as DataClass -from Table import Table +from .Table import Table from Common.String import ConvertToSqlString ## TableDec diff --git a/BaseTools/Source/Python/Table/TableDsc.py b/BaseTools/Source/Python/Table/TableDsc.py index 69477d544d8e..c8d6e4b3dc15 100644 --- a/BaseTools/Source/Python/Table/TableDsc.py +++ b/BaseTools/Source/Python/Table/TableDsc.py @@ -14,9 +14,10 @@ ## # Import Modules # +from __future__ import absolute_import import Common.EdkLogger as EdkLogger import CommonDataClass.DataClass as DataClass -from Table import Table +from .Table import Table from Common.String import ConvertToSqlString ## TableDsc diff --git a/BaseTools/Source/Python/Table/TableEotReport.py b/BaseTools/Source/Python/Table/TableEotReport.py index 740105c8f99d..a32779524fff 100644 --- a/BaseTools/Source/Python/Table/TableEotReport.py +++ b/BaseTools/Source/Python/Table/TableEotReport.py @@ -14,9 +14,10 @@ ## # Import Modules # +from __future__ import absolute_import import Common.EdkLogger as EdkLogger import Common.LongFilePathOs as os, time -from Table import Table +from .Table import Table from Common.String import ConvertToSqlString2 import Eot.EotToolError as EotToolError import Eot.EotGlobalData as EotGlobalData @@ -73,4 +74,4 @@ class TableEotReport(Table): SqlCommand = """select max(ID) from %s""" % self.Table self.Cur.execute(SqlCommand) for Item in self.Cur: - return Item[0] \ No newline at end of file + return Item[0] diff --git a/BaseTools/Source/Python/Table/TableFdf.py b/BaseTools/Source/Python/Table/TableFdf.py index 927b5d1a3be6..b15c5c21201c 100644 --- a/BaseTools/Source/Python/Table/TableFdf.py +++ b/BaseTools/Source/Python/Table/TableFdf.py @@ -14,9 +14,10 @@ ## # Import Modules # +from __future__ import absolute_import import Common.EdkLogger as EdkLogger import CommonDataClass.DataClass as DataClass -from Table import Table +from .Table import Table from Common.String import ConvertToSqlString ## TableFdf diff --git a/BaseTools/Source/Python/Table/TableFile.py b/BaseTools/Source/Python/Table/TableFile.py index caf749e9d3c5..57e1fc0bcece 100644 --- a/BaseTools/Source/Python/Table/TableFile.py +++ b/BaseTools/Source/Python/Table/TableFile.py @@ -14,8 +14,9 @@ ## # Import Modules # +from __future__ import absolute_import import Common.EdkLogger as EdkLogger -from Table import Table +from .Table import Table from Common.String import ConvertToSqlString import Common.LongFilePathOs as os from CommonDataClass.DataClass import FileClass diff --git a/BaseTools/Source/Python/Table/TableFunction.py b/BaseTools/Source/Python/Table/TableFunction.py index 3d7c2d0ea5a0..97f360cec59e 100644 --- a/BaseTools/Source/Python/Table/TableFunction.py +++ b/BaseTools/Source/Python/Table/TableFunction.py @@ -14,8 +14,9 @@ ## # Import Modules # +from __future__ import absolute_import import Common.EdkLogger as EdkLogger -from Table import Table +from .Table import Table from Common.String import ConvertToSqlString ## TableFunction diff --git a/BaseTools/Source/Python/Table/TableIdentifier.py b/BaseTools/Source/Python/Table/TableIdentifier.py index bcd6d6e1c152..b7b4d9018c0e 100644 --- a/BaseTools/Source/Python/Table/TableIdentifier.py +++ b/BaseTools/Source/Python/Table/TableIdentifier.py @@ -14,9 +14,10 @@ ## # Import Modules # +from __future__ import absolute_import import Common.EdkLogger as EdkLogger from Common.String import ConvertToSqlString -from Table import Table +from .Table import Table ## TableIdentifier # @@ -87,4 +88,4 @@ class TableIdentifier(Table): % (self.Table, self.ID, Modifier, Type, Name, Value, Model, BelongsToFile, BelongsToFunction, StartLine, StartColumn, EndLine, EndColumn) Table.Insert(self, SqlCommand) - return self.ID \ No newline at end of file + return self.ID diff --git a/BaseTools/Source/Python/Table/TableInf.py b/BaseTools/Source/Python/Table/TableInf.py index b6e300b150c1..424c2663ca0f 100644 --- a/BaseTools/Source/Python/Table/TableInf.py +++ b/BaseTools/Source/Python/Table/TableInf.py @@ -14,9 +14,10 @@ ## # Import Modules # +from __future__ import absolute_import import Common.EdkLogger as EdkLogger import CommonDataClass.DataClass as DataClass -from Table import Table +from .Table import Table from Common.String import ConvertToSqlString ## TableInf diff --git a/BaseTools/Source/Python/Table/TablePcd.py b/BaseTools/Source/Python/Table/TablePcd.py index 19623f98f42c..01011062cee4 100644 --- a/BaseTools/Source/Python/Table/TablePcd.py +++ b/BaseTools/Source/Python/Table/TablePcd.py @@ -14,8 +14,9 @@ ## # Import Modules # +from __future__ import absolute_import import Common.EdkLogger as EdkLogger -from Table import Table +from .Table import Table from Common.String import ConvertToSqlString ## TablePcd @@ -87,4 +88,4 @@ class TablePcd(Table): % (self.Table, self.ID, CName, TokenSpaceGuidCName, Token, DatumType, Model, BelongsToFile, BelongsToFunction, StartLine, StartColumn, EndLine, EndColumn) Table.Insert(self, SqlCommand) - return self.ID \ No newline at end of file + return self.ID diff --git a/BaseTools/Source/Python/Table/TableQuery.py b/BaseTools/Source/Python/Table/TableQuery.py index e1d2537394b2..205602d05d6c 100644 --- a/BaseTools/Source/Python/Table/TableQuery.py +++ b/BaseTools/Source/Python/Table/TableQuery.py @@ -14,9 +14,10 @@ ## # Import Modules # +from __future__ import absolute_import import Common.EdkLogger as EdkLogger from Common.String import ConvertToSqlString -from Table import Table +from .Table import Table ## TableQuery # diff --git a/BaseTools/Source/Python/Table/TableReport.py b/BaseTools/Source/Python/Table/TableReport.py index 4af0e98d86b4..40afa15c08c5 100644 --- a/BaseTools/Source/Python/Table/TableReport.py +++ b/BaseTools/Source/Python/Table/TableReport.py @@ -14,9 +14,10 @@ ## # Import Modules # +from __future__ import absolute_import import Common.EdkLogger as EdkLogger import Common.LongFilePathOs as os, time -from Table import Table +from .Table import Table from Common.String import ConvertToSqlString2 import EccToolError as EccToolError import EccGlobalData as EccGlobalData diff --git a/BaseTools/Source/Python/UPT/Library/Parsing.py b/BaseTools/Source/Python/UPT/Library/Parsing.py index bac664506f4d..dbbfff9e9462 100644 --- a/BaseTools/Source/Python/UPT/Library/Parsing.py +++ b/BaseTools/Source/Python/UPT/Library/Parsing.py @@ -16,6 +16,7 @@ ''' Parsing ''' +from __future__ import absolute_import ## # Import Modules @@ -43,7 +44,7 @@ from Logger import StringTable as ST import Logger.Log as Logger from Parser.DecParser import Dec -import GlobalData +from . import GlobalData gPKG_INFO_DICT = {} diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py b/BaseTools/Source/Python/Workspace/DscBuildData.py index 8551a0d8b7e7..4b1c8a257db6 100644 --- a/BaseTools/Source/Python/Workspace/DscBuildData.py +++ b/BaseTools/Source/Python/Workspace/DscBuildData.py @@ -18,6 +18,7 @@ # into PlatformBuildClassObject form for easier use for AutoGen. # from __future__ import print_function +from __future__ import absolute_import from builtins import range from Common.String import * from Common.DataType import * @@ -27,11 +28,11 @@ from types import * from CommonDataClass.CommonClass import SkuInfoClass from Common.TargetTxtClassObject import * from Common.ToolDefClassObject import * -from MetaDataTable import * -from MetaFileTable import * -from MetaFileParser import * +from .MetaDataTable import * +from .MetaFileTable import * +from .MetaFileParser import * -from WorkspaceCommon import GetDeclaredPcd +from .WorkspaceCommon import GetDeclaredPcd from Common.Misc import AnalyzeDscPcd from Common.Misc import ProcessDuplicatedInf import re diff --git a/BaseTools/Source/Python/Workspace/InfBuildData.py b/BaseTools/Source/Python/Workspace/InfBuildData.py index 9fc2e681b73d..85b5fefe26dd 100644 --- a/BaseTools/Source/Python/Workspace/InfBuildData.py +++ b/BaseTools/Source/Python/Workspace/InfBuildData.py @@ -12,12 +12,13 @@ # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. # +from __future__ import absolute_import from builtins import range from Common.String import * from Common.DataType import * from Common.Misc import * from types import * -from MetaFileParser import * +from .MetaFileParser import * from Workspace.BuildClassObject import ModuleBuildClassObject, LibraryClassObject, PcdClassObject ## Module build information from INF file diff --git a/BaseTools/Source/Python/Workspace/MetaFileParser.py b/BaseTools/Source/Python/Workspace/MetaFileParser.py index b96d027cb19e..f871ab717c4b 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileParser.py +++ b/BaseTools/Source/Python/Workspace/MetaFileParser.py @@ -16,6 +16,7 @@ # Import Modules # from __future__ import print_function +from __future__ import absolute_import from builtins import range import Common.LongFilePathOs as os import re @@ -34,8 +35,8 @@ from Common.Expression import * from CommonDataClass.Exceptions import * from Common.LongFilePathSupport import OpenLongFilePath as open -from MetaFileTable import MetaFileStorage -from MetaFileCommentParser import CheckInfComment +from .MetaFileTable import MetaFileStorage +from .MetaFileCommentParser import CheckInfComment ## A decorator used to parse macro definition def ParseMacro(Parser): diff --git a/BaseTools/Source/Python/Workspace/MetaFileTable.py b/BaseTools/Source/Python/Workspace/MetaFileTable.py index 9416065b284f..6cf4c023e246 100644 --- a/BaseTools/Source/Python/Workspace/MetaFileTable.py +++ b/BaseTools/Source/Python/Workspace/MetaFileTable.py @@ -14,13 +14,14 @@ ## # Import Modules # +from __future__ import absolute_import import uuid import Common.EdkLogger as EdkLogger from Common.BuildToolError import FORMAT_INVALID -from MetaDataTable import Table, TableFile -from MetaDataTable import ConvertToSqlString +from .MetaDataTable import Table, TableFile +from .MetaDataTable import ConvertToSqlString from CommonDataClass.DataClass import MODEL_FILE_DSC, MODEL_FILE_DEC, MODEL_FILE_INF, \ MODEL_FILE_OTHERS from Common.DataType import * diff --git a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py index 6b5e0edb0a4d..fd7a3617668c 100644 --- a/BaseTools/Source/Python/Workspace/WorkspaceCommon.py +++ b/BaseTools/Source/Python/Workspace/WorkspaceCommon.py @@ -11,9 +11,10 @@ # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. # +from __future__ import absolute_import from Common.Misc import sdict from Common.DataType import SUP_MODULE_USER_DEFINED -from BuildClassObject import LibraryClassObject +from .BuildClassObject import LibraryClassObject import Common.GlobalData as GlobalData from Workspace.BuildClassObject import StructurePcd diff --git a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py index a3407d113e0f..052d8739bccb 100644 --- a/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py +++ b/BaseTools/Source/Python/Workspace/WorkspaceDatabase.py @@ -15,15 +15,16 @@ ## # Import Modules # +from __future__ import absolute_import import sqlite3 from Common.String import * from Common.DataType import * from Common.Misc import * from types import * -from MetaDataTable import * -from MetaFileTable import * -from MetaFileParser import * +from .MetaDataTable import * +from .MetaFileTable import * +from .MetaFileParser import * from Workspace.DecBuildData import DecBuildData from Workspace.DscBuildData import DscBuildData diff --git a/BaseTools/Source/Python/build/build.py b/BaseTools/Source/Python/build/build.py index 66b46fab5c26..22feae2964cf 100644 --- a/BaseTools/Source/Python/build/build.py +++ b/BaseTools/Source/Python/build/build.py @@ -17,6 +17,7 @@ # Import Modules # from __future__ import print_function +from __future__ import absolute_import import Common.LongFilePathOs as os import re from io import BytesIO @@ -46,7 +47,7 @@ from Common.BuildToolError import * from Workspace.WorkspaceDatabase import * from Common.MultipleWorkspace import MultipleWorkspace as mws -from BuildReport import BuildReport +from .BuildReport import BuildReport from GenPatchPcdTable.GenPatchPcdTable import * from PatchPcdValue.PatchPcdValue import * -- 2.16.1