当前位置: 首页>>代码示例>>Python>>正文


Python Date.is_fuzzy方法代码示例

本文整理汇总了Python中GTG.tools.dates.Date.is_fuzzy方法的典型用法代码示例。如果您正苦于以下问题:Python Date.is_fuzzy方法的具体用法?Python Date.is_fuzzy怎么用?Python Date.is_fuzzy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GTG.tools.dates.Date的用法示例。


在下文中一共展示了Date.is_fuzzy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: set_due_date

# 需要导入模块: from GTG.tools.dates import Date [as 别名]
# 或者: from GTG.tools.dates.Date import is_fuzzy [as 别名]
    def set_due_date(self, new_duedate):
        """Defines the task's due date."""
        def __get_defined_parent_list(task):
            """Recursively fetch a list of parents that have a defined due date
               which is not fuzzy"""
            parent_list = []
            for par_id in task.parents:
                par = self.req.get_task(par_id)
                if par.get_due_date().is_fuzzy():
                    parent_list += __get_defined_parent_list(par)
                else:
                    parent_list.append(par)
            return parent_list

        def __get_defined_child_list(task):
            """Recursively fetch a list of children that have a defined
               due date which is not fuzzy"""
            child_list = []
            for child_id in task.children:
                child = self.req.get_task(child_id)
                if child.get_due_date().is_fuzzy():
                    child_list += __get_defined_child_list(child)
                else:
                    child_list.append(child)
            return child_list

        old_due_date = self.due_date
        new_duedate_obj = Date(new_duedate)  # caching the conversion
        self.due_date = new_duedate_obj
        # If the new date is fuzzy or undefined, we don't update related tasks
        if not new_duedate_obj.is_fuzzy():
            # if the task's start date happens later than the
            # new due date, we update it (except for fuzzy dates)
            if not self.get_start_date().is_fuzzy() and \
                    self.get_start_date() > new_duedate_obj:
                self.set_start_date(new_duedate)
            # if some ancestors' due dates happen before the task's new
            # due date, we update them (except for fuzzy dates)
            for par in __get_defined_parent_list(self):
                if par.get_due_date() < new_duedate_obj:
                    par.set_due_date(new_duedate)
            # we must apply the constraints to the defined & non-fuzzy children
            # as well
            for sub in __get_defined_child_list(self):
                sub_duedate = sub.get_due_date()
                # if the child's due date happens later than the task's: we
                # update it to the task's new due date
                if sub_duedate > new_duedate_obj:
                    sub.set_due_date(new_duedate)
                # if the child's start date happens later than
                # the task's new due date, we update it
                # (except for fuzzy start dates)
                sub_startdate = sub.get_start_date()
                if not sub_startdate.is_fuzzy() and \
                        sub_startdate > new_duedate_obj:
                    sub.set_start_date(new_duedate)
        # If the date changed, we notify the change for the children since the
        # constraints might have changed
        if old_due_date != new_duedate_obj:
            self.recursive_sync()
开发者ID:sagarghuge,项目名称:recurringtask,代码行数:62,代码来源:task.py

示例2: set_endon_date

# 需要导入模块: from GTG.tools.dates import Date [as 别名]
# 或者: from GTG.tools.dates.Date import is_fuzzy [as 别名]
    def set_endon_date(self, new_endondate):
        def __get_defined_parent_list(task):
            """Recursively fetch a list of parents that have a defined due date
               which is not fuzzy"""
            parent_list = []
            for par_id in task.parents:
                par = self.req.get_task(par_id)
                if par.get_due_date().is_fuzzy():
                    parent_list += __get_defined_parent_list(par)
                else:
                    parent_list.append(par)
            return parent_list

        def __get_defined_child_list(task):
            """Recursively fetch a list of children that have a defined
               due date which is not fuzzy"""
            child_list = []
            for child_id in task.children:
                child = self.req.get_task(child_id)
                if child.get_due_date().is_fuzzy():
                    child_list += __get_defined_child_list(child)
                else:
                    child_list.append(child)
            return child_list

        old_endon_date = self.endon_date
        new_endondate_obj = Date(new_endondate)
        self.endon_date = new_endondate_obj
        if not new_endondate_obj.is_fuzzy():
            # if the task's start date happens later than the
            # new endon date, we update it (except for fuzzy dates)
            #We should show it in red. 
            # we must apply the constraints to the defined & non-fuzzy children
            # as well
            for sub in __get_defined_child_list(self):
                sub_duedate = sub.get_due_date()
                # if the child's start date happens later than
                # the task's new endon date, we update it
                # (except for fuzzy start dates)
                #We should show it in red.
        # If the date changed, we notify the change for the children since the
        # constraints might have changed
        if old_endon_date != new_endondate_obj:
            self.recursive_sync()
开发者ID:sagarghuge,项目名称:recurringtask,代码行数:46,代码来源:task.py


注:本文中的GTG.tools.dates.Date.is_fuzzy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。