diff options
author | Eevee (Alex Munroe) <eevee.git@veekun.com> | 2014-08-31 19:02:48 -0700 |
---|---|---|
committer | Eevee (Alex Munroe) <eevee.git@veekun.com> | 2014-08-31 19:02:48 -0700 |
commit | 66caf45e0b152c14bcec5a24e5a31ca75fe4ea73 (patch) | |
tree | 41b408e3b7a8954aa8635d85a20c29768704b389 | |
parent | 998b20062992292fb8be0c235aacf5f5c303e8a9 (diff) | |
download | pyscss-66caf45e0b152c14bcec5a24e5a31ca75fe4ea73.tar.gz |
Preserve the order of slurpy kwargs. Fix a heisentest.
-rw-r--r-- | scss/ast.py | 8 | ||||
-rw-r--r-- | scss/compiler.py | 10 | ||||
-rw-r--r-- | scss/scss_meta.py | 6 | ||||
-rw-r--r-- | scss/tests/test_misc.py | 7 | ||||
-rw-r--r-- | setup.py | 11 |
5 files changed, 30 insertions, 12 deletions
diff --git a/scss/ast.py b/scss/ast.py index fb64f85..51cb91c 100644 --- a/scss/ast.py +++ b/scss/ast.py @@ -11,6 +11,12 @@ from functools import partial import logging import operator +try: + from collections import OrderedDict +except ImportError: + # Backport + from ordereddict import OrderedDict + import six from scss.cssdefs import COLOR_NAMES @@ -441,7 +447,7 @@ class ArgspecLiteral(Expression): ``(args, kwargs)``. """ args = [] - kwargs = {} + kwargs = OrderedDict() # Sass kwargs preserve order for var_node, value_node in self.argpairs: value = value_node.evaluate(calculator, divide=True) if var_node is None: diff --git a/scss/compiler.py b/scss/compiler.py index c941e2c..6304a3c 100644 --- a/scss/compiler.py +++ b/scss/compiler.py @@ -13,6 +13,12 @@ import re import sys import warnings +try: + from collections import OrderedDict +except ImportError: + # Backport + from ordereddict import OrderedDict + import six import scss.config as config @@ -574,7 +580,7 @@ class Compilation(object): def _populate_namespace_from_call(self, name, callee_namespace, mixin, args, kwargs): # Mutation protection args = list(args) - kwargs = dict(kwargs) + kwargs = OrderedDict(kwargs) #m_params = mixin[0] #m_defaults = mixin[1] @@ -665,7 +671,7 @@ class Compilation(object): # TODO CallOp converts Sass names to Python names, so we # have to convert them back to Sass names. would be nice # to avoid this back-and-forth somehow - kwargs = dict( + kwargs = OrderedDict( (normalize_var('$' + key), value) for (key, value) in kwargs.items()) diff --git a/scss/scss_meta.py b/scss/scss_meta.py index 7b2ea96..cfc5839 100644 --- a/scss/scss_meta.py +++ b/scss/scss_meta.py @@ -57,12 +57,6 @@ URL = 'http://github.com/Kronuz/pyScss' DOWNLOAD_URL = 'http://github.com/Kronuz/pyScss/tarball/v' + VERSION LICENSE = "MIT" PROJECT = "pyScss" -INSTALL_REQUIRES = [ - 'six', -] - -if sys.version_info < (3, 4): - INSTALL_REQUIRES.append('enum34') if __name__ == "__main__": print('VERSION = ' + VERSION) diff --git a/scss/tests/test_misc.py b/scss/tests/test_misc.py index 82cc76b..da606f4 100644 --- a/scss/tests/test_misc.py +++ b/scss/tests/test_misc.py @@ -3,6 +3,11 @@ own files, maybe. """ +try: + from collections import OrderedDict +except ImportError: + from ordereddict import OrderedDict + import pytest from scss import Scss @@ -71,7 +76,7 @@ def test_live_errors(): def test_extend_across_files(): compiler = Scss(scss_opts=dict(compress=0)) - compiler._scss_files = {} + compiler._scss_files = OrderedDict() compiler._scss_files['first.css'] = ''' @option style:legacy, short_colors:yes, reverse_colors:yes; .specialClass extends .basicClass { @@ -9,9 +9,16 @@ import sys from setuptools import setup, Extension, Feature # this imports PROJECT, URL, VERSION, AUTHOR, AUTHOR_EMAIL, LICENSE, -# DOWNLOAD_URL, INSTALL_REQUIRES +# DOWNLOAD_URL exec(open('scss/scss_meta.py').read()) +# Dependencies +install_requires = ['six'] +if sys.version_info < (3, 4): + install_requires.append('enum34') +if sys.version_info < (2, 7): + install_requires.append('ordereddict') + # fail safe compilation shamelessly stolen from the simplejson # setup.py file. Original author: Bob Ippolito @@ -98,7 +105,7 @@ def run_setup(with_binary): "Topic :: Text Processing :: Markup", "Topic :: Software Development :: Libraries :: Python Modules" ], - install_requires=INSTALL_REQUIRES, + install_requires=install_requires, packages=[ 'scss', 'scss.extension', |