def _filter_unstarted_categories(category_map, course):
 now = datetime.now(UTC())
 result_map = {}
 unfiltered_queue = [category_map]
 filtered_queue = [result_map]
 while unfiltered_queue:
  unfiltered_map = unfiltered_queue.pop()
  filtered_map = filtered_queue.pop()
  filtered_map['children'] = []
  filtered_map['entries'] = {}
  filtered_map['subcategories'] = {}
  for (child, c_type) in unfiltered_map['children']:
   if ((child in unfiltered_map['entries']) and (c_type == TYPE_ENTRY)):
    if (course.self_paced or (unfiltered_map['entries'][child]['start_date'] <= now)):
     filtered_map['children'].append((child, c_type))
     filtered_map['entries'][child] = {}
     for key in unfiltered_map['entries'][child]:
      if (key != 'start_date'):
       filtered_map['entries'][child][key] = unfiltered_map['entries'][child][key]
    else:
     log.debug(u'Filtering out:%s with start_date: %s', child, unfiltered_map['entries'][child]['start_date'])
   elif (course.self_paced or (unfiltered_map['subcategories'][child]['start_date'] < now)):
    filtered_map['children'].append((child, c_type))
    filtered_map['subcategories'][child] = {}
    unfiltered_queue.append(unfiltered_map['subcategories'][child])
    filtered_queue.append(filtered_map['subcategories'][child])
 return result_map

def _filter_unstarted_categories ( category_map , course ) : now = datetime . now ( UTC ( ) ) result_map = { } unfiltered_queue = [ category_map ] filtered_queue = [ result_map ] while unfiltered_queue : unfiltered_map = unfiltered_queue . pop ( ) filtered_map = filtered_queue . pop ( ) filtered_map [ 'children' ] = [ ] filtered_map [ 'entries' ] = { } filtered_map [ 'subcategories' ] = { } for ( child , c_type ) in unfiltered_map [ 'children' ] : if ( ( child in unfiltered_map [ 'entries' ] ) and ( c_type == TYPE_ENTRY ) ) : if ( course . self_paced or ( unfiltered_map [ 'entries' ] [ child ] [ 'start_date' ] <= now ) ) : filtered_map [ 'children' ] . append ( ( child , c_type ) ) filtered_map [ 'entries' ] [ child ] = { } for key in unfiltered_map [ 'entries' ] [ child ] : if ( key != 'start_date' ) : filtered_map [ 'entries' ] [ child ] [ key ] = unfiltered_map [ 'entries' ] [ child ] [ key ] else : log . debug ( u'Filtering out:%s with start_date: %s' , child , unfiltered_map [ 'entries' ] [ child ] [ 'start_date' ] ) elif ( course . self_paced or ( unfiltered_map [ 'subcategories' ] [ child ] [ 'start_date' ] < now ) ) : filtered_map [ 'children' ] . append ( ( child , c_type ) ) filtered_map [ 'subcategories' ] [ child ] = { } unfiltered_queue . append ( unfiltered_map [ 'subcategories' ] [ child ] ) filtered_queue . append ( filtered_map [ 'subcategories' ] [ child ] ) return result_map
returns a subset of categories from the provided map which have not yet met the start date includes information about category children .