def _get_metadata_from_file(meta_data):
 meta = {}
 if (not meta_data):
  return meta
 if (not meta_data[0]):
  meta_data = meta_data[1:]
 for (i, line) in enumerate(meta_data):
  if (not line):
   break
  match = re_meta(line)
  if match[0]:
   meta[match[0]] = match[1]
 if (u'title' not in meta):
  t = _get_title_from_contents(meta_data)
  if (t is not None):
   meta[u'title'] = t
 return meta

def _get_metadata_from_file ( meta_data ) : meta = { } if ( not meta_data ) : return meta if ( not meta_data [ 0 ] ) : meta_data = meta_data [ 1 : ] for ( i , line ) in enumerate ( meta_data ) : if ( not line ) : break match = re_meta ( line ) if match [ 0 ] : meta [ match [ 0 ] ] = match [ 1 ] if ( u'title' not in meta ) : t = _get_title_from_contents ( meta_data ) if ( t is not None ) : meta [ u'title' ] = t return meta
extract metadata from a posts source file .