def _InitApiApprovalFromAff4Object(api_approval, approval_obj):
 api_approval.id = approval_obj.urn.Basename()
 api_approval.reason = approval_obj.Get(approval_obj.Schema.REASON)
 test_token = access_control.ACLToken(username=approval_obj.Get(approval_obj.Schema.REQUESTOR))
 try:
  approval_obj.CheckAccess(test_token)
  api_approval.is_valid = True
 except access_control.UnauthorizedAccess as e:
  api_approval.is_valid = False
  api_approval.is_valid_message = utils.SmartStr(e)
 notified_users = approval_obj.Get(approval_obj.Schema.NOTIFIED_USERS)
 if notified_users:
  api_approval.notified_users = sorted((u.strip() for u in notified_users.split(',')))
 email_cc = approval_obj.Get(approval_obj.Schema.EMAIL_CC)
 email_cc_addresses = sorted((s.strip() for s in email_cc.split(',')))
 api_approval.email_cc_addresses = (set(email_cc_addresses) - set(api_approval.notified_users))
 api_approval.approvers = sorted(approval_obj.GetNonExpiredApprovers())
 return api_approval

def _InitApiApprovalFromAff4Object ( api_approval , approval_obj ) : api_approval . id = approval_obj . urn . Basename ( ) api_approval . reason = approval_obj . Get ( approval_obj . Schema . REASON ) test_token = access_control . ACLToken ( username = approval_obj . Get ( approval_obj . Schema . REQUESTOR ) ) try : approval_obj . CheckAccess ( test_token ) api_approval . is_valid = True except access_control . UnauthorizedAccess as e : api_approval . is_valid = False api_approval . is_valid_message = utils . SmartStr ( e ) notified_users = approval_obj . Get ( approval_obj . Schema . NOTIFIED_USERS ) if notified_users : api_approval . notified_users = sorted ( ( u . strip ( ) for u in notified_users . split ( ',' ) ) ) email_cc = approval_obj . Get ( approval_obj . Schema . EMAIL_CC ) email_cc_addresses = sorted ( ( s . strip ( ) for s in email_cc . split ( ',' ) ) ) api_approval . email_cc_addresses = ( set ( email_cc_addresses ) - set ( api_approval . notified_users ) ) api_approval . approvers = sorted ( approval_obj . GetNonExpiredApprovers ( ) ) return api_approval
initializes apiapproval from an aff4 object .