How to use the lesscpy.lessc.utility 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_color(self):
        test = utility.is_color
        self.assertTrue(test('#123'))
        self.assertTrue(test('#123456'))
        self.assertTrue(test('#Df3'))
        self.assertTrue(test('#AbCdEf'))
        self.assertFalse(test('#AbCdEg'))
        self.assertFalse(test('#h12345'))
        self.assertFalse(test('#12345'))
        self.assertFalse(test('AbCdEf'))
        self.assertFalse(test(''))
        self.assertFalse(test('.925'))
        self.assertFalse(test(False))
        self.assertFalse(test([]))
github lesscpy / lesscpy / lesscpy / plib / identifier.py View on Github external
list
        """
        parent = scope.scopename
        if parent:
            parent = parent[-1]
            if parent.parsed:
                parsed_names = []
                for name in names:
                    ampersand_count = name.count('&')
                    if ampersand_count:
                        filtered_parts = []
                        for part in parent.parsed:
                            if part and part[0] not in self._subp:
                                filtered_parts.append(part)
                        permutations = list(
                            utility.permutations_with_replacement(
                                filtered_parts, ampersand_count))
                        for permutation in permutations:
                            parsed = []
                            for name_part in name:
                                if name_part == "&":
                                    parent_part = permutation.pop(0)
                                    if parsed and parsed[-1].endswith(']'):
                                        parsed.extend(' ')
                                    if parent_part[-1] == ' ':
                                        parent_part.pop()
                                    parsed.extend(parent_part)
                                else:
                                    parsed.append(name_part)
                            parsed_names.append(parsed)
                    else:
                        # NOTE(saschpe): Maybe this code can be expressed with permutations too?
github lesscpy / lesscpy / lesscpy / lessc / scope.py View on Github external
def _blocks(self, name):
        """Inner wrapper to search for blocks by name.
        """
        i = len(self)
        while i >= 0:
            i -= 1
            if name in self[i]['__names__']:
                for b in self[i]['__blocks__']:
                    r = b.raw()
                    if r and r == name:
                        return b
            else:
                for b in self[i]['__blocks__']:
                    r = b.raw()
                    if r and name.startswith(r):
                        b = utility.blocksearch(b, name)
                        if b:
                            return b
        return False