'Return the IMAP password for this repository.
It tries to get passwords in the following order:
1. evaluate Repository \'remotepasseval\'
2. read password from Repository \'remotepass\'
3. read password from file specified in Repository \'remotepassfile\'
4. read password from ~/.netrc
5. read password from /etc/netrc
On success we return the password.
If all strategies fail we return None.'

def getpassword(self):

    passwd = self.getconf('remotepasseval', None)
    if (passwd is not None):
        return self.localeval.eval(passwd).encode('UTF-8')
    password = self.getconf('remotepass', None)
    if (password is not None):
        return password
    passfile = self.getconf('remotepassfile', None)
    if (passfile is not None):
        fd = codecs.open(os.path.expanduser(passfile), 'r', 'UTF-8')
        password = fd.readline().strip()
        fd.close()
        return password.encode('UTF-8')
    try:
        netrcentry = netrc.netrc().authenticators(self.gethost())
    except IOError as inst:
        if (inst.errno != errno.ENOENT):
            raise
    else:
        if netrcentry:
            user = self.getuser()
            if ((user is None) or (user == netrcentry[0])):
                return netrcentry[2]
    try:
        netrcentry = netrc.netrc('/etc/netrc').authenticators(self.gethost())
    except IOError as inst:
        if (inst.errno not in (errno.ENOENT, errno.EACCES)):
            raise
    else:
        if netrcentry:
            user = self.getuser()
            if ((user is None) or (user == netrcentry[0])):
                return netrcentry[2]
    return None
