summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEevee (Alex Munroe) <eevee.git@veekun.com>2013-08-15 16:08:49 -0700
committerEevee (Alex Munroe) <eevee.git@veekun.com>2013-08-15 16:08:49 -0700
commit072cf09ff15910ef95b5867f935d5379f840358e (patch)
tree1085b0a030645620b78762e8962486b85c9030af
parentc110c14affb066fb861ac688f287d0f3067dd11d (diff)
downloadpyscss-072cf09ff15910ef95b5867f935d5379f840358e.tar.gz
Experimental support for treating all Sass types as 1-lists.
-rw-r--r--scss/functions/core.py3
-rw-r--r--scss/types.py23
2 files changed, 17 insertions, 9 deletions
diff --git a/scss/functions/core.py b/scss/functions/core.py
index 96c87a5..5bbc8c9 100644
--- a/scss/functions/core.py
+++ b/scss/functions/core.py
@@ -541,8 +541,7 @@ def index(lst, val):
@register('map-get', 2)
def map_get(map, key):
- print(repr(map.index.keys()))
- return map.index[key]
+ return map.get_by_key(key)
@register('map-merge', 2)
diff --git a/scss/types.py b/scss/types.py
index 504b3e1..71cceae 100644
--- a/scss/types.py
+++ b/scss/types.py
@@ -35,6 +35,21 @@ class Value(object):
### NOTE: From here on down, the operators are exposed to Sass code and
### thus should ONLY return Sass types
+ # All Sass scalars also act like one-element spaced lists
+ use_comma = False
+
+ def __iter__(self):
+ return iter((self,))
+
+ def __len__(self):
+ return 1
+
+ def __getitem__(self, key):
+ if key != 0:
+ raise IndexError(key)
+
+ return self
+
# Reasonable default for equality
def __eq__(self, other):
return BooleanValue(
@@ -425,13 +440,7 @@ class List(Value):
"""If `values` appears to not be a list, return a list containing it.
Otherwise, return a List as normal.
"""
- if isinstance(values, (List, Map)):
- return values
-
- if not isinstance(values, (list, tuple)):
- values = [values]
-
- return cls(values, use_comma=use_comma)
+ return values
@classmethod
def from_maybe_starargs(cls, args, use_comma=True):