def course_outline_initial_state(locator_to_show, course_structure):
 def find_xblock_info(xblock_info, locator):
  '\n        Finds the xblock info for the specified locator.\n        '
  if (xblock_info['id'] == locator):
   return xblock_info
  children = (xblock_info['child_info']['children'] if xblock_info.get('child_info', None) else None)
  if children:
   for child_xblock_info in children:
    result = find_xblock_info(child_xblock_info, locator)
    if result:
     return result
  return None
 def collect_all_locators(locators, xblock_info):
  '\n        Collect all the locators for an xblock and its children.\n        '
  locators.append(xblock_info['id'])
  children = (xblock_info['child_info']['children'] if xblock_info.get('child_info', None) else None)
  if children:
   for child_xblock_info in children:
    collect_all_locators(locators, child_xblock_info)
 selected_xblock_info = find_xblock_info(course_structure, locator_to_show)
 if (not selected_xblock_info):
  return None
 expanded_locators = []
 collect_all_locators(expanded_locators, selected_xblock_info)
 return {'locator_to_show': locator_to_show, 'expanded_locators': expanded_locators}

def course_outline_initial_state ( locator_to_show , course_structure ) : def find_xblock_info ( xblock_info , locator ) : if ( xblock_info [ 'id' ] == locator ) : return xblock_info children = ( xblock_info [ 'child_info' ] [ 'children' ] if xblock_info . get ( 'child_info' , None ) else None ) if children : for child_xblock_info in children : result = find_xblock_info ( child_xblock_info , locator ) if result : return result return None def collect_all_locators ( locators , xblock_info ) : locators . append ( xblock_info [ 'id' ] ) children = ( xblock_info [ 'child_info' ] [ 'children' ] if xblock_info . get ( 'child_info' , None ) else None ) if children : for child_xblock_info in children : collect_all_locators ( locators , child_xblock_info ) selected_xblock_info = find_xblock_info ( course_structure , locator_to_show ) if ( not selected_xblock_info ) : return None expanded_locators = [ ] collect_all_locators ( expanded_locators , selected_xblock_info ) return { 'locator_to_show' : locator_to_show , 'expanded_locators' : expanded_locators }
returns the desired initial state for the course outline view .