Esempio n. 1
0
def minion_find(args):
    search_filter = args['<text>']
    find_any = False
    if args['find']:
        find_any = True
    match_files = brain.find_files(filter=search_filter, archives=args['--archives'],
                                   find_any=find_any)

    # Set archives if no finds...
    total = brain.get_total_file_count(args['--archives'])

    # Display results / total
    notes_home = brain.get_notes_home()
    match_template = "{matching} of {total} files match search " +\
        "'{search}' in directory {directory}"
    print(match_template.format(
        directory=notes_home,
        matching=len(match_files),
        search=','.join(search_filter),
        total=total))

    # Display results
    # print match_files
    brain.display_output(
        title=None,
        output=match_files,
        raw_files=args['--files'],
    )

    sys.exit(0)
Esempio n. 2
0
def minion_find(args):
    search_filter = args['<text>']
    find_any = False
    if args['find']:
        find_any = True
    match_files = brain.find_files(filter=search_filter,
                                   archives=args['--archives'],
                                   find_any=find_any)

    # Set archives if no finds...
    total = brain.get_total_file_count(args['--archives'])

    # Display results / total
    notes_home = brain.get_notes_home()
    match_template = "{matching} of {total} files match search " +\
        "'{search}' in directory {directory}"
    print match_template.format(directory=notes_home,
                                matching=len(match_files),
                                search=','.join(search_filter),
                                total=total)

    # Display results
    # print match_files
    brain.display_output(
        title=None,
        output=match_files,
        raw_files=args['--files'],
    )

    sys.exit(0)
Esempio n. 3
0
def minion_count(args):
    search_terms = "%s: %s" % (os.path.basename(
        brain.get_notes_home()), ','.join(args['<text>']))
    match_files = get_match_files(args)
    count = len(match_files)
    print "%d - %s" % (count, search_terms)
    sys.exit()
Esempio n. 4
0
def minion_count(args):
    search_terms = "%s: %s" % (
        os.path.basename(brain.get_notes_home()), ','.join(args['<text>'])
    )
    match_files = get_match_files(args)
    count = len(match_files)
    print("%d - %s" % (count, search_terms))
    sys.exit()
Esempio n. 5
0
def minion_folders(args):
    updated_files = []
    # match_files = get_match_files(args)
    match_files = brain.find_files()
    # All poorly used folders
    too_few = 5
    notes_home = brain.get_notes_home()
    for folder in os.listdir(brain.get_notes_home()):
        folder = os.path.join(notes_home, folder)
        if os.path.isdir(folder):
            if len(os.listdir(folder)) < too_few:
                items = brain.find_files(filter=folder)
                for item in items:
                    updated_files.append(item)

    match_files = updated_files

    total = len(match_files)
    count = 0
    for item in match_files:
        count += 1
        print(brain.to_bar(count, total))
        _ = brain.doInboxInteractive(item)
Esempio n. 6
0
def minion_folders(args):
    updated_files = []
    # match_files = get_match_files(args)
    match_files = brain.find_files()
    # All poorly used folders
    too_few = 5
    notes_home = brain.get_notes_home()
    for folder in os.listdir(brain.get_notes_home()):
        folder = os.path.join(notes_home, folder)
        if os.path.isdir(folder):
            if len(os.listdir(folder)) < too_few:
                items = brain.find_files(filter=folder)
                for item in items:
                    updated_files.append(item)

    match_files = updated_files

    total = len(match_files)
    count = 0
    for item in match_files:
        count += 1
        print brain.to_bar(count, total)
        _ = brain.doInboxInteractive(item)
Esempio n. 7
0
def minion_tags(args):
    # Rid of this. Concept of 'tags' does not play well with the
    #       filesystem.
    # Switch to simply using any word as a 'tag'.
    # So what is 'poorly tagged'? Too short of a name? Too many common words?

    # A 'tag cloud' would be pretty awesome...
    notes_home = brain.get_notes_home()
    all_files = brain.find_files()
    word_count = dict()
    for filename in all_files:
        filename = filename.replace(notes_home, '')
        filename = filename.replace('/', '-').replace('.', '-')
        words = filename.split('-')
        print(words)
        for word in words:
            if word in word_count:
                word_count[word] += 1
            else:
                word_count[word] = 1
    # word_count.sort()
    print(word_count)
Esempio n. 8
0
def get_params(args):
    ''' Return some parameters common to many methods. '''
    PARAMS = {
        'topic_fragments': args['<text>'],
        'notes_dir': None,
        'note_template': None,
        'quick': False
    }

# Assign folder per command line parameter
    if args['--folder']:
        folder = os.path.expanduser(args['--folder'])
        notes_home = brain.get_notes_home()
        PARAMS['notes_dir'] = os.path.join(notes_home, folder)

    if args['--template']:
        PARAMS['note_template'] = args['--template']

    if args['--quick']:
        PARAMS['quick'] = True

    return PARAMS
Esempio n. 9
0
def minion_tags(args):
    # Rid of this. Concept of 'tags' does not play well with the
    #       filesystem.
    # Switch to simply using any word as a 'tag'.
    # So what is 'poorly tagged'? Too short of a name? Too many common words?

    # A 'tag cloud' would be pretty awesome...
    notes_home = brain.get_notes_home()
    all_files = brain.find_files()
    word_count = dict()
    for filename in all_files:
        filename = filename.replace(notes_home, '')
        filename = filename.replace('/', '-').replace('.', '-')
        words = filename.split('-')
        print words
        for word in words:
            if word in word_count:
                word_count[word] += 1
            else:
                word_count[word] = 1
    # word_count.sort()
    print word_count
Esempio n. 10
0
def get_params(args):
    ''' Return some parameters common to many methods. '''
    PARAMS = {
        'topic_fragments': args['<text>'],
        'notes_dir': None,
        'note_template': None,
        'quick': False
    }

    # Assign folder per command line parameter
    if args['--folder']:
        folder = os.path.expanduser(args['--folder'])
        notes_home = brain.get_notes_home()
        PARAMS['notes_dir'] = os.path.join(notes_home, folder)

    if args['--template']:
        PARAMS['note_template'] = args['--template']

    if args['--quick']:
        PARAMS['quick'] = True

    return PARAMS