]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Scripts/PackageDocumentTools/packagedoc_cli.py
BaseTools: Refactor python print statements
[mirror_edk2.git] / BaseTools / Scripts / PackageDocumentTools / packagedoc_cli.py
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