]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Refactor python print statements
authorGary Lin <glin@suse.com>
Mon, 25 Jun 2018 10:31:26 +0000 (18:31 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Wed, 27 Jun 2018 08:33:21 +0000 (16:33 +0800)
Refactor print statements to be compatible with python 3.
Based on "futurize -f libfuturize.fixes.fix_print_with_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>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
46 files changed:
BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py
BaseTools/Scripts/BinToPcd.py
BaseTools/Scripts/FormatDosFiles.py
BaseTools/Scripts/MemoryProfileSymbolGen.py
BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py
BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/doxygen.py
BaseTools/Scripts/PackageDocumentTools/plugins/EdkPlugins/basemodel/efibinary.py
BaseTools/Scripts/SmiHandlerProfileSymbolGen.py
BaseTools/Source/Python/AutoGen/AutoGen.py
BaseTools/Source/Python/AutoGen/BuildEngine.py
BaseTools/Source/Python/AutoGen/UniClassObject.py
BaseTools/Source/Python/BPDG/BPDG.py
BaseTools/Source/Python/Common/Expression.py
BaseTools/Source/Python/Common/RangeExpression.py
BaseTools/Source/Python/Common/TargetTxtClassObject.py
BaseTools/Source/Python/Common/VpdInfoFile.py
BaseTools/Source/Python/Ecc/CParser.py
BaseTools/Source/Python/Ecc/CodeFragmentCollector.py
BaseTools/Source/Python/Ecc/Configuration.py
BaseTools/Source/Python/Ecc/Exception.py
BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaDataTable.py
BaseTools/Source/Python/Ecc/Xml/XmlRoutines.py
BaseTools/Source/Python/Ecc/c.py
BaseTools/Source/Python/Eot/CParser.py
BaseTools/Source/Python/Eot/CodeFragmentCollector.py
BaseTools/Source/Python/Eot/InfParserLite.py
BaseTools/Source/Python/Eot/c.py
BaseTools/Source/Python/GenFds/FdfParser.py
BaseTools/Source/Python/GenFds/GenFds.py
BaseTools/Source/Python/GenFds/GenFdsGlobalVariable.py
BaseTools/Source/Python/GenPatchPcdTable/GenPatchPcdTable.py
BaseTools/Source/Python/Pkcs7Sign/Pkcs7Sign.py
BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256GenerateKeys.py
BaseTools/Source/Python/Rsa2048Sha256Sign/Rsa2048Sha256Sign.py
BaseTools/Source/Python/TargetTool/TargetTool.py
BaseTools/Source/Python/UPT/Library/ExpressionValidate.py
BaseTools/Source/Python/UPT/Library/UniClassObject.py
BaseTools/Source/Python/UPT/PomAdapter/DecPomAlignment.py
BaseTools/Source/Python/UPT/UnitTest/DecParserTest.py
BaseTools/Source/Python/UPT/UnitTest/InfBinarySectionTest.py
BaseTools/Source/Python/Workspace/DscBuildData.py
BaseTools/Source/Python/Workspace/MetaFileParser.py
BaseTools/Source/Python/build/build.py
BaseTools/Tests/TestTools.py
BaseTools/Tests/TianoCompress.py
BaseTools/gcc/mingw-gcc-build.py

index 69fd2d54413e975352b54f026fe8c7f102051d3d..534ffd04c5c28fb2972777ceeae79f220d1ad68f 100755 (executable)
@@ -23,6 +23,7 @@
 #
 # ExceptionList if a tool takes an argument with a / add it to the exception list
 #
+from __future__ import print_function\r
 import sys
 import os
 import subprocess
@@ -86,7 +87,7 @@ if __name__ == "__main__":
      ret = main(sys.argv[2:])
 
   except:
-    print "exiting: exception from " + sys.argv[0]
+    print("exiting: exception from " + sys.argv[0])\r
     ret = 2
 
   sys.exit(ret)
index b907d3e5e0008e707955bca75aea28d02da2c357..10b5043325cc23d8872b99e2d8397d409019fd89 100644 (file)
@@ -14,6 +14,7 @@
 '''\r
 BinToPcd\r
 '''\r
+from __future__ import print_function\r
 \r
 import sys\r
 import argparse\r
index 2f2d4d532c76ea4a4c2a2aa181cfa7b36af99a56..3b16af5a4413ca7a6b9e5e9994bdec53c1bce921 100644 (file)
@@ -16,6 +16,7 @@
 #\r
 # Import Modules\r
 #\r
+from __future__ import print_function\r
 import argparse\r
 import os\r
 import os.path\r
index 5709ad4641cb9cb65d8e80cb850bc0fb031dd46e..0a41f9d832713afac94df20905a244702f8fd777 100644 (file)
@@ -14,6 +14,7 @@
 #\r
 ##\r
 \r
+from __future__ import print_function\r
 import os\r
 import re\r
 import sys\r
@@ -58,10 +59,10 @@ class Symbols:
         try:\r
             nmCommand = "nm"\r
             nmLineOption = "-l"\r
-            print "parsing (debug) - " + pdbName\r
+            print("parsing (debug) - " + pdbName)\r
             os.system ('%s %s %s > nmDump.line.log' % (nmCommand, nmLineOption, pdbName))\r
         except :\r
-            print 'ERROR: nm command not available.  Please verify PATH'\r
+            print('ERROR: nm command not available.  Please verify PATH')\r
             return\r
 \r
         #\r
@@ -111,11 +112,11 @@ class Symbols:
             DIA2DumpCommand = "Dia2Dump.exe"\r
             #DIA2SymbolOption = "-p"\r
             DIA2LinesOption = "-l"\r
-            print "parsing (pdb) - " + pdbName\r
+            print("parsing (pdb) - " + pdbName)\r
             #os.system ('%s %s %s > DIA2Dump.symbol.log' % (DIA2DumpCommand, DIA2SymbolOption, pdbName))\r
             os.system ('%s %s %s > DIA2Dump.line.log' % (DIA2DumpCommand, DIA2LinesOption, pdbName))\r
         except :\r
-            print 'ERROR: DIA2Dump command not available.  Please verify PATH'\r
+            print('ERROR: DIA2Dump command not available.  Please verify PATH')\r
             return\r
 \r
         #\r
@@ -254,12 +255,12 @@ def main():
     try :\r
         file = open(Options.inputfilename)\r
     except Exception:\r
-        print "fail to open " + Options.inputfilename\r
+        print("fail to open " + Options.inputfilename)\r
         return 1\r
     try :\r
         newfile = open(Options.outputfilename, "w")\r
     except Exception:\r
-        print "fail to open " + Options.outputfilename\r
+        print("fail to open " + Options.outputfilename)\r
         return 1\r
 \r
     try:\r
index 557ffa4505e4e9fa156c7b246bae526bc12a3dcd..4deeee01a5e87ecb1e10b09e91c27efa9fae9216 100644 (file)
@@ -12,6 +12,7 @@
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 #\r
 \r
+from __future__ import print_function\r
 import os, sys, logging, traceback, subprocess\r
 from optparse import OptionParser\r
 \r
@@ -62,7 +63,7 @@ def parseCmdArgs():
     default = "C:\\Program Files\\doxygen\\bin\\doxygen.exe"\r
     if options.DoxygenPath is None:\r
         if os.path.exists(default):\r
-            print "Warning: Assume doxygen tool is installed at %s. If not, please specify via -x" % default\r
+            print("Warning: Assume doxygen tool is installed at %s. If not, please specify via -x" % default)\r
             options.DoxygenPath = default\r
         else:\r
             errors.append('- Please specify the path of doxygen tool installation via option -x! or install it in default path %s' % default)\r
@@ -80,7 +81,7 @@ def parseCmdArgs():
         if options.PackagePath is not None and os.path.exists(options.PackagePath):\r
             dirpath = os.path.dirname(options.PackagePath)\r
             default = os.path.join (dirpath, "Document")\r
-            print 'Warning: Assume document output at %s. If not, please specify via option -o' % default\r
+            print('Warning: Assume document output at %s. If not, please specify via option -o' % default)\r
             options.OutputPath = default\r
             if not os.path.exists(default):\r
                 try:\r
@@ -92,21 +93,21 @@ def parseCmdArgs():
 \r
     if options.Arch is None:\r
         options.Arch = 'ALL'\r
-        print "Warning: Assume arch is \"ALL\". If not, specify via -a"\r
+        print("Warning: Assume arch is \"ALL\". If not, specify via -a")\r
 \r
     if options.DocumentMode is None:\r
         options.DocumentMode = "HTML"\r
-        print "Warning: Assume document mode is \"HTML\". If not, specify via -m"\r
+        print("Warning: Assume document mode is \"HTML\". If not, specify via -m")\r
 \r
     if options.IncludeOnly is None:\r
         options.IncludeOnly = False\r
-        print "Warning: Assume generate package document for all package\'s source including publich interfaces and implementation libraries and modules."\r
+        print("Warning: Assume generate package document for all package\'s source including publich interfaces and implementation libraries and modules.")\r
 \r
     if options.DocumentMode.lower() == 'chm':\r
         default = "C:\\Program Files\\HTML Help Workshop\\hhc.exe"\r
         if options.HtmlWorkshopPath is None:\r
             if os.path.exists(default):\r
-                print 'Warning: Assume the installation path of Microsoft HTML Workshop is %s. If not, specify via option -c.' % default\r
+                print('Warning: Assume the installation path of Microsoft HTML Workshop is %s. If not, specify via option -c.' % default)\r
                 options.HtmlWorkshopPath = default\r
             else:\r
                 errors.append('- Please specify the installation path of Microsoft HTML Workshop via option -c!')\r
@@ -114,7 +115,7 @@ def parseCmdArgs():
             errors.append('- The installation path of Microsoft HTML Workshop %s does not exists. ' % options.HtmlWorkshopPath)\r
 \r
     if len(errors) != 0:\r
-        print '\n'\r
+        print('\n')\r
         parser.error('Fail to start due to following reasons: \n%s' %'\n'.join(errors))\r
     return (options.WorkspacePath, options.PackagePath, options.DoxygenPath, options.OutputPath,\r
             options.Arch, options.DocumentMode, options.IncludeOnly, options.HtmlWorkshopPath)\r
@@ -130,21 +131,21 @@ def createPackageObject(wsPath, pkgPath):
     return pkgObj\r
 \r
 def callbackLogMessage(msg, level):\r
-    print msg.strip()\r
+    print(msg.strip())\r
 \r
 def callbackCreateDoxygenProcess(doxPath, configPath):\r
     if sys.platform == 'win32':\r
         cmd = '"%s" %s' % (doxPath, configPath)\r
     else:\r
         cmd = '%s %s' % (doxPath, configPath)\r
-    print cmd\r
+    print(cmd)\r
     subprocess.call(cmd, shell=True)\r
 \r
 \r
 def DocumentFixup(outPath, arch):\r
     # find BASE_LIBRARY_JUMP_BUFFER structure reference page\r
 \r
-    print '\n    >>> Start fixup document \n'\r
+    print('\n    >>> Start fixup document \n')\r
 \r
     for root, dirs, files in os.walk(outPath):\r
         for dir in dirs:\r
@@ -172,10 +173,10 @@ def DocumentFixup(outPath, arch):
             if text.find('MdePkg/Include/Library/UefiApplicationEntryPoint.h File Reference') != -1:\r
                 FixPageUefiApplicationEntryPoint(fullpath, text)\r
 \r
-    print '    >>> Finish all document fixing up! \n'\r
+    print('    >>> Finish all document fixing up! \n')\r
 \r
 def FixPageBaseLib(path, text):\r
-    print '    >>> Fixup BaseLib file page at file %s \n' % path\r
+    print('    >>> Fixup BaseLib file page at file %s \n' % path)\r
     lines = text.split('\n')\r
     lastBaseJumpIndex = -1\r
     lastIdtGateDescriptor = -1\r
@@ -211,10 +212,10 @@ def FixPageBaseLib(path, text):
     except:\r
         logging.getLogger().error("     <<< Fail to fixup file %s\n" % path)\r
         return\r
-    print "    <<< Finish to fixup file %s\n" % path\r
+    print("    <<< Finish to fixup file %s\n" % path)\r
 \r
 def FixPageIA32_IDT_GATE_DESCRIPTOR(path, text):\r
-    print '    >>> Fixup structure reference IA32_IDT_GATE_DESCRIPTOR at file %s \n' % path\r
+    print('    >>> Fixup structure reference IA32_IDT_GATE_DESCRIPTOR at file %s \n' % path)\r
     lines = text.split('\n')\r
     for index in range(len(lines) - 1, -1, -1):\r
         line = lines[index].strip()\r
@@ -229,10 +230,10 @@ def FixPageIA32_IDT_GATE_DESCRIPTOR(path, text):
     except:\r
         logging.getLogger().error("     <<< Fail to fixup file %s\n" % path)\r
         return\r
-    print "    <<< Finish to fixup file %s\n" % path\r
+    print("    <<< Finish to fixup file %s\n" % path)\r
 \r
 def FixPageBASE_LIBRARY_JUMP_BUFFER(path, text):\r
-    print '    >>> Fixup structure reference BASE_LIBRARY_JUMP_BUFFER at file %s \n' % path\r
+    print('    >>> Fixup structure reference BASE_LIBRARY_JUMP_BUFFER at file %s \n' % path)\r
     lines = text.split('\n')\r
     bInDetail = True\r
     bNeedRemove = False\r
@@ -266,10 +267,10 @@ def FixPageBASE_LIBRARY_JUMP_BUFFER(path, text):
     except:\r
         logging.getLogger().error("     <<< Fail to fixup file %s" % path)\r
         return\r
-    print "    <<< Finish to fixup file %s\n" % path\r
+    print("    <<< Finish to fixup file %s\n" % path)\r
 \r
 def FixPageUefiDriverEntryPoint(path, text):\r
-    print '    >>> Fixup file reference MdePkg/Include/Library/UefiDriverEntryPoint.h at file %s \n' % path\r
+    print('    >>> Fixup file reference MdePkg/Include/Library/UefiDriverEntryPoint.h at file %s \n' % path)\r
     lines = text.split('\n')\r
     bInModuleEntry = False\r
     bInEfiMain     = False\r
@@ -318,11 +319,11 @@ def FixPageUefiDriverEntryPoint(path, text):
     except:\r
         logging.getLogger().error("     <<< Fail to fixup file %s" % path)\r
         return\r
-    print "    <<< Finish to fixup file %s\n" % path\r
+    print("    <<< Finish to fixup file %s\n" % path)\r
 \r
 \r
 def FixPageUefiApplicationEntryPoint(path, text):\r
-    print '    >>> Fixup file reference MdePkg/Include/Library/UefiApplicationEntryPoint.h at file %s \n' % path\r
+    print('    >>> Fixup file reference MdePkg/Include/Library/UefiApplicationEntryPoint.h at file %s \n' % path)\r
     lines = text.split('\n')\r
     bInModuleEntry = False\r
     bInEfiMain     = False\r
@@ -371,7 +372,7 @@ def FixPageUefiApplicationEntryPoint(path, text):
     except:\r
         logging.getLogger().error("     <<< Fail to fixup file %s" % path)\r
         return\r
-    print "    <<< Finish to fixup file %s\n" % path\r
+    print("    <<< Finish to fixup file %s\n" % path)\r
 \r
 if __name__ == '__main__':\r
     wspath, pkgpath, doxpath, outpath, archtag, docmode, isinc, hwpath = parseCmdArgs()\r
@@ -424,6 +425,6 @@ if __name__ == '__main__':
         else:\r
             cmd = '%s %s' % (hwpath, indexpath)\r
         subprocess.call(cmd)\r
-        print '\nFinish to generate package document! Please open %s for review' % os.path.join(outpath, 'html', 'index.chm')\r
+        print('\nFinish to generate package document! Please open %s for review' % os.path.join(outpath, 'html', 'index.chm'))\r
     else:\r
-        print '\nFinish to generate package document! Please open %s for review' % os.path.join(outpath, 'html', 'index.html')\r
+        print('\nFinish to generate package document! Please open %s for review' % os.path.join(outpath, 'html', 'index.html'))\r
index a177590af5972918f94eeb0f9efd98b6430e6982..fe2ba1d8a8420602ca406aa5649a9bbff59b6e8b 100644 (file)
@@ -11,6 +11,7 @@
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 #\r
 \r
+from __future__ import print_function\r
 import os\r
 \r
 from message import *\r
@@ -446,4 +447,4 @@ if __name__== '__main__':
     p.AddPage(Page('PCD', 'pcds'))\r
 \r
     df.Generate()\r
-    print df\r
+    print(df)\r
index 9db16a63c07a4d64a7bf013a84edd73065caf1f6..290287b817e775367c7ebc00b1c2a09aee9362d6 100644 (file)
@@ -11,6 +11,7 @@
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 #\r
 \r
+from __future__ import print_function\r
 import array\r
 import uuid\r
 import re\r
@@ -250,12 +251,12 @@ class EfiFirmwareVolumeHeader(BinaryItem):
         return list2int(self._arr.tolist()[48:50])\r
 \r
     def Dump(self):\r
-        print 'Signature: %s' % self.GetSigunature()\r
-        print 'Attribute: 0x%X' % self.GetAttribute()\r
-        print 'Header Length: 0x%X' % self.GetHeaderLength()\r
-        print 'File system Guid: ', self.GetFileSystemGuid()\r
-        print 'Revision: 0x%X' % self.GetRevision()\r
-        print 'FvLength: 0x%X' % self.GetFvLength()\r
+        print('Signature: %s' % self.GetSigunature())\r
+        print('Attribute: 0x%X' % self.GetAttribute())\r
+        print('Header Length: 0x%X' % self.GetHeaderLength())\r
+        print('File system Guid: ', self.GetFileSystemGuid())\r
+        print('Revision: 0x%X' % self.GetRevision())\r
+        print('FvLength: 0x%X' % self.GetFvLength())\r
 \r
     def GetFileSystemGuid(self):\r
         list = self._arr.tolist()\r
@@ -348,7 +349,7 @@ class EfiFfs(object):
                 line.append('0x%X' % int(item))\r
                 count += 1\r
             else:\r
-                print ' '.join(line)\r
+                print(' '.join(line))\r
                 count = 0\r
                 line = []\r
                 line.append('0x%X' % int(item))\r
@@ -445,11 +446,11 @@ class EfiFfsHeader(BinaryItem):
         return 'Unknown Ffs State'\r
 \r
     def Dump(self):\r
-        print "FFS name: ", self.GetNameGuid()\r
-        print "FFS type: ", self.GetType()\r
-        print "FFS attr: 0x%X" % self.GetAttributes()\r
-        print "FFS size: 0x%X" % self.GetFfsSize()\r
-        print "FFS state: 0x%X" % self.GetState()\r
+        print("FFS name: ", self.GetNameGuid())\r
+        print("FFS type: ", self.GetType())\r
+        print("FFS attr: 0x%X" % self.GetAttributes())\r
+        print("FFS size: 0x%X" % self.GetFfsSize())\r
+        print("FFS state: 0x%X" % self.GetState())\r
 \r
     def GetRawData(self):\r
         return self._arr.tolist()\r
@@ -528,8 +529,8 @@ class EfiSectionHeader(BinaryItem):
         return self.section_type_map[type]\r
 \r
     def Dump(self):\r
-        print 'size = 0x%X' % self.GetSectionSize()\r
-        print 'type = 0x%X' % self.GetType()\r
+        print('size = 0x%X' % self.GetSectionSize())\r
+        print('type = 0x%X' % self.GetType())\r
 \r
 \r
 \r
index 26c09241038678e2b1f95832421d808264c6bf3a..8ad5d471d0527a1805921f31dbe6865dad12b147 100644 (file)
@@ -14,6 +14,7 @@
 #\r
 ##\r
 \r
+from __future__ import print_function\r
 import os\r
 import re\r
 import sys\r
@@ -61,10 +62,10 @@ class Symbols:
         try:\r
             nmCommand = "nm"\r
             nmLineOption = "-l"\r
-            print "parsing (debug) - " + pdbName\r
+            print("parsing (debug) - " + pdbName)\r
             os.system ('%s %s %s > nmDump.line.log' % (nmCommand, nmLineOption, pdbName))\r
         except :\r
-            print 'ERROR: nm command not available.  Please verify PATH'\r
+            print('ERROR: nm command not available.  Please verify PATH')\r
             return\r
 \r
         #\r
@@ -103,11 +104,11 @@ class Symbols:
             DIA2DumpCommand = "Dia2Dump.exe"\r
             #DIA2SymbolOption = "-p"\r
             DIA2LinesOption = "-l"\r
-            print "parsing (pdb) - " + pdbName\r
+            print("parsing (pdb) - " + pdbName)\r
             #os.system ('%s %s %s > DIA2Dump.symbol.log' % (DIA2DumpCommand, DIA2SymbolOption, pdbName))\r
             os.system ('%s %s %s > DIA2Dump.line.log' % (DIA2DumpCommand, DIA2LinesOption, pdbName))\r
         except :\r
-            print 'ERROR: DIA2Dump command not available.  Please verify PATH'\r
+            print('ERROR: DIA2Dump command not available.  Please verify PATH')\r
             return\r
 \r
         #\r
@@ -235,14 +236,14 @@ def main():
     try :\r
         DOMTree = xml.dom.minidom.parse(Options.inputfilename)\r
     except Exception:\r
-        print "fail to open input " + Options.inputfilename\r
+        print("fail to open input " + Options.inputfilename)\r
         return 1\r
 \r
     if Options.guidreffilename is not None:\r
         try :\r
             guidreffile = open(Options.guidreffilename)\r
         except Exception:\r
-            print "fail to open guidref" + Options.guidreffilename\r
+            print("fail to open guidref" + Options.guidreffilename)\r
             return 1\r
         genGuidString(guidreffile)\r
         guidreffile.close()\r
@@ -277,7 +278,7 @@ def main():
 \r
                     Handler = smiHandler.getElementsByTagName("Handler")\r
                     RVA = Handler[0].getElementsByTagName("RVA")\r
-                    print "    Handler RVA: %s" % RVA[0].childNodes[0].data\r
+                    print("    Handler RVA: %s" % RVA[0].childNodes[0].data)\r
 \r
                     if (len(RVA)) >= 1:\r
                         rvaName = RVA[0].childNodes[0].data\r
@@ -289,7 +290,7 @@ def main():
 \r
                     Caller = smiHandler.getElementsByTagName("Caller")\r
                     RVA = Caller[0].getElementsByTagName("RVA")\r
-                    print "    Caller RVA: %s" % RVA[0].childNodes[0].data\r
+                    print("    Caller RVA: %s" % RVA[0].childNodes[0].data)\r
 \r
                     if (len(RVA)) >= 1:\r
                         rvaName = RVA[0].childNodes[0].data\r
@@ -302,7 +303,7 @@ def main():
     try :\r
         newfile = open(Options.outputfilename, "w")\r
     except Exception:\r
-        print "fail to open output" + Options.outputfilename\r
+        print("fail to open output" + Options.outputfilename)\r
         return 1\r
 \r
     newfile.write(DOMTree.toprettyxml(indent = "\t", newl = "\n", encoding = "utf-8"))\r
index 72d801df8fd5d1bfd03835298e9b475f5b085f8d..e268c4c0a1cfa41bb298196cec4aa2a308960f92 100644 (file)
@@ -15,6 +15,7 @@
 \r
 ## Import Modules\r
 #\r
+from __future__ import print_function\r
 import Common.LongFilePathOs as os\r
 import re\r
 import os.path as path\r
@@ -688,7 +689,7 @@ class WorkspaceAutoGen(AutoGen):
             os.makedirs(self.BuildDir)\r
         with open(os.path.join(self.BuildDir, 'AutoGen'), 'w+') as file:\r
             for f in AllWorkSpaceMetaFiles:\r
-                print >> file, f\r
+                print(f, file=file)\r
         return True\r
 \r
     def _GenPkgLevelHash(self, Pkg):\r
@@ -4362,7 +4363,7 @@ class ModuleAutoGen(AutoGen):
             os.remove (self.GetTimeStampPath())\r
         with open(self.GetTimeStampPath(), 'w+') as file:\r
             for f in FileSet:\r
-                print >> file, f\r
+                print(f, file=file)\r
 \r
     Module          = property(_GetModule)\r
     Name            = property(_GetBaseName)\r
index ad1919442e6e8db05d72a11042661bfb89e52fef..d4daa309376173e405d75bf5e012522d2b1f461e 100644 (file)
@@ -14,6 +14,7 @@
 ##\r
 # Import Modules\r
 #\r
+from __future__ import print_function\r
 import Common.LongFilePathOs as os\r
 import re\r
 import copy\r
@@ -597,19 +598,19 @@ if __name__ == '__main__':
     EdkLogger.Initialize()\r
     if len(sys.argv) > 1:\r
         Br = BuildRule(sys.argv[1])\r
-        print str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "MSFT"][1])\r
-        print\r
-        print str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "INTEL"][1])\r
-        print\r
-        print str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "GCC"][1])\r
-        print\r
-        print str(Br[".ac", "ACPI_TABLE", "IA32", "MSFT"][1])\r
-        print\r
-        print str(Br[".h", "ACPI_TABLE", "IA32", "INTEL"][1])\r
-        print\r
-        print str(Br[".ac", "ACPI_TABLE", "IA32", "MSFT"][1])\r
-        print\r
-        print str(Br[".s", SUP_MODULE_SEC, "IPF", "COMMON"][1])\r
-        print\r
-        print str(Br[".s", SUP_MODULE_SEC][1])\r
+        print(str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "MSFT"][1]))\r
+        print()\r
+        print(str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "INTEL"][1]))\r
+        print()\r
+        print(str(Br[".c", SUP_MODULE_DXE_DRIVER, "IA32", "GCC"][1]))\r
+        print()\r
+        print(str(Br[".ac", "ACPI_TABLE", "IA32", "MSFT"][1]))\r
+        print()\r
+        print(str(Br[".h", "ACPI_TABLE", "IA32", "INTEL"][1]))\r
+        print()\r
+        print(str(Br[".ac", "ACPI_TABLE", "IA32", "MSFT"][1]))\r
+        print()\r
+        print(str(Br[".s", SUP_MODULE_SEC, "IPF", "COMMON"][1]))\r
+        print()\r
+        print(str(Br[".s", SUP_MODULE_SEC][1]))\r
 \r
index 06cf3e7d5162b694f38f0a30c295706f19e05534..3a931c6f27663a600baa6ca9140f7548c84cc9a3 100644 (file)
@@ -16,6 +16,7 @@
 ##\r
 # Import Modules\r
 #\r
+from __future__ import print_function\r
 import Common.LongFilePathOs as os, codecs, re\r
 import distutils.util\r
 import Common.EdkLogger as EdkLogger\r
@@ -684,12 +685,12 @@ class UniFileClassObject(object):
     # Show the instance itself\r
     #\r
     def ShowMe(self):\r
-        print self.LanguageDef\r
+        print(self.LanguageDef)\r
         #print self.OrderedStringList\r
         for Item in self.OrderedStringList:\r
-            print Item\r
+            print(Item)\r
             for Member in self.OrderedStringList[Item]:\r
-                print str(Member)\r
+                print(str(Member))\r
 \r
 # This acts like the main() function for the script, unless it is 'import'ed into another\r
 # script.\r
index 6c8f89f5d12bb6502c41ae156e6acf1cc8a16a0d..86c44abb67a6c956a7907b4b5e82a18e93cde8a5 100644 (file)
@@ -20,6 +20,7 @@
 ##\r
 # Import Modules\r
 #\r
+from __future__ import print_function\r
 import Common.LongFilePathOs as os\r
 import sys\r
 import encodings.ascii\r
@@ -132,7 +133,7 @@ def MyOptionParser():
 #\r
 def StartBpdg(InputFileName, MapFileName, VpdFileName, Force):\r
     if os.path.exists(VpdFileName) and not Force:\r
-        print "\nFile %s already exist, Overwrite(Yes/No)?[Y]: " % VpdFileName\r
+        print("\nFile %s already exist, Overwrite(Yes/No)?[Y]: " % VpdFileName)\r
         choice = sys.stdin.readline()\r
         if choice.strip().lower() not in ['y', 'yes', '']:\r
             return\r
index 7b04dcdb36ccf4172a018dff37d8baccbaeef43b..c63030a16e6e624a7895141ce4e796054c728a96 100644 (file)
@@ -12,6 +12,7 @@
 \r
 ## Import Modules\r
 #\r
+from __future__ import print_function\r
 from Common.GlobalData import *\r
 from CommonDataClass.Exceptions import BadExpression\r
 from CommonDataClass.Exceptions import WrnExpression\r
@@ -1028,10 +1029,10 @@ if __name__ == '__main__':
         if input in 'qQ':\r
             break\r
         try:\r
-            print ValueExpression(input)(True)\r
-            print ValueExpression(input)(False)\r
+            print(ValueExpression(input)(True))\r
+            print(ValueExpression(input)(False))\r
         except WrnExpression as Ex:\r
-            print Ex.result\r
-            print str(Ex)\r
+            print(Ex.result)\r
+            print(str(Ex))\r
         except Exception as Ex:\r
-            print str(Ex)\r
+            print(str(Ex))\r
index b6f99447057c411e632ac33513c9bfa5742d1553..4c29bc9ee4bd88c2660345b0ce8bf7fb09689fae 100644 (file)
@@ -12,6 +12,7 @@
 \r
 # # Import Modules\r
 #\r
+from __future__ import print_function\r
 from Common.GlobalData import *\r
 from CommonDataClass.Exceptions import BadExpression\r
 from CommonDataClass.Exceptions import WrnExpression\r
@@ -85,11 +86,11 @@ class RangeContainer(object):
         self.__clean__()\r
         \r
     def dump(self):\r
-        print "----------------------"\r
+        print("----------------------")\r
         rangelist = ""\r
         for object in self.rangelist:\r
             rangelist = rangelist + "[%d , %d]" % (object.start, object.end)\r
-        print rangelist\r
+        print(rangelist)\r
         \r
         \r
 class XOROperatorObject(object):   \r
index f8459c892e365845e2cd0d32706b27cfa84a276f..8ba8dd31a8c598f82f201bc402a52247ccc39187 100644 (file)
@@ -14,6 +14,7 @@
 ##\r
 # Import Modules\r
 #\r
+from __future__ import print_function\r
 import Common.LongFilePathOs as os\r
 import EdkLogger\r
 import DataType\r
@@ -158,6 +159,6 @@ def TargetTxtDict(ConfDir):
 if __name__ == '__main__':\r
     pass\r
     Target = TargetTxtDict(os.getenv("WORKSPACE"))\r
-    print Target.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER]\r
-    print Target.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TARGET]\r
-    print Target.TargetTxtDictionary\r
+    print(Target.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_MAX_CONCURRENT_THREAD_NUMBER])\r
+    print(Target.TargetTxtDictionary[DataType.TAB_TAT_DEFINES_TARGET])\r
+    print(Target.TargetTxtDictionary)\r
index 8ff544ed769d580aa25f7ee4e45a395917494ef3..09b8196faf0743b5f604caab691b077ea1ad5ccb 100644 (file)
@@ -15,6 +15,7 @@
 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 #\r
+from __future__ import print_function\r
 import Common.LongFilePathOs as os\r
 import re\r
 import Common.EdkLogger as EdkLogger\r
@@ -248,7 +249,7 @@ def CallExtenalBPDGTool(ToolPath, VpdFileName):
     except Exception as X:\r
         EdkLogger.error("BPDG", BuildToolError.COMMAND_FAILURE, ExtraData=str(X))\r
     (out, error) = PopenObject.communicate()\r
-    print out\r
+    print(out)\r
     while PopenObject.returncode is None :\r
         PopenObject.wait()\r
     \r
index ddc6cbd506aa637ac87beb018339d77743c78bc9..d5fd3a37a167e50970b44fb52c2a08a74937930c 100644 (file)
@@ -1,5 +1,6 @@
 # $ANTLR 3.0.1 C.g 2010-02-23 09:58:53\r
 \r
+from __future__ import print_function\r
 from antlr3 import *\r
 from antlr3.compat import set, frozenset\r
          \r
@@ -102,8 +103,8 @@ class CParser(Parser):
         self.postfix_expression_stack = []\r
 \r
     def printTokenInfo(self, line, offset, tokenText):\r
-       print str(line)+ ',' + str(offset) + ':' + str(tokenText)\r
-        \r
+        print(str(line)+ ',' + str(offset) + ':' + str(tokenText))\r
+\r
     def StorePredicateExpression(self, StartLine, StartOffset, EndLine, EndOffset, Text):\r
        PredExp = CodeFragment.PredicateExpression(Text, (StartLine, StartOffset), (EndLine, EndOffset))\r
        FileProfile.PredicateExpressionList.append(PredExp)\r
index ffa51de7c1bfd76c4f085eb882a1bd8bee32a1f7..2efae2c7c1de9c0dfe92ba9fa9cfcc14cd385acc 100644 (file)
@@ -16,6 +16,7 @@
 # Import Modules\r
 #\r
 \r
+from __future__ import print_function\r
 import re\r
 import Common.LongFilePathOs as os\r
 import sys\r
@@ -533,58 +534,58 @@ class CodeFragmentCollector:
         \r
     def PrintFragments(self):\r
         \r
-        print '################# ' + self.FileName + '#####################'\r
+        print('################# ' + self.FileName + '#####################')\r
         \r
-        print '/****************************************/'\r
-        print '/*************** COMMENTS ***************/'\r
-        print '/****************************************/'\r
+        print('/****************************************/')\r
+        print('/*************** COMMENTS ***************/')\r
+        print('/****************************************/')\r
         for comment in FileProfile.CommentList:\r
-            print str(comment.StartPos) + comment.Content\r
+            print(str(comment.StartPos) + comment.Content)\r
         \r
-        print '/****************************************/'\r
-        print '/********* PREPROCESS DIRECTIVES ********/'\r
-        print '/****************************************/'\r
+        print('/****************************************/')\r
+        print('/********* PREPROCESS DIRECTIVES ********/')\r
+        print('/****************************************/')\r
         for pp in FileProfile.PPDirectiveList:\r
-            print str(pp.StartPos) + pp.Content\r
+            print(str(pp.StartPos) + pp.Content)\r
         \r
-        print '/****************************************/'\r
-        print '/********* VARIABLE DECLARATIONS ********/'\r
-        print '/****************************************/'\r
+        print('/****************************************/')\r
+        print('/********* VARIABLE DECLARATIONS ********/')\r
+        print('/****************************************/')\r
         for var in FileProfile.VariableDeclarationList:\r
-            print str(var.StartPos) + var.Modifier + ' '+ var.Declarator\r
+            print(str(var.StartPos) + var.Modifier + ' '+ var.Declarator)\r
             \r
-        print '/****************************************/'\r
-        print '/********* FUNCTION DEFINITIONS *********/'\r
-        print '/****************************************/'\r
+        print('/****************************************/')\r
+        print('/********* FUNCTION DEFINITIONS *********/')\r
+        print('/****************************************/')\r
         for func in FileProfile.FunctionDefinitionList:\r
-            print str(func.StartPos) + func.Modifier + ' '+ func.Declarator + ' ' + str(func.NamePos)\r
+            print(str(func.StartPos) + func.Modifier + ' '+ func.Declarator + ' ' + str(func.NamePos))\r
             \r
-        print '/****************************************/'\r
-        print '/************ ENUMERATIONS **************/'\r
-        print '/****************************************/'\r
+        print('/****************************************/')\r
+        print('/************ ENUMERATIONS **************/')\r
+        print('/****************************************/')\r
         for enum in FileProfile.EnumerationDefinitionList:\r
-            print str(enum.StartPos) + enum.Content\r
+            print(str(enum.StartPos) + enum.Content)\r
         \r
-        print '/****************************************/'\r
-        print '/*********** STRUCTS/UNIONS *************/'\r
-        print '/****************************************/'\r
+        print('/****************************************/')\r
+        print('/*********** STRUCTS/UNIONS *************/')\r
+        print('/****************************************/')\r
         for su in FileProfile.StructUnionDefinitionList:\r
-            print str(su.StartPos) + su.Content\r
+            print(str(su.StartPos) + su.Content)\r
             \r
-        print '/****************************************/'\r
-        print '/********* PREDICATE EXPRESSIONS ********/'\r
-        print '/****************************************/'\r
+        print('/****************************************/')\r
+        print('/********* PREDICATE EXPRESSIONS ********/')\r
+        print('/****************************************/')\r
         for predexp in FileProfile.PredicateExpressionList:\r
-            print str(predexp.StartPos) + predexp.Content\r
+            print(str(predexp.StartPos) + predexp.Content)\r
         \r
-        print '/****************************************/'    \r
-        print '/************** TYPEDEFS ****************/'\r
-        print '/****************************************/'\r
+        print('/****************************************/')\r
+        print('/************** TYPEDEFS ****************/')\r
+        print('/****************************************/')\r
         for typedef in FileProfile.TypedefDefinitionList:\r
-            print str(typedef.StartPos) + typedef.ToType\r
+            print(str(typedef.StartPos) + typedef.ToType)\r
         \r
 if __name__ == "__main__":\r
     \r
     collector = CodeFragmentCollector(sys.argv[1])\r
     collector.PreprocessFile()\r
-    print "For Test."\r
+    print("For Test.")\r
index 217b60f4f319a4d6e6f4773db3fecb1ad2925128..4711bbd54fdccffbc37f5648eb000240853eb951 100644 (file)
@@ -14,6 +14,7 @@
 ##\r
 # Import Modules\r
 #\r
+from __future__ import print_function\r
 import Common.LongFilePathOs as os\r
 import Common.EdkLogger as EdkLogger\r
 from Common.DataType import *\r
@@ -419,9 +420,9 @@ class Configuration(object):
                 self.__dict__[_ConfigFileToInternalTranslation[List[0]]] = List[1]\r
 \r
     def ShowMe(self):\r
-        print self.Filename\r
+        print(self.Filename)\r
         for Key in self.__dict__.keys():\r
-            print Key, '=', self.__dict__[Key]\r
+            print(Key, '=', self.__dict__[Key])\r
 \r
 #\r
 # test that our dict and out class still match in contents.\r
index b0882afa6289933bb0f79bd6e83f02db5644ded5..bde41c3a4b570931d9b2cc2336b483d1800c5b75 100644 (file)
@@ -14,6 +14,7 @@
 ##\r
 # Import Modules\r
 #\r
+from __future__ import print_function\r
 from Xml.XmlRoutines import *\r
 import Common.LongFilePathOs as os\r
 \r
@@ -84,4 +85,4 @@ class ExceptionCheck(object):
 #\r
 if __name__ == '__main__':\r
     El = ExceptionCheck('C:\\Hess\\Project\\BuildTool\\src\\Ecc\\exception.xml')\r
-    print El.ExceptionList\r
+    print(El.ExceptionList)\r
index fc65e9a2bd3c0e9aa182d8998ffea954fea29407..a056c3759fb18aade3164b7eb65aaa53d17b1512 100644 (file)
@@ -14,6 +14,7 @@
 ##\r
 # Import Modules\r
 #\r
+from __future__ import print_function\r
 import Common.LongFilePathOs as os\r
 \r
 import Common.EdkLogger as EdkLogger\r
@@ -99,7 +100,7 @@ class Table(object):
         try:\r
             self.Cur.execute(SqlCommand)\r
         except Exception as e:\r
-            print "An error occurred when Drop a table:", e.args[0]\r
+            print("An error occurred when Drop a table:", e.args[0])\r
 \r
     ## Get count\r
     #\r
index d5fb80fcf98214bb57e19eaf5d552456a82a8568..811106133cb4ad3a4dccf5a27c79a105298aa09c 100644 (file)
@@ -15,6 +15,7 @@
 ##\r
 # Import Modules\r
 #\r
+from __future__ import print_function\r
 import xml.dom.minidom\r
 from Common.LongFilePathSupport import OpenLongFilePath as open\r
 \r
@@ -215,7 +216,7 @@ def XmlParseFile(FileName):
         XmlFile.close()\r
         return Dom\r
     except Exception as X:\r
-        print X\r
+        print(X)\r
         return ""\r
 \r
 # This acts like the main() function for the script, unless it is 'import'ed\r
@@ -225,5 +226,5 @@ if __name__ == '__main__':
     A = CreateXmlElement('AAA', 'CCC',  [['AAA', '111'], ['BBB', '222']], [['A', '1'], ['B', '2']])\r
     B = CreateXmlElement('ZZZ', 'CCC',  [['XXX', '111'], ['YYY', '222']], [['A', '1'], ['B', '2']])\r
     C = CreateXmlList('DDD', 'EEE', [A, B], ['FFF', 'GGG'])\r
-    print C.toprettyxml(indent = " ")\r
+    print(C.toprettyxml(indent = " "))\r
     pass\r
index 99b22725e6bacb788653eae2cabd397613f60458..e2a5cc8487fabeaaa65aa15e52f82cf4e962a39a 100644 (file)
@@ -11,6 +11,7 @@
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 #\r
 \r
+from __future__ import print_function\r
 import sys\r
 import Common.LongFilePathOs as os\r
 import re\r
@@ -2285,7 +2286,7 @@ def CheckDoxygenTripleForwardSlash(FullFileName):
         for Result in ResultSet:\r
             CommentSet.append(Result)\r
     except:\r
-        print 'Unrecognized chars in comment of file %s', FullFileName\r
+        print('Unrecognized chars in comment of file %s', FullFileName)\r
 \r
 \r
     for Result in CommentSet:\r
@@ -2438,7 +2439,7 @@ def CheckFuncHeaderDoxygenComments(FullFileName):
         for Result in ResultSet:\r
             CommentSet.append(Result)\r
     except:\r
-        print 'Unrecognized chars in comment of file %s', FullFileName\r
+        print('Unrecognized chars in comment of file %s', FullFileName)\r
 \r
     # Func Decl check\r
     SqlStatement = """ select Modifier, Name, StartLine, ID, Value\r
@@ -2469,7 +2470,7 @@ def CheckFuncHeaderDoxygenComments(FullFileName):
         for Result in ResultSet:\r
             CommentSet.append(Result)\r
     except:\r
-        print 'Unrecognized chars in comment of file %s', FullFileName\r
+        print('Unrecognized chars in comment of file %s', FullFileName)\r
 \r
     SqlStatement = """ select Modifier, Header, StartLine, ID, Name\r
                        from Function\r
@@ -2634,9 +2635,9 @@ if __name__ == '__main__':
     try:\r
         test_file = sys.argv[1]\r
     except IndexError as v:\r
-        print "Usage: %s filename" % sys.argv[0]\r
+        print("Usage: %s filename" % sys.argv[0])\r
         sys.exit(1)\r
     MsgList = CheckFuncHeaderDoxygenComments(test_file)\r
     for Msg in MsgList:\r
-        print Msg\r
-    print 'Done!'\r
+        print(Msg)\r
+    print('Done!')\r
index ddc6cbd506aa637ac87beb018339d77743c78bc9..d5fd3a37a167e50970b44fb52c2a08a74937930c 100644 (file)
@@ -1,5 +1,6 @@
 # $ANTLR 3.0.1 C.g 2010-02-23 09:58:53\r
 \r
+from __future__ import print_function\r
 from antlr3 import *\r
 from antlr3.compat import set, frozenset\r
          \r
@@ -102,8 +103,8 @@ class CParser(Parser):
         self.postfix_expression_stack = []\r
 \r
     def printTokenInfo(self, line, offset, tokenText):\r
-       print str(line)+ ',' + str(offset) + ':' + str(tokenText)\r
-        \r
+        print(str(line)+ ',' + str(offset) + ':' + str(tokenText))\r
+\r
     def StorePredicateExpression(self, StartLine, StartOffset, EndLine, EndOffset, Text):\r
        PredExp = CodeFragment.PredicateExpression(Text, (StartLine, StartOffset), (EndLine, EndOffset))\r
        FileProfile.PredicateExpressionList.append(PredExp)\r
index 87f179206d846b575b836a05876cfe837ed6052d..1e30e2ce62e284c21f12e48474ea20d09e2a2314 100644 (file)
@@ -15,6 +15,7 @@
 ##\r
 # Import Modules\r
 #\r
+from __future__ import print_function\r
 import re\r
 import Common.LongFilePathOs as os\r
 import sys\r
@@ -379,49 +380,49 @@ class CodeFragmentCollector:
     #\r
     def PrintFragments(self):\r
 \r
-        print '################# ' + self.FileName + '#####################'\r
+        print('################# ' + self.FileName + '#####################')\r
 \r
-        print '/****************************************/'\r
-        print '/*************** ASSIGNMENTS ***************/'\r
-        print '/****************************************/'\r
+        print('/****************************************/')\r
+        print('/*************** ASSIGNMENTS ***************/')\r
+        print('/****************************************/')\r
         for asign in FileProfile.AssignmentExpressionList:\r
-            print str(asign.StartPos) + asign.Name + asign.Operator + asign.Value\r
+            print(str(asign.StartPos) + asign.Name + asign.Operator + asign.Value)\r
 \r
-        print '/****************************************/'\r
-        print '/********* PREPROCESS DIRECTIVES ********/'\r
-        print '/****************************************/'\r
+        print('/****************************************/')\r
+        print('/********* PREPROCESS DIRECTIVES ********/')\r
+        print('/****************************************/')\r
         for pp in FileProfile.PPDirectiveList:\r
-            print str(pp.StartPos) + pp.Content\r
+            print(str(pp.StartPos) + pp.Content)\r
 \r
-        print '/****************************************/'\r
-        print '/********* VARIABLE DECLARATIONS ********/'\r
-        print '/****************************************/'\r
+        print('/****************************************/')\r
+        print('/********* VARIABLE DECLARATIONS ********/')\r
+        print('/****************************************/')\r
         for var in FileProfile.VariableDeclarationList:\r
-            print str(var.StartPos) + var.Modifier + ' '+ var.Declarator\r
+            print(str(var.StartPos) + var.Modifier + ' '+ var.Declarator)\r
 \r
-        print '/****************************************/'\r
-        print '/********* FUNCTION DEFINITIONS *********/'\r
-        print '/****************************************/'\r
+        print('/****************************************/')\r
+        print('/********* FUNCTION DEFINITIONS *********/')\r
+        print('/****************************************/')\r
         for func in FileProfile.FunctionDefinitionList:\r
-            print str(func.StartPos) + func.Modifier + ' '+ func.Declarator + ' ' + str(func.NamePos)\r
+            print(str(func.StartPos) + func.Modifier + ' '+ func.Declarator + ' ' + str(func.NamePos))\r
 \r
-        print '/****************************************/'\r
-        print '/************ ENUMERATIONS **************/'\r
-        print '/****************************************/'\r
+        print('/****************************************/')\r
+        print('/************ ENUMERATIONS **************/')\r
+        print('/****************************************/')\r
         for enum in FileProfile.EnumerationDefinitionList:\r
-            print str(enum.StartPos) + enum.Content\r
+            print(str(enum.StartPos) + enum.Content)\r
 \r
-        print '/****************************************/'\r
-        print '/*********** STRUCTS/UNIONS *************/'\r
-        print '/****************************************/'\r
+        print('/****************************************/')\r
+        print('/*********** STRUCTS/UNIONS *************/')\r
+        print('/****************************************/')\r
         for su in FileProfile.StructUnionDefinitionList:\r
-            print str(su.StartPos) + su.Content\r
+            print(str(su.StartPos) + su.Content)\r
 \r
-        print '/****************************************/'\r
-        print '/************** TYPEDEFS ****************/'\r
-        print '/****************************************/'\r
+        print('/****************************************/')\r
+        print('/************** TYPEDEFS ****************/')\r
+        print('/****************************************/')\r
         for typedef in FileProfile.TypedefDefinitionList:\r
-            print str(typedef.StartPos) + typedef.ToType\r
+            print(str(typedef.StartPos) + typedef.ToType)\r
 \r
 ##\r
 #\r
@@ -430,4 +431,4 @@ class CodeFragmentCollector:
 #\r
 if __name__ == "__main__":\r
 \r
-    print "For Test."\r
+    print("For Test.")\r
index 584a95d6f3e43d1ff4ad52f86edd5ca3ee97c54c..24f0d50246e5ba131bfc78ce0e9794d342e3f4ae 100644 (file)
@@ -14,6 +14,7 @@
 ##\r
 # Import Modules\r
 #\r
+from __future__ import print_function\r
 import Common.LongFilePathOs as os\r
 import Common.EdkLogger as EdkLogger\r
 from Common.DataType import *\r
@@ -164,8 +165,8 @@ if __name__ == '__main__':
     Db.InitDatabase()\r
     P = EdkInfParser(os.path.normpath("C:\Framework\Edk\Sample\Platform\Nt32\Dxe\PlatformBds\PlatformBds.inf"), Db, '', '')\r
     for Inf in P.Sources:\r
-        print Inf\r
+        print(Inf)\r
     for Item in P.Macros:\r
-        print Item, P.Macros[Item]\r
+        print(Item, P.Macros[Item])\r
 \r
-    Db.Close()
\ No newline at end of file
+    Db.Close()\r
index 8199ce5ee73edefdef65649f66c082fd318305cd..c70f62f393a9751b839c637c94c16df13a6c8e9d 100644 (file)
@@ -15,6 +15,7 @@
 ##\r
 # Import Modules\r
 #\r
+from __future__ import print_function\r
 import sys\r
 import Common.LongFilePathOs as os\r
 import re\r
@@ -384,4 +385,4 @@ if __name__ == '__main__':
     EdkLogger.SetLevel(EdkLogger.QUIET)\r
     CollectSourceCodeDataIntoDB(sys.argv[1])\r
 \r
-    print 'Done!'\r
+    print('Done!')\r
index a99a5e7ac6938e8452899108a0c5e624998a67a4..6b4f724f6d9ca6aec7828a606855874be9a1b004 100644 (file)
@@ -16,6 +16,7 @@
 ##\r
 # Import Modules\r
 #\r
+from __future__ import print_function\r
 import re\r
 \r
 import Fd\r
@@ -4777,7 +4778,7 @@ if __name__ == "__main__":
     try:\r
         test_file = sys.argv[1]\r
     except IndexError as v:\r
-        print "Usage: %s filename" % sys.argv[0]\r
+        print("Usage: %s filename" % sys.argv[0])\r
         sys.exit(1)\r
 \r
     parser = FdfParser(test_file)\r
@@ -4785,7 +4786,7 @@ if __name__ == "__main__":
         parser.ParseFile()\r
         parser.CycleReferenceCheck()\r
     except Warning as X:\r
-        print str(X)\r
+        print(str(X))\r
     else:\r
-        print "Success!"\r
+        print("Success!")\r
 \r
index ba3950dacd8a3d141e42cf27901efaf5eecb60fc..1552ab4ee3a8aa74a0def9f25a95b5be72be1850 100644 (file)
@@ -15,6 +15,7 @@
 ##\r
 # Import Modules\r
 #\r
+from __future__ import print_function\r
 from optparse import OptionParser\r
 import sys\r
 import Common.LongFilePathOs as os\r
@@ -689,7 +690,7 @@ class GenFds :
         ModuleDict = BuildDb.BuildObject[DscFile, TAB_COMMON, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag].Modules\r
         for Key in ModuleDict:\r
             ModuleObj = BuildDb.BuildObject[Key, TAB_COMMON, GenFdsGlobalVariable.TargetName, GenFdsGlobalVariable.ToolChainTag]\r
-            print ModuleObj.BaseName + ' ' + ModuleObj.ModuleType\r
+            print(ModuleObj.BaseName + ' ' + ModuleObj.ModuleType)\r
 \r
     def GenerateGuidXRefFile(BuildDb, ArchList, FdfParserObj):\r
         GuidXRefFileName = os.path.join(GenFdsGlobalVariable.FvDir, "Guid.xref")\r
index c1d656227609c3e6210b74c4758908a1a8cef144..73b52030d929a2ae18a9da8499b8b2261615775e 100644 (file)
@@ -15,6 +15,7 @@
 ##\r
 # Import Modules\r
 #\r
+from __future__ import print_function\r
 import Common.LongFilePathOs as os\r
 import sys\r
 import subprocess\r
@@ -736,7 +737,7 @@ class GenFdsGlobalVariable:
             GenFdsGlobalVariable.InfLogger (out)\r
             GenFdsGlobalVariable.InfLogger (error)\r
             if PopenObject.returncode != 0:\r
-                print "###", cmd\r
+                print("###", cmd)\r
                 EdkLogger.error("GenFds", COMMAND_FAILURE, errorMess)\r
 \r
     def VerboseLogger (msg):\r
index f40c8bd01b239f0a9547443af718f19905ca0c3d..d7084fbe88dacfc4440cf7fa448bcda1f312ab68 100644 (file)
@@ -17,6 +17,7 @@
 #\r
 \r
 #======================================  External Libraries ========================================\r
+from __future__ import print_function\r
 import optparse\r
 import Common.LongFilePathOs as os\r
 import re\r
@@ -216,7 +217,7 @@ if __name__ == '__main__':
     (options, args) = parser.parse_args()\r
 \r
     if options.mapfile is None or options.efifile is None:\r
-        print parser.get_usage()\r
+        print(parser.get_usage())\r
     elif os.path.exists(options.mapfile) and os.path.exists(options.efifile):\r
         list = parsePcdInfoFromMapFile(options.mapfile, options.efifile)\r
         if list is not None:\r
@@ -225,6 +226,6 @@ if __name__ == '__main__':
             else:\r
                 generatePcdTable(list, options.mapfile.replace('.map', '.BinaryPcdTable.txt'))\r
         else:\r
-            print 'Fail to generate Patch PCD Table based on map file and efi file'\r
+            print('Fail to generate Patch PCD Table based on map file and efi file')\r
     else:\r
-        print 'Fail to generate Patch PCD Table for fail to find map file or efi file!'\r
+        print('Fail to generate Patch PCD Table for fail to find map file or efi file!')\r
index de8575676cac8938afc957f9e321e122a007d9e7..4f79d0f82967019f87f2fa656e96dd050a86a8d2 100644 (file)
@@ -19,6 +19,7 @@
 '''\r
 Pkcs7Sign\r
 '''\r
+from __future__ import print_function\r
 \r
 import os\r
 import sys\r
@@ -113,14 +114,14 @@ if __name__ == '__main__':
   try:\r
     Process = subprocess.Popen('%s version' % (OpenSslCommand), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
   except:\r
-    print 'ERROR: Open SSL command not available.  Please verify PATH or set OPENSSL_PATH'\r
+    print('ERROR: Open SSL command not available.  Please verify PATH or set OPENSSL_PATH')\r
     sys.exit(1)\r
 \r
   Version = Process.communicate()\r
   if Process.returncode <> 0:\r
-    print 'ERROR: Open SSL command not available.  Please verify PATH or set OPENSSL_PATH'\r
+    print('ERROR: Open SSL command not available.  Please verify PATH or set OPENSSL_PATH')\r
     sys.exit(Process.returncode)\r
-  print Version[0]\r
+  print(Version[0])\r
 \r
   #\r
   # Read input file into a buffer and save input filename\r
@@ -134,7 +135,7 @@ if __name__ == '__main__':
   #\r
   OutputDir = os.path.dirname(args.OutputFile)\r
   if not os.path.exists(OutputDir):\r
-    print 'ERROR: The output path does not exist: %s' % OutputDir\r
+    print('ERROR: The output path does not exist: %s' % OutputDir)\r
     sys.exit(1)\r
   args.OutputFileName = args.OutputFile\r
 \r
@@ -170,7 +171,7 @@ if __name__ == '__main__':
         args.SignerPrivateCertFile = open(args.SignerPrivateCertFileName, 'rb')\r
         args.SignerPrivateCertFile.close()\r
       except:\r
-        print 'ERROR: test signer private cert file %s missing' % (args.SignerPrivateCertFileName)\r
+        print('ERROR: test signer private cert file %s missing' % (args.SignerPrivateCertFileName))\r
         sys.exit(1)\r
 \r
     #\r
@@ -196,7 +197,7 @@ if __name__ == '__main__':
         args.OtherPublicCertFile = open(args.OtherPublicCertFileName, 'rb')\r
         args.OtherPublicCertFile.close()\r
       except:\r
-        print 'ERROR: test other public cert file %s missing' % (args.OtherPublicCertFileName)\r
+        print('ERROR: test other public cert file %s missing' % (args.OtherPublicCertFileName))\r
         sys.exit(1)\r
 \r
     format = "%dsQ" % len(args.InputFileBuffer)\r
@@ -242,11 +243,11 @@ if __name__ == '__main__':
         args.TrustedPublicCertFile = open(args.TrustedPublicCertFileName, 'rb')\r
         args.TrustedPublicCertFile.close()\r
       except:\r
-        print 'ERROR: test trusted public cert file %s missing' % (args.TrustedPublicCertFileName)\r
+        print('ERROR: test trusted public cert file %s missing' % (args.TrustedPublicCertFileName))\r
         sys.exit(1)\r
 \r
     if not args.SignatureSizeStr:\r
-      print "ERROR: please use the option --signature-size to specify the size of the signature data!"\r
+      print("ERROR: please use the option --signature-size to specify the size of the signature data!")\r
       sys.exit(1)\r
     else:\r
       if args.SignatureSizeStr.upper().startswith('0X'):\r
@@ -254,10 +255,10 @@ if __name__ == '__main__':
       else:\r
         SignatureSize = (long)(args.SignatureSizeStr)\r
     if SignatureSize < 0:\r
-        print "ERROR: The value of option --signature-size can't be set to negative value!"\r
+        print("ERROR: The value of option --signature-size can't be set to negative value!")\r
         sys.exit(1)\r
     elif SignatureSize > len(args.InputFileBuffer):\r
-        print "ERROR: The value of option --signature-size is exceed the size of the input file !"\r
+        print("ERROR: The value of option --signature-size is exceed the size of the input file !")\r
         sys.exit(1)\r
 \r
     args.SignatureBuffer = args.InputFileBuffer[0:SignatureSize]\r
@@ -277,7 +278,7 @@ if __name__ == '__main__':
     Process = subprocess.Popen('%s smime -verify -inform DER -content %s -CAfile %s' % (OpenSslCommand, args.OutputFileName, args.TrustedPublicCertFileName), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
     Process.communicate(input=args.SignatureBuffer)[0]\r
     if Process.returncode <> 0:\r
-      print 'ERROR: Verification failed'\r
+      print('ERROR: Verification failed')\r
       os.remove (args.OutputFileName)\r
       sys.exit(Process.returncode)\r
 \r
index 9711de8f5c2eb2d58ac255cca25ca9a9402b165b..41bcaa0437c516826fa852ce3278f1dd7aaccb4f 100644 (file)
@@ -22,6 +22,7 @@
 '''\r
 Rsa2048Sha256GenerateKeys\r
 '''\r
+from __future__ import print_function\r
 \r
 import os\r
 import sys\r
@@ -75,14 +76,14 @@ if __name__ == '__main__':
   try:\r
     Process = subprocess.Popen('%s version' % (OpenSslCommand), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
   except:  \r
-    print 'ERROR: Open SSL command not available.  Please verify PATH or set OPENSSL_PATH'\r
+    print('ERROR: Open SSL command not available.  Please verify PATH or set OPENSSL_PATH')\r
     sys.exit(1)\r
     \r
   Version = Process.communicate()\r
   if Process.returncode <> 0:\r
-    print 'ERROR: Open SSL command not available.  Please verify PATH or set OPENSSL_PATH'\r
+    print('ERROR: Open SSL command not available.  Please verify PATH or set OPENSSL_PATH')\r
     sys.exit(Process.returncode)\r
-  print Version[0]\r
+  print(Version[0])\r
   \r
   args.PemFileName = []\r
   \r
@@ -103,7 +104,7 @@ if __name__ == '__main__':
       Process = subprocess.Popen('%s genrsa -out %s 2048' % (OpenSslCommand, Item.name), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
       Process.communicate()\r
       if Process.returncode <> 0:\r
-        print 'ERROR: RSA 2048 key generation failed'\r
+        print('ERROR: RSA 2048 key generation failed')\r
         sys.exit(Process.returncode)\r
       \r
   #\r
@@ -125,7 +126,7 @@ if __name__ == '__main__':
     Process = subprocess.Popen('%s rsa -in %s -modulus -noout' % (OpenSslCommand, Item), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
     PublicKeyHexString = Process.communicate()[0].split('=')[1].strip()\r
     if Process.returncode <> 0:\r
-      print 'ERROR: Unable to extract public key from private key'\r
+      print('ERROR: Unable to extract public key from private key')\r
       sys.exit(Process.returncode)\r
     PublicKey = ''\r
     for Index in range (0, len(PublicKeyHexString), 2):\r
@@ -138,7 +139,7 @@ if __name__ == '__main__':
     Process.stdin.write (PublicKey)\r
     PublicKeyHash = PublicKeyHash + Process.communicate()[0]\r
     if Process.returncode <> 0:\r
-      print 'ERROR: Unable to extract SHA 256 hash of public key'\r
+      print('ERROR: Unable to extract SHA 256 hash of public key')\r
       sys.exit(Process.returncode)\r
 \r
   #\r
@@ -171,4 +172,4 @@ if __name__ == '__main__':
   # If verbose is enabled display the public key in C structure format\r
   #\r
   if args.Verbose:\r
-    print 'PublicKeySha256 = ' + PublicKeyHashC    \r
+    print('PublicKeySha256 = ' + PublicKeyHashC)\r
index d36a14ffb7756eddb346d752058dbbd01f7909b3..2944b634fb7a27298bccf09f5cac14f3d9150048 100644 (file)
@@ -17,6 +17,7 @@
 '''\r
 Rsa2048Sha256Sign\r
 '''\r
+from __future__ import print_function\r
 \r
 import os\r
 import sys\r
@@ -96,14 +97,14 @@ if __name__ == '__main__':
   try:\r
     Process = subprocess.Popen('%s version' % (OpenSslCommand), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
   except:  \r
-    print 'ERROR: Open SSL command not available.  Please verify PATH or set OPENSSL_PATH'\r
+    print('ERROR: Open SSL command not available.  Please verify PATH or set OPENSSL_PATH')\r
     sys.exit(1)\r
     \r
   Version = Process.communicate()\r
   if Process.returncode <> 0:\r
-    print 'ERROR: Open SSL command not available.  Please verify PATH or set OPENSSL_PATH'\r
+    print('ERROR: Open SSL command not available.  Please verify PATH or set OPENSSL_PATH')\r
     sys.exit(Process.returncode)\r
-  print Version[0]\r
+  print(Version[0])\r
   \r
   #\r
   # Read input file into a buffer and save input filename\r
@@ -117,7 +118,7 @@ if __name__ == '__main__':
   #\r
   OutputDir = os.path.dirname(args.OutputFile)\r
   if not os.path.exists(OutputDir):\r
-    print 'ERROR: The output path does not exist: %s' % OutputDir\r
+    print('ERROR: The output path does not exist: %s' % OutputDir)\r
     sys.exit(1)\r
   args.OutputFileName = args.OutputFile\r
 \r
@@ -144,7 +145,7 @@ if __name__ == '__main__':
       args.PrivateKeyFile = open(args.PrivateKeyFileName, 'rb')\r
       args.PrivateKeyFile.close()\r
     except:\r
-      print 'ERROR: test signing private key file %s missing' % (args.PrivateKeyFileName)\r
+      print('ERROR: test signing private key file %s missing' % (args.PrivateKeyFileName))\r
       sys.exit(1)\r
 \r
   #\r
@@ -202,14 +203,14 @@ if __name__ == '__main__':
     # Verify that the Hash Type matches the expected SHA256 type\r
     #\r
     if uuid.UUID(bytes_le = Header.HashType) <> EFI_HASH_ALGORITHM_SHA256_GUID:\r
-      print 'ERROR: unsupport hash GUID'\r
+      print('ERROR: unsupport hash GUID')\r
       sys.exit(1)\r
 \r
     #\r
     # Verify the public key\r
     #\r
     if Header.PublicKey <> PublicKey:\r
-      print 'ERROR: Public key in input file does not match public key from private key file'\r
+      print('ERROR: Public key in input file does not match public key from private key file')\r
       sys.exit(1)\r
 \r
     FullInputFileBuffer = args.InputFileBuffer\r
@@ -228,7 +229,7 @@ if __name__ == '__main__':
     Process = subprocess.Popen('%s dgst -sha256 -prverify "%s" -signature %s' % (OpenSslCommand, args.PrivateKeyFileName, args.OutputFileName), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)\r
     Process.communicate(input=FullInputFileBuffer)\r
     if Process.returncode <> 0:\r
-      print 'ERROR: Verification failed'\r
+      print('ERROR: Verification failed')\r
       os.remove (args.OutputFileName)\r
       sys.exit(Process.returncode)\r
 \r
index 9fb89549cc29fed836f7585520327dedaf337542..0d4a59198e7bd84a628093fd733894a37d453e4a 100644 (file)
@@ -12,6 +12,7 @@
 #  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 #\r
 \r
+from __future__ import print_function\r
 import Common.LongFilePathOs as os\r
 import sys\r
 import traceback\r
@@ -32,7 +33,7 @@ class TargetTool():
         self.Arg       = args[0]\r
         self.FileName  = os.path.normpath(os.path.join(self.WorkSpace, 'Conf', 'target.txt'))\r
         if os.path.isfile(self.FileName) == False:\r
-            print "%s does not exist." % self.FileName\r
+            print("%s does not exist." % self.FileName)\r
             sys.exit(1)\r
         self.TargetTxtDictionary = {\r
             TAB_TAT_DEFINES_ACTIVE_PLATFORM                            : None,\r
@@ -83,14 +84,14 @@ class TargetTool():
         errMsg  = ''\r
         for Key in self.TargetTxtDictionary:\r
             if type(self.TargetTxtDictionary[Key]) == type([]):\r
-                print "%-30s = %s" % (Key, ''.join(elem + ' ' for elem in self.TargetTxtDictionary[Key]))\r
+                print("%-30s = %s" % (Key, ''.join(elem + ' ' for elem in self.TargetTxtDictionary[Key])))\r
             elif self.TargetTxtDictionary[Key] is None:\r
                 errMsg += "  Missing %s configuration information, please use TargetTool to set value!" % Key + os.linesep \r
             else:\r
-                print "%-30s = %s" % (Key, self.TargetTxtDictionary[Key])\r
+                print("%-30s = %s" % (Key, self.TargetTxtDictionary[Key]))\r
         \r
         if errMsg != '':\r
-            print os.linesep + 'Warning:' + os.linesep + errMsg\r
+            print(os.linesep + 'Warning:' + os.linesep + errMsg)\r
             \r
     def RWFile(self, CommentCharacter, KeySplitCharacter, Num):\r
         try:\r
@@ -109,7 +110,7 @@ class TargetTool():
                             if Key not in existKeys:\r
                                 existKeys.append(Key)\r
                             else:\r
-                                print "Warning: Found duplicate key item in original configuration files!"\r
+                                print("Warning: Found duplicate key item in original configuration files!")\r
                                 \r
                             if Num == 0:\r
                                 Line = "%-30s = \n" % Key\r
@@ -120,7 +121,7 @@ class TargetTool():
                             fw.write(Line)\r
             for key in self.TargetTxtDictionary:\r
                 if key not in existKeys:\r
-                    print "Warning: %s does not exist in original configuration file" % key\r
+                    print("Warning: %s does not exist in original configuration file" % key)\r
                     Line = GetConfigureKeyValue(self, key)\r
                     if Line is None:\r
                         Line = "%-30s = " % key\r
@@ -223,25 +224,25 @@ if __name__ == '__main__':
     EdkLogger.Initialize()\r
     EdkLogger.SetLevel(EdkLogger.QUIET)\r
     if os.getenv('WORKSPACE') is None:\r
-        print "ERROR: WORKSPACE should be specified or edksetup script should be executed before run TargetTool"\r
+        print("ERROR: WORKSPACE should be specified or edksetup script should be executed before run TargetTool")\r
         sys.exit(1)\r
         \r
     (opt, args) = MyOptionParser()\r
     if len(args) != 1 or (args[0].lower() != 'print' and args[0].lower() != 'clean' and args[0].lower() != 'set'):\r
-        print "The number of args isn't 1 or the value of args is invalid."\r
+        print("The number of args isn't 1 or the value of args is invalid.")\r
         sys.exit(1)\r
     if opt.NUM is not None and opt.NUM < 1:\r
-        print "The MAX_CONCURRENT_THREAD_NUMBER must be larger than 0."\r
+        print("The MAX_CONCURRENT_THREAD_NUMBER must be larger than 0.")\r
         sys.exit(1)\r
     if opt.TARGET is not None and len(opt.TARGET) > 1:\r
         for elem in opt.TARGET:\r
             if elem == '0':\r
-                print "0 will clear the TARGET setting in target.txt and can't combine with other value."\r
+                print("0 will clear the TARGET setting in target.txt and can't combine with other value.")\r
                 sys.exit(1)\r
     if opt.TARGET_ARCH is not None and len(opt.TARGET_ARCH) > 1:\r
         for elem in opt.TARGET_ARCH:\r
             if elem == '0':\r
-                print "0 will clear the TARGET_ARCH setting in target.txt and can't combine with other value."\r
+                print("0 will clear the TARGET_ARCH setting in target.txt and can't combine with other value.")\r
                 sys.exit(1)\r
 \r
     try:\r
index ca21e6995217485303d956978529c47176b1e784..afa5b2407ec55eae2ca77ae3bd6343eb04f296db 100644 (file)
@@ -14,6 +14,7 @@
 '''\r
 ExpressionValidate\r
 '''\r
+from __future__ import print_function\r
 \r
 ##\r
 # Import Modules\r
@@ -566,7 +567,7 @@ def IsValidFeatureFlagExp(Token, Flag=False):
 \r
 if __name__ == '__main__':\r
 #    print IsValidRangeExpr('LT 9')\r
-    print _LogicalExpressionParser('gCrownBayTokenSpaceGuid.PcdPciDevice1BridgeAddressLE0').IsValidLogicalExpression()\r
+    print(_LogicalExpressionParser('gCrownBayTokenSpaceGuid.PcdPciDevice1BridgeAddressLE0').IsValidLogicalExpression())\r
 \r
 \r
     \r
index 299cd871444b0614b4d30e74841e8bb70496d246..a464cbf702f7eb29f6fee2679b9dceb5271af520 100644 (file)
@@ -14,6 +14,7 @@
 """\r
 Collect all defined strings in multiple uni files\r
 """\r
+from __future__ import print_function\r
 \r
 ##\r
 # Import Modules\r
@@ -730,7 +731,7 @@ class UniFileClassObject(object):
                     EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, ExtraData=File.Path)\r
                 NewLines.append(Line)\r
             else:\r
-                print Line\r
+                print(Line)\r
                 EdkLogger.Error("Unicode File Parser", ToolError.FORMAT_INVALID, ExtraData=File.Path)\r
                     \r
         if StrName and not StrName.split()[1].startswith(u'STR_'):\r
@@ -1022,12 +1023,12 @@ class UniFileClassObject(object):
     # Show the instance itself\r
     #\r
     def ShowMe(self):\r
-        print self.LanguageDef\r
+        print(self.LanguageDef)\r
         #print self.OrderedStringList\r
         for Item in self.OrderedStringList:\r
-            print Item\r
+            print(Item)\r
             for Member in self.OrderedStringList[Item]:\r
-                print str(Member)\r
+                print(str(Member))\r
     \r
     #\r
     # Read content from '!include' UNI file \r
index 436dc90e6dd3a48880e53cfd6157262cc1abb70c..074aa311f31da7e9574a8a7245c450d5e27d6353 100644 (file)
@@ -15,6 +15,7 @@
 '''\r
 DecPomAlignment\r
 '''\r
+from __future__ import print_function\r
 \r
 ##\r
 # Import Modules\r
@@ -902,47 +903,47 @@ class DecPomAlignment(PackageObject):
     # Print all members and their values of Package class\r
     #\r
     def ShowPackage(self):\r
-        print '\nName =', self.GetName()\r
-        print '\nBaseName =', self.GetBaseName()\r
-        print '\nVersion =', self.GetVersion() \r
-        print '\nGuid =', self.GetGuid()\r
+        print('\nName =', self.GetName())\r
+        print('\nBaseName =', self.GetBaseName())\r
+        print('\nVersion =', self.GetVersion())\r
+        print('\nGuid =', self.GetGuid())\r
         \r
-        print '\nStandardIncludes = %d ' \\r
-            % len(self.GetStandardIncludeFileList()),\r
+        print('\nStandardIncludes = %d ' \\r
+            % len(self.GetStandardIncludeFileList()), end=' ')\r
         for Item in self.GetStandardIncludeFileList():\r
-            print Item.GetFilePath(), '  ', Item.GetSupArchList()\r
-        print '\nPackageIncludes = %d \n' \\r
-            % len(self.GetPackageIncludeFileList()),\r
+            print(Item.GetFilePath(), '  ', Item.GetSupArchList())\r
+        print('\nPackageIncludes = %d \n' \\r
+            % len(self.GetPackageIncludeFileList()), end=' ')\r
         for Item in self.GetPackageIncludeFileList():\r
-            print Item.GetFilePath(), '  ', Item.GetSupArchList()\r
+            print(Item.GetFilePath(), '  ', Item.GetSupArchList())\r
              \r
-        print '\nGuids =', self.GetGuidList()\r
+        print('\nGuids =', self.GetGuidList())\r
         for Item in self.GetGuidList():\r
-            print Item.GetCName(), Item.GetGuid(), Item.GetSupArchList()\r
-        print '\nProtocols =', self.GetProtocolList()\r
+            print(Item.GetCName(), Item.GetGuid(), Item.GetSupArchList())\r
+        print('\nProtocols =', self.GetProtocolList())\r
         for Item in self.GetProtocolList():\r
-            print Item.GetCName(), Item.GetGuid(), Item.GetSupArchList()\r
-        print '\nPpis =', self.GetPpiList()\r
+            print(Item.GetCName(), Item.GetGuid(), Item.GetSupArchList())\r
+        print('\nPpis =', self.GetPpiList())\r
         for Item in self.GetPpiList():\r
-            print Item.GetCName(), Item.GetGuid(), Item.GetSupArchList()\r
-        print '\nLibraryClasses =', self.GetLibraryClassList()\r
+            print(Item.GetCName(), Item.GetGuid(), Item.GetSupArchList())\r
+        print('\nLibraryClasses =', self.GetLibraryClassList())\r
         for Item in self.GetLibraryClassList():\r
-            print Item.GetLibraryClass(), Item.GetRecommendedInstance(), \\r
-            Item.GetSupArchList()\r
-        print '\nPcds =', self.GetPcdList()\r
+            print(Item.GetLibraryClass(), Item.GetRecommendedInstance(), \\r
+            Item.GetSupArchList())\r
+        print('\nPcds =', self.GetPcdList())\r
         for Item in self.GetPcdList():\r
-            print 'CName=', Item.GetCName(), 'TokenSpaceGuidCName=', \\r
+            print('CName=', Item.GetCName(), 'TokenSpaceGuidCName=', \\r
                 Item.GetTokenSpaceGuidCName(), \\r
                 'DefaultValue=', Item.GetDefaultValue(), \\r
                 'ValidUsage=', Item.GetValidUsage(), \\r
                 'SupArchList', Item.GetSupArchList(), \\r
-                'Token=', Item.GetToken(), 'DatumType=', Item.GetDatumType()\r
+                'Token=', Item.GetToken(), 'DatumType=', Item.GetDatumType())\r
  \r
         for Item in self.GetMiscFileList():\r
-            print Item.GetName()\r
+            print(Item.GetName())\r
             for FileObjectItem in Item.GetFileList():\r
-                print FileObjectItem.GetURI()\r
-        print '****************\n'\r
+                print(FileObjectItem.GetURI())\r
+        print('****************\n')\r
 \r
 ## GenPcdDeclaration\r
 #\r
index 8b4ece2617a1a7dbbdcc5a1eee0bd9d31f3c0da3..5f0abcafef27927b77c6baa3d5b452340bfede8d 100644 (file)
@@ -11,6 +11,7 @@
 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
+from __future__ import print_function\r
 import os\r
 import unittest\r
 \r
@@ -66,7 +67,7 @@ def TestTemplate(TestString, TestFunc):
         # Close file\r
         f.close()\r
     except:\r
-        print 'Can not create temporary file [%s]!' % Path\r
+        print('Can not create temporary file [%s]!' % Path)\r
         exit(-1)\r
 \r
     # Call test function to test\r
@@ -279,6 +280,6 @@ if __name__ == '__main__':
     unittest.FunctionTestCase(TestDecPcd).runTest()\r
     unittest.FunctionTestCase(TestDecUserExtension).runTest()\r
 \r
-    print 'All tests passed...'\r
+    print('All tests passed...')\r
 \r
 \r
index f3b43ee0bc2754949a725057c948f2b12b053a89..626f17426de77f1a024347f8669a27b2d3f27baf 100644 (file)
@@ -11,6 +11,7 @@
 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
+from __future__ import print_function\r
 import os\r
 #import Object.Parser.InfObject as InfObject\r
 from Object.Parser.InfCommonObject import CurrentLine\r
@@ -271,7 +272,7 @@ def PrepareTest(String):
                 TempFile  = open (FileName, "w")    \r
                 TempFile.close()\r
             except:\r
-                print "File Create Error"\r
+                print("File Create Error")\r
         CurrentLine = CurrentLine()\r
         CurrentLine.SetFileName("Test")\r
         CurrentLine.SetLineString(Item[0])\r
@@ -376,11 +377,11 @@ if __name__ == '__main__':
             try:\r
                 InfBinariesInstance.SetBinary(Ver = Ver, ArchList = ArchList)\r
             except:\r
-                print "Test Failed!"\r
+                print("Test Failed!")\r
                 AllPassedFlag = False\r
     \r
     if AllPassedFlag :\r
-        print 'All tests passed...'\r
+        print('All tests passed...')\r
     else:\r
-        print 'Some unit test failed!'\r
+        print('Some unit test failed!')\r
 \r
index a001162e8e3b74315f90d1a837e0116b5f6d1f1a..7f289c103fb9c0a726cbf679ecb7e2276465d57f 100644 (file)
@@ -17,6 +17,7 @@
 #  This class is used to retrieve information stored in database and convert them\r
 # into PlatformBuildClassObject form for easier use for AutoGen.\r
 #\r
+from __future__ import print_function\r
 from Common.StringUtils import *\r
 from Common.DataType import *\r
 from Common.Misc import *\r
@@ -1373,7 +1374,7 @@ class DscBuildData(PlatformBuildClassObject):
             for (skuname,StoreName,PcdGuid,PcdName,PcdValue) in Str_Pcd_Values:\r
                 str_pcd_obj = S_pcd_set.get((PcdName, PcdGuid))\r
                 if str_pcd_obj is None:\r
-                    print PcdName, PcdGuid\r
+                    print(PcdName, PcdGuid)\r
                     raise\r
                 if str_pcd_obj.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_HII],\r
                                         self._PCD_TYPE_STRING_[MODEL_PCD_DYNAMIC_EX_HII]]:\r
@@ -1808,7 +1809,7 @@ class DscBuildData(PlatformBuildClassObject):
                         EdkLogger.error('Build', FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " %\r
                                         (".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName)), FieldList[FieldName][1], FieldList[FieldName][2]))\r
                     except:\r
-                        print "error"\r
+                        print("error")\r
                 try:\r
                     Value, ValueSize = ParseFieldValue (FieldList[FieldName][0])\r
                 except Exception:\r
index f1cfa73fd4f2a0df111b1c76bbd88f0cff8b2981..d5fbf6f095bf502d3dd9b4b412209747d224db7f 100644 (file)
@@ -15,6 +15,7 @@
 ##\r
 # Import Modules\r
 #\r
+from __future__ import print_function\r
 import Common.LongFilePathOs as os\r
 import re\r
 import time\r
@@ -1630,7 +1631,7 @@ class DscParser(MetaFileParser):
         try:\r
             self._ValueList[2] = '|'.join(ValList)\r
         except Exception:\r
-            print ValList\r
+            print(ValList)\r
 \r
     def __ProcessComponent(self):\r
         self._ValueList[0] = ReplaceMacro(self._ValueList[0], self._Macros)\r
index 4600c46be1beca44bb3ab33b55404f24904636df..416aa73549d115b1acfe877c45aa836f73e7200f 100644 (file)
@@ -16,6 +16,7 @@
 ##\r
 # Import Modules\r
 #\r
+from __future__ import print_function\r
 import Common.LongFilePathOs as os\r
 import re\r
 import StringIO\r
@@ -2195,7 +2196,7 @@ class Build():
                     toolsFile = os.path.join(FvDir, 'GuidedSectionTools.txt')\r
                     toolsFile = open(toolsFile, 'wt')\r
                     for guidedSectionTool in guidAttribs:\r
-                        print >> toolsFile, ' '.join(guidedSectionTool)\r
+                        print(' '.join(guidedSectionTool), file=toolsFile)\r
                     toolsFile.close()\r
 \r
     ## Returns the full path of the tool.\r
index 27afd79f2094dd742c72a2b13525bb685bc9f3b9..be7b4ad4285628bdb942ef9279ccf6b6e29f19df 100644 (file)
@@ -1,3 +1,4 @@
+from __future__ import print_function\r
 ## @file\r
 # Utility functions and classes for BaseTools unit tests\r
 #\r
@@ -91,9 +92,9 @@ class BaseToolsTest(unittest.TestCase):
             os.remove(path)\r
 \r
     def DisplayBinaryData(self, description, data):\r
-        print description, '(base64 encoded):'\r
+        print(description, '(base64 encoded):')\r
         b64data = base64.b64encode(data)\r
-        print b64data\r
+        print(b64data)\r
 \r
     def DisplayFile(self, fileName):\r
         sys.stdout.write(self.ReadTmpFile(fileName))\r
index e141364162118142df6bfa92b907a4b735f62839..f6a4a6ae9c5d9fcda91c8434d47347247a2e1f73 100644 (file)
@@ -15,6 +15,7 @@
 ##\r
 # Import Modules\r
 #\r
+from __future__ import print_function\r
 import os\r
 import random\r
 import sys\r
@@ -52,8 +53,8 @@ class Tests(TestTools.BaseToolsTest):
         finish = self.ReadTmpFile('output2')\r
         startEqualsFinish = start == finish\r
         if not startEqualsFinish:\r
-            print\r
-            print 'Original data did not match decompress(compress(data))'\r
+            print()\r
+            print('Original data did not match decompress(compress(data))')\r
             self.DisplayBinaryData('original data', start)\r
             self.DisplayBinaryData('after compression', self.ReadTmpFile('output1'))\r
             self.DisplayBinaryData('after decomression', finish)\r
index 7b1076c38bb5965bda43806761ba5a63f262c2e9..20984d3ec8785990908aeecbb3cfc1f75707f3b8 100755 (executable)
@@ -17,6 +17,7 @@
 #
 
 
+from __future__ import print_function\r
 from optparse import OptionParser
 import os
 import shutil
@@ -34,7 +35,7 @@ if sys.version_info < (2, 5):
     #
     # This script (and edk2 BaseTools) require Python 2.5 or newer
     #
-    print 'Python version 2.5 or later is required.'
+    print('Python version 2.5 or later is required.')\r
     sys.exit(-1)
 
 #
@@ -146,37 +147,37 @@ class Config:
         if not self.options.skip_gcc:
             building.append('gcc')
         if len(building) == 0:
-            print "Nothing will be built!"
-            print
-            print "Please try using --help and then change the configuration."
+            print("Nothing will be built!")\r
+            print()\r
+            print("Please try using --help and then change the configuration.")\r
             return False
 
-        print "Current directory:"
-        print "   ", self.base_dir
-        print "Sources download/extraction:", self.Relative(self.src_dir)
-        print "Build directory            :", self.Relative(self.build_dir)
-        print "Prefix (install) directory :", self.Relative(self.prefix)
-        print "Create symlinks directory  :", self.Relative(self.symlinks)
-        print "Building                   :", ', '.join(building)
-        print
+        print("Current directory:")\r
+        print("   ", self.base_dir)\r
+        print("Sources download/extraction:", self.Relative(self.src_dir))\r
+        print("Build directory            :", self.Relative(self.build_dir))\r
+        print("Prefix (install) directory :", self.Relative(self.prefix))\r
+        print("Create symlinks directory  :", self.Relative(self.symlinks))\r
+        print("Building                   :", ', '.join(building))\r
+        print()\r
         answer = raw_input("Is this configuration ok? (default = no): ")
         if (answer.lower() not in ('y', 'yes')):
-            print
-            print "Please try using --help and then change the configuration."
+            print()\r
+            print("Please try using --help and then change the configuration.")\r
             return False
 
         if self.arch.lower() == 'ipf':
-            print
-            print 'Please note that the IPF compiler built by this script has'
-            print 'not yet been validated!'
-            print
+            print()\r
+            print('Please note that the IPF compiler built by this script has')\r
+            print('not yet been validated!')\r
+            print()\r
             answer = raw_input("Are you sure you want to build it? (default = no): ")
             if (answer.lower() not in ('y', 'yes')):
-                print
-                print "Please try using --help and then change the configuration."
+                print()\r
+                print("Please try using --help and then change the configuration.")\r
                 return False
 
-        print
+        print()\r
         return True
 
     def Relative(self, path):
@@ -275,7 +276,7 @@ class SourceFiles:
             wDots = (100 * received * blockSize) / fileSize / 10
             if wDots > self.dots:
                 for i in range(wDots - self.dots):
-                    print '.',
+                    print('.', end=' ')\r
                     sys.stdout.flush()
                     self.dots += 1
 
@@ -286,18 +287,18 @@ class SourceFiles:
                     self.dots = 0
                     local_file = os.path.join(self.config.src_dir, fdata['filename'])
                     url = fdata['url']
-                    print 'Downloading %s:' % fname, url
+                    print('Downloading %s:' % fname, url)\r
                     if retries > 0:
-                        print '(retry)',
+                        print('(retry)', end=' ')\r
                     sys.stdout.flush()
 
                     completed = False
                     if os.path.exists(local_file):
                         md5_pass = self.checkHash(fdata)
                         if md5_pass:
-                            print '[md5 match]',
+                            print('[md5 match]', end=' ')\r
                         else:
-                            print '[md5 mismatch]',
+                            print('[md5 mismatch]', end=' ')\r
                         sys.stdout.flush()
                         completed = md5_pass
 
@@ -313,32 +314,32 @@ class SourceFiles:
                     if not completed and os.path.exists(local_file):
                         md5_pass = self.checkHash(fdata)
                         if md5_pass:
-                            print '[md5 match]',
+                            print('[md5 match]', end=' ')\r
                         else:
-                            print '[md5 mismatch]',
+                            print('[md5 mismatch]', end=' ')\r
                         sys.stdout.flush()
                         completed = md5_pass
 
                     if completed:
-                        print '[done]'
+                        print('[done]')\r
                         break
                     else:
-                        print '[failed]'
-                        print '  Tried to retrieve', url
-                        print '  to', local_file
-                        print 'Possible fixes:'
-                        print '* If you are behind a web-proxy, try setting the',
-                        print 'http_proxy environment variable'
-                        print '* You can try to download this file separately',
-                        print 'and rerun this script'
+                        print('[failed]')\r
+                        print('  Tried to retrieve', url)\r
+                        print('  to', local_file)\r
+                        print('Possible fixes:')\r
+                        print('* If you are behind a web-proxy, try setting the', end=' ')\r
+                        print('http_proxy environment variable')\r
+                        print('* You can try to download this file separately', end=' ')\r
+                        print('and rerun this script')\r
                         raise Exception()
                 
                 except KeyboardInterrupt:
-                    print '[KeyboardInterrupt]'
+                    print('[KeyboardInterrupt]')\r
                     return False
 
                 except Exception as e:\r
-                    print e
+                    print(e)\r
 
             if not completed: return False
 
@@ -396,7 +397,7 @@ class Extracter:
             extractedMd5 = open(extracted).read()
 
         if extractedMd5 != moduleMd5:
-            print 'Extracting %s:' % self.config.Relative(local_file)
+            print('Extracting %s:' % self.config.Relative(local_file))\r
             tar = tarfile.open(local_file)
             tar.extractall(extractDst)
             open(extracted, 'w').write(moduleMd5)
@@ -480,7 +481,7 @@ class Builder:
 
         os.chdir(base_dir)
 
-        print '%s module is now built and installed' % module
+        print('%s module is now built and installed' % module)\r
 
     def RunCommand(self, cmd, module, stage, skipable=False):
         if skipable:
@@ -495,13 +496,13 @@ class Builder:
                 stderr=subprocess.STDOUT
                 )
 
-        print '%s [%s] ...' % (module, stage),
+        print('%s [%s] ...' % (module, stage), end=' ')\r
         sys.stdout.flush()
         p = popen(cmd)
         output = p.stdout.read()
         p.wait()
         if p.returncode != 0:
-            print '[failed!]'
+            print('[failed!]')\r
             logFile = os.path.join(self.config.build_dir, 'log.txt')
             f = open(logFile, "w")
             f.write(output)
@@ -509,7 +510,7 @@ class Builder:
             raise Exception, 'Failed to %s %s\n' % (stage, module) + \
                 'See output log at %s' % self.config.Relative(logFile)
         else:
-            print '[done]'
+            print('[done]')\r
 
         if skipable:
             self.MarkBuildStepComplete('%s.%s' % (module, stage))
@@ -526,13 +527,13 @@ class Builder:
             linkdst = os.path.join(links_dir, link)
             if not os.path.lexists(linkdst):
                 if not startPrinted:
-                    print 'Making symlinks in %s:' % self.config.Relative(links_dir),
+                    print('Making symlinks in %s:' % self.config.Relative(links_dir), end=' ')\r
                     startPrinted = True
-                print link,
+                print(link, end=' ')\r
                 os.symlink(src, linkdst)
 
         if startPrinted:
-            print '[done]'
+            print('[done]')\r
 
 class App:
     """class App
@@ -551,9 +552,9 @@ class App:
         sources = SourceFiles(config)
         result = sources.GetAll()
         if result:
-            print 'All files have been downloaded & verified'
+            print('All files have been downloaded & verified')\r
         else:
-            print 'An error occured while downloading a file'
+            print('An error occured while downloading a file')\r
             return
 
         Extracter(sources, config).ExtractAll()