How to use the lesscpy.lessc.utility.is_variable function in lesscpy

To help you get started, we’ve selected a few lesscpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lesscpy / lesscpy / test / test_utility.py View on Github external
def test_is_variable(self):
        test = utility.is_variable
        self.assertTrue(test('@var'))
        self.assertTrue(test('-@var'))
        self.assertFalse(test('var'))
        self.assertFalse(test(''))
        self.assertFalse(test(False))
        self.assertFalse(test([]))
github lesscpy / lesscpy / lesscpy / plib / identifier.py View on Github external
def replace_variables(tokens, scope):
            return [
                scope.swap(t)
                if (utility.is_variable(t) and not t in reserved.tokens) else t
                for t in tokens
            ]
github lesscpy / lesscpy / lesscpy / lessc / parser.py View on Github external
def p_media_query_value(self, p):
        """ media_query_value           : number
                                        | variable
                                        | word
                                        | color
                                        | expression
        """
        if utility.is_variable(p[1]):
            var = self.scope.variables(''.join(p[1]))
            if var:
                value = var.value[0]
                if hasattr(value, 'parse'):
                    p[1] = value.parse(self.scope)
                else:
                    p[1] = value
        if isinstance(p[1], Expression):
            p[0] = p[1].parse(self.scope)
        else:
            p[0] = p[1]
github lesscpy / lesscpy / lesscpy / plib / mixin.py View on Github external
Variable object or None
        """
        if isinstance(var, Variable):
            # kwarg
            if arg:
                if utility.is_variable(arg[0]):
                    tmp = scope.variables(arg[0])
                    if not tmp:
                        return None
                    val = tmp.value
                else:
                    val = arg
                var = Variable(var.tokens[:-1] + [val])
        else:
            # arg
            if utility.is_variable(var):
                if arg is None:
                    raise SyntaxError('Missing argument to mixin')
                elif utility.is_variable(arg[0]):
                    tmp = scope.variables(arg[0])
                    if not tmp:
                        return None
                    val = tmp.value
                else:
                    val = arg
                var = Variable([var, None, val])
            else:
                return None
        return var
github lesscpy / lesscpy / lesscpy / plib / mixin.py View on Github external
def _parse_arg(self, var, arg, scope):
        """ Parse a single argument to mixin.
        args:
            var (Variable object): variable
            arg (mixed): argument
            scope (Scope object): current scope
        returns:
            Variable object or None
        """
        if isinstance(var, Variable):
            # kwarg
            if arg:
                if utility.is_variable(arg[0]):
                    tmp = scope.variables(arg[0])
                    if not tmp:
                        return None
                    val = tmp.value
                else:
                    val = arg
                var = Variable(var.tokens[:-1] + [val])
        else:
            # arg
            if utility.is_variable(var):
                if arg is None:
                    raise SyntaxError('Missing argument to mixin')
                elif utility.is_variable(arg[0]):
                    tmp = scope.variables(arg[0])
                    if not tmp:
                        return None
github lesscpy / lesscpy / lesscpy / plib / mixin.py View on Github external
# kwarg
            if arg:
                if utility.is_variable(arg[0]):
                    tmp = scope.variables(arg[0])
                    if not tmp:
                        return None
                    val = tmp.value
                else:
                    val = arg
                var = Variable(var.tokens[:-1] + [val])
        else:
            # arg
            if utility.is_variable(var):
                if arg is None:
                    raise SyntaxError('Missing argument to mixin')
                elif utility.is_variable(arg[0]):
                    tmp = scope.variables(arg[0])
                    if not tmp:
                        return None
                    val = tmp.value
                else:
                    val = arg
                var = Variable([var, None, val])
            else:
                return None
        return var
github lesscpy / lesscpy / lesscpy / plib / process.py View on Github external
def replace_vars(self, tokens):
        """
        Replace variables in tokenlist
        """
        return [self.swap(t) 
                if utility.is_variable(t)
                else t
                for t in tokens]