<s> import codecs <EOL> import ConfigParser <EOL> import logging <EOL> from logging . handlers import RotatingFileHandler <EOL> from notes_db import NotesDB , SyncError , ReadError , WriteError <EOL> import argparse <EOL> import os <EOL> import sys <EOL> import time <EOL> from utils import KeyValueObject , SubjectMixin <EOL> import view <EOL> import webbrowser <EOL> try : <EOL> import markdown <EOL> except ImportError : <EOL> HAVE_MARKDOWN = False <EOL> else : <EOL> HAVE_MARKDOWN = True <EOL> try : <EOL> import docutils <EOL> import docutils . core <EOL> except ImportError : <EOL> HAVE_DOCUTILS = False <EOL> else : <EOL> HAVE_DOCUTILS = True <EOL> VERSION = "<STR_LIT>" <EOL> class Config : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , app_dir ) : <EOL> """<STR_LIT>""" <EOL> self . app_dir = app_dir <EOL> home = os . path . abspath ( os . path . expanduser ( '<STR_LIT>' ) ) <EOL> defaults = { '<STR_LIT>' : app_dir , <EOL> '<STR_LIT>' : app_dir , <EOL> '<STR_LIT>' : home , <EOL> '<STR_LIT>' : '<STR_LIT:0>' , <EOL> '<STR_LIT>' : '<STR_LIT:2>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:1>' , <EOL> '<STR_LIT>' : '<STR_LIT:1>' , <EOL> '<STR_LIT>' : '<STR_LIT:1>' , <EOL> '<STR_LIT>' : '<STR_LIT:1>' , <EOL> '<STR_LIT>' : os . path . join ( home , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : os . path . join ( home , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : '<STR_LIT:default>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:0>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:1>' , <EOL> '<STR_LIT>' : '<STR_LIT:1>' , <EOL> '<STR_LIT>' : None , <EOL> } <EOL> args = self . parse_cmd_line_opts ( ) <EOL> cfg_files = [ os . path . join ( app_dir , '<STR_LIT>' ) , <EOL> os . path . join ( home , '<STR_LIT>' ) , <EOL> os . path . join ( home , '<STR_LIT>' ) , <EOL> os . path . join ( home , '<STR_LIT>' ) , <EOL> os . path . join ( home , '<STR_LIT>' ) ] <EOL> if args is not None and args . cfg is not None : <EOL> cfg_files . extend ( [ os . path . join ( app_dir , args . cfg ) , args . cfg ] ) <EOL> cp = ConfigParser . SafeConfigParser ( defaults ) <EOL> self . files_read = cp . read ( cfg_files ) <EOL> cfg_sec = '<STR_LIT>' <EOL> if not cp . has_section ( cfg_sec ) : <EOL> cp . add_section ( cfg_sec ) <EOL> self . ok = False <EOL> else : <EOL> self . ok = True <EOL> self . sn_username = cp . get ( cfg_sec , '<STR_LIT>' , raw = True ) <EOL> self . sn_password = cp . get ( cfg_sec , '<STR_LIT>' , raw = True ) <EOL> self . simplenote_sync = cp . getint ( cfg_sec , '<STR_LIT>' ) <EOL> self . db_path = cp . get ( cfg_sec , '<STR_LIT>' ) <EOL> self . notes_as_txt = cp . getint ( cfg_sec , '<STR_LIT>' ) <EOL> self . txt_path = os . path . join ( home , cp . get ( cfg_sec , '<STR_LIT>' ) ) <EOL> self . search_mode = cp . get ( cfg_sec , '<STR_LIT>' ) <EOL> self . case_sensitive = cp . getint ( cfg_sec , '<STR_LIT>' ) <EOL> self . search_tags = cp . getint ( cfg_sec , '<STR_LIT>' ) <EOL> self . sort_mode = cp . getint ( cfg_sec , '<STR_LIT>' ) <EOL> self . pinned_ontop = cp . getint ( cfg_sec , '<STR_LIT>' ) <EOL> self . housekeeping_interval = cp . getint ( cfg_sec , '<STR_LIT>' ) <EOL> self . housekeeping_interval_ms = self . housekeeping_interval * <NUM_LIT:1000> <EOL> self . theme = cp . get ( cfg_sec , '<STR_LIT>' ) <EOL> self . font_family = cp . get ( cfg_sec , '<STR_LIT>' ) <EOL> self . font_size = cp . getint ( cfg_sec , '<STR_LIT>' ) <EOL> self . list_font_family = cp . get ( cfg_sec , '<STR_LIT>' ) <EOL> self . list_font_family_fixed = cp . get ( cfg_sec , '<STR_LIT>' ) <EOL> self . list_font_size = cp . getint ( cfg_sec , '<STR_LIT>' ) <EOL> self . layout = cp . get ( cfg_sec , '<STR_LIT>' ) <EOL> self . print_columns = cp . getint ( cfg_sec , '<STR_LIT>' ) <EOL> self . background_color = cp . get ( cfg_sec , '<STR_LIT>' ) <EOL> self . rest_css_path = cp . get ( cfg_sec , '<STR_LIT>' ) <EOL> self . debug = cp . getint ( cfg_sec , '<STR_LIT>' ) <EOL> def parse_cmd_line_opts ( self ) : <EOL> if __name__ != '<STR_LIT:__main__>' : <EOL> return None <EOL> parser = argparse . ArgumentParser ( ) <EOL> parser . add_argument ( '<STR_LIT>' , '<STR_LIT:-c>' , default = '<STR_LIT>' , dest = '<STR_LIT>' , <EOL> metavar = '<STR_LIT>' , help = '<STR_LIT>' ) <EOL> args = parser . parse_args ( ) <EOL> return args <EOL> class NotesListModel ( SubjectMixin ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self ) : <EOL> SubjectMixin . __init__ ( self ) <EOL> self . list = [ ] <EOL> self . match_regexps = [ ] <EOL> def set_list ( self , alist ) : <EOL> self . list = alist <EOL> self . notify_observers ( '<STR_LIT>' , None ) <EOL> def get_idx ( self , key ) : <EOL> """<STR_LIT>""" <EOL> found = [ i for i , e in enumerate ( self . list ) if e . key == key ] <EOL> if found : <EOL> return found [ <NUM_LIT:0> ] <EOL> else : <EOL> return - <NUM_LIT:1> <EOL> class Controller : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , config ) : <EOL> self . config = config <EOL> self . config . app_version = VERSION <EOL> if not os . path . exists ( self . config . db_path ) : <EOL> os . mkdir ( self . config . db_path ) <EOL> log_filename = os . path . join ( self . config . db_path , '<STR_LIT>' ) <EOL> lhandler = RotatingFileHandler ( log_filename , maxBytes = <NUM_LIT> , backupCount = <NUM_LIT:1> ) <EOL> lhandler . setLevel ( logging . DEBUG ) <EOL> lhandler . setFormatter ( logging . Formatter ( fmt = '<STR_LIT>' ) ) <EOL> logger = logging . getLogger ( ) <EOL> if self . config . debug == <NUM_LIT:1> : <EOL> logger . setLevel ( logging . DEBUG ) <EOL> logger . addHandler ( lhandler ) <EOL> logging . debug ( '<STR_LIT>' ) <EOL> logging . debug ( '<STR_LIT>' % ( str ( self . config . files_read ) , ) ) <EOL> if self . config . sn_username == '<STR_LIT>' : <EOL> self . config . simplenote_sync = <NUM_LIT:0> <EOL> css = self . config . rest_css_path <EOL> if css : <EOL> if css . startswith ( "<STR_LIT>" ) : <EOL> css = css . replace ( <EOL> "<STR_LIT>" , os . path . abspath ( os . path . expanduser ( '<STR_LIT>' ) ) , <NUM_LIT:1> ) <EOL> self . config . rest_css_path = css <EOL> if not os . path . exists ( css ) : <EOL> self . config . rest_css_path = None <EOL> self . notes_list_model = NotesListModel ( ) <EOL> self . view = view . View ( self . config , self . notes_list_model ) <EOL> try : <EOL> self . notes_db = NotesDB ( self . config ) <EOL> except ReadError , e : <EOL> emsg = "<STR_LIT>" + str ( e ) <EOL> self . view . show_error ( '<STR_LIT>' , emsg ) <EOL> exit ( <NUM_LIT:1> ) <EOL> self . notes_db . add_observer ( '<STR_LIT>' , self . observer_notes_db_synced_note ) <EOL> self . notes_db . add_observer ( '<STR_LIT>' , self . observer_notes_db_change_note_status ) <EOL> if self . config . simplenote_sync : <EOL> self . notes_db . add_observer ( '<STR_LIT>' , self . observer_notes_db_sync_full ) <EOL> self . sync_full ( ) <EOL> self . view . add_observer ( '<STR_LIT>' , <EOL> self . observer_view_click_notelink ) <EOL> self . view . add_observer ( '<STR_LIT>' , self . observer_view_delete_note ) <EOL> self . view . add_observer ( '<STR_LIT>' , self . observer_view_select_note ) <EOL> self . view . add_observer ( '<STR_LIT>' , self . observer_view_change_entry ) <EOL> self . view . add_observer ( '<STR_LIT>' , self . observer_view_change_text ) <EOL> self . view . add_observer ( '<STR_LIT>' , self . observer_view_change_pinned ) <EOL> self . view . add_observer ( '<STR_LIT>' , self . observer_view_create_note ) <EOL> self . view . add_observer ( '<STR_LIT>' , self . observer_view_keep_house ) <EOL> self . view . add_observer ( '<STR_LIT>' , self . observer_view_markdown ) <EOL> self . view . add_observer ( '<STR_LIT>' , self . observer_view_rest ) <EOL> self . view . add_observer ( '<STR_LIT>' , self . observer_view_delete_tag ) <EOL> self . view . add_observer ( '<STR_LIT>' , self . observer_view_add_tag ) <EOL> if self . config . simplenote_sync : <EOL> self . view . add_observer ( '<STR_LIT>' , lambda v , et , e : self . sync_full ( ) ) <EOL> self . view . add_observer ( '<STR_LIT>' , self . observer_view_sync_current_note ) <EOL> self . view . add_observer ( '<STR_LIT>' , self . observer_view_close ) <EOL> self . view . set_cs ( self . config . case_sensitive , silent = True ) <EOL> self . view . set_search_mode ( self . config . search_mode , silent = True ) <EOL> self . view . add_observer ( '<STR_LIT>' , self . observer_view_change_cs ) <EOL> self . view . add_observer ( '<STR_LIT>' , self . observer_view_change_search_mode ) <EOL> nn , match_regexp , active_notes = self . notes_db . filter_notes ( ) <EOL> self . notes_list_model . set_list ( nn ) <EOL> self . notes_list_model . match_regexp = match_regexp <EOL> self . view . set_note_tally ( len ( nn ) , active_notes , len ( self . notes_db . notes ) ) <EOL> self . selected_note_idx = - <NUM_LIT:1> <EOL> self . view . select_note ( <NUM_LIT:0> ) <EOL> def get_selected_note_key ( self ) : <EOL> if self . selected_note_idx >= <NUM_LIT:0> : <EOL> return self . notes_list_model . list [ self . selected_note_idx ] . key <EOL> else : <EOL> return None <EOL> def main_loop ( self ) : <EOL> if not self . config . files_read : <EOL> self . view . show_warning ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> elif not self . config . ok : <EOL> wmsg = ( '<STR_LIT>' + '<STR_LIT>' ) % ( str ( self . config . files_read ) , ) <EOL> self . view . show_warning ( '<STR_LIT>' , wmsg ) <EOL> self . view . main_loop ( ) <EOL> def observer_notes_db_change_note_status ( self , notes_db , evt_type , evt ) : <EOL> skey = self . get_selected_note_key ( ) <EOL> if skey == evt . key : <EOL> self . view . set_note_status ( self . notes_db . get_note_status ( skey ) ) <EOL> def observer_notes_db_sync_full ( self , notes_db , evt_type , evt ) : <EOL> logging . debug ( evt . msg ) <EOL> self . view . set_status_text ( evt . msg ) <EOL> def observer_notes_db_synced_note ( self , notes_db , evt_type , evt ) : <EOL> """<STR_LIT>""" <EOL> selected_note_o = self . notes_list_model . list [ self . selected_note_idx ] <EOL> if selected_note_o . key == evt . lkey : <EOL> if selected_note_o . note [ '<STR_LIT:content>' ] != evt . old_note [ '<STR_LIT:content>' ] : <EOL> self . view . mute_note_data_changes ( ) <EOL> self . view . set_note_data ( selected_note_o . note , reset_undo = False ) <EOL> self . view . unmute_note_data_changes ( ) <EOL> def observer_view_click_notelink ( self , view , evt_type , note_name ) : <EOL> idx = self . view . select_note_by_name ( note_name ) <EOL> if idx < <NUM_LIT:0> : <EOL> self . view . set_search_entry_text ( note_name ) <EOL> def observer_view_delete_note ( self , view , evt_type , evt ) : <EOL> assert ( evt . sel == self . selected_note_idx ) <EOL> key = self . get_selected_note_key ( ) <EOL> nidx = evt . sel + <NUM_LIT:1> <EOL> if nidx >= <NUM_LIT:0> and nidx < self . view . get_number_of_notes ( ) : <EOL> self . view . select_note ( nidx ) <EOL> self . notes_db . delete_note ( key ) <EOL> self . view . set_search_entry_text ( self . view . get_search_entry_text ( ) ) <EOL> def helper_markdown_to_html ( self ) : <EOL> if self . selected_note_idx >= <NUM_LIT:0> : <EOL> key = self . notes_list_model . list [ self . selected_note_idx ] . key <EOL> c = self . notes_db . get_note_content ( key ) <EOL> logging . debug ( "<STR_LIT>" % ( key , ) ) <EOL> if HAVE_MARKDOWN : <EOL> logging . debug ( "<STR_LIT>" % ( key , ) ) <EOL> html = markdown . markdown ( c ) <EOL> logging . debug ( "<STR_LIT>" ) <EOL> else : <EOL> logging . debug ( "<STR_LIT>" ) <EOL> html = "<STR_LIT>" <EOL> html += "<STR_LIT>" <EOL> fn = os . path . join ( self . config . db_path , key + '<STR_LIT>' ) <EOL> f = codecs . open ( fn , mode = '<STR_LIT:wb>' , encoding = '<STR_LIT:utf-8>' ) <EOL> s = u"""<STR_LIT>""" % ( '<STR_LIT>' if self . view . get_continuous_rendering ( ) else "<STR_LIT>" , html , ) <EOL> f . write ( s ) <EOL> f . close ( ) <EOL> return fn <EOL> def helper_rest_to_html ( self ) : <EOL> if self . selected_note_idx >= <NUM_LIT:0> : <EOL> key = self . notes_list_model . list [ self . selected_note_idx ] . key <EOL> c = self . notes_db . get_note_content ( key ) <EOL> if HAVE_DOCUTILS : <EOL> settings = { } <EOL> if self . config . rest_css_path : <EOL> settings [ '<STR_LIT>' ] = self . config . rest_css_path <EOL> html = docutils . core . publish_string ( <EOL> c , writer_name = '<STR_LIT:html>' , settings_overrides = settings ) <EOL> else : <EOL> html = "<STR_LIT>" <EOL> html += "<STR_LIT>" <EOL> fn = os . path . join ( self . config . db_path , key + '<STR_LIT>' ) <EOL> f = codecs . open ( fn , mode = '<STR_LIT:wb>' , encoding = '<STR_LIT:utf-8>' ) <EOL> s = u"""<STR_LIT>""" % ( unicode ( html , '<STR_LIT:utf8>' ) , ) <EOL> f . write ( s ) <EOL> f . close ( ) <EOL> return fn <EOL> def observer_view_markdown ( self , view , evt_type , evt ) : <EOL> fn = self . helper_markdown_to_html ( ) <EOL> fn_uri = '<STR_LIT>' + os . path . abspath ( fn ) <EOL> webbrowser . open ( fn_uri ) <EOL> def observer_view_rest ( self , view , evt_type , evt ) : <EOL> fn = self . helper_rest_to_html ( ) <EOL> fn_uri = '<STR_LIT>' + os . path . abspath ( fn ) <EOL> webbrowser . open ( fn_uri ) <EOL> def helper_save_sync_msg ( self ) : <EOL> saven = self . notes_db . get_save_queue_len ( ) <EOL> if self . config . simplenote_sync : <EOL> syncn = self . notes_db . get_sync_queue_len ( ) <EOL> wfsn = self . notes_db . waiting_for_simplenote <EOL> else : <EOL> syncn = wfsn = <NUM_LIT:0> <EOL> savet = '<STR_LIT>' % ( saven , ) if saven > <NUM_LIT:0> else '<STR_LIT>' <EOL> synct = '<STR_LIT>' % ( syncn , ) if syncn > <NUM_LIT:0> else '<STR_LIT>' <EOL> wfsnt = '<STR_LIT>' if wfsn else '<STR_LIT>' <EOL> return '<STR_LIT:U+0020>' . join ( [ i for i in [ savet , synct , wfsnt ] if i ] ) <EOL> def observer_view_keep_house ( self , view , evt_type , evt ) : <EOL> nsaved = self . notes_db . save_threaded ( ) <EOL> msg = self . helper_save_sync_msg ( ) <EOL> if self . config . simplenote_sync : <EOL> nsynced , sync_errors = self . notes_db . sync_to_server_threaded ( ) <EOL> if sync_errors : <EOL> msg = '<STR_LIT:U+0020>' . join ( [ i for i in [ msg , '<STR_LIT>' ] if i ] ) <EOL> self . view . set_status_text ( msg ) <EOL> if self . view . get_continuous_rendering ( ) : <EOL> self . helper_markdown_to_html ( ) <EOL> def observer_view_select_note ( self , view , evt_type , evt ) : <EOL> self . select_note ( evt . sel ) <EOL> def observer_view_sync_current_note ( self , view , evt_type , evt ) : <EOL> if self . selected_note_idx >= <NUM_LIT:0> : <EOL> key = self . notes_list_model . list [ self . selected_note_idx ] . key <EOL> ret = self . notes_db . sync_note_unthreaded ( key ) <EOL> if ret and ret [ <NUM_LIT:1> ] == True : <EOL> self . view . update_selected_note_data ( <EOL> self . notes_db . notes [ key ] ) <EOL> self . view . set_status_text ( <EOL> '<STR_LIT>' ) <EOL> elif ret [ <NUM_LIT:1> ] == False : <EOL> self . view . set_status_text ( <EOL> '<STR_LIT>' ) <EOL> elif ret is None : <EOL> self . view . set_status_text ( <EOL> '<STR_LIT>' ) <EOL> def observer_view_change_cs ( self , view , evt_type , evt ) : <EOL> if evt . value != self . config . case_sensitive : <EOL> self . config . case_sensitive = evt . value <EOL> self . view . refresh_notes_list ( ) <EOL> def observer_view_change_search_mode ( self , view , evt_type , evt ) : <EOL> if evt . value != self . config . search_mode : <EOL> self . config . search_mode = evt . value <EOL> self . view . refresh_notes_list ( ) <EOL> def observer_view_change_entry ( self , view , evt_type , evt ) : <EOL> k = self . get_selected_note_key ( ) <EOL> nn , match_regexp , active_notes = self . notes_db . filter_notes ( evt . value ) <EOL> self . notes_list_model . set_list ( nn ) <EOL> self . notes_list_model . match_regexp = match_regexp <EOL> self . view . set_note_tally ( len ( nn ) , active_notes , len ( self . notes_db . notes ) ) <EOL> idx = self . notes_list_model . get_idx ( k ) <EOL> if idx < <NUM_LIT:0> : <EOL> self . view . select_note ( <NUM_LIT:0> ) <EOL> self . view . see_first_search_instance ( ) <EOL> else : <EOL> self . view . select_note ( idx , silent = True ) <EOL> self . selected_note_idx = idx <EOL> new_note = self . notes_db . get_note ( k ) <EOL> if self . view . is_note_different ( new_note ) : <EOL> logging . debug ( "<STR_LIT>" % ( k , ) ) <EOL> self . view . update_selected_note_data ( new_note ) <EOL> else : <EOL> self . view . activate_search_string_highlights ( ) <EOL> def observer_view_change_text ( self , view , evt_type , evt ) : <EOL> if self . selected_note_idx >= <NUM_LIT:0> : <EOL> key = self . notes_list_model . list [ self . selected_note_idx ] . key <EOL> self . notes_db . set_note_content ( key , <EOL> self . view . get_text ( ) ) <EOL> def observer_view_change_tags ( self , view , evt_type , evt ) : <EOL> if self . selected_note_idx >= <NUM_LIT:0> : <EOL> key = self . notes_list_model . list [ self . selected_note_idx ] . key <EOL> self . notes_db . set_note_tags ( key , evt . value ) <EOL> self . view . cmd_notes_list_select ( ) <EOL> def observer_view_delete_tag ( self , view , evt_type , evt ) : <EOL> key = self . notes_list_model . list [ self . selected_note_idx ] . key <EOL> self . notes_db . delete_note_tag ( key , evt . tag ) <EOL> self . view . cmd_notes_list_select ( ) <EOL> def observer_view_add_tag ( self , view , evt_type , evt ) : <EOL> key = self . notes_list_model . list [ self . selected_note_idx ] . key <EOL> self . notes_db . add_note_tags ( key , evt . tags ) <EOL> self . view . cmd_notes_list_select ( ) <EOL> self . view . tags_entry_var . set ( '<STR_LIT>' ) <EOL> def observer_view_change_pinned ( self , view , evt_type , evt ) : <EOL> if self . selected_note_idx >= <NUM_LIT:0> : <EOL> key = self . notes_list_model . list [ self . selected_note_idx ] . key <EOL> self . notes_db . set_note_pinned ( key , evt . value ) <EOL> def observer_view_close ( self , view , evt_type , evt ) : <EOL> self . notes_db . save_threaded ( ) <EOL> if self . config . simplenote_sync : <EOL> self . notes_db . sync_to_server_threaded ( wait_for_idle = False ) <EOL> syncn = self . notes_db . get_sync_queue_len ( ) <EOL> wfsn = self . notes_db . waiting_for_simplenote <EOL> else : <EOL> syncn = wfsn = <NUM_LIT:0> <EOL> saven = self . notes_db . get_save_queue_len ( ) <EOL> if saven or syncn or wfsn : <EOL> msg = "<STR_LIT>" + self . helper_save_sync_msg ( ) <EOL> really_want_to_exit = self . view . askyesno ( "<STR_LIT>" , msg ) <EOL> if really_want_to_exit : <EOL> self . view . close ( ) <EOL> else : <EOL> self . view . close ( ) <EOL> def observer_view_create_note ( self , view , evt_type , evt ) : <EOL> new_key = self . notes_db . create_note ( evt . title ) <EOL> self . view . set_search_entry_text ( '<STR_LIT>' ) <EOL> idx = self . notes_list_model . get_idx ( new_key ) <EOL> self . view . select_note ( idx ) <EOL> def select_note ( self , idx ) : <EOL> """<STR_LIT>""" <EOL> if idx >= <NUM_LIT:0> : <EOL> key = self . notes_list_model . list [ idx ] . key <EOL> note = self . notes_db . get_note ( key ) <EOL> self . view . set_note_editing ( True ) <EOL> else : <EOL> key = None <EOL> note = None <EOL> idx = - <NUM_LIT:1> <EOL> self . view . clear_note_ui ( ) <EOL> self . view . set_note_editing ( False ) <EOL> self . selected_note_idx = idx <EOL> self . view . mute_note_data_changes ( ) <EOL> self . view . set_note_data ( note ) <EOL> if key : <EOL> self . view . set_note_status ( self . notes_db . get_note_status ( key ) ) <EOL> self . view . unmute_note_data_changes ( ) <EOL> def sync_full ( self ) : <EOL> try : <EOL> sync_from_server_errors = self . notes_db . sync_full ( ) <EOL> except SyncError , e : <EOL> self . view . show_error ( '<STR_LIT>' , e ) <EOL> except WriteError , e : <EOL> emsg = "<STR_LIT>" + str ( e ) <EOL> self . view . show_error ( '<STR_LIT>' , emsg ) <EOL> exit ( <NUM_LIT:1> ) <EOL> else : <EOL> self . view . refresh_notes_list ( ) <EOL> if sync_from_server_errors > <NUM_LIT:0> : <EOL> self . view . show_error ( '<STR_LIT>' , '<STR_LIT>' % ( sync_from_server_errors , ) ) <EOL> def main ( ) : <EOL> if hasattr ( sys , '<STR_LIT>' ) and sys . frozen : <EOL> appdir , _ = os . path . split ( sys . executable ) <EOL> else : <EOL> dirname , _ = os . path . split ( os . path . realpath ( __file__ ) ) <EOL> if dirname and dirname != os . curdir : <EOL> appdir = dirname <EOL> else : <EOL> appdir = os . getcwd ( ) <EOL> appdir_full_path = os . path . abspath ( appdir ) <EOL> config = Config ( appdir_full_path ) <EOL> controller = Controller ( config ) <EOL> controller . main_loop ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> main ( ) </s>
