예제 #1
0
파일: minion.py 프로젝트: pavelki/minion
def date_sort(filename):
    '''Provide a date sort that puts None first.'''
    content = brain.get_file_content(filename)
    first_date = brain.get_first_date(content)
    if first_date:
        return first_date
    return datetime.datetime.now()
예제 #2
0
파일: minion.py 프로젝트: rbianco3/minion
def date_sort(filename):
    '''Provide a date sort that puts None first.'''
    content = brain.get_file_content(filename)
    first_date = brain.get_first_date(content)
    if first_date:
        return first_date
    return datetime.datetime.now()
예제 #3
0
    def test_create_new_note(self):
        TestFileStuff.clean_directory()

        file_path, _ = brain.create_new_note(TEST_TOPIC, note_template='note')
        file_count = os.listdir(TEST_DATA_DIRECTORY)
        self.assertEqual(len(file_count), 1)
        self.assertEqual(file_path, TEST_FILE_PATH)

        content = brain.get_file_content(TEST_FILE_PATH)
        self.assertTrue(TEST_FILE_INITIAL_CONTENT in content)
예제 #4
0
    def test_create_new_note(self):
        TestFileStuff.clean_directory()

        file_path, _ = brain.create_new_note(TEST_TOPIC, note_template='note')
        file_count = os.listdir(TEST_DATA_DIRECTORY)
        self.assertEqual(len(file_count), 1)
        self.assertEqual(file_path, TEST_FILE_PATH)

        content = brain.get_file_content(TEST_FILE_PATH)
        self.assertTrue(TEST_FILE_INITIAL_CONTENT in content)
예제 #5
0
파일: minion.py 프로젝트: rbianco3/minion
def minion_dates(args):
    '''Display all notes with dates in them and filtered by keywords.'''
    events = dict()
    match_files = get_match_files(args)
    for filename in match_files:
        content = brain.get_file_content(filename)
        dates = brain.get_unique_dates(content)
        if dates:
            for date in dates:
                try:
                    if date in events:
                        events[date].append(filename)
                    else:
                        events[date] = [filename]
                except ValueError:
                    # Date before 1900
                    _LOGGER.warn('Encountered date before 1900.')

    days_back = int(brain.get_setting('notes', 'default_recent_days'))
    recent_date = datetime.datetime.today() - datetime.timedelta(
        days=days_back)
    recent_date = recent_date.date()
    upcoming = dict()
    recent = dict()
    today = dict()
    # Sort the events into three sets - past, today and upcoming
    today_date = datetime.datetime.today().date()
    for key in events:
        date_str = key.strftime(get_date_format())
        if key > today_date:
            upcoming[date_str] = events[key]
        elif key == today_date:
            today[date_str] = events[key]
        elif key > recent_date:
            recent[date_str] = events[key]

    brain.display_output('Recent Dates', recent)
    print
    brain.display_output('Today', today)
    print
    brain.display_output('Upcoming Dates', upcoming)
    print
예제 #6
0
파일: minion.py 프로젝트: pavelki/minion
def minion_dates(args):
    '''Display all notes with dates in them and filtered by keywords.'''
    events = dict()
    match_files = get_match_files(args)
    for filename in match_files:
        content = brain.get_file_content(filename)
        dates = brain.get_unique_dates(content)
        if dates:
            for date in dates:
                try:
                    if date in events:
                        events[date].append(filename)
                    else:
                        events[date] = [filename]
                except ValueError:
                    # Date before 1900
                    _LOGGER.warn('Encountered date before 1900.')

    days_back = int(brain.get_setting('notes', 'default_recent_days'))
    recent_date = datetime.datetime.today() - datetime.timedelta(days=days_back)
    recent_date = recent_date.date()
    upcoming = dict()
    recent = dict()
    today = dict()
    # Sort the events into three sets - past, today and upcoming
    today_date = datetime.datetime.today().date()
    for key in events:
        date_str = key.strftime(get_date_format())
        if key > today_date:
            upcoming[date_str] = events[key]
        elif key == today_date:
            today[date_str] = events[key]
        elif key > recent_date:
            recent[date_str] = events[key]

    brain.display_output('Recent Dates', recent)
    print()
    brain.display_output('Today', today)
    print()
    brain.display_output('Upcoming Dates', upcoming)
    print()