def get_logs_times(wikidir, period, reference_date=None): """Get constituent log notes and time spent for the specified period. E.g. for a month, this would return the notes and times for each contained week. Return notes separated by lines and headed by dates. :param str wikidir: The path to the planner wiki :param :class:`~composer.timeperiod.Period` period: A :returns tuple: The logs (str) and times (list) """ planner = FilesystemPlanner(wikidir) reference_date = reference_date or planner.date current_date = period.get_start_date(reference_date) logs = get_constituent_logs(period, current_date, wikidir) constituent_period = get_next_period(period, decreasing=True) (logs_string, times) = ("", []) for log in logs: (log, time) = extract_log_time_from_text(log.read()) start_date = constituent_period.get_start_date(current_date) # TODO: in case of missing logs, this mislabels the # log period. Instead, rely on get_constituent_logs to # provide source information instead of independently # computing things here logs_string += ( get_log_filename(start_date, constituent_period) + "\n" + log + "\n\n" ) times.append(time) current_date = constituent_period.get_end_date( current_date ) + timedelta(days=1) return (logs_string, times)
def test_advance_planner_year(): """Actually operate on a wiki that's configured such that a year advance is in order. After running the test check that this is what has happened (git status / diff if git managed test wikis) """ WIKIPATH = 'tests/testwikis/yearwiki' tasklist = FilesystemTasklist(WIKIPATH) planner = FilesystemPlanner(WIKIPATH, tasklist) preferences = {'week_theme': '', 'agenda_reviewed': Year} planner.set_preferences(preferences) status, next_day_planner = planner.advance() next_period = get_next_period(status) if status < Year else status planner.save(next_period) next_day_planner.save(status) planner.tasklist.save() assert status == Year