當前位置: 首頁>>代碼示例>>Python>>正文


Python copy.source_expressions方法代碼示例

本文整理匯總了Python中copy.source_expressions方法的典型用法代碼示例。如果您正苦於以下問題:Python copy.source_expressions方法的具體用法?Python copy.source_expressions怎麽用?Python copy.source_expressions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在copy的用法示例。


在下文中一共展示了copy.source_expressions方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: as_sql

# 需要導入模塊: import copy [as 別名]
# 或者: from copy import source_expressions [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 source_expressions [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 source_expressions [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 source_expressions [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: set_source_expressions

# 需要導入模塊: import copy [as 別名]
# 或者: from copy import source_expressions [as 別名]
def set_source_expressions(self, exprs):
        self.source_expressions = exprs 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:4,代碼來源:expressions.py

示例6: resolve_expression

# 需要導入模塊: import copy [as 別名]
# 或者: from copy import source_expressions [as 別名]
def resolve_expression(self, query=None, allow_joins=True, reuse=None, summarize=False, for_save=False):
        c = self.copy()
        c.is_summary = summarize
        for pos, arg in enumerate(c.source_expressions):
            c.source_expressions[pos] = arg.resolve_expression(query, allow_joins, reuse, summarize, for_save)
        return c 
開發者ID:lanbing510,項目名稱:GTDWeb,代碼行數:8,代碼來源:expressions.py

示例7: as_sql

# 需要導入模塊: import copy [as 別名]
# 或者: from copy import source_expressions [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

示例8: __init__

# 需要導入模塊: import copy [as 別名]
# 或者: from copy import source_expressions [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

示例9: __repr__

# 需要導入模塊: import copy [as 別名]
# 或者: from copy import source_expressions [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

示例10: __str__

# 需要導入模塊: import copy [as 別名]
# 或者: from copy import source_expressions [as 別名]
def __str__(self):
        return self.arg_joiner.join(str(arg) for arg in self.source_expressions) 
開發者ID:reBiocoder,項目名稱:bioforum,代碼行數:4,代碼來源:expressions.py

示例11: __repr__

# 需要導入模塊: import copy [as 別名]
# 或者: from copy import source_expressions [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

示例12: __init__

# 需要導入模塊: import copy [as 別名]
# 或者: from copy import source_expressions [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.source_expressions方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。