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


Python Date.someday方法代码示例

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


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

示例1: test_parse_fuzzy_dates

# 需要导入模块: from GTG.tools.dates import Date [as 别名]
# 或者: from GTG.tools.dates.Date import someday [as 别名]
 def test_parse_fuzzy_dates(self):
     """ Parse fuzzy dates like now, soon, later, someday """
     self.assertEqual(Date.parse("now"), Date.now())
     self.assertEqual(Date.parse("soon"), Date.soon())
     self.assertEqual(Date.parse("later"), Date.someday())
     self.assertEqual(Date.parse("someday"), Date.someday())
     self.assertEqual(Date.parse(""), Date.no_date())
开发者ID:lefred,项目名称:backend_gtgonline,代码行数:9,代码来源:test_dates.py

示例2: test_parse_local_fuzzy_dates

# 需要导入模块: from GTG.tools.dates import Date [as 别名]
# 或者: from GTG.tools.dates.Date import someday [as 别名]
 def test_parse_local_fuzzy_dates(self):
     """ Parse fuzzy dates in their localized version """
     self.assertEqual(Date.parse(_("now")), Date.now())
     self.assertEqual(Date.parse(_("soon")), Date.soon())
     self.assertEqual(Date.parse(_("later")), Date.someday())
     self.assertEqual(Date.parse(_("someday")), Date.someday())
     self.assertEqual(Date.parse(""), Date.no_date())
开发者ID:lefred,项目名称:backend_gtgonline,代码行数:9,代码来源:test_dates.py

示例3: workview

# 需要导入模块: from GTG.tools.dates import Date [as 别名]
# 或者: from GTG.tools.dates.Date import someday [as 别名]
 def workview(self, task, parameters=None):
     wv = (self.active(task) and
           self.is_started(task) and
           self.is_workable(task) and
           self.no_disabled_tag(task) and
           task.get_due_date() != Date.someday())
     return wv
开发者ID:abseabse,项目名称:gtg,代码行数:9,代码来源:treefactory.py

示例4: check_commands

# 需要导入模块: from GTG.tools.dates import Date [as 别名]
# 或者: from GTG.tools.dates.Date import someday [as 别名]
    def check_commands(commands_list):
        """ Execute search commands

        This method is recursive for !or and !and """

        def fulltext_search(task, word):
            """ check if task contains the word """
            word = word.lower()
            text = task.get_excerpt(strip_tags=False).lower()
            title = task.get_title().lower()

            return word in text or word in title

        value_checks = {
            'after': lambda t, v: task.get_due_date() > v,
            'before': lambda t, v: task.get_due_date() < v,
            'tag': lambda t, v: v in task.get_tags_name(),
            'word': fulltext_search,
            'today': lambda task, v: task.get_due_date() == Date.today(),
            'tomorrow': lambda task, v: task.get_due_date() == Date.tomorrow(),
            'nodate': lambda task, v: task.get_due_date() == Date.no_date(),
            'now': lambda task, v: task.get_due_date() == Date.now(),
            'soon': lambda task, v: task.get_due_date() == Date.soon(),
            'someday': lambda task, v: task.get_due_date() == Date.someday(),
            'notag': lambda task, v: task.get_tags() == [],
        }

        for command in commands_list:
            cmd, positive, args = command[0], command[1], command[2:]
            result = False

            if cmd == 'or':
                for sub_cmd in args[0]:
                    if check_commands([sub_cmd]):
                        result = True
                        break
            elif value_checks.get(cmd, None):
                if len(args) > 0:
                    args = args[0]
                result = value_checks[cmd](task, args)

            if (positive and not result) or (not positive and result):
                return False

        return True
开发者ID:abseabse,项目名称:gtg,代码行数:47,代码来源:search.py

示例5: get_node_bgcolor

# 需要导入模块: from GTG.tools.dates import Date [as 别名]
# 或者: from GTG.tools.dates.Date import someday [as 别名]
    def get_node_bgcolor(self, node):
        """ This method checks the urgency of a node (task) and returns its
         urgency background color"""
        sdate = node.get_start_date()
        ddate = node.get_due_date()
        daysleft = ddate.days_left()

        # Dates undefined (Fix to bug #1039655)
        if ddate == Date.today():
            return self._get_color(2)  # High urgency
        elif daysleft < 0 and ddate != Date.no_date():
            return self._get_color(3)  # Overdue
        elif (
            sdate == Date.no_date()  # Has no start date
            and ddate != Date.no_date()  # and a due date
            and not ddate.is_fuzzy()
        ):  # which is not fuzzy, is fixed
            return self._get_color(1)  # Normal

        # Fuzzy dates (now, soon, someday)
        # These can ignore the start date
        if ddate == Date.now():
            return self._get_color(2)
        elif ddate == Date.soon():
            return self._get_color(1)
        elif ddate == Date.someday():
            return self._get_color(0)

        # Dates fully defined. Calculate gradient color
        elif sdate != Date.no_date() != ddate:
            dayspan = (ddate - sdate).days
            redf = self._pref_data["reddays"]
            reddays = int(ceil(redf / 100.0 * dayspan))

            # Gradient variables
            grad_dayspan = dayspan - reddays
            grad_half_dayspan = grad_dayspan / 2.0

            # Default to low urgency color
            color = self._get_color(0)

            # CL : low urgency color
            # CN : normal urgency color
            # CH : high urgency color
            # CO : overdue color
            # To understand this section, it is easier to draw out a
            # timeline divided into 3 sections: CL to CN, CN to CH and
            # the reddays section. Then point out the spans of the
            # different variables (dayspan, daysleft, reddays,
            # grad_dayspan, grad_half_dayspan)
            if daysleft < 0:  # CO
                color = self._get_color(3)
            elif daysleft <= reddays:  # CH
                color = self._get_color(2)
            elif daysleft <= (dayspan - grad_half_dayspan):
                # Gradient CN to CH
                # Has to be float so division by it is non-zero
                steps = float(grad_half_dayspan)
                step = grad_half_dayspan - (daysleft - reddays)
                color = self._get_gradient_color(self._get_color(1), self._get_color(2), step / steps)
            elif daysleft <= dayspan:
                # Gradient CL to CN
                steps = float(grad_half_dayspan)
                step = grad_half_dayspan - (daysleft - reddays - grad_half_dayspan)
                color = self._get_gradient_color(self._get_color(0), self._get_color(1), step / steps)

            return color

        # Insufficient data to determine urgency
        else:
            return None
开发者ID:nidhinbalakrishnan,项目名称:gtg,代码行数:73,代码来源:urgency_color.py


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