def __init__(self, th=None, master=None): if master is None: return self.master = master self.timeh = th self.mlist = ["Begin", "End", "Project"] self.alist = ["Date", "New", "Project"] self.command = self._decide self.genq = GeneralQuery(parent=self, replace=1) self.frame = self.genq.get_frame() self.dict = {} #dictionary of projects
def __init__(self, master=None, title=None, nc=None): """Must have master, and ncore, title is optional.""" if master == None or nc ==None: return self.master = master self.nc = nc #ncore, the database to search through self.mlist = ["Begin", "End", "Project", "Phrase"] self.command = self.search genq = GeneralQuery(parent=self) self.frame = genq.get_frame() self.disp = Text(self.frame, height=10, width=80, wrap=WORD, bg="#008888", spacing1=5) self.disp.pack()
def __init__(self, master=None, title=None, nc=None): """Must have master, and ncore, title is optional.""" if master == None or nc == None: return self.master = master self.nc = nc #ncore, the database to search through self.mlist = ["Begin", "End", "Project", "Phrase"] self.command = self.search genq = GeneralQuery(parent=self) self.frame = genq.get_frame() self.disp = Text(self.frame, height=10, width=80, wrap=WORD, bg="#008888", spacing1=5) self.disp.pack()
class TimeSummary(object): """For retrieving times from the data base. And updating.""" func = None def __init__(self, th=None, master=None): if master is None: return self.master = master self.timeh = th self.mlist = ["Begin", "End", "Project"] self.alist = ["Date", "New", "Project"] self.command = self._decide self.genq = GeneralQuery(parent=self, replace=1) self.frame = self.genq.get_frame() self.dict = {} #dictionary of projects def _decide(self, list_, replace=None): """Decide which command to call""" if replace == 1: self.replace(list_) else: self.search(list_) def replace(self, list_): """Gets date, new time and Project and replaces the time.""" (date, time_, project) = list_ if date != "": date = int(date) else: print "Need a specific date." return if time_ == "" or project == None: print "Need all three." return if time_.find(':') > 0: #time given in hh:mm:ss hms = time_.split(":") time_ = int(hms[0]) * 3600 + int(hms[1]) * 60 + int(hms[2]) else: time_ = int(time_) self.timeh.update(project, time_, date, replace=1) def search(self, list_): """Search for times in projects on specified days.""" beg = list_[0].strip() end = list_[1].strip() project = list_[2].strip() for each in self.dict: self.dict[each].clear() if beg != "": beg = int(beg) else: beg = None if end != "": end = int(end) else: end = None if project: if project not in self.dict: self.dict[project] = TimeDisp(self.frame, project, self.genq) for row in self.timeh.ret_notes(b_date=beg, e_date=end, project=project): self.dict[project].append(row[0], row[1]) self.dict[project].update() else: for row in self.timeh.ret_notes(b_date=beg, e_date=end): if row[0] not in self.dict: self.dict[row[0]] = TimeDisp(self.frame, row[0], self.genq) self.dict[row[0]].append(row[1], row[2]) self.dict[row[0]].update()
class TimeSummary(object): """For retrieving times from the data base. And updating.""" func = None def __init__(self, th=None, master=None): if master is None: return self.master = master self.timeh = th self.mlist = ["Begin", "End", "Project"] self.alist = ["Date", "New", "Project"] self.command = self._decide self.genq = GeneralQuery(parent=self, replace=1) self.frame = self.genq.get_frame() self.dict = {} #dictionary of projects def _decide(self, list_, replace=None): """Decide which command to call""" if replace == 1: self.replace(list_) else: self.search(list_) def replace(self, list_): """Gets date, new time and Project and replaces the time.""" (date, time_, project) = list_ if date != "": date = int(date) else: print "Need a specific date." return if time_ == "" or project == None: print "Need all three." return if time_.find(':') > 0: #time given in hh:mm:ss hms = time_.split(":") time_ = int(hms[0])*3600 + int(hms[1])*60 + int(hms[2]) else: time_ = int(time_) self.timeh.update(project, time_, date, replace=1) def search(self, list_): """Search for times in projects on specified days.""" beg = list_[0].strip() end = list_[1].strip() project = list_[2].strip() for each in self.dict: self.dict[each].clear() if beg != "": beg = int(beg) else: beg = None if end != "": end = int(end) else: end = None if project: if project not in self.dict: self.dict[project] = TimeDisp(self.frame, project, self.genq) for row in self.timeh.ret_notes(b_date=beg, e_date=end, project=project): self.dict[project].append(row[0], row[1]) self.dict[project].update() else: for row in self.timeh.ret_notes(b_date=beg, e_date=end): if row[0] not in self.dict: self.dict[row[0]] = TimeDisp(self.frame, row[0], self.genq) self.dict[row[0]].append(row[1], row[2]) self.dict[row[0]].update()