Пример #1
0
def add_note(mn, config_store, args):
    """
    Save a new note.

    :param Mininote mn: Mininote instance
    :param ConfigStore config_store: User configuration
    :param argparse.Namespace args: Command line options
    """
    if args.note is None:
        note_string = raw_input(colorstr('DIM', 'mn> '))
    else:
        note_string = args.note
    mn.add_note(Note(note_string))
Пример #2
0
def query_notes(mn, config_store, args):
    """
    Display search results.

    :param Mininote mn: Mininote instance
    :param ConfigStore config_store: User configuration
    :param argparse.Namespace args: Command line options
    """
    from collections import Counter

    INLINE_TAG_STYLE = 'BRIGHT-CYAN'
    INLINE_DATE_STYLE = 'MAGENTA'
    TAGLIST_TAG_STYLE = 'BRIGHT-CYAN'
    TAGLIST_COUNT_STYLE = 'DIM'

    def colorize(word):
        if word.startswith('#'):
            return colorstr(INLINE_TAG_STYLE, word)
        else:
            return word

    time0 = time.time()
    tagcounts = Counter()
    for note in mn.search(args.note):
        tagcounts.update(note.tags)
        colordate = colorstr(INLINE_DATE_STYLE,
                             '{}: '.format(note.strft_created_time))
        colortext = ' '.join(map(colorize, note.text.split(' ')))
        print(colordate + colortext)

    if len(tagcounts) > 0:
        print('\n' + ' '.join([
            colorstr(TAGLIST_TAG_STYLE, '#{}'.format(tag)) +
            colorstr(TAGLIST_COUNT_STYLE, ' ({}) '.format(count))
            for tag, count in sorted(
                tagcounts.items(), key=lambda p: p[1], reverse=True)
        ]))

    logger.debug('Total search/display time: {}'.format(time.time() - time0))
Пример #3
0
def add_note(mn, config_store, args):
    """
    Save a new note.

    :param Mininote mn: Mininote instance
    :param ConfigStore config_store: User configuration
    :param argparse.Namespace args: Command line options
    """
    if args.note is None:
        note_string = raw_input(colorstr('DIM', 'mn> '))
    else:
        note_string = args.note
    mn.add_note(Note(note_string))
Пример #4
0
def query_notes(mn, config_store, args):
    """
    Display search results.

    :param Mininote mn: Mininote instance
    :param ConfigStore config_store: User configuration
    :param argparse.Namespace args: Command line options
    """
    from collections import Counter

    INLINE_TAG_STYLE = 'BRIGHT-CYAN'
    INLINE_DATE_STYLE = 'MAGENTA'
    TAGLIST_TAG_STYLE = 'BRIGHT-CYAN'
    TAGLIST_COUNT_STYLE = 'DIM'

    def colorize(word):
        if word.startswith('#'):
            return colorstr(INLINE_TAG_STYLE, word)
        else:
            return word

    time0 = time.time()
    tagcounts = Counter()
    for note in mn.search(args.note):
        tagcounts.update(note.tags)
        colordate = colorstr(INLINE_DATE_STYLE, '{}: '.format(note.strft_created_time))
        colortext = ' '.join(map(colorize, note.text.split(' ')))
        print(colordate + colortext)

    if len(tagcounts) > 0:
        print('\n' + ' '.join([colorstr(TAGLIST_TAG_STYLE, '#{}'.format(tag)) +
                               colorstr(TAGLIST_COUNT_STYLE, ' ({}) '.format(count))
                               for tag, count
                               in sorted(tagcounts.items(), key=lambda p:p[1], reverse=True)]))

    logger.debug('Total search/display time: {}'.format(time.time()-time0))
Пример #5
0
 def colorize(word):
     if word.startswith('#'):
         return colorstr(INLINE_TAG_STYLE, word)
     else:
         return word
Пример #6
0
 def colorize(word):
     if word.startswith('#'):
         return colorstr(INLINE_TAG_STYLE, word)
     else:
         return word