<s> from django . conf import settings <EOL> from pyquery import PyQuery <EOL> from kitsune . wiki . models import Document <EOL> REPLIES_DOCUMENT_SLUG = '<STR_LIT>' <EOL> def get_common_replies ( locale = settings . WIKI_DEFAULT_LANGUAGE ) : <EOL> """<STR_LIT>""" <EOL> replies = [ ] <EOL> try : <EOL> default_doc = Document . objects . get ( <EOL> slug = REPLIES_DOCUMENT_SLUG , <EOL> locale = settings . WIKI_DEFAULT_LANGUAGE ) <EOL> except Document . DoesNotExist : <EOL> return replies <EOL> if locale != default_doc . locale : <EOL> translated_doc = default_doc . translated_to ( locale ) <EOL> if translated_doc and translated_doc . current_revision : <EOL> doc = translated_doc <EOL> else : <EOL> doc = default_doc <EOL> else : <EOL> doc = default_doc <EOL> pq = PyQuery ( doc . html ) <EOL> try : <EOL> current_node = pq ( '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> except IndexError : <EOL> return replies <EOL> current_category = None <EOL> current_response = None <EOL> while current_node is not None : <EOL> if current_node . tag == '<STR_LIT>' : <EOL> current_category = { <EOL> '<STR_LIT:title>' : current_node . text , <EOL> '<STR_LIT>' : [ ] } <EOL> replies . append ( current_category ) <EOL> elif current_node . tag == '<STR_LIT>' : <EOL> current_response = { <EOL> '<STR_LIT:title>' : current_node . text , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> current_category [ '<STR_LIT>' ] . append ( current_response ) <EOL> elif current_node . tag == '<STR_LIT:p>' : <EOL> text = current_node . text_content ( ) . strip ( ) <EOL> if text and current_response : <EOL> current_response [ '<STR_LIT>' ] = text <EOL> current_node = current_node . getnext ( ) <EOL> return replies </s>
