<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def get_perm_by_code(perm_code,**kwargs):
 """ Get a permission by its code """


    try:
        perm = db.DBSession.query(Perm).filter(Perm.code==perm_code).one()
        return perm
    except NoResultFound:
        raise ResourceNotFoundError("Permission not found (perm_code={})".format(perm_code))