def verify_list(mailchimp, list_id, course_id):
 lists = mailchimp.lists(filters={'list_id': list_id})['data']
 if (len(lists) != 1):
  log.error('incorrect list id')
  return False
 list_name = lists[0]['name']
 log.debug('list name: %s', list_name)
 parts = course_id.replace('_', ' ').replace('/', ' ').split()
 count = sum((1 for p in parts if (p in list_name)))
 if (count < 3):
  log.info(course_id)
  log.info(list_name)
  log.error('course_id does not match list name')
  return False
 return True

def verify_list ( mailchimp , list_id , course_id ) : lists = mailchimp . lists ( filters = { 'list_id' : list_id } ) [ 'data' ] if ( len ( lists ) != 1 ) : log . error ( 'incorrect list id' ) return False list_name = lists [ 0 ] [ 'name' ] log . debug ( 'list name: %s' , list_name ) parts = course_id . replace ( '_' , ' ' ) . replace ( '/' , ' ' ) . split ( ) count = sum ( ( 1 for p in parts if ( p in list_name ) ) ) if ( count < 3 ) : log . info ( course_id ) log . info ( list_name ) log . error ( 'course_id does not match list name' ) return False return True
verifies that the given list_id corresponds to the course_id returns boolean: whether or not course_id matches list_id .