Exemple #1
0
    def invoke(self, args, note_q_get):
        """
        If neither sorting, nor the notes are requested, this method
        hands off the work to ``invoke_on_note``.

        All other cases are handled within this method.
        """

        # we cover the easiest "default" approach with this guard clause:
        if not args.notes and not args.sort:
            self._printed_tags = set()
            super(TagsSubCommand, self).invoke(args, note_q_get)
            return

        # collect all tags and if required all corresponding notes
        tags_and_notes = {}
        for note in set(iter(note_q_get, QUEUE_END_SYMBOL)):
            for tag in note.tags:
                notes = tags_and_notes.setdefault(tag, set())
                if args.notes:
                    notes.add(note)

        # sort the tags if need be
        tags = tags_and_notes.keys()
        if args.sort:
            tags.sort(key=lambda s: s.lower())

        # output
        for tag in tags:
            print_colored_2("#%s\n" % tag)
            if args.notes:
                for note in tags_and_notes[tag]:
                    print_default("\t%s\n" % note)
Exemple #2
0
    def invoke(self, args, note_q_get):
        """
        If neither sorting, nor the notes are requested, this method
        hands off the work to ``invoke_on_note``.

        All other cases are handled within this method.
        """

        # we cover the easiest "default" approach with this guard clause:
        if not args.notes and not args.sort:
            self._printed_tags = set()
            super(TagsSubCommand, self).invoke(args, note_q_get)
            return

        # collect all tags and if required all corresponding notes
        tags_and_notes = {}
        for note in set(iter(note_q_get, QUEUE_END_SYMBOL)):
            for tag in note.tags:
                notes = tags_and_notes.setdefault(tag, set())
                if args.notes:
                    notes.add(note)

        # sort the tags if need be
        tags = tags_and_notes.keys()
        if args.sort:
            tags.sort(key=lambda s: s.lower())

        # output
        for tag in tags:
            print_colored_2("#%s\n" % tag)
            if args.notes:
                for note in tags_and_notes[tag]:
                    print_default("\t%s\n" % note)
Exemple #3
0
 def invoke_on_note(self, args, note):
     """
     Prints tags w/o sorting them and w/o displaying corresponding
     notes.
     """
     for tag in set(note.tags) - self._printed_tags:
         print_colored_2("#%s\n" % tag)
         self._printed_tags.add(tag)
Exemple #4
0
 def invoke_on_note(self, args, note):
     """
     Prints tags w/o sorting them and w/o displaying corresponding
     notes.
     """
     for tag in set(note.tags) - self._printed_tags:
         print_colored_2("#%s\n" % tag)
         self._printed_tags.add(tag)
Exemple #5
0
    def invoke_on_note(self, args, note):
        self.listed_paths.append(note.abspath)

        print_colored("%u " % len(self.listed_paths), True)
        pathname, filename = path_split(note.path)
        print_default("%s%s" % (pathname, pathsep))
        print_highlighted("%s%s" % (filename, linesep))

        if args.tags:
            tags = note.tags
            if tags:
                print_default("\n")
                for tag in tags:
                    print_colored_2("\t#%s\n" % tag)
                print_default("\n")
Exemple #6
0
    def invoke_on_note(self, args, note):
        self.listed_paths.append(note.abspath)

        print_colored("%u " % len(self.listed_paths), True)
        pathname, filename = path_split(note.path)
        print_default("%s%s" % (pathname, pathsep))
        print_highlighted("%s%s" % (filename, linesep))

        if args.tags:
            tags = note.tags
            if tags:
                print_default("\n")
                for tag in tags:
                    print_colored_2("\t#%s\n" % tag)
                print_default("\n")