(self, tarinfo, targetpath)
Set owner of targetpath according to tarinfo.
Set owner of targetpath according to tarinfo.
Set owner of targetpath according to tarinfo .
def chown(self, tarinfo, targetpath):
        """Set owner of targetpath according to tarinfo.
        """
        if pwd and hasattr(os, "geteuid") and os.geteuid() == 0:
            # We have to be root to do so.
            try:
                g = grp.getgrnam(tarinfo.gname)[2]
            except KeyError:
                g = tarinfo.gid
            try:
                u = pwd.getpwnam(tarinfo.uname)[2]
            except KeyError:
                u = tarinfo.uid
            try:
                if tarinfo.issym() and hasattr(os, "lchown"):
                    os.lchown(targetpath, u, g)
                else:
                    if sys.platform != "os2emx":
                        os.chown(targetpath, u, g)
            except EnvironmentError as e:
                raise ExtractError("could not change owner")
def chown ( self , tarinfo , targetpath ) : if pwd and hasattr ( os , "geteuid" ) and os . geteuid ( ) == 0 : # We have to be root to do so. try : g = grp . getgrnam ( tarinfo . gname ) [ 2 ] except KeyError : g = tarinfo . gid try : u = pwd . getpwnam ( tarinfo . uname ) [ 2 ] except KeyError : u = tarinfo . uid try : if tarinfo . issym ( ) and hasattr ( os , "lchown" ) : os . lchown ( targetpath , u , g ) else : if sys . platform != "os2emx" : os . chown ( targetpath , u , g ) except EnvironmentError as e : raise ExtractError ( "could not change owner" )