def get_common_replies(locale=settings.WIKI_DEFAULT_LANGUAGE):
 replies = []
 try:
  default_doc = Document.objects.get(slug=REPLIES_DOCUMENT_SLUG, locale=settings.WIKI_DEFAULT_LANGUAGE)
 except Document.DoesNotExist:
  return replies
 if (locale != default_doc.locale):
  translated_doc = default_doc.translated_to(locale)
  if (translated_doc and translated_doc.current_revision):
   doc = translated_doc
  else:
   doc = default_doc
 else:
  doc = default_doc
 pq = PyQuery(doc.html)
 try:
  current_node = pq('h1')[0]
 except IndexError:
  return replies
 current_category = None
 current_response = None
 while (current_node is not None):
  if (current_node.tag == 'h1'):
   current_category = {'title': current_node.text, 'responses': []}
   replies.append(current_category)
  elif (current_node.tag == 'h2'):
   current_response = {'title': current_node.text, 'response': ''}
   current_category['responses'].append(current_response)
  elif (current_node.tag == 'p'):
   text = current_node.text_content().strip()
   if (text and current_response):
    current_response['response'] = text
  current_node = current_node.getnext()
 return replies

def get_common_replies ( locale = settings . WIKI_DEFAULT_LANGUAGE ) : replies = [ ] try : default_doc = Document . objects . get ( slug = REPLIES_DOCUMENT_SLUG , locale = settings . WIKI_DEFAULT_LANGUAGE ) except Document . DoesNotExist : return replies if ( locale != default_doc . locale ) : translated_doc = default_doc . translated_to ( locale ) if ( translated_doc and translated_doc . current_revision ) : doc = translated_doc else : doc = default_doc else : doc = default_doc pq = PyQuery ( doc . html ) try : current_node = pq ( 'h1' ) [ 0 ] except IndexError : return replies current_category = None current_response = None while ( current_node is not None ) : if ( current_node . tag == 'h1' ) : current_category = { 'title' : current_node . text , 'responses' : [ ] } replies . append ( current_category ) elif ( current_node . tag == 'h2' ) : current_response = { 'title' : current_node . text , 'response' : '' } current_category [ 'responses' ] . append ( current_response ) elif ( current_node . tag == 'p' ) : text = current_node . text_content ( ) . strip ( ) if ( text and current_response ) : current_response [ 'response' ] = text current_node = current_node . getnext ( ) return replies
returns the common replies .