def evaluation_test(self, mComposition, mLabel): # $CURRENT_DATE evaluation mLabel.setText("__$CURRENT_DATE__") assert mLabel.displayText() == ("__" + QDate.currentDate().toString() + "__") # $CURRENT_DATE() evaluation mLabel.setText("__$CURRENT_DATE(dd)(ok)__") expected = "__" + QDateTime.currentDateTime().toString("dd") + "(ok)__" assert mLabel.displayText() == expected # $CURRENT_DATE() evaluation (inside an expression) mLabel.setText("__[%$CURRENT_DATE(dd) + 1%](ok)__") dd = QDate.currentDate().day() expected = "__%d(ok)__" % (dd + 1) assert mLabel.displayText() == expected # expression evaluation (without associated feature) mLabel.setText("__[%\"NAME_1\"%][%21*2%]__") assert mLabel.displayText() == "__[NAME_1]42__"
def timeForChecking(self): """ determine whether it's the time for checking for news and updates now """ if self.checkingOnStartInterval() == 0: return True settings = QSettings() try: # QSettings may contain ivalid value... interval = settings.value(settingsGroup + "/checkOnStartLastDate", type=QDate).daysTo(QDate.currentDate()) except: interval = 0 if interval >= self.checkingOnStartInterval(): return True else: return False
def saveCheckingOnStartLastDate(self): """ set today's date as the day of last checking """ settings = QSettings() settings.setValue(settingsGroup + "/checkOnStartLastDate", QDate.currentDate())