utils.py 文件源码

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

项目:aegea 作者: kislyuk 项目源码 文件源码
def timestamp_parameter(timestamp, allow_none=True):

    if timestamp is None:
        if allow_none:
            return None
        raise ValueError("Timestamp value cannot be None")

    if isinstance(timestamp, datetime):
        return timestamp.isoformat()

    if isinstance(timestamp, basestring):
        if not ISO_8601.match(timestamp):
            raise ValueError(("Invalid timestamp: %s is not a valid ISO-8601"
                              " formatted date") % timestamp)
        return timestamp

    raise ValueError("Cannot accept type %s for timestamp" % type(timestamp))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号