本文整理汇总了Python中Task.Task.id方法的典型用法代码示例。如果您正苦于以下问题:Python Task.id方法的具体用法?Python Task.id怎么用?Python Task.id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Task.Task
的用法示例。
在下文中一共展示了Task.id方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_save_tasks_and_pomo
# 需要导入模块: from Task import Task [as 别名]
# 或者: from Task.Task import id [as 别名]
def test_save_tasks_and_pomo(self):
storage = Storage(TimeDouble())
pomo = Pomo()
storage.pomo = pomo
task = Task("Task1", "Task1Description word\nMultiline", 1000)
task.id = 1
task.state = "Blocked"
task.blocked_reason = "BlockedReason"
storage.tasks.append(task)
task = Task("Task2", "Task2Description", 1001)
task.id = 2
task.close(1002)
storage.tasks.append(task)
openDouble.reset()
fileDouble = FileDouble()
openDouble.add_file(fileDouble)
storage.save('test_file')
self.assertEqual('test_file', openDouble.filename[0])
self.assertEqual('w+', openDouble.mode[0])
self.assertEqual("""#### Task
## State: Blocked
## Blocked Reason
BlockedReason
## Closed Reason
## Id: 1
## Date Created: 1000
## Date Closed:
## Date Due:
## Time Estimate: 0
## Time Spent: 0
## Summary
Task1
## Description
Task1Description word
Multiline
#### Task
## State: Closed
## Blocked Reason
## Closed Reason
## Id: 2
## Date Created: 1001
## Date Closed: 1002
## Date Due:
## Time Estimate: 0
## Time Spent: 0
## Summary
Task2
## Description
Task2Description
#### Pomodoro
## Time Remaining: 1500.000000
## Running: false
""", fileDouble.written_data)
示例2: test_save_tasks
# 需要导入模块: from Task import Task [as 别名]
# 或者: from Task.Task import id [as 别名]
def test_save_tasks(self):
storage = Storage(TimeDouble())
task = Task("Task1", "Task1Description word\nMultiline", 10001)
task.id = 1
task.state = "Blocked"
task.blocked_reason = "BlockedReason"
storage.tasks.append(task)
task = Task("Task2", "Task2Description", 10002)
task.id = 2
task.close(10003, "Test Reason")
task.set_due_date(10004.1)
task.time_spent = 100
storage.tasks.append(task)
openDouble.reset()
fileDouble = FileDouble()
openDouble.add_file(fileDouble)
storage.save('test_file')
self.assertEqual('test_file', openDouble.filename[0])
self.assertEqual('w+', openDouble.mode[0])
self.assertEqual("""#### Task
## State: Blocked
## Blocked Reason
BlockedReason
## Closed Reason
## Id: 1
## Date Created: 10001
## Date Closed:
## Date Due:
## Time Estimate: 0
## Time Spent: 0
## Summary
Task1
## Description
Task1Description word
Multiline
#### Task
## State: Closed
## Blocked Reason
## Closed Reason
Test Reason
## Id: 2
## Date Created: 10002
## Date Closed: 10003
## Date Due: 10004
## Time Estimate: 0
## Time Spent: 100
## Summary
Task2
## Description
Task2Description
""", fileDouble.written_data)
示例3: test_sort_backlog_alphanumeric
# 需要导入模块: from Task import Task [as 别名]
# 或者: from Task.Task import id [as 别名]
def test_sort_backlog_alphanumeric(self):
StorageDouble.reset()
# [Summary, id, due_date]
tasksTruth = [["Task1", 1, 9],
["Task2", 2, 8],
["Task3", 3, 7],
["Task4", 4, 6],
["Taske", 5, None],
["Taskd", 6, None],
["Taskc", 7, None],
["Taskb", 8, None],
["Taska", 9, None]]
# Add some tasks and set due dates
for truth in tasksTruth:
task = Task(truth[0], "", 0)
task.id = truth[1]
task.set_due_date(truth[2])
StorageDouble.add_task(task)
# Verify they get sorted correctly
self.assertTrue(self._runTsk('sort_backlog -a'))
idOrderTruth = [4, 3, 2, 1, 9, 8, 7, 6, 5]
idOrder = [ t.id for t in StorageDouble.tasks ]
self.assertEquals(idOrderTruth, idOrder)
示例4: importTasks
# 需要导入模块: from Task import Task [as 别名]
# 或者: from Task.Task import id [as 别名]
def importTasks():
# --- Read tasks from files.
global taskList,resourceFileName,taskFileName,dependencyFileName
global resources
fptasks = open(taskFileName,"r")#"tasks.txt","r")
for line in fptasks.readlines():
newTask = Task()
t = line.split(",")
newTask.name = t[1]
newTask.id = int(t[0])
newTask.duration = int(t[2])
adjacencyList[newTask.id] = []
taskList.append(newTask)
fptasks.close()
#---- Read resources
fpresources = open(resourceFileName,"r")#("resources.txt","r")
for line in fpresources.readlines():
r = line.strip().split(",")
newResource = Resource(int(r[0]),r[1])
resources += [newResource]
fpresources.close()
# ---- Read depedencies and create predecessor list -----
fpdependencies = open(dependencyFileName,"r")#("dependencies.txt","r")
for line in fpdependencies.readlines():
line = line.rstrip()
print(line)
x = line.split(",")
if(len(x)>1):
task = getTaskFromId(int(x[0]))
for i in range(1,len(x)):
task.predecessors.append(int(x[i]))
"""if len(x) >1:
z = x[1]
for task in taskList:
if task.id == int(x[0]):
y = z.strip().split(",")
for b in y:
task.predecessors.append(int(b))"""
#print(x[0],task.predecessor)
fpdependencies.close()
# ---- Create successor list ----
for succTask in taskList:
#succTask = getTaskFromId()
for predId in succTask.predecessors:
task = getTaskFromId(predId)
task.successors.append(succTask.id)
adjacencyList[task.id] = task.successors
示例5: test_open
# 需要导入模块: from Task import Task [as 别名]
# 或者: from Task.Task import id [as 别名]
def test_open(self):
task = Task("Task", "", 0)
task.id = 1
task.close()
StorageDouble.add_task(task)
self.assertTrue(self._runTsk('open 1'))
self.assertTrue(StorageDouble.get_task(1).is_open())
self.assertFalse(self._runTsk('open 2'))
示例6: test_close_reason
# 需要导入模块: from Task import Task [as 别名]
# 或者: from Task.Task import id [as 别名]
def test_close_reason(self):
task = Task("Task", "", 0)
task.id = 1
task.open()
StorageDouble.add_task(task)
self.assertTrue(self._runTsk('close 1 --r=Reason'))
self.assertTrue(StorageDouble.get_task(1).is_closed())
self.assertEquals("Reason", StorageDouble.get_task(1).closed_reason)
self.assertFalse(self._runTsk('close 2'))
示例7: setUp
# 需要导入模块: from Task import Task [as 别名]
# 或者: from Task.Task import id [as 别名]
def setUp(self):
StorageDouble.reset()
# [Summary, id, due_date]
tasksTruth = [["Task1", 1],
["Task2", 2],
["Task3", 3],
["Task4", 4],
["Task5", 5],
["Task6", 6],
["Task7", 7],
["Task8", 8],
["Task9", 9]]
# Add some tasks and set due dates
for truth in tasksTruth:
task = Task(truth[0], "", 0)
task.id = truth[1]
StorageDouble.add_task(task)
示例8: load
# 需要导入模块: from Task import Task [as 别名]
# 或者: from Task.Task import id [as 别名]
def load(self, filename):
f = open(filename, 'r')
f = FileWrapper(f)
state = "Start"
newtask = None
newpomo = None
skip_read = False
while True:
if not skip_read:
line = f.readline()
skip_read = False
if line == "":
break
if state == "Start":
if re.match("#### Task", line):
newtask = Task("", "")
state = "Task_State"
skip_read = True
if re.match("#### Pomodoro", line):
newpomo = Pomo()
state = "Pomo_Remaining"
elif state == "Task_State":
found, val = self._loadField(f, 'State', hasfield=True)
if not found:
return False
newtask.state = val
found, val = self._loadField(f, 'Blocked Reason', hasfield=True, multiline=True)
if not found:
return False
if val is not None:
newtask.blocked_reason = "".join(val).strip()
found, val = self._loadField(f, 'Closed Reason', hasfield=True, multiline=True)
if not found:
return False
if val is not None:
newtask.closed_reason = "".join(val).strip()
found, val = self._loadField(f, 'Id', hasfield=True)
if not found:
return False
if val is not None:
newtask.id = int(val)
found, val = self._loadField(f, 'Date Created', hasfield=True)
if not found:
return False
if val is not None:
newtask.date_created = int(val)
found, val = self._loadField(f, 'Date Closed', hasfield=True)
if not found:
return False
if val is not None:
newtask.date_closed = int(val)
found, val = self._loadField(f, 'Date Due', hasfield=True)
if not found:
return False
if val is not None:
newtask.date_due = int(val)
found, val = self._loadField(f, 'Time Estimate', hasfield=True)
if not found:
return False
if val is not None:
newtask.time_estimate = int(val)
found, val = self._loadField(f, 'Time Spent', hasfield=True)
if not found:
return False
if val is not None:
newtask.time_spent = int(val)
found, val = self._loadField(f, 'Summary', hasfield=True, multiline=True)
if not found:
return False
if val is not None:
newtask.summary = "".join(val).strip()
found, val = self._loadField(f, 'Description', hasfield=True, multiline=True)
if not found:
return False
if val is not None:
newtask.description = "".join(val).strip()
self.tasks.append(newtask)
state = "End"
elif state == "End":
if re.match("#### Task", line) or re.match("#### Pomodoro", line):
if re.match("#### Task", line):
state = "Task_State"
skip_read = True
newtask = Task("", "")
else:
#.........这里部分代码省略.........