]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/Common/EdkIIWorkspace.py
BaseTools: expression can use single in instead of 3 API calls.
[mirror_edk2.git] / BaseTools / Source / Python / Common / EdkIIWorkspace.py
index a494e814a6e95805aeb296de1eb02ec4b05ad0c5..f22a545b77ce94fec23ae2c110fef5b333a3cec4 100644 (file)
@@ -1,8 +1,8 @@
 ## @file\r
 # This is the base class for applications that operate on an EDK II Workspace \r
 #\r
-# Copyright (c) 2007, Intel Corporation\r
-# All rights reserved. This program and the accompanying materials\r
+# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>\r
+# This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
 # http://opensource.org/licenses/bsd-license.php\r
 ##\r
 # Import Modules\r
 #\r
-import os, sys, time\r
+import Common.LongFilePathOs as os, sys, time\r
 from DataType import *\r
+from Common.LongFilePathSupport import OpenLongFilePath as open\r
+from Common.MultipleWorkspace import MultipleWorkspace as mws\r
 \r
 ## EdkIIWorkspace\r
 #\r
@@ -57,7 +59,7 @@ class EdkIIWorkspace:
             #\r
             # Load TianoCoreOrgLogo, used for GUI tool\r
             #\r
-            self.Icon = wx.Icon(self.WorkspaceFile('tools/Python/TianoCoreOrgLogo.gif'),wx.BITMAP_TYPE_GIF)\r
+            self.Icon = wx.Icon(self.WorkspaceFile('tools/Python/TianoCoreOrgLogo.gif'), wx.BITMAP_TYPE_GIF)\r
         except:\r
             self.Icon = None\r
             \r
@@ -111,7 +113,7 @@ class EdkIIWorkspace:
     # @retval string  The full path filename\r
     #\r
     def WorkspaceFile(self, FileName):\r
-        return os.path.realpath(os.path.join(self.WorkspaceDir,FileName))\r
+        return os.path.realpath(mws.join(self.WorkspaceDir,FileName))\r
 \r
     ## Convert to a real path filename\r
     #\r
@@ -149,7 +151,7 @@ class EdkIIWorkspace:
     def XmlParseFileSection (self, FileName, SectionTag):\r
         if self.Verbose:\r
             print FileName\r
-        return XmlParseFileSection (self.WorkspaceFile(FileName), SectionTag)        \r
+        return XmlParseFileSection (self.WorkspaceFile(FileName), SectionTag)\r
 \r
     ## Save a XML file\r
     #\r
@@ -217,19 +219,19 @@ class EdkIIWorkspace:
 #\r
 def ConvertTextFileToDictionary(FileName, Dictionary, CommentCharacter, KeySplitCharacter, ValueSplitFlag, ValueSplitCharacter):\r
     try:\r
-        F = open(FileName,'r')\r
+        F = open(FileName, 'r')\r
     except:\r
         return False\r
     Keys = []\r
     for Line in F:\r
-        LineList = Line.split(KeySplitCharacter,1)\r
+        LineList = Line.split(KeySplitCharacter, 1)\r
         if len(LineList) >= 2:\r
             Key = LineList[0].split()\r
-            if len(Key) == 1 and Key[0][0] != CommentCharacter and Key[0] not in Keys: \r
+            if len(Key) == 1 and Key[0][0] != CommentCharacter and Key[0] not in Keys:\r
                 if ValueSplitFlag:\r
-                    Dictionary[Key[0]] = LineList[1].replace('\\','/').split(ValueSplitCharacter)\r
+                    Dictionary[Key[0]] = LineList[1].replace('\\', '/').split(ValueSplitCharacter)\r
                 else:\r
-                    Dictionary[Key[0]] = LineList[1].strip().replace('\\','/')\r
+                    Dictionary[Key[0]] = LineList[1].strip().replace('\\', '/')\r
                 Keys += [Key[0]]\r
     F.close()\r
     return True\r
@@ -250,7 +252,7 @@ def ConvertTextFileToDictionary(FileName, Dictionary, CommentCharacter, KeySplit
 #\r
 def ConvertDictionaryToTextFile(FileName, Dictionary, CommentCharacter, KeySplitCharacter, ValueSplitFlag, ValueSplitCharacter):\r
     try:\r
-        F = open(FileName,'r')\r
+        F = open(FileName, 'r')\r
         Lines = []\r
         Lines = F.readlines()\r
         F.close()\r
@@ -263,7 +265,7 @@ def ConvertDictionaryToTextFile(FileName, Dictionary, CommentCharacter, KeySplit
             MaxLength = len(Key)\r
     Index = 0\r
     for Line in Lines:\r
-        LineList = Line.split(KeySplitCharacter,1)\r
+        LineList = Line.split(KeySplitCharacter, 1)\r
         if len(LineList) >= 2:\r
             Key = LineList[0].split()\r
             if len(Key) == 1 and Key[0][0] != CommentCharacter and Key[0] in Dictionary:\r
@@ -273,17 +275,17 @@ def ConvertDictionaryToTextFile(FileName, Dictionary, CommentCharacter, KeySplit
                     Line = '%-*s %c %s\n' % (MaxLength, Key[0], KeySplitCharacter, Dictionary[Key[0]])\r
                 Lines.pop(Index)\r
                 if Key[0] in Keys:\r
-                    Lines.insert(Index,Line)\r
+                    Lines.insert(Index, Line)\r
                     Keys.remove(Key[0])\r
         Index += 1\r
     for RemainingKey in Keys:\r
         if ValueSplitFlag:\r
-            Line = '%-*s %c %s\n' % (MaxLength, RemainingKey, KeySplitCharacter,' '.join(Dictionary[RemainingKey])) \r
+            Line = '%-*s %c %s\n' % (MaxLength, RemainingKey, KeySplitCharacter, ' '.join(Dictionary[RemainingKey]))\r
         else:\r
             Line = '%-*s %c %s\n' % (MaxLength, RemainingKey, KeySplitCharacter, Dictionary[RemainingKey])\r
         Lines.append(Line)\r
     try:\r
-        F = open(FileName,'w')\r
+        F = open(FileName, 'w')\r
     except:\r
         return False\r
     F.writelines(Lines)\r