python类BaseSet()的实例源码

converters.py 文件源码 项目:true_review_web2py 作者: lucadealfaro 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def escape_item(val, charset):
    if type(val) in [tuple, list, set]:
        return escape_sequence(val, charset)
    if type(val) is dict:
        return escape_dict(val, charset)
    if PYTHON3 and hasattr(val, "decode") and not isinstance(val, unicode):
        # deal with py3k bytes
        val = val.decode(charset)
    encoder = encoders[type(val)]
    val = encoder(val)
    if type(val) in [str, int]:
        return val
    val = val.encode(charset)
    return val
converters.py 文件源码 项目:true_review_web2py 作者: lucadealfaro 项目源码 文件源码 阅读 82 收藏 0 点赞 0 评论 0
def convert_time(connection, field, obj):
    """Returns a TIME column as a time object:

      >>> time_or_None('15:06:17')
      datetime.time(15, 6, 17)

    Illegal values are returned as None:

      >>> time_or_None('-25:06:17') is None
      True
      >>> time_or_None('random crap') is None
      True

    Note that MySQL always returns TIME columns as (+|-)HH:MM:SS, but
    can accept values as (+|-)DD HH:MM:SS. The latter format will not
    be parsed correctly by this function.

    Also note that MySQL's TIME column corresponds more closely to
    Python's timedelta and not time. However if you want TIME columns
    to be treated as time-of-day and not a time offset, then you can
    use set this function as the converter for FIELD_TYPE.TIME.
    """
    try:
        microseconds = 0
        if "." in obj:
            (obj, tail) = obj.split('.')
            microseconds = int(tail)
        hours, minutes, seconds = obj.split(':')
        return datetime.time(hour=int(hours), minute=int(minutes),
                             second=int(seconds), microsecond=microseconds)
    except ValueError:
        return None
converters.py 文件源码 项目:true_review_web2py 作者: lucadealfaro 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def convert_set(s):
    return set(s.split(","))
__init__.py 文件源码 项目:true_review_web2py 作者: lucadealfaro 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __ne__(self, other):
        if isinstance(other, set):
            return super(DBAPISet, self).__ne__(self, other)
        else:
            return other not in self
converters.py 文件源码 项目:spc 作者: whbrewer 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def escape_item(val, charset):
    if type(val) in [tuple, list, set]:
        return escape_sequence(val, charset)
    if type(val) is dict:
        return escape_dict(val, charset)
    if PYTHON3 and hasattr(val, "decode") and not isinstance(val, unicode):
        # deal with py3k bytes
        val = val.decode(charset)
    encoder = encoders[type(val)]
    val = encoder(val)
    if type(val) in [str, int]:
        return val
    val = val.encode(charset)
    return val
converters.py 文件源码 项目:spc 作者: whbrewer 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def convert_time(connection, field, obj):
    """Returns a TIME column as a time object:

      >>> time_or_None('15:06:17')
      datetime.time(15, 6, 17)

    Illegal values are returned as None:

      >>> time_or_None('-25:06:17') is None
      True
      >>> time_or_None('random crap') is None
      True

    Note that MySQL always returns TIME columns as (+|-)HH:MM:SS, but
    can accept values as (+|-)DD HH:MM:SS. The latter format will not
    be parsed correctly by this function.

    Also note that MySQL's TIME column corresponds more closely to
    Python's timedelta and not time. However if you want TIME columns
    to be treated as time-of-day and not a time offset, then you can
    use set this function as the converter for FIELD_TYPE.TIME.
    """
    try:
        microseconds = 0
        if "." in obj:
            (obj, tail) = obj.split('.')
            microseconds = int(tail)
        hours, minutes, seconds = obj.split(':')
        return datetime.time(hour=int(hours), minute=int(minutes),
                             second=int(seconds), microsecond=microseconds)
    except ValueError:
        return None
converters.py 文件源码 项目:spc 作者: whbrewer 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def convert_set(s):
    return set(s.split(","))
__init__.py 文件源码 项目:spc 作者: whbrewer 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def __ne__(self, other):
        if isinstance(other, set):
            return super(DBAPISet, self).__ne__(self, other)
        else:
            return other not in self
converters.py 文件源码 项目:Problematica-public 作者: TechMaz 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def escape_item(val, charset):
    if type(val) in [tuple, list, set]:
        return escape_sequence(val, charset)
    if type(val) is dict:
        return escape_dict(val, charset)
    if PYTHON3 and hasattr(val, "decode") and not isinstance(val, unicode):
        # deal with py3k bytes
        val = val.decode(charset)
    encoder = encoders[type(val)]
    val = encoder(val)
    if type(val) in [str, int]:
        return val
    val = val.encode(charset)
    return val
converters.py 文件源码 项目:Problematica-public 作者: TechMaz 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def convert_time(connection, field, obj):
    """Returns a TIME column as a time object:

      >>> time_or_None('15:06:17')
      datetime.time(15, 6, 17)

    Illegal values are returned as None:

      >>> time_or_None('-25:06:17') is None
      True
      >>> time_or_None('random crap') is None
      True

    Note that MySQL always returns TIME columns as (+|-)HH:MM:SS, but
    can accept values as (+|-)DD HH:MM:SS. The latter format will not
    be parsed correctly by this function.

    Also note that MySQL's TIME column corresponds more closely to
    Python's timedelta and not time. However if you want TIME columns
    to be treated as time-of-day and not a time offset, then you can
    use set this function as the converter for FIELD_TYPE.TIME.
    """
    try:
        microseconds = 0
        if "." in obj:
            (obj, tail) = obj.split('.')
            microseconds = int(tail)
        hours, minutes, seconds = obj.split(':')
        return datetime.time(hour=int(hours), minute=int(minutes),
                             second=int(seconds), microsecond=microseconds)
    except ValueError:
        return None
converters.py 文件源码 项目:Problematica-public 作者: TechMaz 项目源码 文件源码 阅读 31 收藏 0 点赞 0 评论 0
def convert_set(s):
    return set(s.split(","))
__init__.py 文件源码 项目:Problematica-public 作者: TechMaz 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def __ne__(self, other):
        if isinstance(other, set):
            return super(DBAPISet, self).__ne__(self, other)
        else:
            return other not in self
converters.py 文件源码 项目:slugiot-client 作者: slugiot 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def escape_item(val, charset):
    if type(val) in [tuple, list, set]:
        return escape_sequence(val, charset)
    if type(val) is dict:
        return escape_dict(val, charset)
    if PYTHON3 and hasattr(val, "decode") and not isinstance(val, unicode):
        # deal with py3k bytes
        val = val.decode(charset)
    encoder = encoders[type(val)]
    val = encoder(val)
    if type(val) in [str, int]:
        return val
    val = val.encode(charset)
    return val
converters.py 文件源码 项目:slugiot-client 作者: slugiot 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def convert_time(connection, field, obj):
    """Returns a TIME column as a time object:

      >>> time_or_None('15:06:17')
      datetime.time(15, 6, 17)

    Illegal values are returned as None:

      >>> time_or_None('-25:06:17') is None
      True
      >>> time_or_None('random crap') is None
      True

    Note that MySQL always returns TIME columns as (+|-)HH:MM:SS, but
    can accept values as (+|-)DD HH:MM:SS. The latter format will not
    be parsed correctly by this function.

    Also note that MySQL's TIME column corresponds more closely to
    Python's timedelta and not time. However if you want TIME columns
    to be treated as time-of-day and not a time offset, then you can
    use set this function as the converter for FIELD_TYPE.TIME.
    """
    try:
        microseconds = 0
        if "." in obj:
            (obj, tail) = obj.split('.')
            microseconds = int(tail)
        hours, minutes, seconds = obj.split(':')
        return datetime.time(hour=int(hours), minute=int(minutes),
                             second=int(seconds), microsecond=microseconds)
    except ValueError:
        return None
converters.py 文件源码 项目:slugiot-client 作者: slugiot 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def convert_set(s):
    return set(s.split(","))
__init__.py 文件源码 项目:slugiot-client 作者: slugiot 项目源码 文件源码 阅读 20 收藏 0 点赞 0 评论 0
def __ne__(self, other):
        if isinstance(other, set):
            return super(DBAPISet, self).__ne__(self, other)
        else:
            return other not in self
converters.py 文件源码 项目:StuffShare 作者: StuffShare 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def escape_item(val, charset):
    if type(val) in [tuple, list, set]:
        return escape_sequence(val, charset)
    if type(val) is dict:
        return escape_dict(val, charset)
    if PYTHON3 and hasattr(val, "decode") and not isinstance(val, unicode):
        # deal with py3k bytes
        val = val.decode(charset)
    encoder = encoders[type(val)]
    val = encoder(val)
    if type(val) in [str, int]:
        return val
    val = val.encode(charset)
    return val
converters.py 文件源码 项目:StuffShare 作者: StuffShare 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def convert_time(connection, field, obj):
    """Returns a TIME column as a time object:

      >>> time_or_None('15:06:17')
      datetime.time(15, 6, 17)

    Illegal values are returned as None:

      >>> time_or_None('-25:06:17') is None
      True
      >>> time_or_None('random crap') is None
      True

    Note that MySQL always returns TIME columns as (+|-)HH:MM:SS, but
    can accept values as (+|-)DD HH:MM:SS. The latter format will not
    be parsed correctly by this function.

    Also note that MySQL's TIME column corresponds more closely to
    Python's timedelta and not time. However if you want TIME columns
    to be treated as time-of-day and not a time offset, then you can
    use set this function as the converter for FIELD_TYPE.TIME.
    """
    try:
        microseconds = 0
        if "." in obj:
            (obj, tail) = obj.split('.')
            microseconds = int(tail)
        hours, minutes, seconds = obj.split(':')
        return datetime.time(hour=int(hours), minute=int(minutes),
                             second=int(seconds), microsecond=microseconds)
    except ValueError:
        return None
converters.py 文件源码 项目:StuffShare 作者: StuffShare 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def convert_set(s):
    return set(s.split(","))
__init__.py 文件源码 项目:StuffShare 作者: StuffShare 项目源码 文件源码 阅读 22 收藏 0 点赞 0 评论 0
def __ne__(self, other):
        if isinstance(other, set):
            return super(DBAPISet, self).__ne__(self, other)
        else:
            return other not in self


问题


面经


文章

微信
公众号

扫码关注公众号