diff options
author | German M. Bravo <german.mb@deipi.com> | 2013-10-07 09:10:59 -0500 |
---|---|---|
committer | German M. Bravo <german.mb@deipi.com> | 2013-10-07 09:10:59 -0500 |
commit | ec419cf96650d3b1fabd39acd057747a0ae77760 (patch) | |
tree | f85e0452f2de17624d0b613f8367143256172140 | |
parent | 7b953669c48598cbf1f45eb558f46746318ac418 (diff) | |
download | pyscss-ec419cf96650d3b1fabd39acd057747a0ae77760.tar.gz |
Avoid having '0' being output as '-0' (-0.0 causes this)
-rw-r--r-- | scss/types.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/scss/types.py b/scss/types.py index 2f283ad..6cc58f7 100644 --- a/scss/types.py +++ b/scss/types.py @@ -261,12 +261,12 @@ class Number(Value): def __float__(self): return float(self.value) - def __neg__(self): - return self * Number(-1) - def __pos__(self): return self + def __neg__(self): + return self * Number(-1) + def __str__(self): return self.render() @@ -479,10 +479,14 @@ class Number(Value): else: unit = '' - if compress and unit in ZEROABLE_UNITS and self.value == 0: + value = self.value + if compress and unit in ZEROABLE_UNITS and value == 0: return '0' - val = "%0.05f" % round(self.value, 5) + if value == 0: # -0.0 is plain 0 + value = 0 + + val = "%0.05f" % round(value, 5) val = val.rstrip('0').rstrip('.') if compress and val.startswith('0.'): |