Ejemplo n.º 1
0
 def _from_python(self, value, state):
     """ returns a string using the correct grouping """
     dec_places = util.find_precision(value)
     if dec_places > 0:
         return format.format_decimal(value, dec_places)
     else:
         return format.format_number(value)
Ejemplo n.º 2
0
 def _from_python(self, value, state):
     """Return a string using the correct grouping."""
     dec_places = util.find_precision(value)
     if dec_places > 0:
         return format.format_decimal(value, dec_places)
     else:
         return format.format_number(value)
Ejemplo n.º 3
0
    def _from_python(self, value, state):
        """Return a string using the correct grouping.

        If the validator was instantiated with a decimals parameter,
        this is used for the number  of decimals. If None ist given,
        the number of decimals is determined by the value itself.

        """
        if self.decimals is None:
            decimals = util.find_precision(value)
        else:
            decimals = self.decimals
        if decimals > 0:
            return format.format_decimal(value, decimals)
        else:
            return format.format_number(value)