当前位置: 首页>>代码示例>>Python>>正文


Python Todo.Todo类代码示例

本文整理汇总了Python中topydo.lib.Todo.Todo的典型用法代码示例。如果您正苦于以下问题:Python Todo类的具体用法?Python Todo怎么用?Python Todo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Todo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_todo_number1

    def test_todo_number1(self):
        todo = Todo("No number")
        self.todolist.add_todo(todo)

        todo = self.todolist.todo(6)
        self.assertIsInstance(todo, Todo)
        self.assertEqual(todo.text(), "No number")
开发者ID:netimen,项目名称:topydo,代码行数:7,代码来源:TodoListTest.py

示例2: _advance_recurring_todo_helper

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
开发者ID:netimen,项目名称:topydo,代码行数:32,代码来源:Recurrence.py

示例3: advance_recurring_todo

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
开发者ID:MinchinWeb,项目名称:topydo,代码行数:44,代码来源:Recurrence.py

示例4: test_priority_color3

    def test_priority_color3(self):
        config("test/data/ColorsTest3.conf")
        todo_a = Todo('(A) Foo')
        todo_b = Todo('(B) Bar')
        todo_z = Todo('(Z) FooBar')
        todo_d = Todo('(D) Baz')
        todo_c = Todo('(C) FooBaz')

        color_a = config().priority_color(todo_a.priority()).as_ansi()
        color_b = config().priority_color(todo_b.priority()).as_ansi()
        color_z = config().priority_color(todo_z.priority()).as_ansi()
        color_d = config().priority_color(todo_d.priority()).as_ansi()
        color_c = config().priority_color(todo_c.priority()).as_ansi()

        self.assertEqual(color_a, '\033[0;35m')
        self.assertEqual(color_b, '\033[0;1;36m')
        self.assertEqual(color_z, NEUTRAL_COLOR)
        self.assertEqual(color_d, '\033[0;31m')
        self.assertEqual(color_c, '\033[0;37m')
开发者ID:MinchinWeb,项目名称:topydo,代码行数:19,代码来源:test_colors.py

示例5: test_priority_color1

    def test_priority_color1(self):
        config("test/data/ColorsTest1.conf")
        todo_a = Todo('(A) Foo')
        todo_b = Todo('(B) Bar')
        todo_c = Todo('(C) FooBar')

        color_a = config().priority_color(todo_a.priority()).as_ansi()
        color_b = config().priority_color(todo_b.priority()).as_ansi()
        color_c = config().priority_color(todo_c.priority()).as_ansi()

        self.assertEqual(color_a, '\033[0;31m')
        self.assertEqual(color_b, '\033[0;32m')
        self.assertEqual(color_c, '\033[0;33m')
开发者ID:MinchinWeb,项目名称:topydo,代码行数:13,代码来源:test_colors.py

示例6: test_empty_color_values

    def test_empty_color_values(self):
        config("test/data/ColorsTest5.conf")
        project_color = config().project_color().as_ansi(p_decoration='bold')
        context_color = config().context_color().as_ansi(p_decoration='bold')
        link_color = config().link_color().as_ansi(p_decoration='underline')
        metadata_color = config().metadata_color().as_ansi(p_decoration='bold')

        todo_a = Todo('(A) Foo')
        todo_b = Todo('(B) Bar')
        todo_c = Todo('(C) FooBar')

        color_a = config().priority_color(todo_a.priority()).as_ansi()
        color_b = config().priority_color(todo_b.priority()).as_ansi()
        color_c = config().priority_color(todo_c.priority()).as_ansi()

        self.assertEqual(color_a, NEUTRAL_COLOR)
        self.assertEqual(color_b, NEUTRAL_COLOR)
        self.assertEqual(color_c, NEUTRAL_COLOR)
        self.assertEqual(project_color, '')
        self.assertEqual(context_color, '')
        self.assertEqual(link_color, '')
        self.assertEqual(metadata_color, '')
开发者ID:MinchinWeb,项目名称:topydo,代码行数:22,代码来源:test_colors.py

示例7: test_empty_colorscheme

    def test_empty_colorscheme(self):
        config("test/data/config1")
        project_color = config().project_color().as_ansi(p_decoration='bold')
        context_color = config().context_color().as_ansi(p_decoration='bold')
        link_color = config().link_color().as_ansi(p_decoration='underline')
        metadata_color = config().metadata_color().as_ansi(p_decoration='bold')

        todo_a = Todo('(A) Foo')
        todo_b = Todo('(B) Bar')
        todo_c = Todo('(C) FooBar')

        color_a = config().priority_color(todo_a.priority()).as_ansi()
        color_b = config().priority_color(todo_b.priority()).as_ansi()
        color_c = config().priority_color(todo_c.priority()).as_ansi()

        self.assertEqual(color_a, '\033[0;36m')
        self.assertEqual(color_b, '\033[0;33m')
        self.assertEqual(color_c, '\033[0;34m')
        self.assertEqual(project_color, '\033[1;31m')
        self.assertEqual(context_color, '\033[1;35m')
        self.assertEqual(link_color, '\033[4;36m')
        self.assertEqual(metadata_color, '\033[1;32m')
开发者ID:MinchinWeb,项目名称:topydo,代码行数:22,代码来源:test_colors.py

示例8: test_length1

 def test_length1(self):
     todo = Todo("(C) Foo t:2014-01-01 due:2013-12-31")
     self.assertEqual(todo.length(), 0)
开发者ID:bram85,项目名称:topydo,代码行数:3,代码来源:test_todo.py

示例9: days_till_due

 def days_till_due(self):
     todo = Todo("(C) due:" + tomorrow_date())
     self.assertEqual(todo.days_till_due(), 1)
开发者ID:bram85,项目名称:topydo,代码行数:3,代码来源:test_todo.py

示例10: test_overdue3

 def test_overdue3(self):
     todo = Todo("(C) Foo due:" + today_date())
     self.assertFalse(todo.is_overdue())
开发者ID:bram85,项目名称:topydo,代码行数:3,代码来源:test_todo.py

示例11: test_overdue2

 def test_overdue2(self):
     todo = Todo("(C) Foo due:" + tomorrow_date())
     self.assertFalse(todo.is_overdue())
开发者ID:bram85,项目名称:topydo,代码行数:3,代码来源:test_todo.py

示例12: test_length10

 def test_length10(self):
     todo = Todo("(C) Foo t:2017-06-30")
     self.assertEqual(todo.length(), 0)
开发者ID:bram85,项目名称:topydo,代码行数:3,代码来源:test_todo.py

示例13: setUp

 def setUp(self):
     super(RecurrenceTest, self).setUp()
     self.todo = Todo("Test rec:1w")
开发者ID:netimen,项目名称:topydo,代码行数:3,代码来源:RecurrenceTest.py

示例14: test_length5

 def test_length5(self):
     todo = Todo("(C) 2015-11-18 Foo)")
     self.assertEqual(todo.length(), 0)
开发者ID:bram85,项目名称:topydo,代码行数:3,代码来源:test_todo.py

示例15: test_active3

 def test_active3(self):
     todo = Todo("x 2014-06-09 Foo t:2014-01-01")
     self.assertFalse(todo.is_active())
开发者ID:bram85,项目名称:topydo,代码行数:3,代码来源:test_todo.py


注:本文中的topydo.lib.Todo.Todo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。