python类IntFlag()的实例源码

extract_enums.py 文件源码 项目:pg_query 作者: lelit 项目源码 文件源码 阅读 19 收藏 0 点赞 0 评论 0
def determine_enum_type_and_value(enum):
    type = 'IntEnum'
    value = int_enum_value_factory

    for item in enum.values.enumerators:
        if item.value:
            if isinstance(item.value, c_ast.Constant) and item.value.type == 'char':
                type = 'str, Enum'
                value = char_enum_value_factory
                break
            elif isinstance(item.value, c_ast.BinaryOp) and item.value.op == '<<':
                type = 'IntFlag'
                break

    return type, value


问题


面经


文章

微信
公众号

扫码关注公众号