How to use the lesscpy.lessc.utility.with_unit 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_with_unit(self):
        test = utility.with_unit
        self.assertEqual('1px', test((1, 'px')))
        self.assertEqual('1px', test(1, 'px'))
        self.assertEqual('1.0px', test(1.0, 'px'))
        self.assertEqual('0.0px', test('.0', 'px'))
        self.assertEqual('0.6px', test(.6, 'px'))
        self.assertEqual('1', test(1))
        self.assertEqual('1', test(1, None))
        self.assertEqual('1', test(1, ))
github lesscpy / lesscpy / lesscpy / plib / call.py View on Github external
def increment(self, value, *args):
        """ Increment function
        args:
            value (str): target
        returns:
            str
        """
        n, u = utility.analyze_number(value)
        return utility.with_unit(n + 1, u)
github lesscpy / lesscpy / lesscpy / plib / call.py View on Github external
def round(self, value, *args):
        """ Round number
        args:
            value (str): target
        returns:
            str
        """
        n, u = utility.analyze_number(value)
        return utility.with_unit(
            int(utility.away_from_zero_round(float(n))), u)
github lesscpy / lesscpy / lesscpy / plib / call.py View on Github external
def decrement(self, value, *args):
        """ Decrement function
        args:
            value (str): target
        returns:
            str
        """
        n, u = utility.analyze_number(value)
        return utility.with_unit(n - 1, u)
github lesscpy / lesscpy / lesscpy / plib / call.py View on Github external
def percentage(self, value, *args):
        """ Return percentage value
        args:
            value (str): target
        returns:
            str
        """
        n, u = utility.analyze_number(value)
        n = int(n * 100.0)
        u = '%'
        return utility.with_unit(n, u)
github lesscpy / lesscpy / lesscpy / plib / call.py View on Github external
def ceil(self, value, *args):
        """ Ceil number
        args:
            value (str): target
        returns:
            str
        """
        n, u = utility.analyze_number(value)
        return utility.with_unit(int(math.ceil(n)), u)
github lesscpy / lesscpy / lesscpy / plib / call.py View on Github external
def floor(self, value, *args):
        """ Floor number
        args:
            value (str): target
        returns:
            str
        """
        n, u = utility.analyze_number(value)
        return utility.with_unit(int(math.floor(n)), u)