<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def setpurpose(self, purpose):
 """ Sets certificate purpose which verified certificate should match @param purpose - number from 1 to 9 or standard strind defined in Openssl possible strings - sslcient,sslserver, nssslserver, smimesign,i smimeencrypt, crlsign, any, ocsphelper """

        if isinstance(purpose, str):
            purp_no = libcrypto.X509_PURPOSE_get_by_sname(purpose)
            if purp_no <= 0:
                raise X509Error("Invalid certificate purpose '%s'" % purpose)
        elif isinstance(purpose, int):
            purp_no = purpose
        if libcrypto.X509_STORE_set_purpose(self.store, purp_no) <= 0:
            raise X509Error("cannot set purpose")