コード例 #1
0
def _advance_recurring_todo_helper(p_todo, p_offset):
    """
    Given a Todo item, return a new instance of a Todo item with the dates
    shifted according to the recurrence rule.

    The new date is calculated from the given p_offset value.

    When no recurrence tag is present, an exception is raised.
    """

    todo = Todo(p_todo.source())
    pattern = todo.tag_value('rec')

    if not pattern:
        raise NoRecurrenceException()

    length = todo.length()
    new_due = relative_date_to_date(pattern, p_offset)

    if not new_due:
        raise NoRecurrenceException()

    # pylint: disable=E1103
    todo.set_tag(config().tag_due(), new_due.isoformat())

    if todo.start_date():
        new_start = new_due - timedelta(length)
        todo.set_tag(config().tag_start(), new_start.isoformat())

    todo.set_creation_date(date.today())

    return todo
コード例 #2
0
ファイル: Recurrence.py プロジェクト: netimen/topydo
def _advance_recurring_todo_helper(p_todo, p_offset):
    """
    Given a Todo item, return a new instance of a Todo item with the dates
    shifted according to the recurrence rule.

    The new date is calculated from the given p_offset value.

    When no recurrence tag is present, an exception is raised.
    """

    todo = Todo(p_todo.source())
    pattern = todo.tag_value('rec')

    if not pattern:
        raise NoRecurrenceException()

    length = todo.length()
    new_due = relative_date_to_date(pattern, p_offset)

    if not new_due:
        raise NoRecurrenceException()

    # pylint: disable=E1103
    todo.set_tag(config().tag_due(), new_due.isoformat())

    if todo.start_date():
        new_start = new_due - timedelta(length)
        todo.set_tag(config().tag_start(), new_start.isoformat())

    todo.set_creation_date(date.today())

    return todo
コード例 #3
0
def advance_recurring_todo(p_todo, p_offset=None, p_strict=False):
    """
    Given a Todo item, return a new instance of a Todo item with the dates
    shifted according to the recurrence rule.

    Strict means that the real due date is taken as a offset, not today or a
    future date to determine the offset.

    When the todo item has no due date, then the date is used passed by the
    caller (defaulting to today).

    When no recurrence tag is present, an exception is raised.
    """
    todo = Todo(p_todo.source())
    pattern = todo.tag_value('rec')

    if not pattern:
        raise NoRecurrenceException()
    elif pattern.startswith('+'):
        p_strict = True
        # strip off the +
        pattern = pattern[1:]

    if p_strict:
        offset = p_todo.due_date() or p_offset or date.today()
    else:
        offset = p_offset or date.today()

    length = todo.length()
    new_due = relative_date_to_date(pattern, offset)

    if not new_due:
        raise NoRecurrenceException()

    # pylint: disable=E1103
    todo.set_tag(config().tag_due(), new_due.isoformat())

    if todo.start_date():
        new_start = new_due - timedelta(length)
        todo.set_tag(config().tag_start(), new_start.isoformat())

    if config().auto_creation_date():
        todo.set_creation_date(date.today())

    return todo
コード例 #4
0
ファイル: Recurrence.py プロジェクト: MinchinWeb/topydo
def advance_recurring_todo(p_todo, p_offset=None, p_strict=False):
    """
    Given a Todo item, return a new instance of a Todo item with the dates
    shifted according to the recurrence rule.

    Strict means that the real due date is taken as a offset, not today or a
    future date to determine the offset.

    When the todo item has no due date, then the date is used passed by the
    caller (defaulting to today).

    When no recurrence tag is present, an exception is raised.
    """
    todo = Todo(p_todo.source())
    pattern = todo.tag_value('rec')

    if not pattern:
        raise NoRecurrenceException()
    elif pattern.startswith('+'):
        p_strict = True
        # strip off the +
        pattern = pattern[1:]

    if p_strict:
        offset = p_todo.due_date() or p_offset or date.today()
    else:
        offset = p_offset or date.today()

    length = todo.length()
    new_due = relative_date_to_date(pattern, offset)

    if not new_due:
        raise NoRecurrenceException()

    # pylint: disable=E1103
    todo.set_tag(config().tag_due(), new_due.isoformat())

    if todo.start_date():
        new_start = new_due - timedelta(length)
        todo.set_tag(config().tag_start(), new_start.isoformat())

    todo.set_creation_date(date.today())

    return todo
コード例 #5
0
 def test_length3(self):
     todo = Todo("(C) Foo t:2014-01-01 due:2014-01-02")
     self.assertEqual(todo.length(), 1)
コード例 #6
0
 def test_length1(self):
     todo = Todo("(C) Foo t:2014-01-01 due:2013-12-31")
     self.assertEqual(todo.length(), 0)
コード例 #7
0
ファイル: test_todo.py プロジェクト: bram85/topydo
 def test_length5(self):
     todo = Todo("(C) 2015-11-18 Foo)")
     self.assertEqual(todo.length(), 0)
コード例 #8
0
ファイル: test_todo.py プロジェクト: bram85/topydo
 def test_length4(self):
     todo = Todo("(C) Foo)")
     self.assertEqual(todo.length(), 0)
コード例 #9
0
ファイル: test_todo.py プロジェクト: bram85/topydo
 def test_length3(self):
     todo = Todo("(C) Foo t:2014-01-01 due:2014-01-02")
     self.assertEqual(todo.length(), 1)
コード例 #10
0
 def test_length10(self):
     todo = Todo("(C) Foo t:2017-06-30")
     self.assertEqual(todo.length(), 0)
コード例 #11
0
 def test_length6(self):
     todo = Todo("(C) 2015-11-18 Foo due:2015-11-19)")
     self.assertEqual(todo.length(), 1)
コード例 #12
0
ファイル: test_todo.py プロジェクト: bram85/topydo
 def test_length10(self):
     todo = Todo("(C) Foo t:2017-06-30")
     self.assertEqual(todo.length(), 0)
コード例 #13
0
ファイル: test_todo.py プロジェクト: bram85/topydo
 def test_length8(self):
     todo = Todo("(C) 2015-11-18 Foo t:2015-11-19 due:2015-11-20)")
     self.assertEqual(todo.length(), 1)
コード例 #14
0
ファイル: test_todo.py プロジェクト: bram85/topydo
 def test_length6(self):
     todo = Todo("(C) 2015-11-18 Foo due:2015-11-19)")
     self.assertEqual(todo.length(), 1)
コード例 #15
0
 def test_length5(self):
     todo = Todo("(C) 2015-11-18 Foo)")
     self.assertEqual(todo.length(), 0)
コード例 #16
0
 def test_length4(self):
     todo = Todo("(C) Foo)")
     self.assertEqual(todo.length(), 0)
コード例 #17
0
 def test_length11(self):
     todo = Todo("(C) Foo t:2017-06-31 due:2017-07-01")
     self.assertEqual(todo.length(), 0)
コード例 #18
0
ファイル: test_todo.py プロジェクト: bram85/topydo
 def test_length1(self):
     todo = Todo("(C) Foo t:2014-01-01 due:2013-12-31")
     self.assertEqual(todo.length(), 0)
コード例 #19
0
ファイル: test_todo.py プロジェクト: bram85/topydo
 def test_length11(self):
     todo = Todo("(C) Foo t:2017-06-31 due:2017-07-01")
     self.assertEqual(todo.length(), 0)
コード例 #20
0
 def test_length8(self):
     todo = Todo("(C) 2015-11-18 Foo t:2015-11-19 due:2015-11-20)")
     self.assertEqual(todo.length(), 1)