def import_attached_events(db_session, account, message):
 assert (account is not None)
 for part in message.attached_event_files:
  part_data = ''
  try:
   part_data = part.block.data
   if (part_data == ''):
    continue
   new_events = events_from_ics(account.namespace, account.emailed_events_calendar, part_data)
  except MalformedEventError:
   log.error('Attached event parsing error', account_id=account.id, message_id=message.id, logstash_tag='icalendar_autoimport', event_part_id=part.id)
   continue
  except (AssertionError, TypeError, RuntimeError, AttributeError, ValueError, UnboundLocalError, LookupError, ImportError, NameError):
   log.error('Unhandled exception during message parsing', message_id=message.id, event_part_id=part.id, logstash_tag='icalendar_autoimport', traceback=traceback.format_exception(sys.exc_info()[0], sys.exc_info()[1], sys.exc_info()[2]))
   continue
  process_invites(db_session, message, account, new_events['invites'])
  if (account.provider != 'gmail'):
   process_nylas_rsvps(db_session, message, account, new_events['rsvps'])

def import_attached_events ( db_session , account , message ) : assert ( account is not None ) for part in message . attached_event_files : part_data = '' try : part_data = part . block . data if ( part_data == '' ) : continue new_events = events_from_ics ( account . namespace , account . emailed_events_calendar , part_data ) except MalformedEventError : log . error ( 'Attached event parsing error' , account_id = account . id , message_id = message . id , logstash_tag = 'icalendar_autoimport' , event_part_id = part . id ) continue except ( AssertionError , TypeError , RuntimeError , AttributeError , ValueError , UnboundLocalError , LookupError , ImportError , NameError ) : log . error ( 'Unhandled exception during message parsing' , message_id = message . id , event_part_id = part . id , logstash_tag = 'icalendar_autoimport' , traceback = traceback . format_exception ( sys . exc_info ( ) [ 0 ] , sys . exc_info ( ) [ 1 ] , sys . exc_info ( ) [ 2 ] ) ) continue process_invites ( db_session , message , account , new_events [ 'invites' ] ) if ( account . provider != 'gmail' ) : process_nylas_rsvps ( db_session , message , account , new_events [ 'rsvps' ] )
import events from a file into the emailed events calendar .