Example #1
0
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)
Example #2
0
 def setUp(self):
     self.planner = FilesystemPlanner()
     self.planner.date = datetime.date.today()
     tasklist = FilesystemTasklist()
     tasklist.file = StringIO(self.tasklist)
     self.planner.tasklist = tasklist
     self.planner.daythemesfile = StringIO(self.daythemes)
     self.planner.dayfile = StringIO(self.daytemplate)
     self.planner.weekfile = StringIO(self.weektemplate)
     self.planner.monthfile = StringIO(self.monthtemplate)
     self.planner.quarterfile = StringIO(self.quartertemplate)
     self.planner.yearfile = StringIO(self.yeartemplate)
     self.planner.checkpoints_year_file = StringIO(self.checkpoints_year)
     self.planner.checkpoints_quarter_file = StringIO(
         self.checkpoints_quarter
     )
     self.planner.checkpoints_month_file = StringIO(self.checkpoints_month)
     self.planner.checkpoints_week_file = StringIO(self.checkpoints_week)
     self.planner.checkpoints_weekday_file = StringIO(
         self.checkpoints_weekday
     )
     self.planner.checkpoints_weekend_file = StringIO(
         self.checkpoints_weekend
     )
     self.planner.periodic_year_file = StringIO(self.periodic_year)
     self.planner.periodic_quarter_file = StringIO(self.periodic_quarter)
     self.planner.periodic_month_file = StringIO(self.periodic_month)
     self.planner.periodic_week_file = StringIO(self.periodic_week)
     self.planner.periodic_day_file = StringIO(self.periodic_day)
     self.planner.week_theme = ''
     self.planner.location = ''
     self.planner.next_day_planner = FilesystemPlanner()
     self.planner.agenda_reviewed = Year
     mock_get_log = MagicMock()
     mock_get_log.return_value = True
     self.planner.get_log = mock_get_log
Example #3
0
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
Example #4
0
    def test_agenda_does_not_have_scheduled_tasks(self):
        """Check that if a scheduled task on the current day's agenda is
        technically due tomorrow, it isn't carried over by the logfile
        creation process since it should happen indirectly via tasklist advance
        which would place the task in the tomorrow section if applicable.
        """
        # TODO: note this test is almost identical to the undone one, with just
        # a different date -- obviously, these tests need to be refactored at
        # some point
        next_day = datetime.date(2012, 12, 25)
        (date, day, month, year) = (
            next_day.day,
            next_day.strftime('%A'),
            next_day.strftime('%B'),
            next_day.year,
        )
        tasklist = FilesystemTasklist()
        tasklist.file = StringIO(self.tasklist)
        daythemesfile = StringIO(self.daythemes)
        dayfile = StringIO(self.daytemplate_undone)
        checkpointsfile = StringIO(self.checkpoints_weekday)
        periodicfile = StringIO(self.periodic_day)
        checkpointsfile = StringIO(self.checkpoints_weekday)

        planner = FilesystemPlanner()
        planner.tasklist = tasklist
        planner.daythemesfile = daythemesfile
        planner.checkpoints_weekday_file = checkpointsfile
        planner.periodic_day_file = periodicfile
        planner.dayfile = dayfile
        planner.next_day_planner = FilesystemPlanner()

        dailythemes = self.daythemes.lower()
        theme = dailythemes[dailythemes.index(day.lower()):]
        theme = theme[theme.index(':'):].strip(': ')
        theme = theme[:theme.index('\n')].strip().upper()
        theme = "*" + theme + "*"

        daytemplate = ""
        daytemplate += "= %s %s %d, %d =\n" % (
            day.upper(),
            month[:3].upper(),
            date,
            year,
        )
        daytemplate += "\n"
        if len(theme) > 2:
            daytemplate += "Theme: %s\n" % theme
            daytemplate += "\n"
        daytemplate += "CHECKPOINTS:\n"
        daytemplate += self.checkpoints_weekday
        daytemplate += "\n"
        daytemplate += "AGENDA:\n"
        daytemplate += "[ ] s'posed to do\n"
        daytemplate += "[\\] kinda did\n"
        daytemplate += "\n"
        daytemplate += "DAILYs:\n"
        daytemplate += self.periodic_day
        daytemplate += "\n"
        daytemplate += "NOTES:\n\n\n"
        daytemplate += "TIME SPENT ON PLANNER: "

        planner.create_log(Day, next_day)

        self.assertEqual(planner.next_day_planner.dayfile.read(), daytemplate)
Example #5
0
    def test_agenda_has_both_tomorrows_tasks_and_undone_tasks(self):
        """ Check that tomorrow's agenda has both undone tasks from today's agenda as well as tasks added for tomorrow """
        next_day = datetime.date(2012, 12, 10)
        (date, day, month, year) = (
            next_day.day,
            next_day.strftime('%A'),
            next_day.strftime('%B'),
            next_day.year,
        )
        tasklist = FilesystemTasklist()
        tasklist.file = StringIO(self.tasklist_tomorrow)
        daythemesfile = StringIO(self.daythemes)
        dayfile = StringIO(self.daytemplate_undone)
        checkpointsfile = StringIO(self.checkpoints_weekday)
        periodicfile = StringIO(self.periodic_day)
        checkpointsfile = StringIO(self.checkpoints_weekday)

        planner = FilesystemPlanner()
        planner.tasklist = tasklist
        planner.daythemesfile = daythemesfile
        planner.checkpoints_weekday_file = checkpointsfile
        planner.periodic_day_file = periodicfile
        planner.dayfile = dayfile
        planner.next_day_planner = FilesystemPlanner()

        dailythemes = self.daythemes.lower()
        theme = dailythemes[dailythemes.index(day.lower()):]
        theme = theme[theme.index(':'):].strip(': ')
        theme = theme[:theme.index('\n')].strip().upper()
        theme = "*" + theme + "*"

        daytemplate = ""
        daytemplate += "= %s %s %d, %d =\n" % (
            day.upper(),
            month[:3].upper(),
            date,
            year,
        )
        daytemplate += "\n"
        if len(theme) > 2:
            daytemplate += "Theme: %s\n" % theme
            daytemplate += "\n"
        daytemplate += "CHECKPOINTS:\n"
        daytemplate += self.checkpoints_weekday
        daytemplate += "\n"
        daytemplate += "AGENDA:\n"
        daytemplate += "[ ] contact dude\n"
        daytemplate += "[\\] make X\n"
        daytemplate += "[o] call somebody [$DECEMBER 12, 2012$]\n"
        daytemplate += "[o] apply for something [DECEMBER 26, 2012]\n"
        daytemplate += "[ ] finish project\n"
        daytemplate += "[ ] s'posed to do\n"
        daytemplate += "[\\] kinda did\n"
        daytemplate += "\n"
        daytemplate += "DAILYs:\n"
        daytemplate += self.periodic_day
        daytemplate += "\n"
        daytemplate += "NOTES:\n\n\n"
        daytemplate += "TIME SPENT ON PLANNER: "

        planner.create_log(Day, next_day)

        self.assertEqual(planner.next_day_planner.dayfile.read(), daytemplate)
Example #6
0
    def test_agenda_has_undone_tasks(self):
        """ Check that any undone tasks from today are carried over to tomorrow's agenda """
        next_day = datetime.date(2012, 12, 10)
        (date, day, month, year) = (
            next_day.day,
            next_day.strftime('%A'),
            next_day.strftime('%B'),
            next_day.year,
        )
        tasklist = FilesystemTasklist()
        tasklist.file = StringIO(self.tasklist)
        daythemesfile = StringIO(self.daythemes)
        dayfile = StringIO(self.daytemplate_undone)
        checkpointsfile = StringIO(self.checkpoints_weekday)
        periodicfile = StringIO(self.periodic_day)
        checkpointsfile = StringIO(self.checkpoints_weekday)

        planner = FilesystemPlanner()
        planner.tasklist = tasklist
        planner.daythemesfile = daythemesfile
        planner.checkpoints_weekday_file = checkpointsfile
        planner.periodic_day_file = periodicfile
        planner.dayfile = dayfile
        planner.next_day_planner = FilesystemPlanner()

        dailythemes = self.daythemes.lower()
        theme = dailythemes[dailythemes.index(day.lower()):]
        theme = theme[theme.index(':'):].strip(': ')
        theme = theme[:theme.index('\n')].strip().upper()
        theme = "*" + theme + "*"

        daytemplate = ""
        daytemplate += "= %s %s %d, %d =\n" % (
            day.upper(),
            month[:3].upper(),
            date,
            year,
        )
        daytemplate += "\n"
        if len(theme) > 2:
            daytemplate += "Theme: %s\n" % theme
            daytemplate += "\n"
        daytemplate += "CHECKPOINTS:\n"
        daytemplate += self.checkpoints_weekday
        daytemplate += "\n"
        daytemplate += "AGENDA:\n"
        daytemplate += "[ ] s'posed to do\n"
        daytemplate += "[\\] kinda did\n"
        daytemplate += "\n"
        daytemplate += "DAILYs:\n"
        daytemplate += self.periodic_day
        daytemplate += "\n"
        daytemplate += "NOTES:\n\n\n"
        daytemplate += "TIME SPENT ON PLANNER: "

        planner.create_log(Day, next_day)

        self.assertEqual(planner.next_day_planner.dayfile.read(), daytemplate)
Example #7
0
    def test_agenda_is_empty_when_tomorrow_and_undone_are_empty(self):
        """ Check that tomorrow's agenda is empty when no tasks are undone from today, and no tasks have been added for tomorrow """
        next_day = datetime.date(2012, 12, 10)
        (date, day, month, year) = (
            next_day.day,
            next_day.strftime('%A'),
            next_day.strftime('%B'),
            next_day.year,
        )
        tasklist = FilesystemTasklist()
        tasklist.file = StringIO(self.tasklist)
        daythemesfile = StringIO(self.daythemes)
        dayfile = StringIO(self.daytemplate)
        checkpointsfile = StringIO(self.checkpoints_weekday)
        periodicfile = StringIO(self.periodic_day)
        checkpointsfile = StringIO(self.checkpoints_weekday)

        planner = FilesystemPlanner()
        planner.tasklist = tasklist
        planner.daythemesfile = daythemesfile
        planner.checkpoints_weekday_file = checkpointsfile
        planner.periodic_day_file = periodicfile
        planner.dayfile = dayfile
        planner.next_day_planner = FilesystemPlanner()

        dailythemes = self.daythemes.lower()
        theme = dailythemes[dailythemes.index(day.lower()):]
        theme = theme[theme.index(':'):].strip(': ')
        theme = theme[:theme.index('\n')].strip().upper()
        theme = "*" + theme + "*"

        daytemplate = ""
        daytemplate += "= %s %s %d, %d =\n" % (
            day.upper(),
            month[:3].upper(),
            date,
            year,
        )
        daytemplate += "\n"
        if len(theme) > 2:
            daytemplate += "Theme: %s\n" % theme
            daytemplate += "\n"
        daytemplate += "CHECKPOINTS:\n"
        daytemplate += self.checkpoints_weekday
        daytemplate += "\n"
        daytemplate += "AGENDA:\n"
        daytemplate += "\n"
        daytemplate += "DAILYs:\n"
        daytemplate += self.periodic_day
        daytemplate += "\n"
        daytemplate += "NOTES:\n\n\n"
        daytemplate += "TIME SPENT ON PLANNER: "

        planner.create_log(Day, next_day)

        self.assertEqual(planner.next_day_planner.dayfile.read(), daytemplate)
Example #8
0
def _planner():
    tasklist_contents = (
        "TOMORROW:\n"
        "[ ] contact dude\n"
        "[\\] make X\n"
        "[ ] call somebody\n"
        "[ ] finish project\n"
        "\n"
        "THIS WEEK:\n"
        "[\\] write a script to automatically pull from plan files into a current day in planner (replacing template files)\n"
        "[ ] help meags set up planner\n"
        "\t[x] create life mindmap with meags\n"
        "\t[x] incorporate life mindmap into planner with meags\n"
        "\t[x] swap meags' Esc and CapsLock on personal laptop\n"
        "\t[x] vim education and workflow\n"
        "\t[x] help meags build a routine of entering data for the day\n"
        "\t[ ] meags to schedule all activities (currently unscheduled)\n"
        "\t[ ] set up meags work laptop with vim/planner/truecrypt/dropbox\n"
        "\t[-] set up git access on your domain\n"
        "\t[ ] set up dropbox+truecrypt planner access for meags\n"
        "\n"
        "THIS MONTH:\n"
        "[ ] get India Tour reimbursement\n"
        "\t[x] resend all receipts and info to Amrit\n"
        "\t[x] send reminder email to Amrit\n"
        "\t[x] coordinate with amrit to go to stanford campus\n"
        "\t[x] remind amrit if no response\n"
        "\t[x] check Stanford calendar for appropriate time\n"
        "\t[x] email amrit re: thursday?\n"
        "\t[x] email amrit re: monday [$FRIDAY MORNING$]\n"
        "\t[x] wait for response\n"
        "\t[-] send reminder on Wed night\n"
        "\t[x] respond to amrit's email re: amount correction\n"
        "\t[x] wait to hear back [remind $MONDAY$]\n"
        "\t[-] followup with ASSU on reimbursement [$TUESDAY$]\n"
        "\t[x] pick up reimbursement, give difference check to raag\n"
        "\t[x] cash check\n"
        "\t[x] confirm deposit\n"
        "\t[ ] confirm debit of 810 by raag [$DECEMBER 10$]\n"
        "[ ] do residual monthlys\n"
        "[ ] get a good scratchy post for ferdy (fab?)\n"
        "\n"
        "SOMEDAY:\n")

    yeartemplate = ("= 2012 =\n"
                    "\n"
                    'Theme: *"PUT IT BACK" 2012*\n'
                    "\n"
                    "\t* [[Q2 2012]]\n"
                    "\t* [[Q1 2012]]\n"
                    "\n"
                    "CHECKPOINTS:\n"
                    "[ ] Q1 - []\n"
                    "[ ] Q2 - []\n"
                    "[ ] Q3 - []\n"
                    "[ ] Q4 - []\n"
                    "\n"
                    "AGENDA:\n"
                    "\n"
                    "YEARLYs:\n"
                    "[ ] 1 significant life achievement\n"
                    "\n"
                    "NOTES:\n"
                    "\n"
                    "\n"
                    "TIME SPENT ON PLANNER: \n")

    quartertemplate = ("= Q3 2012 =\n"
                       "\n"
                       "\t* [[Month of July, 2012]]\n"
                       "\n"
                       "CHECKPOINTS:\n"
                       "[ ] MONTH 1 - []\n"
                       "[ ] MONTH 2 - []\n"
                       "[ ] MONTH 3 - []\n"
                       "\n"
                       "AGENDA:\n"
                       "\n"
                       "QUARTERLYs:\n"
                       "[ ] 1 major research achievement\n"
                       "[ ] 1 major coding achievement\n"
                       "[ ] 1 unique achievement\n"
                       "[ ] update financials\n"
                       "\n"
                       "NOTES:\n"
                       "\n"
                       "\n"
                       "TIME SPENT ON PLANNER: \n")

    monthtemplate = (
        "= DECEMBER 2012 =\n"
        "\t* [[Week of December 1, 2012]]\n"
        "\n"
        "CHECKPOINTS:\n"
        "[ ] WEEK 1 - []\n[ ] WEEK 2 - []\n[ ] WEEK 3 - []\n[ ] WEEK 4 - []\n"
        "\n"
        "AGENDA:\n"
        "\n"
        "MONTHLYs:\n"
        "[ ] Read 1 book\n[ ] Complete 1 nontrivial coding objective\n[ ] publish 1 blog post\n[ ] backup laptop data\n[ ] update financials\n"
        "\n"
        "NOTES:\n"
        "\n\n"
        "TIME SPENT ON PLANNER: ")

    weektemplate = (
        "= WEEK OF DECEMBER 1, 2012 =\n"
        "\n"
        "Theme: *WEEK OF THEME*\n"
        "\n"
        "\t* [[December 4, 2012]]\n"
        "\t* [[December 3, 2012]]\n"
        "\t* [[December 2, 2012]]\n"
        "\t* [[December 1, 2012]]\n"
        "\n"
        "CHECKPOINTS:\n"
        "[ ] SUN - []\n[ ] MON - []\n[ ] TUE - []\n[ ] WED - []\n[ ] THU - []\n[ ] FRI - []\n[ ] SAT - []\n"
        "\n"
        "AGENDA:\n"
        "\n"
        "WEEKLYs:\n"
        "[ ] Complete 1 nontrivial research objective\n[ ] Meet+followup >= 1 person\n[ ] 6-10 hrs coding\n[ ] teach ferdy 1 trick\n"
        "\n"
        "NOTES:\n"
        "\n\n"
        "TIME SPENT ON PLANNER: ")

    daytemplate = (
        "CHECKPOINTS:\n"
        "[x] 7:00am - wake up [9:00]\n"
        "[x] 7:05am - brush + change [11:00]\n"
        "[ ] 7:10am - protein []\n"
        "[ ] 7:15am - gym []\n"
        "[x] 8:00am - shower [11:10]\n"
        "[ ] 11:05pm - $nasal irrigation$ []\n"
        "[x] 11:10pm - update schedule [12:25]\n"
        "[x] 11:15pm - get stuff ready for morning((1) clothes:shirt,underwear,jeans,jacket,belt; (2) laptop+charger; (3) binder+texts+pen+pencil; (4) headphones) [8:45]\n"
        "[x] 11:30pm - sleep [12:45]\n"
        "\n"
        "AGENDA:\n"
        "[x] did do\n"
        "\t[x] this\n"
        "\t[x] and this\n"
        "[ ] s'posed to do\n"
        "[\\] kinda did\n"
        "[o] i'm waitin on you!\n"
        "[x] take out trash\n"
        "[x] floss\n"
        "\n"
        "DAILYs:\n"
        "[ ] 40 mins gym\n"
        "[x] Make bed\n"
        "[x] 5 mins housework (dishes, clearing, folding, trash, ...)\n"
        "\n"
        "NOTES:\n"
        "\n"
        "\n"
        "TIME SPENT ON PLANNER: 15 mins")

    checkpoints_year = "[ ] Q1 - []\n[ ] Q2 - []\n[ ] Q3 - []\n[ ] Q4 - []\n"
    checkpoints_quarter = (
        "[ ] MONTH 1 - []\n[ ] MONTH 2 - []\n[ ] MONTH 3 - []\n")
    checkpoints_month = (
        "[ ] WEEK 1 - []\n[ ] WEEK 2 - []\n[ ] WEEK 3 - []\n[ ] WEEK 4 - []\n")
    checkpoints_week = "[ ] SUN - []\n[ ] MON - []\n[ ] TUE - []\n[ ] WED - []\n[ ] THU - []\n[ ] FRI - []\n[ ] SAT - []\n"
    checkpoints_weekday = (
        "[ ] 7:00am - wake up []\n[ ] 7:05am - brush + change []\n[ ] 7:10am - protein []\n"
        "[ ] 7:15am - gym []\n[ ] 8:00am - shower []\n[ ] 8:15am - dump []\n"
        "[ ] 11:00pm - (start winding down) brush []\n[ ] 11:05pm - $nasal irrigation$ []\n"
        "[ ] 11:10pm - update schedule []\n[ ] 11:15pm - get stuff ready for morning"
        "((1) clothes:shirt,underwear,jeans,jacket,belt; (2) laptop+charger; (3) binder+texts+pen+pencil; (4) headphones"
        ") []\n[ ] 11:30pm - sleep []\n")
    checkpoints_weekend = (
        "[ ] 8:00am - wake up []\n[ ] 8:05am - brush + change []\n[ ] 8:10am - protein []\n"
        "[ ] 8:15am - gym []\n[ ] 9:00am - shower []\n[ ] 9:15am - weigh yourself (saturday) []\n"
    )

    periodic_year = "[ ] 1 significant life achievement\n"
    periodic_quarter = "[ ] 1 major research achievement\n[ ] 1 major coding achievement\n[ ] 1 unique achievement\n[ ] update financials\n"
    periodic_month = "[ ] Read 1 book\n[ ] Complete 1 nontrivial coding objective\n[ ] publish 1 blog post\n[ ] backup laptop data\n[ ] update financials\n"
    periodic_week = "[ ] Complete 1 nontrivial research objective\n[ ] Meet+followup >= 1 person\n[ ] 6-10 hrs coding\n[ ] teach ferdy 1 trick\n"
    periodic_day = "[ ] 40 mins gym\n[ ] Make bed\n[ ] 3 meals\n[ ] $nasal spray$\n[ ] Update schedule\n"
    daythemes = ("SUNDAY: Groceries Day\n"
                 "MONDAY: \n"
                 "TUESDAY:Cleaning Day\n"
                 "WEDNESDAY:\n"
                 "THURSDAY:\n"
                 "FRIDAY:\n"
                 "SATURDAY: LAUNDRY DAY\n")

    planner = FilesystemPlanner()
    tasklist = FilesystemTasklist()
    tasklist.file = StringIO(tasklist_contents)
    planner.tasklist = tasklist
    planner.daythemesfile = StringIO(daythemes)
    planner.periodic_day_file = StringIO(periodic_day)
    planner.periodic_week_file = StringIO(periodic_week)
    planner.periodic_month_file = StringIO(periodic_month)
    planner.periodic_quarter_file = StringIO(periodic_quarter)
    planner.periodic_year_file = StringIO(periodic_year)
    planner.checkpoints_weekday_file = StringIO(checkpoints_weekday)
    planner.checkpoints_weekend_file = StringIO(checkpoints_weekend)
    planner.checkpoints_week_file = StringIO(checkpoints_week)
    planner.checkpoints_month_file = StringIO(checkpoints_month)
    planner.checkpoints_quarter_file = StringIO(checkpoints_quarter)
    planner.checkpoints_year_file = StringIO(checkpoints_year)
    planner.dayfile = StringIO(daytemplate)
    planner.weekfile = StringIO(weektemplate)
    planner.monthfile = StringIO(monthtemplate)
    planner.quarterfile = StringIO(quartertemplate)
    planner.yearfile = StringIO(yeartemplate)
    planner.next_day_planner = FilesystemPlanner()

    planner.date = datetime.date.today()
    planner.location = ''

    return planner