diff options
author | Eevee (Alex Munroe) <eevee.git@veekun.com> | 2013-07-31 19:07:31 -0700 |
---|---|---|
committer | Eevee (Alex Munroe) <eevee.git@veekun.com> | 2013-07-31 19:07:31 -0700 |
commit | 01f751b241261c8e4247a9a9d3af554f6c5ea7ad (patch) | |
tree | 3ec781dc7fa6a56f4204e886825f9c178a183dc4 | |
parent | 3f75ec2517e9b1a2a900406d8b0bce06b7ab29ac (diff) | |
download | pyscss-01f751b241261c8e4247a9a9d3af554f6c5ea7ad.tar.gz |
Remove old unit stuff.
-rw-r--r-- | scss/__init__.py | 1 | ||||
-rw-r--r-- | scss/cssdefs.py | 46 | ||||
-rw-r--r-- | scss/expression.py | 2 | ||||
-rw-r--r-- | scss/functions/core.py | 11 | ||||
-rw-r--r-- | scss/tests/functions/test_core.py | 1 |
5 files changed, 7 insertions, 54 deletions
diff --git a/scss/__init__.py b/scss/__init__.py index 6acdadb..4a70fcf 100644 --- a/scss/__init__.py +++ b/scss/__init__.py @@ -58,7 +58,6 @@ from scss import config from scss.cssdefs import ( SEPARATOR, _ml_comment_re, _sl_comment_re, - _zero_units_re, _zero_re, _escape_chars_re, _spaces_re, _expand_rules_space_re, _collapse_properties_space_re, _strings_re, _prop_split_re, diff --git a/scss/cssdefs.py b/scss/cssdefs.py index 3c763b6..19af7bf 100644 --- a/scss/cssdefs.py +++ b/scss/cssdefs.py @@ -213,50 +213,6 @@ ZEROABLE_UNITS = frozenset(( 'cm', 'mm', 'in', 'px', 'pt', 'pc', )) -_units_weights = { - 'em': 10, - 'mm': 10, - 'ms': 10, - 'hz': 10, - '%': 100, -} -_conv = { - 'size': { - 'em': 13.0, - 'px': 1.0 - }, - 'length': { - 'mm': 1.0, - 'cm': 10.0, - 'in': 25.4, - 'pt': 25.4 / 72, - 'pc': 25.4 / 6 - }, - 'time': { - 'ms': 1.0, - 's': 1000.0 - }, - 'freq': { - 'hz': 1.0, - 'khz': 1000.0 - }, - 'any': { - '%': 1.0 / 100 - } -} - -# units and conversions -_units = ['em', 'ex', 'px', 'cm', 'mm', 'in', 'pt', 'pc', 'deg', 'rad' - 'grad', 'ms', 's', 'hz', 'khz', '%'] -_zero_units = ['em', 'ex', 'px', 'cm', 'mm', 'in', 'pt', 'pc'] # units that can be zeroed -_conv_type = {} -_conv_factor = {} -for t, m in _conv.items(): - for k, f in m.items(): - _conv_type[k] = t - _conv_factor[k] = f -del t, m, k, f - # ------------------------------------------------------------------------------ # Built-in CSS function reference @@ -331,8 +287,6 @@ _expr_glob_re = re.compile(r''' # XXX these still need to be fixed; the //-in-functions thing is a chumpy hack _ml_comment_re = re.compile(r'\/\*(.*?)\*\/', re.DOTALL) _sl_comment_re = re.compile(r'(?<!\burl[(])(?<!\w{2}:)\/\/.*') -_zero_units_re = re.compile(r'\b0(' + '|'.join(map(re.escape, _zero_units)) + r')(?!\w)', re.IGNORECASE) -_zero_re = re.compile(r'\b0\.(?=\d)') _escape_chars_re = re.compile(r'([^-a-zA-Z0-9_])') _interpolate_re = re.compile(r'(#\{\s*)?(\$[-\w]+)(?(1)\s*\})') diff --git a/scss/expression.py b/scss/expression.py index 0669c04..5af719b 100644 --- a/scss/expression.py +++ b/scss/expression.py @@ -6,7 +6,7 @@ import operator import re import scss.config as config -from scss.cssdefs import COLOR_NAMES, is_builtin_css_function, _expr_glob_re, _interpolate_re, _units, _variable_re +from scss.cssdefs import COLOR_NAMES, is_builtin_css_function, _expr_glob_re, _interpolate_re, _variable_re from scss.types import BooleanValue, ColorValue, ListValue, Null, NumberValue, ParserValue, String from scss.util import dequote, normalize_var, to_str diff --git a/scss/functions/core.py b/scss/functions/core.py index 63844f3..6569726 100644 --- a/scss/functions/core.py +++ b/scss/functions/core.py @@ -9,7 +9,7 @@ import logging import math import operator -from scss.cssdefs import _conv_type, _units_weights, _variable_re +from scss.cssdefs import _variable_re from scss.functions.library import FunctionLibrary from scss.types import BooleanValue, ColorValue, ListValue, NumberValue, QuotedStringValue, StringValue, String @@ -547,10 +547,11 @@ def unitless(value): @register('comparable', 2) def comparable(number1, number2): - n1, n2 = NumberValue(number1), NumberValue(number2) - type1 = _conv_type.get(n1.unit) - type2 = _conv_type.get(n2.unit) - return BooleanValue(type1 == type2) + left = number1.to_base_units() + right = number2.to_base_units() + return BooleanValue( + left.unit_numer == right.unit_numer + and left.unit_denom == right.unit_denom) # ------------------------------------------------------------------------------ diff --git a/scss/tests/functions/test_core.py b/scss/tests/functions/test_core.py index 53184a3..53b03b0 100644 --- a/scss/tests/functions/test_core.py +++ b/scss/tests/functions/test_core.py @@ -315,7 +315,6 @@ def test_unitless(calc): assert calc('unitless(100)') == calc('true') assert calc('unitless(100px)') == calc('false') -@xfail(reason="pyscss erroneously converts between px and em") def test_comparable(calc): # Examples from the Ruby docs assert calc('comparable(2px, 1px)') == calc('true') |