nncli

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

commit 02cbf284ab0828a1d40d1724bd25eceb3a20b8c6
parent f7f8a7d9ef1c73b81a9195b9eb9fe7e46310f065
Author: Eric Davis <edavis@insanum.com>
Date:   Fri, 11 Jul 2014 16:44:21 -0700

new flag 'T' for a trashed note

Diffstat:
Msncli.py | 14+++-----------
Mutils.py | 10++++++++++
Mview_note.py | 5+----
Mview_titles.py | 13++-----------
4 files changed, 16 insertions(+), 26 deletions(-)

diff --git a/sncli.py b/sncli.py @@ -795,18 +795,10 @@ def cli_list_notes(self, search_string): note_list, match_regex, all_notes_cnt = \ self.ndb.filter_notes(search_string) for n in note_list: - note = n.note - if 'systemtags' in note: - flags = '' - if 'pinned' in note['systemtags']: flags = flags + u'*' - else: flags = flags + u' ' - if 'markdown' in note['systemtags']: flags = flags + u'm' - else: flags = flags + u' ' - else: - flags = ' ' - print note['key'] + \ + flags = utils.get_note_flags(n.note) + print n.key + \ u' [' + flags + u'] ' + \ - utils.get_note_title(note) + utils.get_note_title(n.note) def cli_dump_notes(self, search_string, key=None): diff --git a/utils.py b/utils.py @@ -14,6 +14,16 @@ def generate_random_key(): """ return '%030x' % (random.randrange(256**15),) +def get_note_flags(note): + flags = '' + flags += u'T' if note['deleted'] else u' ' + if 'systemtags' in note: + flags += u'*' if 'pinned' in note['systemtags'] else u' ' + flags += u'm' if 'markdown' in note['systemtags'] else u' ' + else: + flags += ' ' + return flags + def get_note_title(note): mo = note_title_re.match(note.get('content', '')) if mo: diff --git a/view_note.py b/view_note.py @@ -66,10 +66,7 @@ def get_status_bar(self): mod_time, wrap='clip'), 'status_bar') - flags = '' - if self.note.has_key("systemtags"): - if 'pinned' in self.note['systemtags']: flags = flags + u'*' - if 'markdown' in self.note['systemtags']: flags = flags + u'm' + flags = utils.get_note_flags(self.note) status_tags_flags = \ ('pack', urwid.AttrMap(urwid.Text(u'[' + tags + u'] [' + flags + u']'), 'status_bar')) diff --git a/view_titles.py b/view_titles.py @@ -37,23 +37,14 @@ def format_title(self, note): specifier (decimal) and a left justification (-) like that supported by printf. - %F -- flags ('*' for pinned, 'm' for markdown) + %F -- flags ('T' for trashed, '*' for pinned, 'm' for markdown) %T -- tags %D -- date %N -- note title """ title = utils.get_note_title(note) - - # get the note flags - if note.has_key("systemtags"): - flags = '' - if 'pinned' in note['systemtags']: flags = flags + u'*' - else: flags = flags + u' ' - if 'markdown' in note['systemtags']: flags = flags + u'm' - else: flags = flags + u' ' - else: - flags = ' ' + flags = utils.get_note_flags(note) # get the note tags tags = '%s' % ','.join(note['tags'])