(self, wanted_user)
Get user from a passwd file
Get user from a passwd file
Get user from a passwd file
def _get_user_from_file(self, wanted_user):
        """Get user from a passwd file"""
        wanted_uid = ""
        if (isinstance(wanted_user, int) or
                re.match("^\\d+$", wanted_user)):
            wanted_uid = str(wanted_user)
            wanted_user = ""
        try:
            inpasswd = open(self.passwd_file)
        except (IOError, OSError):
            return ("", "", "", "", "", "")
        else:
            for line in inpasswd:
                (user, dummy, uid, gid, gecos, home,
                 shell) = line.strip().split(':')
                if wanted_user and user == wanted_user:
                    return (user, uid, gid, gecos, home, shell)
                if wanted_uid and uid == wanted_uid:
                    return (user, uid, gid, gecos, home, shell)
            inpasswd.close()
            return ("", "", "", "", "", "")
def _get_user_from_file ( self , wanted_user ) : wanted_uid = "" if ( isinstance ( wanted_user , int ) or re . match ( "^\\d+$" , wanted_user ) ) : wanted_uid = str ( wanted_user ) wanted_user = "" try : inpasswd = open ( self . passwd_file ) except ( IOError , OSError ) : return ( "" , "" , "" , "" , "" , "" ) else : for line in inpasswd : ( user , dummy , uid , gid , gecos , home , shell ) = line . strip ( ) . split ( ':' ) if wanted_user and user == wanted_user : return ( user , uid , gid , gecos , home , shell ) if wanted_uid and uid == wanted_uid : return ( user , uid , gid , gecos , home , shell ) inpasswd . close ( ) return ( "" , "" , "" , "" , "" , "" )