Python copy.source_expressions() Examples

The following are code examples for showing how to use copy.source_expressions(). They are extracted from open source Python projects. You can vote up the examples you like or vote down the ones you don't like. You can also save this page to your account.

Example 1
Project: lifesoundtrack   Author: MTG   File: expressions.py    (license) View Source Project 6 votes vote down vote up
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 
Example 2
Project: liberator   Author: libscie   File: expressions.py    (license) View Source Project 6 votes vote down vote up
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 
Example 3
Project: LatinSounds_AppEnviaMail   Author: G3ek-aR   File: expressions.py    (license) View Source Project 6 votes vote down vote up
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 
Example 4
Project: CodingDojo   Author: ComputerSocietyUNB   File: expressions.py    (license) View Source Project 5 votes vote down vote up
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 
Example 5
Project: CodingDojo   Author: ComputerSocietyUNB   File: expressions.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 6
Project: CodingDojo   Author: ComputerSocietyUNB   File: expressions.py    (license) View Source Project 5 votes vote down vote up
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 
Example 7
Project: CodingDojo   Author: ComputerSocietyUNB   File: expressions.py    (license) View Source Project 5 votes vote down vote up
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 
Example 8
Project: lifesoundtrack   Author: MTG   File: expressions.py    (license) View Source Project 5 votes vote down vote up
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 
Example 9
Project: lifesoundtrack   Author: MTG   File: expressions.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 10
Project: lifesoundtrack   Author: MTG   File: expressions.py    (license) View Source Project 5 votes vote down vote up
def set_source_expressions(self, exprs):
        self.source_expressions = exprs 
Example 11
Project: lifesoundtrack   Author: MTG   File: expressions.py    (license) View Source Project 5 votes vote down vote up
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 
Example 12
Project: liberator   Author: libscie   File: expressions.py    (license) View Source Project 5 votes vote down vote up
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 
Example 13
Project: liberator   Author: libscie   File: expressions.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 14
Project: liberator   Author: libscie   File: expressions.py    (license) View Source Project 5 votes vote down vote up
def set_source_expressions(self, exprs):
        self.source_expressions = exprs 
Example 15
Project: liberator   Author: libscie   File: expressions.py    (license) View Source Project 5 votes vote down vote up
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 
Example 16
Project: djanoDoc   Author: JustinChavez   File: expressions.py    (license) View Source Project 5 votes vote down vote up
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 
Example 17
Project: djanoDoc   Author: JustinChavez   File: expressions.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 18
Project: djanoDoc   Author: JustinChavez   File: expressions.py    (license) View Source Project 5 votes vote down vote up
def set_source_expressions(self, exprs):
        self.source_expressions = exprs 
Example 19
Project: djanoDoc   Author: JustinChavez   File: expressions.py    (license) View Source Project 5 votes vote down vote up
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 
Example 20
Project: djanoDoc   Author: JustinChavez   File: expressions.py    (license) View Source Project 5 votes vote down vote up
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 
Example 21
Project: django-next-train   Author: bitpixdigital   File: expressions.py    (license) View Source Project 5 votes vote down vote up
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 
Example 22
Project: django-next-train   Author: bitpixdigital   File: expressions.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 23
Project: django-next-train   Author: bitpixdigital   File: expressions.py    (license) View Source Project 5 votes vote down vote up
def set_source_expressions(self, exprs):
        self.source_expressions = exprs 
Example 24
Project: django-next-train   Author: bitpixdigital   File: expressions.py    (license) View Source Project 5 votes vote down vote up
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 
Example 25
Project: django-next-train   Author: bitpixdigital   File: expressions.py    (license) View Source Project 5 votes vote down vote up
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 
Example 26
Project: LatinSounds_AppEnviaMail   Author: G3ek-aR   File: expressions.py    (license) View Source Project 5 votes vote down vote up
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 
Example 27
Project: LatinSounds_AppEnviaMail   Author: G3ek-aR   File: expressions.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 28
Project: LatinSounds_AppEnviaMail   Author: G3ek-aR   File: expressions.py    (license) View Source Project 5 votes vote down vote up
def set_source_expressions(self, exprs):
        self.source_expressions = exprs 
Example 29
Project: LatinSounds_AppEnviaMail   Author: G3ek-aR   File: expressions.py    (license) View Source Project 5 votes vote down vote up
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 
Example 30
Project: django-wechat-api   Author: crazy-canux   File: expressions.py    (license) View Source Project 5 votes vote down vote up
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 
Example 31
Project: django-wechat-api   Author: crazy-canux   File: expressions.py    (license) View Source Project 5 votes vote down vote up
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) 
Example 32
Project: django-wechat-api   Author: crazy-canux   File: expressions.py    (license) View Source Project 5 votes vote down vote up
def set_source_expressions(self, exprs):
        self.source_expressions = exprs 
Example 33
Project: django-wechat-api   Author: crazy-canux   File: expressions.py    (license) View Source Project 5 votes vote down vote up
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 
Example 34
Project: django-wechat-api   Author: crazy-canux   File: expressions.py    (license) View Source Project 5 votes vote down vote up
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 
Example 35
Project: CodingDojo   Author: ComputerSocietyUNB   File: expressions.py    (license) View Source Project 4 votes vote down vote up
def set_source_expressions(self, exprs):
        self.source_expressions = exprs