nncli

NextCloud Notes Command Line Interface
git clone git://git.danielmoch.com/nncli.git
Log | Files | Refs | LICENSE

commit e209a0a559b095dfb482b07f9aa6feb2ff3e6edf
parent 31a14dcaed07236a7e3d94f8b5418953fda3d3be
Author: Eric Davis <edavis@insanum.com>
Date:   Tue, 24 Jun 2014 22:21:49 -0700

code formatting

Diffstat:
Msncli.py | 235++++++++++++++++++++++++++++++++++++++++---------------------------------------
1 file changed, 118 insertions(+), 117 deletions(-)

diff --git a/sncli.py b/sncli.py @@ -11,91 +11,92 @@ class Config: def __init__(self): self.home = os.path.abspath(os.path.expanduser('~')) - defaults = { - 'sn_username' : '', - 'sn_password' : '', - 'db_path' : os.path.join(self.home, '.sncli'), - 'search_mode' : 'gstyle', - 'search_tags' : '1', - 'sort_mode' : '1', - 'pinned_ontop' : '1', - 'tabstop' : '4', - 'format_strftime' : '%Y/%m/%d', - 'format_note_title' : '[%D] %F %N%>%T', - - 'kb_help' : 'h', - 'kb_quit' : 'q', - 'kb_down' : 'j', - 'kb_up' : 'k', - 'kb_page_down' : ' ', - 'kb_page_up' : 'b', - 'kb_half_page_down' : 'ctrl d', - 'kb_half_page_up' : 'ctrl u', - 'kb_bottom' : 'G', - 'kb_top' : 'g', - 'kb_view_note' : 'enter', - 'kb_view_log' : 'l', - 'kb_tabstop2' : '2', - 'kb_tabstop4' : '4', - 'kb_tabstop8' : '8', - - 'clr_default_fg' : 'default', - 'clr_default_bg' : 'default', - - 'clr_note_title_day_fg' : 'dark blue', - 'clr_note_title_day_bg' : 'default', - 'clr_note_title_day_focus_fg' : 'white', - 'clr_note_title_day_focus_bg' : 'default', - - 'clr_note_title_week_fg' : 'dark blue', - 'clr_note_title_week_bg' : 'default', - 'clr_note_title_week_focus_fg' : 'white', - 'clr_note_title_week_focus_bg' : 'default', - - 'clr_note_title_month_fg' : 'dark blue', - 'clr_note_title_month_bg' : 'default', - 'clr_note_title_month_focus_fg' : 'white', - 'clr_note_title_month_focus_bg' : 'default', - - 'clr_note_title_year_fg' : 'dark blue', - 'clr_note_title_year_bg' : 'default', - 'clr_note_title_year_focus_fg' : 'white', - 'clr_note_title_year_focus_bg' : 'default', - - 'clr_note_title_ancient_fg' : 'dark blue', - 'clr_note_title_ancient_bg' : 'default', - 'clr_note_title_ancient_focus_fg' : 'white', - 'clr_note_title_ancient_focus_bg' : 'default', - - 'clr_note_date_fg' : 'dark blue', - 'clr_note_date_bg' : 'default', - 'clr_note_date_focus_fg' : 'white', - 'clr_note_date_focus_bg' : 'default', - - 'clr_note_flags_fg' : 'dark blue', - 'clr_note_flags_bg' : 'default', - 'clr_note_flags_focus_fg' : 'white', - 'clr_note_flags_focus_bg' : 'default', - - 'clr_note_tags_fg' : 'dark blue', - 'clr_note_tags_bg' : 'default', - 'clr_note_tags_focus_fg' : 'white', - 'clr_note_tags_focus_bg' : 'default', - - 'clr_note_content_fg' : 'default', - 'clr_note_content_bg' : 'default', - 'clr_note_content_focus_fg' : 'white', - 'clr_note_content_focus_bg' : 'light red', - - 'clr_help_header_fg' : 'dark blue', - 'clr_help_header_bg' : 'default', - 'clr_help_key_fg' : 'default', - 'clr_help_key_bg' : 'default', - 'clr_help_config_fg' : 'dark green', - 'clr_help_config_bg' : 'default', - 'clr_help_descr_fg' : 'default', - 'clr_help_descr_bg' : 'default' - } + defaults = \ + { + 'sn_username' : '', + 'sn_password' : '', + 'db_path' : os.path.join(self.home, '.sncli'), + 'search_mode' : 'gstyle', + 'search_tags' : '1', + 'sort_mode' : '1', + 'pinned_ontop' : '1', + 'tabstop' : '4', + 'format_strftime' : '%Y/%m/%d', + 'format_note_title' : '[%D] %F %N%>%T', + + 'kb_help' : 'h', + 'kb_quit' : 'q', + 'kb_down' : 'j', + 'kb_up' : 'k', + 'kb_page_down' : ' ', + 'kb_page_up' : 'b', + 'kb_half_page_down' : 'ctrl d', + 'kb_half_page_up' : 'ctrl u', + 'kb_bottom' : 'G', + 'kb_top' : 'g', + 'kb_view_note' : 'enter', + 'kb_view_log' : 'l', + 'kb_tabstop2' : '2', + 'kb_tabstop4' : '4', + 'kb_tabstop8' : '8', + + 'clr_default_fg' : 'default', + 'clr_default_bg' : 'default', + + 'clr_note_title_day_fg' : 'dark blue', + 'clr_note_title_day_bg' : 'default', + 'clr_note_title_day_focus_fg' : 'white', + 'clr_note_title_day_focus_bg' : 'default', + + 'clr_note_title_week_fg' : 'dark blue', + 'clr_note_title_week_bg' : 'default', + 'clr_note_title_week_focus_fg' : 'white', + 'clr_note_title_week_focus_bg' : 'default', + + 'clr_note_title_month_fg' : 'dark blue', + 'clr_note_title_month_bg' : 'default', + 'clr_note_title_month_focus_fg' : 'white', + 'clr_note_title_month_focus_bg' : 'default', + + 'clr_note_title_year_fg' : 'dark blue', + 'clr_note_title_year_bg' : 'default', + 'clr_note_title_year_focus_fg' : 'white', + 'clr_note_title_year_focus_bg' : 'default', + + 'clr_note_title_ancient_fg' : 'dark blue', + 'clr_note_title_ancient_bg' : 'default', + 'clr_note_title_ancient_focus_fg' : 'white', + 'clr_note_title_ancient_focus_bg' : 'default', + + 'clr_note_date_fg' : 'dark blue', + 'clr_note_date_bg' : 'default', + 'clr_note_date_focus_fg' : 'white', + 'clr_note_date_focus_bg' : 'default', + + 'clr_note_flags_fg' : 'dark blue', + 'clr_note_flags_bg' : 'default', + 'clr_note_flags_focus_fg' : 'white', + 'clr_note_flags_focus_bg' : 'default', + + 'clr_note_tags_fg' : 'dark blue', + 'clr_note_tags_bg' : 'default', + 'clr_note_tags_focus_fg' : 'white', + 'clr_note_tags_focus_bg' : 'default', + + 'clr_note_content_fg' : 'default', + 'clr_note_content_bg' : 'default', + 'clr_note_content_focus_fg' : 'white', + 'clr_note_content_focus_bg' : 'light red', + + 'clr_help_header_fg' : 'dark blue', + 'clr_help_header_bg' : 'default', + 'clr_help_key_fg' : 'default', + 'clr_help_key_bg' : 'default', + 'clr_help_config_fg' : 'dark green', + 'clr_help_config_bg' : 'default', + 'clr_help_descr_fg' : 'default', + 'clr_help_descr_bg' : 'default' + } cp = ConfigParser.SafeConfigParser(defaults) self.configs_read = cp.read([os.path.join(self.home, '.snclirc')]) @@ -119,8 +120,8 @@ def __init__(self): self.format_strftime = cp.get(cfg_sec, 'format_strftime', raw=True) self.format_note_title = cp.get(cfg_sec, 'format_note_title', raw=True) - self.clr_default_fg = cp.get(cfg_sec, 'clr_default_fg') - self.clr_default_bg = cp.get(cfg_sec, 'clr_default_bg') + self.clr_default_fg = cp.get(cfg_sec, 'clr_default_fg') + self.clr_default_bg = cp.get(cfg_sec, 'clr_default_bg') self.clr_note_title_day_fg = cp.get(cfg_sec, 'clr_note_title_day_fg') self.clr_note_title_day_bg = cp.get(cfg_sec, 'clr_note_title_day_bg') @@ -167,33 +168,33 @@ def __init__(self): self.clr_note_content_focus_fg = cp.get(cfg_sec, 'clr_note_content_focus_fg') self.clr_note_content_focus_bg = cp.get(cfg_sec, 'clr_note_content_focus_bg') - self.clr_help_header_fg = cp.get(cfg_sec, 'clr_help_header_fg') - self.clr_help_header_bg = cp.get(cfg_sec, 'clr_help_header_bg') - self.clr_help_key_fg = cp.get(cfg_sec, 'clr_help_key_fg') - self.clr_help_key_bg = cp.get(cfg_sec, 'clr_help_key_bg') - self.clr_help_config_fg = cp.get(cfg_sec, 'clr_help_config_fg') - self.clr_help_config_bg = cp.get(cfg_sec, 'clr_help_config_bg') - self.clr_help_descr_fg = cp.get(cfg_sec, 'clr_help_descr_fg') - self.clr_help_descr_bg = cp.get(cfg_sec, 'clr_help_descr_bg') + self.clr_help_header_fg = cp.get(cfg_sec, 'clr_help_header_fg') + self.clr_help_header_bg = cp.get(cfg_sec, 'clr_help_header_bg') + self.clr_help_key_fg = cp.get(cfg_sec, 'clr_help_key_fg') + self.clr_help_key_bg = cp.get(cfg_sec, 'clr_help_key_bg') + self.clr_help_config_fg = cp.get(cfg_sec, 'clr_help_config_fg') + self.clr_help_config_bg = cp.get(cfg_sec, 'clr_help_config_bg') + self.clr_help_descr_fg = cp.get(cfg_sec, 'clr_help_descr_fg') + self.clr_help_descr_bg = cp.get(cfg_sec, 'clr_help_descr_bg') self.keybinds = \ - { - 'help' : [ cp.get(cfg_sec, 'kb_help'), 'Help' ], - 'quit' : [ cp.get(cfg_sec, 'kb_quit'), 'Quit' ], - 'down' : [ cp.get(cfg_sec, 'kb_down'), 'Scroll down one line' ], - 'up' : [ cp.get(cfg_sec, 'kb_up'), 'Scroll up one line' ], - 'page_down' : [ cp.get(cfg_sec, 'kb_page_down'), 'Page down' ], - 'page_up' : [ cp.get(cfg_sec, 'kb_page_up'), 'Page up' ], - 'half_page_down' : [ cp.get(cfg_sec, 'kb_half_page_down'), 'Half page down' ], - 'half_page_up' : [ cp.get(cfg_sec, 'kb_half_page_up'), 'Half page up' ], - 'bottom' : [ cp.get(cfg_sec, 'kb_bottom'), 'Goto bottom' ], - 'top' : [ cp.get(cfg_sec, 'kb_top'), 'Goto top' ], - 'view_note' : [ cp.get(cfg_sec, 'kb_view_note'), 'View note' ], - 'view_log' : [ cp.get(cfg_sec, 'kb_view_log'), 'View log' ], - 'tabstop2' : [ cp.get(cfg_sec, 'kb_tabstop2'), 'View with tabstop=2' ], - 'tabstop4' : [ cp.get(cfg_sec, 'kb_tabstop4'), 'View with tabstop=4' ], - 'tabstop8' : [ cp.get(cfg_sec, 'kb_tabstop8'), 'View with tabstop=8' ] - } + { + 'help' : [ cp.get(cfg_sec, 'kb_help'), 'Help' ], + 'quit' : [ cp.get(cfg_sec, 'kb_quit'), 'Quit' ], + 'down' : [ cp.get(cfg_sec, 'kb_down'), 'Scroll down one line' ], + 'up' : [ cp.get(cfg_sec, 'kb_up'), 'Scroll up one line' ], + 'page_down' : [ cp.get(cfg_sec, 'kb_page_down'), 'Page down' ], + 'page_up' : [ cp.get(cfg_sec, 'kb_page_up'), 'Page up' ], + 'half_page_down' : [ cp.get(cfg_sec, 'kb_half_page_down'), 'Half page down' ], + 'half_page_up' : [ cp.get(cfg_sec, 'kb_half_page_up'), 'Half page up' ], + 'bottom' : [ cp.get(cfg_sec, 'kb_bottom'), 'Goto bottom' ], + 'top' : [ cp.get(cfg_sec, 'kb_top'), 'Goto top' ], + 'view_note' : [ cp.get(cfg_sec, 'kb_view_note'), 'View note' ], + 'view_log' : [ cp.get(cfg_sec, 'kb_view_log'), 'View log' ], + 'tabstop2' : [ cp.get(cfg_sec, 'kb_tabstop2'), 'View with tabstop=2' ], + 'tabstop4' : [ cp.get(cfg_sec, 'kb_tabstop4'), 'View with tabstop=4' ], + 'tabstop8' : [ cp.get(cfg_sec, 'kb_tabstop8'), 'View with tabstop=8' ] + } class sncli: @@ -222,8 +223,8 @@ def __init__(self): self.last_view = [] # XXX - self.all_notes, match_regex, self.all_notes_cnt = self.ndb.filter_notes() - return + #self.all_notes, match_regex, self.all_notes_cnt = self.ndb.filter_notes() + #return self.ndb.add_observer('synced:note', self.observer_notes_db_synced_note) self.ndb.add_observer('change:note-status', self.observer_notes_db_change_note_status) @@ -259,15 +260,15 @@ def list_get_note_json(index): def get_config(): return self.config + def get_logfile(): + return self.logfile + def push_last_view(view): self.last_view.append(view) def pop_last_view(): return self.last_view.pop() - def get_logfile(): - return self.logfile - def handle_common_scroll_keybind(obj, size, key): if key == self.config.keybinds['down'][0]: