Implements @include, for @mixins

def _do_include(self, rule, p_selectors, p_parents, p_children, scope, media, c_lineno, c_property, c_codestr, code, name):
        """
        Implements @include, for @mixins
        """
        funct, params, _ = name.partition('(')
        funct = funct.strip()
        funct = self.do_glob_math(
            funct, rule[CONTEXT], rule[OPTIONS], rule, True)
        params = split_params(depar(params + _))
        new_params = {}
        num_args = 0
        for param in params:
            varname, _, param = param.partition(':')
            if param:
                param = param.strip()
                varname = varname.strip()
            else:
                param = varname.strip()
                varname = num_args
                if param:
                    num_args += 1
            if param:
                new_params[varname] = param
        mixin = rule[OPTIONS].get('@mixin %s:%s' % (funct, num_args))
        if not mixin:
            # Fallback to single parmeter:
            mixin = rule[OPTIONS].get('@mixin %s:1' % (funct,))
            if mixin and all(map(lambda o: isinstance(o, int), new_params.keys())):
                new_params = {0: ', '.join(new_params.values())}
        if mixin:
            m_params = mixin[0]
            m_vars = mixin[1].copy()
            m_codestr = mixin[2]
            for varname, value in new_params.items():
                try:
                    m_param = m_params[varname]
                except:
                    m_param = varname
                value = self.calculate(
                    value, rule[CONTEXT], rule[OPTIONS], rule)
                m_vars[m_param] = value
            for p in m_vars:
                if p not in new_params:
                    if isinstance(m_vars[p], basestring):
                        value = self.calculate(
                            m_vars[p], m_vars, rule[OPTIONS], rule)
                        m_vars[p] = value
            _context = rule[CONTEXT].copy()
            _context.update(m_vars)
            _rule = spawn_rule(
                rule, codestr=m_codestr, context=_context, lineno=c_lineno)
            self.manage_children(
                _rule, p_selectors, p_parents, p_children, scope, media)
        else:
            log.error("Required mixin not found: %s:%d (%s)",
                      funct, num_args, rule[INDEX][rule[LINENO]])