@@ -42,11 +42,12 @@ class Edk2Path(object):
4242 #
4343 def __init__ (self , ws , packagepathlist ):
4444 self .WorkspacePath = ws
45+ self .logger = logging .getLogger ("Edk2Path" )
4546 if (not os .path .isabs (ws )):
4647 self .WorkspacePath = os .path .abspath (os .path .join (os .getcwd (), ws ))
4748
4849 if (not os .path .isdir (self .WorkspacePath )):
49- logging .error ("Workspace path invalid. {0}" .format (ws ))
50+ self . logger .error ("Workspace path invalid. {0}" .format (ws ))
5051 raise Exception ("Workspace path invalid. {0}" .format (ws ))
5152
5253 # Set PackagePath
@@ -66,7 +67,7 @@ def __init__(self, ws, packagepathlist):
6667 error = False
6768 for a in self .PackagePathList :
6869 if (not os .path .isdir (a )):
69- logging .error ("Invalid package path entry {0}" .format (a ))
70+ self . logger .error ("Invalid package path entry {0}" .format (a ))
7071 error = True
7172
7273 # report error
@@ -84,8 +85,8 @@ def GetEdk2RelativePathFromAbsolutePath(self, abspath):
8485 # found our path...now lets correct for case
8586 relpath = abspath [len (a ):]
8687 found = True
87- logging .debug ("Successfully converted AbsPath to Edk2Relative Path using PackagePath" )
88- logging .debug ("AbsolutePath: %s found in PackagePath: %s" % (abspath , a ))
88+ self . logger .debug ("Successfully converted AbsPath to Edk2Relative Path using PackagePath" )
89+ self . logger .debug ("AbsolutePath: %s found in PackagePath: %s" % (abspath , a ))
8990 break
9091
9192 if (not found ):
@@ -95,16 +96,16 @@ def GetEdk2RelativePathFromAbsolutePath(self, abspath):
9596 # found our path...now lets correct for case
9697 relpath = abspath [len (self .WorkspacePath ):]
9798 found = True
98- logging .debug ("Successfully converted AbsPath to Edk2Relative Path using WorkspacePath" )
99- logging .debug ("AbsolutePath: %s found in Workspace: %s" % (abspath , self .WorkspacePath ))
99+ self . logger .debug ("Successfully converted AbsPath to Edk2Relative Path using WorkspacePath" )
100+ self . logger .debug ("AbsolutePath: %s found in Workspace: %s" % (abspath , self .WorkspacePath ))
100101
101102 if (found ):
102103 relpath = relpath .replace (os .sep , "/" )
103104 return relpath .lstrip ("/" )
104105
105106 # didn't find the path for conversion.
106- logging .error ("Failed to convert AbsPath to Edk2Relative Path" )
107- logging .error ("AbsolutePath: %s" % abspath )
107+ self . logger .error ("Failed to convert AbsPath to Edk2Relative Path" )
108+ self . logger .error ("AbsolutePath: %s" % abspath )
108109 return None
109110
110111 def GetAbsolutePathOnThisSytemFromEdk2RelativePath (self , relpath ):
@@ -117,8 +118,8 @@ def GetAbsolutePathOnThisSytemFromEdk2RelativePath(self, relpath):
117118 abspath = os .path .join (a , relpath )
118119 if (os .path .exists (abspath )):
119120 return abspath
120- logging .error ("Failed to convert Edk2Relative Path to an Absolute Path on this system." )
121- logging .error ("Relative Path: %s" % relpath )
121+ self . logger .error ("Failed to convert Edk2Relative Path to an Absolute Path on this system." )
122+ self . logger .error ("Relative Path: %s" % relpath )
122123
123124 return None
124125
@@ -130,7 +131,7 @@ def GetAbsolutePathOnThisSytemFromEdk2RelativePath(self, relpath):
130131 #
131132 # @ret Name of Package that the module is in.
132133 def GetContainingPackage (self , InputPath ):
133- logging .debug ("GetContainingPackage: %s" % InputPath )
134+ self . logger .debug ("GetContainingPackage: %s" % InputPath )
134135
135136 dirpathprevious = os .path .dirname (InputPath )
136137 dirpath = os .path .dirname (InputPath )
@@ -141,15 +142,15 @@ def GetContainingPackage(self, InputPath):
141142 #
142143 if (dirpath in self .PackagePathList ):
143144 a = os .path .basename (dirpathprevious )
144- logging .debug ("Reached Package Path. Using previous directory: %s" % a )
145+ self . logger .debug ("Reached Package Path. Using previous directory: %s" % a )
145146 return a
146147 #
147148 # if at the root of the workspace return the previous dir.
148149 # this catches cases where a package has no DEC
149150 #
150151 if (dirpath == self .WorkspacePath ):
151152 a = os .path .basename (dirpathprevious )
152- logging .debug ("Reached Workspace Path. Using previous directory: %s" % a )
153+ self . logger .debug ("Reached Workspace Path. Using previous directory: %s" % a )
153154 return a
154155 #
155156 # Check for a DEC file in this folder
@@ -158,13 +159,13 @@ def GetContainingPackage(self, InputPath):
158159 for f in os .listdir (dirpath ):
159160 if fnmatch .fnmatch (f , '*.dec' ):
160161 a = os .path .basename (dirpath )
161- logging .debug ("Found DEC file at %s. Pkg is: %s" , dirpath , a )
162+ self . logger .debug ("Found DEC file at %s. Pkg is: %s" , dirpath , a )
162163 return a
163164
164165 dirpathprevious = dirpath
165166 dirpath = os .path .dirname (dirpath )
166167
167- logging .error ("Failed to find containing package for %s" % InputPath )
168- logging .info ("PackagePath is: %s" % os .pathsep .join (self .PackagePathList ))
169- logging .info ("Workspace path is : %s" % self .WorkspacePath )
168+ self . logger .error ("Failed to find containing package for %s" % InputPath )
169+ self . logger .info ("PackagePath is: %s" % os .pathsep .join (self .PackagePathList ))
170+ self . logger .info ("Workspace path is : %s" % self .WorkspacePath )
170171 return None
0 commit comments