本文整理汇总了Python中topydo.lib.Todo.Todo.length方法的典型用法代码示例。如果您正苦于以下问题:Python Todo.length方法的具体用法?Python Todo.length怎么用?Python Todo.length使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类topydo.lib.Todo.Todo
的用法示例。
在下文中一共展示了Todo.length方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _advance_recurring_todo_helper
# 需要导入模块: from topydo.lib.Todo import Todo [as 别名]
# 或者: from topydo.lib.Todo.Todo import length [as 别名]
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: advance_recurring_todo
# 需要导入模块: from topydo.lib.Todo import Todo [as 别名]
# 或者: from topydo.lib.Todo.Todo import length [as 别名]
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
示例3: test_length5
# 需要导入模块: from topydo.lib.Todo import Todo [as 别名]
# 或者: from topydo.lib.Todo.Todo import length [as 别名]
def test_length5(self):
todo = Todo("(C) 2015-11-18 Foo)")
self.assertEqual(todo.length(), 0)
示例4: test_length4
# 需要导入模块: from topydo.lib.Todo import Todo [as 别名]
# 或者: from topydo.lib.Todo.Todo import length [as 别名]
def test_length4(self):
todo = Todo("(C) Foo)")
self.assertEqual(todo.length(), 0)
示例5: test_length3
# 需要导入模块: from topydo.lib.Todo import Todo [as 别名]
# 或者: from topydo.lib.Todo.Todo import length [as 别名]
def test_length3(self):
todo = Todo("(C) Foo t:2014-01-01 due:2014-01-02")
self.assertEqual(todo.length(), 1)
示例6: test_length1
# 需要导入模块: from topydo.lib.Todo import Todo [as 别名]
# 或者: from topydo.lib.Todo.Todo import length [as 别名]
def test_length1(self):
todo = Todo("(C) Foo t:2014-01-01 due:2013-12-31")
self.assertEqual(todo.length(), 0)
示例7: test_length11
# 需要导入模块: from topydo.lib.Todo import Todo [as 别名]
# 或者: from topydo.lib.Todo.Todo import length [as 别名]
def test_length11(self):
todo = Todo("(C) Foo t:2017-06-31 due:2017-07-01")
self.assertEqual(todo.length(), 0)
示例8: test_length10
# 需要导入模块: from topydo.lib.Todo import Todo [as 别名]
# 或者: from topydo.lib.Todo.Todo import length [as 别名]
def test_length10(self):
todo = Todo("(C) Foo t:2017-06-30")
self.assertEqual(todo.length(), 0)
示例9: test_length8
# 需要导入模块: from topydo.lib.Todo import Todo [as 别名]
# 或者: from topydo.lib.Todo.Todo import length [as 别名]
def test_length8(self):
todo = Todo("(C) 2015-11-18 Foo t:2015-11-19 due:2015-11-20)")
self.assertEqual(todo.length(), 1)
示例10: test_length6
# 需要导入模块: from topydo.lib.Todo import Todo [as 别名]
# 或者: from topydo.lib.Todo.Todo import length [as 别名]
def test_length6(self):
todo = Todo("(C) 2015-11-18 Foo due:2015-11-19)")
self.assertEqual(todo.length(), 1)