<s> from . import util <EOL> from . import helpers <EOL> from . xpath import xpb <EOL> class Essays ( object ) : <EOL> """<STR_LIT>""" <EOL> @ staticmethod <EOL> def build_essay_property ( essay_index , essay_name ) : <EOL> essay_xpb = xpb . div ( id = '<STR_LIT>' . format ( essay_index ) ) <EOL> essay_text_xpb = essay_xpb . div . with_class ( '<STR_LIT:text>' ) . div . with_class ( '<STR_LIT>' ) <EOL> @ property <EOL> def essay ( self ) : <EOL> try : <EOL> essay_text = essay_text_xpb . get_text_ ( self . _essays ) . strip ( ) <EOL> except IndexError : <EOL> return None <EOL> if essay_name not in self . _short_name_to_title : <EOL> self . _short_name_to_title [ essay_name ] = helpers . replace_chars ( <EOL> essay_xpb . a . with_class ( '<STR_LIT>' ) . get_text_ ( <EOL> self . _profile . profile_tree <EOL> ) <EOL> ) <EOL> return essay_text <EOL> @ essay . setter <EOL> def set_essay_text ( self , essay_text ) : <EOL> self . _submit_essay ( essay_index , essay_text ) <EOL> return set_essay_text <EOL> @ classmethod <EOL> def _init_essay_properties ( cls ) : <EOL> for essay_index , essay_name in enumerate ( cls . essay_names ) : <EOL> setattr ( cls , essay_name , <EOL> cls . build_essay_property ( essay_index , essay_name ) ) <EOL> _essays_xpb = xpb . div ( id = '<STR_LIT>' ) <EOL> essay_names = [ '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' ] <EOL> def __init__ ( self , profile ) : <EOL> """<STR_LIT>""" <EOL> self . _profile = profile <EOL> self . _short_name_to_title = { } <EOL> @ property <EOL> def short_name_to_title ( self ) : <EOL> for i in self : pass <EOL> return self . _short_name_to_title <EOL> @ util . cached_property <EOL> def _essays ( self ) : <EOL> return self . _essays_xpb . one_ ( self . _profile . profile_tree ) <EOL> def _submit_essay ( self , essay_id , essay_body ) : <EOL> self . _profile . authcode_post ( '<STR_LIT>' , data = { <EOL> "<STR_LIT>" : essay_id , <EOL> "<STR_LIT>" : essay_body , <EOL> "<STR_LIT>" : <NUM_LIT:1> <EOL> } ) <EOL> self . refresh ( ) <EOL> def refresh ( self ) : <EOL> self . _profile . refresh ( ) <EOL> util . cached_property . bust_caches ( self ) <EOL> def __iter__ ( self ) : <EOL> for essay_name in self . essay_names : <EOL> yield getattr ( self , essay_name ) <EOL> Essays . _init_essay_properties ( ) </s>
