本文整理汇总了Python中task.Task.done方法的典型用法代码示例。如果您正苦于以下问题:Python Task.done方法的具体用法?Python Task.done怎么用?Python Task.done使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类task.Task
的用法示例。
在下文中一共展示了Task.done方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: read_tasks
# 需要导入模块: from task import Task [as 别名]
# 或者: from task.Task import done [as 别名]
def read_tasks(cls, infile):
tasks = []
default_tz = pytz.utc
for event, elem in etree.iterparse(infile, events=("start", "end")):
if event == "start":
if elem.tag == "defaults":
in_defaults = True
else:
# Stop reading as soon as the </tasks> tag is encountered.
if elem.tag == "tasks":
break
elif elem.tag == "defaults":
in_defaults = False
# Otherwise, parse each <task> element in accordance to the way
# it was output.
elif elem.tag == "task":
attrs = elem.attrib
# XXX When project of a task becomes something more than
# just a string, the code will probably break on the
# following line.
if "project" in attrs:
project = attrs["project"]
else:
project = ""
task = Task(name=elem.text, project=project, id=int(attrs["id"]))
if "done" in attrs:
task.done = bool(int(attrs["done"]))
if "time" in attrs:
task.time = cls._timedelta_fromrepr(attrs["time"])
if "deadline" in attrs:
task.deadline = cls._read_time(attrs, "deadline", default_tz=default_tz)
tasks.append(task)
elif elem.tag == "timezone" and in_defaults:
default_tz = pytz.timezone(elem.text)
return tasks
示例2: read_tasks
# 需要导入模块: from task import Task [as 别名]
# 或者: from task.Task import done [as 别名]
def read_tasks(cls, infile):
tasks = []
default_tz = pytz.utc
in_tasks = False
in_groups = False
in_defaults = False
for event, elem in etree.iterparse(infile, events=('start', 'end')):
if event == 'start':
if elem.tag == 'defaults':
in_defaults = True
elif elem.tag == 'tasks':
in_tasks = True
continue
elif elem.tag == 'groups':
in_groups = True
# if event == 'end':
else:
if elem.tag == 'defaults':
in_defaults = False
elif elem.tag == "groups":
in_groups = False
# Stop reading as soon as the </tasks> tag is encountered.
elif elem.tag == "tasks":
break
# Skip the subtree describing groupings.
if in_groups:
continue
elif in_tasks and elem.tag == "task":
# Otherwise, parse each <task> element in accordance to the
# way it was output.
attrs = elem.attrib
# XXX When project of a task becomes something more than
# just a string, the code will probably break on the
# following line.
if 'project' in attrs:
project = attrs['project']
else:
project = ''
task = Task(name=elem.text,
project=project,
id=int(attrs['id']))
if 'done' in attrs:
task.done = bool(int(attrs['done']))
if 'time' in attrs:
task.time = cls._timedelta_fromrepr(attrs['time'])
if 'deadline' in attrs:
task.deadline = cls._read_time(attrs, 'deadline',
default_tz=default_tz)
tasks.append(task)
elif in_defaults and elem.tag == 'timezone':
default_tz = pytz.timezone(elem.text)
return tasks