public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Gary Lin <glin@suse.com>
To: edk2-devel@lists.01.org
Cc: Yonghong Zhu <yonghong.zhu@intel.com>, Liming Gao <liming.gao@intel.com>
Subject: [PATCH v2 09/16] BaseTools: Use absolute import in Common
Date: Fri, 13 Jul 2018 18:18:40 +0800	[thread overview]
Message-ID: <20180713101847.7485-10-glin@suse.com> (raw)
In-Reply-To: <20180713101847.7485-1-glin@suse.com>

Based on "futurize -f libfuturize.fixes.fix_absolute_import

Contributed-under: TianoCore Contribution Agreement 1.1
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Signed-off-by: Gary Lin <glin@suse.com>
---
 BaseTools/Source/Python/Common/Database.py             | 8 ++++----
 BaseTools/Source/Python/Common/EdkLogger.py            | 3 ++-
 BaseTools/Source/Python/Common/Expression.py           | 3 ++-
 BaseTools/Source/Python/Common/LongFilePathOs.py       | 3 ++-
 BaseTools/Source/Python/Common/Misc.py                 | 9 +++++----
 BaseTools/Source/Python/Common/Parsing.py              | 5 +++--
 BaseTools/Source/Python/Common/StringUtils.py          | 9 +++++----
 BaseTools/Source/Python/Common/TargetTxtClassObject.py | 9 +++++----
 BaseTools/Source/Python/Common/ToolDefClassObject.py   | 9 +++++----
 9 files changed, 33 insertions(+), 25 deletions(-)

diff --git a/BaseTools/Source/Python/Common/Database.py b/BaseTools/Source/Python/Common/Database.py
index 6abfa1f15e35..1c543aeb41b1 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 StringUtils import *
-from DataType import *
+from .StringUtils 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()
-
diff --git a/BaseTools/Source/Python/Common/EdkLogger.py b/BaseTools/Source/Python/Common/EdkLogger.py
index 3f462df49ada..19749066ecee 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 51e8d2174a8f..ccc736846afa 100644
--- a/BaseTools/Source/Python/Common/Expression.py
+++ b/BaseTools/Source/Python/Common/Expression.py
@@ -13,10 +13,11 @@
 ## Import Modules
 #
 from __future__ import print_function
+from __future__ import absolute_import
 from Common.GlobalData import *
 from CommonDataClass.Exceptions import BadExpression
 from CommonDataClass.Exceptions import WrnExpression
-from Misc import GuidStringToGuidStructureString, ParseFieldValue, IsFieldValueAnArray
+from .Misc import GuidStringToGuidStructureString, ParseFieldValue, IsFieldValueAnArray
 import Common.EdkLogger as EdkLogger
 import copy
 from Common.DataType import *
diff --git a/BaseTools/Source/Python/Common/LongFilePathOs.py b/BaseTools/Source/Python/Common/LongFilePathOs.py
index 4939a8bc733c..53528546b782 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
 import time
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
index b56ddd532471..79d1ff28f50b 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
 import Common.LongFilePathOs as os
 import sys
 import string
@@ -30,10 +31,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
@@ -474,7 +475,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 527852a50c09..889251b69935 100644
--- a/BaseTools/Source/Python/Common/Parsing.py
+++ b/BaseTools/Source/Python/Common/Parsing.py
@@ -14,9 +14,10 @@
 ##
 # Import Modules
 #
-from StringUtils import *
+from __future__ import absolute_import
+from .StringUtils import *
 from CommonDataClass.DataClass import *
-from DataType import *
+from .DataType import *
 
 ## ParseDefineMacro
 #
diff --git a/BaseTools/Source/Python/Common/StringUtils.py b/BaseTools/Source/Python/Common/StringUtils.py
index 723faac0f9f3..da2949dbadef 100644
--- a/BaseTools/Source/Python/Common/StringUtils.py
+++ b/BaseTools/Source/Python/Common/StringUtils.py
@@ -14,14 +14,15 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 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 8ba8dd31a8c5..55a2f564821e 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 7cc7e22839e1..05a1ddfbcc89 100644
--- a/BaseTools/Source/Python/Common/ToolDefClassObject.py
+++ b/BaseTools/Source/Python/Common/ToolDefClassObject.py
@@ -14,19 +14,20 @@
 ##
 # Import Modules
 #
+from __future__ import absolute_import
 import Common.LongFilePathOs as os
 import re
-import EdkLogger
+from . import EdkLogger
 
-from BuildToolError import *
-from TargetTxtClassObject import *
+from .BuildToolError import *
+from .TargetTxtClassObject import *
 from Common.LongFilePathSupport import OpenLongFilePath as open
 from Common.Misc import PathClass
 from Common.StringUtils import NormPath
 import Common.GlobalData as GlobalData
 from Common import GlobalData
 from Common.MultipleWorkspace import MultipleWorkspace as mws
-from DataType import TAB_TOD_DEFINES_TARGET, TAB_TOD_DEFINES_TOOL_CHAIN_TAG,\
+from .DataType import TAB_TOD_DEFINES_TARGET, TAB_TOD_DEFINES_TOOL_CHAIN_TAG,\
                      TAB_TOD_DEFINES_TARGET_ARCH, TAB_TOD_DEFINES_COMMAND_TYPE\
                      , TAB_TOD_DEFINES_FAMILY, TAB_TOD_DEFINES_BUILDRULEFAMILY
 
-- 
2.18.0



  parent reply	other threads:[~2018-07-13 10:19 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-13 10:18 [PATCH v2 00/16] BaseTools: Adopt absolute import Gary Lin
2018-07-13 10:18 ` [PATCH v2 01/16] BaseTools: Treat GenFds.py as a python module Gary Lin
2018-07-13 10:18 ` [PATCH v2 02/16] BaseTools: Use absolute import in GenFds Gary Lin
2018-07-13 10:18 ` [PATCH v2 03/16] BaseTools: Move OverrideAttribs to OptRomInfStatement.py Gary Lin
2018-07-13 10:18 ` [PATCH v2 04/16] BaseTools: Move FindExtendTool to GenFdsGlobalVariable.py Gary Lin
2018-07-13 10:18 ` [PATCH v2 05/16] BaseTools: Move ImageBinDict " Gary Lin
2018-07-13 10:18 ` [PATCH v2 06/16] BaseTools: Use absolute import in AutoGen Gary Lin
2018-07-13 10:18 ` [PATCH v2 07/16] BaseTools: Treat BPDG.py as a python module Gary Lin
2018-07-13 10:18 ` [PATCH v2 08/16] BaseTools: Use absolute import in BPDG Gary Lin
2018-07-13 10:18 ` Gary Lin [this message]
2018-07-13 10:18 ` [PATCH v2 10/16] BaseTools: Treat Ecc.py as a python module Gary Lin
2018-07-13 10:18 ` [PATCH v2 11/16] BaseTools: Use absolute import in Ecc Gary Lin
2018-07-13 10:18 ` [PATCH v2 12/16] BaseTools: Use absolute import in Eot Gary Lin
2018-07-13 10:18 ` [PATCH v2 13/16] BaseTools: Use absolute import in Table Gary Lin
2018-07-13 10:18 ` [PATCH v2 14/16] BaseTools: Use absolute import in UPT Gary Lin
2018-07-13 10:18 ` [PATCH v2 15/16] BaseTools: Use absolute import in Workspace Gary Lin
2018-07-13 10:18 ` [PATCH v2 16/16] BaseTools: Use absolute import in Scripts Gary Lin
2018-07-13 15:07 ` [PATCH v2 00/16] BaseTools: Adopt absolute import Carsey, Jaben

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180713101847.7485-10-glin@suse.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox