| | |
| | | if formatting is None: |
| | | formatting = self.formatting |
| | | formatter = FormatterFactory.get_formatter(formatting) |
| | | if formatting == "str": |
| | | if formatting == "str" or formatting == "string": |
| | | return formatter.toFormat(self.value) |
| | | elif glyph is None and unit is None: |
| | | return ("${}$").format(formatter.toFormat(self.value)) |
| | |
| | | type = spl[0] |
| | | arglist = spl[1:] |
| | | |
| | | if type == "sci": |
| | | if type == "sci" or type == "scientific": |
| | | return SciFloatFormatter(arglist) |
| | | elif type == "str": |
| | | elif type == "str" or type == "string": |
| | | return StringFormatter() |
| | | elif type == "eng": |
| | | elif type == "eng" or type == "engineering": |
| | | return EngFloatFormatter(arglist) |
| | | elif type == "dec": |
| | | return DecFloatFormatter(arglist) |
| | | elif type == "prefix": |
| | | return PrefixFloatFormatter(arglist) |
| | | elif type == "dec" or type == "decimal": |
| | | return EngFloatFormatter(arglist) #fallback to engineering |
| | | else: |
| | | return None |
| | | |
| | |
| | | return float(man) |
| | | |
| | | |
| | | class DecFloatFormatter(EngFloatFormatter): |
| | | class PrefixFloatFormatter(EngFloatFormatter): |
| | | def __init__(self, formatparameters): |
| | | if len(formatparameters) != 1: |
| | | raise Exceptions.WrongParameters("Dec format accept only one argument") |