kron.py 文件源码

python
阅读 15 收藏 0 点赞 0 评论 0

项目:kron 作者: qtfkwk 项目源码 文件源码
def search(cls, name=None):
        """Resolve timezone given a name

        ``name`` can be:

        * omitted or None: returns name of the local timezone via
          tzlocal or UTC
        * string matching a timezone name in ``pytz.all_timezones``:
          returns the timezone name in proper case
        * empty string ('') or wildcard regular expression ('.*'):
          returns a list with all timezone names
        * any other string: used as a regular expression; multiple or
          zero matches returns a list with the matched timezone names
        """
        if name == None:
            try:
                return tzlocal.get_localzone().zone
            except:
                return 'UTC'
        if name in pytz.all_timezones:
            return name
        name_ = name.lower()
        matches = []
        for t in pytz.all_timezones:
            t_ = t.lower()
            if name_ == t_:
                return t
            if re.search(name, t) or re.search(name_, t_):
                matches.append(t)
        if len(matches) == 1:
            return matches[0]
        else:
            return matches

# Error classes
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号