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


Python copy.extra方法代码示例

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


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

示例1: as_sql

# 需要导入模块: import copy [as 别名]
# 或者: from copy import extra [as 别名]
def as_sql(self, compiler, connection, function=None, template=None, arg_joiner=None, **extra_context):
        connection.ops.check_expression_support(self)
        sql_parts = []
        params = []
        for arg in self.source_expressions:
            arg_sql, arg_params = compiler.compile(arg)
            sql_parts.append(arg_sql)
            params.extend(arg_params)
        data = self.extra.copy()
        data.update(**extra_context)
        # Use the first supplied value in this order: the parameter to this
        # method, a value supplied in __init__()'s **extra (the value in
        # `data`), or the value defined on the class.
        if function is not None:
            data['function'] = function
        else:
            data.setdefault('function', self.function)
        template = template or data.get('template', self.template)
        arg_joiner = arg_joiner or data.get('arg_joiner', self.arg_joiner)
        data['expressions'] = data['field'] = arg_joiner.join(sql_parts)
        return template % data, params 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:23,代码来源:expressions.py

示例2: as_sql

# 需要导入模块: import copy [as 别名]
# 或者: from copy import extra [as 别名]
def as_sql(self, compiler, connection, function=None, template=None, arg_joiner=None, **extra_context):
        connection.ops.check_expression_support(self)
        sql_parts = []
        params = []
        for arg in self.source_expressions:
            arg_sql, arg_params = compiler.compile(arg)
            sql_parts.append(arg_sql)
            params.extend(arg_params)
        data = {**self.extra, **extra_context}
        # Use the first supplied value in this order: the parameter to this
        # method, a value supplied in __init__()'s **extra (the value in
        # `data`), or the value defined on the class.
        if function is not None:
            data['function'] = function
        else:
            data.setdefault('function', self.function)
        template = template or data.get('template', self.template)
        arg_joiner = arg_joiner or data.get('arg_joiner', self.arg_joiner)
        data['expressions'] = data['field'] = arg_joiner.join(sql_parts)
        return template % data, params 
开发者ID:PacktPublishing,项目名称:Hands-On-Application-Development-with-PyCharm,代码行数:22,代码来源:expressions.py

示例3: __init__

# 需要导入模块: import copy [as 别名]
# 或者: from copy import extra [as 别名]
def __init__(self, *expressions, **extra):
        output_field = extra.pop('output_field', None)
        super(Func, self).__init__(output_field=output_field)
        self.source_expressions = self._parse_expressions(*expressions)
        self.extra = extra 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:7,代码来源:expressions.py

示例4: __repr__

# 需要导入模块: import copy [as 别名]
# 或者: from copy import extra [as 别名]
def __repr__(self):
        args = self.arg_joiner.join(str(arg) for arg in self.source_expressions)
        extra = ', '.join(str(key) + '=' + str(val) for key, val in self.extra.items())
        if extra:
            return "{}({}, {})".format(self.__class__.__name__, args, extra)
        return "{}({})".format(self.__class__.__name__, args) 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:8,代码来源:expressions.py

示例5: as_sql

# 需要导入模块: import copy [as 别名]
# 或者: from copy import extra [as 别名]
def as_sql(self, compiler, connection, function=None, template=None):
        connection.ops.check_expression_support(self)
        sql_parts = []
        params = []
        for arg in self.source_expressions:
            arg_sql, arg_params = compiler.compile(arg)
            sql_parts.append(arg_sql)
            params.extend(arg_params)
        if function is None:
            self.extra['function'] = self.extra.get('function', self.function)
        else:
            self.extra['function'] = function
        self.extra['expressions'] = self.extra['field'] = self.arg_joiner.join(sql_parts)
        template = template or self.extra.get('template', self.template)
        return template % self.extra, params 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:17,代码来源:expressions.py

示例6: copy

# 需要导入模块: import copy [as 别名]
# 或者: from copy import extra [as 别名]
def copy(self):
        copy = super(Func, self).copy()
        copy.source_expressions = self.source_expressions[:]
        copy.extra = self.extra.copy()
        return copy 
开发者ID:lanbing510,项目名称:GTDWeb,代码行数:7,代码来源:expressions.py

示例7: __init__

# 需要导入模块: import copy [as 别名]
# 或者: from copy import extra [as 别名]
def __init__(self, *expressions, output_field=None, **extra):
        if self.arity is not None and len(expressions) != self.arity:
            raise TypeError(
                "'%s' takes exactly %s %s (%s given)" % (
                    self.__class__.__name__,
                    self.arity,
                    "argument" if self.arity == 1 else "arguments",
                    len(expressions),
                )
            )
        super().__init__(output_field=output_field)
        self.source_expressions = self._parse_expressions(*expressions)
        self.extra = extra 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:15,代码来源:expressions.py

示例8: __repr__

# 需要导入模块: import copy [as 别名]
# 或者: from copy import extra [as 别名]
def __repr__(self):
        args = self.arg_joiner.join(str(arg) for arg in self.source_expressions)
        extra = dict(self.extra, **self._get_repr_options())
        if extra:
            extra = ', '.join(str(key) + '=' + str(val) for key, val in sorted(extra.items()))
            return "{}({}, {})".format(self.__class__.__name__, args, extra)
        return "{}({})".format(self.__class__.__name__, args) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:9,代码来源:expressions.py

示例9: _get_repr_options

# 需要导入模块: import copy [as 别名]
# 或者: from copy import extra [as 别名]
def _get_repr_options(self):
        """Return a dict of extra __init__() options to include in the repr."""
        return {} 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:5,代码来源:expressions.py

示例10: copy

# 需要导入模块: import copy [as 别名]
# 或者: from copy import extra [as 别名]
def copy(self):
        copy = super().copy()
        copy.source_expressions = self.source_expressions[:]
        copy.extra = self.extra.copy()
        return copy 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:7,代码来源:expressions.py

示例11: __invert__

# 需要导入模块: import copy [as 别名]
# 或者: from copy import extra [as 别名]
def __invert__(self):
        return type(self)(self.queryset, negated=(not self.negated), **self.extra) 
开发者ID:reBiocoder,项目名称:bioforum,代码行数:4,代码来源:expressions.py

示例12: __repr__

# 需要导入模块: import copy [as 别名]
# 或者: from copy import extra [as 别名]
def __repr__(self):
        args = self.arg_joiner.join(str(arg) for arg in self.source_expressions)
        extra = {**self.extra, **self._get_repr_options()}
        if extra:
            extra = ', '.join(str(key) + '=' + str(val) for key, val in sorted(extra.items()))
            return "{}({}, {})".format(self.__class__.__name__, args, extra)
        return "{}({})".format(self.__class__.__name__, args) 
开发者ID:PacktPublishing,项目名称:Hands-On-Application-Development-with-PyCharm,代码行数:9,代码来源:expressions.py

示例13: __init__

# 需要导入模块: import copy [as 别名]
# 或者: from copy import extra [as 别名]
def __init__(self, *expressions, **extra):
        if self.arity is not None and len(expressions) != self.arity:
            raise TypeError(
                "'%s' takes exactly %s %s (%s given)" % (
                    self.__class__.__name__,
                    self.arity,
                    "argument" if self.arity == 1 else "arguments",
                    len(expressions),
                )
            )
        output_field = extra.pop('output_field', None)
        super(Func, self).__init__(output_field=output_field)
        self.source_expressions = self._parse_expressions(*expressions)
        self.extra = extra 
开发者ID:Yeah-Kun,项目名称:python,代码行数:16,代码来源:expressions.py


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