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


Python cutils._distill_params方法代码示例

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


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

示例1: py_fallback

# 需要导入模块: from sqlalchemy import cutils [as 别名]
# 或者: from sqlalchemy.cutils import _distill_params [as 别名]
def py_fallback():
    def _distill_params(multiparams, params):
        """Given arguments from the calling form *multiparams, **params,
        return a list of bind parameter structures, usually a list of
        dictionaries.

        In the case of 'raw' execution which accepts positional parameters,
        it may be a list of tuples or lists.

        """

        if not multiparams:
            if params:
                return [params]
            else:
                return []
        elif len(multiparams) == 1:
            zero = multiparams[0]
            if isinstance(zero, (list, tuple)):
                if not zero or hasattr(zero[0], '__iter__') and \
                        not hasattr(zero[0], 'strip'):
                    # execute(stmt, [{}, {}, {}, ...])
                    # execute(stmt, [(), (), (), ...])
                    return zero
                else:
                    # execute(stmt, ("value", "value"))
                    return [zero]
            elif hasattr(zero, 'keys'):
                # execute(stmt, {"key":"value"})
                return [zero]
            else:
                # execute(stmt, "value")
                return [[zero]]
        else:
            if hasattr(multiparams[0], '__iter__') and \
                    not hasattr(multiparams[0], 'strip'):
                return multiparams
            else:
                return [multiparams]

    return locals() 
开发者ID:jpush,项目名称:jbox,代码行数:43,代码来源:util.py

示例2: py_fallback

# 需要导入模块: from sqlalchemy import cutils [as 别名]
# 或者: from sqlalchemy.cutils import _distill_params [as 别名]
def py_fallback():
    def _distill_params(multiparams, params):
        """Given arguments from the calling form *multiparams, **params,
        return a list of bind parameter structures, usually a list of
        dictionaries.

        In the case of 'raw' execution which accepts positional parameters,
        it may be a list of tuples or lists.

        """

        if not multiparams:
            if params:
                return [params]
            else:
                return []
        elif len(multiparams) == 1:
            zero = multiparams[0]
            if isinstance(zero, (list, tuple)):
                if not zero or hasattr(zero[0], '__iter__') and \
                        not hasattr(zero[0], 'strip'):
                    # execute(stmt, [{}, {}, {}, ...])
                    # execute(stmt, [(), (), (), ...])
                    return zero
                else:
                    # execute(stmt, ("value", "value"))
                    return [zero]
            elif hasattr(zero, 'keys'):
                # execute(stmt, {"key":"value"})
                return [zero]
            else:
                # execute(stmt, "value")
                return [[zero]]
        else:
            if hasattr(multiparams[0], '__iter__') and \
                not hasattr(multiparams[0], 'strip'):
                return multiparams
            else:
                return [multiparams]

    return locals() 
开发者ID:binhex,项目名称:moviegrabber,代码行数:43,代码来源:util.py


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