nncli

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

commit 8df81bd4383e76510be68d63573fd94db967fc72
parent 87cb4ece7b2cb0350f1b699cc5fe1916e0054692
Author: Samuel Walladge <samuel@swalladge.id.au>
Date:   Sat, 11 Feb 2017 17:43:04 +1030

deterministic tag sorting, use configured sort mode on start

Diffstat:
Msimplenote_cli/sncli.py | 6++++--
Msimplenote_cli/utils.py | 3++-
Msimplenote_cli/view_titles.py | 2+-
3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/simplenote_cli/sncli.py b/simplenote_cli/sncli.py @@ -1036,7 +1036,8 @@ def cli_list_notes(self, regex, search_string): note_list, match_regex, all_notes_cnt = \ self.ndb.filter_notes( search_string, - search_mode='regex' if regex else 'gstyle') + search_mode='regex' if regex else 'gstyle', + sort_mode=self.config.get_config('sort_mode')) for n in note_list: flags = utils.get_note_flags(n.note) print((n.key + \ @@ -1077,7 +1078,8 @@ def cli_dump_notes(self, regex, search_string): note_list, match_regex, all_notes_cnt = \ self.ndb.filter_notes( search_string, - search_mode='regex' if regex else 'gstyle') + search_mode='regex' if regex else 'gstyle', + sort_mode=self.config.get_config('sort_mode')) for n in note_list: self.cli_note_dump(n.key) diff --git a/simplenote_cli/utils.py b/simplenote_cli/utils.py @@ -151,7 +151,8 @@ def sort_by_title_pinned(a): def sort_notes_by_tags(notes, pinned_ontop=False): notes.sort(key=lambda i: (pinned_ontop and not note_pinned(i.note), len(i.note.get('tags')) == 0, - i.note.get('tags'))) + i.note.get('tags', []), + -float(i.note.get('modifydate', 0)))) def sort_by_modify_date_pinned(a): if note_pinned(a.note): diff --git a/simplenote_cli/view_titles.py b/simplenote_cli/view_titles.py @@ -13,7 +13,7 @@ def __init__(self, config, args): self.search_string = args['search_string'] self.log = args['log'] self.note_list, self.match_regex, self.all_notes_cnt = \ - self.ndb.filter_notes(self.search_string) + self.ndb.filter_notes(self.search_string, sort_mode=self.config.get_config('sort_mode')) super(ViewTitles, self).__init__( urwid.SimpleFocusListWalker(self.get_note_titles()))