edk2toollib/uefi/edk2/path_utilities.py
def GetEdk2RelativePathFromAbsolutePath(self, abspath):
        ''' Given an absolute path return a edk2 path relative
        to workspace or packagespath.

        If not valid return None
        '''

        relpath = None
        found = False
        if abspath is None:
            return None
        for a in (os.path.normcase(p) for p in self.PackagePathList):
            a = a if a.endswith(os.sep) else a + os.sep  # add sep if no trailing separater

            # iterate over a normalized case of packages path including trailing separater
            # to ensure match is of full directory path.
            if os.path.normcase(abspath).startswith(a):
                # found our path...now use original strings to avoid
                # change in case
                relpath = abspath[len(a):]
                found = True
                self.logger.debug("Successfully converted AbsPath to Edk2Relative Path using PackagePath")
                self.logger.debug("AbsolutePath: %s found in PackagePath: %s" % (abspath, a))
                break

        if(not found):
            # Does path start with workspace path
            wsp = self.WorkspacePath if self.WorkspacePath.endswith(os.sep) else self.WorkspacePath + os.sep
            if os.path.normcase(abspath).startswith(os.path.normcase(wsp)):
                # found our path...now use original strings to avoid
                # change in case
                relpath = abspath[len(wsp):]
                found = True
                self.logger.debug("Successfully converted AbsPath to Edk2Relative Path using WorkspacePath")
                self.logger.debug("AbsolutePath: %s found in Workspace: %s" % (abspath, self.WorkspacePath))

        if(found):
            relpath = relpath.replace(os.sep, "/")
            return relpath.lstrip("/")

        # didn't find the path for conversion.
        self.logger.error("Failed to convert AbsPath to Edk2Relative Path")
        self.logger.error("AbsolutePath: %s" % abspath)
        return None
 Given an absolute path return a edk2 path relative
        to workspace or packagespath.

        If not valid return None
        
Given an absolute path return a edk2 path relative
to workspace or packagespath.

If not valid return None
Given an absolute path return a edk2 path relative to workspace or packagespath . If not valid return None
def GetEdk2RelativePathFromAbsolutePath(self, abspath):
        relpath = None
        found = False
        if abspath is None:
            return None
        for a in (os.path.normcase(p) for p in self.PackagePathList):
            a = a if a.endswith(os.sep) else a + os.sep  
            if os.path.normcase(abspath).startswith(a):
                relpath = abspath[len(a):]
                found = True
                self.logger.debug("Successfully converted AbsPath to Edk2Relative Path using PackagePath")
                self.logger.debug("AbsolutePath: %s found in PackagePath: %s" % (abspath, a))
                break
        if(not found):
            wsp = self.WorkspacePath if self.WorkspacePath.endswith(os.sep) else self.WorkspacePath + os.sep
            if os.path.normcase(abspath).startswith(os.path.normcase(wsp)):
                relpath = abspath[len(wsp):]
                found = True
                self.logger.debug("Successfully converted AbsPath to Edk2Relative Path using WorkspacePath")
                self.logger.debug("AbsolutePath: %s found in Workspace: %s" % (abspath, self.WorkspacePath))
        if(found):
            relpath = relpath.replace(os.sep, "/")
            return relpath.lstrip("/")
        self.logger.error("Failed to convert AbsPath to Edk2Relative Path")
        self.logger.error("AbsolutePath: %s" % abspath)
        return None
def GetEdk2RelativePathFromAbsolutePath ( self , abspath ) : relpath = None found = False if abspath is None : return None for a in ( os . path . normcase ( p ) for p in self . PackagePathList ) : a = a if a . endswith ( os . sep ) else a + os . sep if os . path . normcase ( abspath ) . startswith ( a ) : relpath = abspath [ len ( a ) : ] found = True self . logger . debug ( "Successfully converted AbsPath to Edk2Relative Path using PackagePath" ) self . logger . debug ( "AbsolutePath: %s found in PackagePath: %s" % ( abspath , a ) ) break if ( not found ) : wsp = self . WorkspacePath if self . WorkspacePath . endswith ( os . sep ) else self . WorkspacePath + os . sep if os . path . normcase ( abspath ) . startswith ( os . path . normcase ( wsp ) ) : relpath = abspath [ len ( wsp ) : ] found = True self . logger . debug ( "Successfully converted AbsPath to Edk2Relative Path using WorkspacePath" ) self . logger . debug ( "AbsolutePath: %s found in Workspace: %s" % ( abspath , self . WorkspacePath ) ) if ( found ) : relpath = relpath . replace ( os . sep , "/" ) return relpath . lstrip ( "/" ) self . logger . error ( "Failed to convert AbsPath to Edk2Relative Path" ) self . logger . error ( "AbsolutePath: %s" % abspath ) return None
Given an absolute path return a edk2 path relative
to workspace or packagespath.
Given an absolute path return a edk2 path relative to workspace or packagespath .
''' Given an absolute path return a edk2 path relative
        to workspace or packagespath.

        If not valid return None
        ''' # add sep if no trailing separater # iterate over a normalized case of packages path including trailing separater # to ensure match is of full directory path. # found our path...now use original strings to avoid # change in case # Does path start with workspace path # found our path...now use original strings to avoid # change in case # didn't find the path for conversion.
self
abspath