def extract_metadata(module_data):
 metadata = None
 start_line = (-1)
 start_col = (-1)
 end_line = (-1)
 end_col = (-1)
 targets = None
 mod_ast_tree = ast.parse(module_data)
 for (root_idx, child) in enumerate(mod_ast_tree.body):
  if isinstance(child, ast.Assign):
   for target in child.targets:
    if (target.id == 'ANSIBLE_METADATA'):
     if isinstance(child.value, ast.Dict):
      metadata = ast.literal_eval(child.value)
      try:
       next_node = mod_ast_tree.body[(root_idx + 1)]
       next_lineno = next_node.lineno
       next_col_offset = next_node.col_offset
      except IndexError:
       next_lineno = None
       next_col_offset = None
      (end_line, end_col) = seek_end_of_dict(module_data, (child.lineno - 1), child.col_offset, next_lineno, next_col_offset)
     elif isinstance(child.value, ast.Str):
      metadata = yaml.safe_load(child.value.s)
      end_line = seek_end_of_string(module_data)
     elif isinstance(child.value, ast.Bytes):
      metadata = yaml.safe_load(to_text(child.value.s, errors='surrogate_or_strict'))
      end_line = seek_end_of_string(module_data)
     else:
      continue
     start_line = (child.lineno - 1)
     start_col = child.col_offset
     targets = [t.id for t in child.targets]
     break
  if (metadata is not None):
   break
 return (metadata, start_line, start_col, end_line, end_col, targets)

def extract_metadata ( module_data ) : metadata = None start_line = ( - 1 ) start_col = ( - 1 ) end_line = ( - 1 ) end_col = ( - 1 ) targets = None mod_ast_tree = ast . parse ( module_data ) for ( root_idx , child ) in enumerate ( mod_ast_tree . body ) : if isinstance ( child , ast . Assign ) : for target in child . targets : if ( target . id == 'ANSIBLE_METADATA' ) : if isinstance ( child . value , ast . Dict ) : metadata = ast . literal_eval ( child . value ) try : next_node = mod_ast_tree . body [ ( root_idx + 1 ) ] next_lineno = next_node . lineno next_col_offset = next_node . col_offset except IndexError : next_lineno = None next_col_offset = None ( end_line , end_col ) = seek_end_of_dict ( module_data , ( child . lineno - 1 ) , child . col_offset , next_lineno , next_col_offset ) elif isinstance ( child . value , ast . Str ) : metadata = yaml . safe_load ( child . value . s ) end_line = seek_end_of_string ( module_data ) elif isinstance ( child . value , ast . Bytes ) : metadata = yaml . safe_load ( to_text ( child . value . s , errors = 'surrogate_or_strict' ) ) end_line = seek_end_of_string ( module_data ) else : continue start_line = ( child . lineno - 1 ) start_col = child . col_offset targets = [ t . id for t in child . targets ] break if ( metadata is not None ) : break return ( metadata , start_line , start_col , end_line , end_col , targets )
try to determine metadata from video title .