forked from emanuelez/PySynergy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TaskObject.py
92 lines (67 loc) · 2.58 KB
/
TaskObject.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env python
# encoding: utf-8
"""
TaskObject.py
Created by Emanuele Zattin and Aske Olsson on 2011-01-26.
Copyright (c) 2011 Nokia. All rights reserved.
"""
import SynergyObject
import SynergySession
from datetime import datetime
class TaskObject(SynergyObject.SynergyObject):
""" This class wraps a Synergy object with information about author, create time, tasks, status etc. """
def __init__(self, objectname, delimiter, owner, status, create_time, task):
super(TaskObject, self).__init__(objectname, delimiter, owner, status, create_time, task)
self.synopsis = None
self.description = None
self.release = None
self.objects = None
self.complete_time = None
self.attributes = None
def get_display_name(self):
name = [self.get_instance()]
name.append("#")
name.append(self.get_name().strip('task'))
return ''.join(name)
def get_synopsis(self):
return self.synopsis
def set_synopsis(self, synopsis):
self.synopsis = synopsis
def get_description(self):
return self.description
def set_description(self, description):
self.description = description
def get_release(self):
return self.release
def set_release(self, release):
self.release = release
def get_objects(self):
return self.objects
def set_objects(self, objects):
self.objects = objects
def add_object(self, o):
if self.objects is None:
self.objects = [o]
else:
self.objects.append(o)
def get_complete_time(self):
return self.complete_time
def set_complete_time(self, complete_time):
self.complete_time = complete_time
def set_attributes(self, attributes):
self.attributes = attributes
self.complete_time = self.find_status_time('complete', self.attributes['status_log'], self.instance)
if 'task_description' in self.attributes.keys():
self.description = self.attributes['task_description']
if 'task_number' in self.attributes.keys():
self.attributes['task_number'] = self.get_display_name()
def get_attributes(self):
return self.attributes
def find_status_time(self, status, status_log, db):
earliest = datetime.today()
for line in status_log.splitlines():
if status in line and db in line:
time = datetime.strptime(line.partition(': Status')[0], "%a %b %d %H:%M:%S %Y")
if time < earliest:
earliest = time
return earliest