Beispiel #1
0
    def saveAllDetails(self):
        #Here save all details in a file. Use Pickle
        details={}
        #a dict of all details
        if self.task_name_lineEdit.text() == "":
            self.task_name_lineEdit.setPlaceholderText("Task name cannot be empty")
            return
        details['task_name']    = self.task_name_lineEdit.text()
        details['description']  = self.description_textEdit.toPlainText()
        details['priority']     = self.priority_spinBox.value()
        details['start_date']   = self.start_date_dateEdit.date()
        details['deadline_date']= self.deadline_dateEdit.date()
        details['resources']    = self.resources_plainTextEdit.toPlainText()
        details['started_check']= self.project_started_checkBox.checkState()
        if (self.new_details == True):
            details['id'] = int(time.time())
        else:
            details['id'] = self.id_of_task
        #save into database file

        d = shelve.open(task_settings.get_path()+"database")
        d[str(details['id'])] = details
        d.close()
#        mainwin.load_task_names_external(self.MainWindow_Ui)
        self.MainWindow_Ui.load_task_names()
        self.MainWindow_Ui.calculate_progress()
        self.Prop_Ui.close()
    def load_task_names(self):
        count = 0
        self.tasks_treeWidget.clear()

        try:
            d = shelve.open(task_settings.get_path() + "database")
            keys = list(d.keys())
            priority = {}
            #store all priorities in order in one dict along with keys
            #displaying keys should be there in a list
            for k in keys:
                priority[str(k)] = d[k]['priority']
            keys = sorted(keys, key=priority.__getitem__)
            print "Load Task Names"
            for key in keys:
                details = d[key]
                #                print "Load Key is : ",key
                item = QtWidgets.QTreeWidgetItem(self.tasks_treeWidget)
                item.setText(0, details['task_name'])
                item.setText(1, str(details['id']))
                #                print "List ",count,":",details['task_name']
                count += 1
            d.close()


#            prop.set_priority_value(self.propWin)
#   function already called in prop.py resetAllDetails()
        except IOError:
            print "Database doesn't exist"
        self.calculate_progress()
 def load_task_names(self):
     #Here save all details in a file. Use shelve
     try:
         d = shelve.open(task_settings.get_path()+"database")
     except Exception as e:
         print "Database not found E:",e
         return
     details={}
        
     progress = 0
     for key in d.keys():
         details = d[key]
         if details['started_check'] == False:
             total_days = details['start_date'].daysTo(details['deadline_date'])
             days_rem = total_days - QtCore.QDate.currentDate().daysTo(details['deadline_date'])
             print "Days remaining = ",days_rem
             try:
                 progress = days_rem*100/total_days
             except ZeroDivisionError:
                 progress = 0
             print "Progress ",progress,"%"
         else:
             progress = 0
         
         if progress != 100 and details['started_check'] == False:
             item = QtWidgets.QTreeWidgetItem(self.ongoing_treeWidget)
             item.setText(0,details['task_name'])
             item.setText(1,str(details['id']))
         elif progress == 100:
             item = QtWidgets.QTreeWidgetItem(self.completed_treeWidget)
             item.setText(0,details['task_name'])
             item.setText(1,str(details['id']))
     d.close()
 def swap_items(self, key1, key2):
     d = shelve.open(task_settings.get_path() + "database")
     first = d[key1]
     second = d[key2]
     #          print "Before Swap: ",first['priority']," ",second['priority']
     tmp = first['priority']
     first['priority'] = second['priority']
     second['priority'] = tmp
     #          print "After Swap: ",first['priority']," ",second['priority']
     d[key1] = first
     d[key2] = second
     d.close()
     self.load_task_names()
Beispiel #5
0
    def set_priority_value(self):
        count=0
        try:
            d = shelve.open(task_settings.get_path()+"database")
            count = len(d.keys())
            print "Count = ",count
        except IOError:
            print "Database file does not exist"
        finally:
            d.close()
        count+=1
        self.priority_spinBox.setValue(count)

        print "Set priority value = ",count
 def calculate_progress(self):
     print "Calculating Progress"
     d = shelve.open(task_settings.get_path() + "database")
     total_progress = 0
     count_of_keys = 0
     self.main_progressBar.setValue(0)
     for key in list(d.keys()):
         p = self.propWin.loadAllDetails(key, only_progress=True)
         if p != 100:
             total_progress += p
             count_of_keys += 1
             self.main_progressBar.setValue(total_progress / count_of_keys)
             #time.sleep(.1)
             #above time delay is for animation
     d.close()
Beispiel #7
0
    def loadAllDetails(self,required_task_id,only_progress = False):
        #Here save all details in a file. Use shelve
        d = shelve.open(task_settings.get_path()+"database")
        details={}
        print "Required TaskId : ",str(required_task_id)
        try:
            details = d[required_task_id]
        except KeyError:
            self.resetAllDetails()
            print "Key does not exist"
            return
        finally:
            d.close()
            
        progress = 0
        if details['started_check'] == False:
            total_days = details['start_date'].daysTo(details['deadline_date'])
            days_rem = total_days - QtCore.QDate.currentDate().daysTo(details['deadline_date'])
            print "Days remaining = ",days_rem
            try:
                progress = days_rem*100/total_days
            except ZeroDivisionError:
                progress = 0
            print "Progress ",progress,"%"
        else:
            progress = 0
 
        if only_progress == True:
            return progress
                                                    
        #a dict of all details
        self.id_of_task = details['id']
        self.task_name_lineEdit.setText(details['task_name'])
        self.description_textEdit.setPlainText(details['description'])
        self.priority_spinBox.setValue(details['priority'])
        self.start_date_dateEdit.setDate(details['start_date'])
        self.deadline_dateEdit.setDate(details['deadline_date'])
        self.resources_plainTextEdit.setPlainText(details['resources'])
        self.project_started_checkBox.setCheckState(details['started_check'])
        self.progress_progressBar.setValue(int(progress))
    def delete_task(self, item):
        self.debug_fun("")

        try:
            d = shelve.open(task_settings.get_path() + "database")

            del_item = item

            del_key = str(del_item.text(1))
            idx = self.tasks_treeWidget.indexOfTopLevelItem(del_item)
            set_priority_item = del_item
            for i in range(len(d.keys())):
                try:
                    rec = self.tasks_treeWidget.itemBelow(set_priority_item)
                    rec_key = str(rec.text(1))
                    print "Set new priority for ", rec.text(0)
                    rec_details = d[rec_key]
                    rec_details['priority'] -= 1
                    d[rec_key] = rec_details
                except Exception as e_msg:
                    print "Delete_task: ", e_msg
                set_priority_item = self.tasks_treeWidget.itemBelow(
                    set_priority_item)
#                del set_priority_item
#free memory
            print "Deleting :", del_key, " with index :", idx
            #            self.tasks_treeWidget.topLevelItem(idx).setText(idx,"")

            try:
                del d[del_key]
            except Exception as e_msg:
                print e_msg

        except AttributeError:
            self.debug_fun("Error: Task name not seleted, cannot delete")

        finally:
            d.close()
#!/usr/bin/env python2
"""
Extract words,phrases from description and feed into my content.
"""
import task_settings
import shelve

d = shelve.open(task_settings.get_path() + "database")
data = []
for k in d.keys():
    data.append(d[k]['description'])
d.close()

da = open(task_settings.get_path() + "words_list.txt")
common_words = da.read().split('\n')
da.close()


def extract_words(text):
    #remove commonly used words
    mywords = text.split(' ')
    words = [w for w in mywords if (w not in common_words)]
    print words


for text in data:
    words = extract_words(text)
    #a list of words
#    generate_feed(words)