summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGerman M. Bravo <german.mb@deipi.com>2013-08-13 16:51:06 -0500
committerGerman M. Bravo <german.mb@deipi.com>2013-08-13 16:51:31 -0500
commit81556aab7ee4897f465907453cd197b82f2a8db1 (patch)
tree97c789b800ecd876449c0ec86034f1ec702bb5ea
parentf21b085aff8c76398bda5eebbe83f1ee6ce4086f (diff)
downloadpyscss-81556aab7ee4897f465907453cd197b82f2a8db1.tar.gz
Make _position() acept lists of python strings and fix __color_stops() to send a list to _positions
-rw-r--r--scss/functions/compass/gradients.py9
-rw-r--r--scss/functions/compass/helpers.py9
2 files changed, 10 insertions, 8 deletions
diff --git a/scss/functions/compass/gradients.py b/scss/functions/compass/gradients.py
index 73dd46b..5119b39 100644
--- a/scss/functions/compass/gradients.py
+++ b/scss/functions/compass/gradients.py
@@ -19,6 +19,7 @@ log = logging.getLogger(__name__)
COMPASS_GRADIENTS_LIBRARY = FunctionLibrary()
register = COMPASS_GRADIENTS_LIBRARY.register
+
# ------------------------------------------------------------------------------
def __color_stops(percentages, *args):
@@ -27,7 +28,7 @@ def __color_stops(percentages, *args):
list(args[0])
elif isinstance(args[0], (StringValue, six.string_types)):
color_stops = []
- colors = split_params(args[0].value)
+ colors = split_params(getattr(args[0], 'value', args[0]))
for color in colors:
color = color.strip()
if color.startswith('color-stop('):
@@ -313,8 +314,8 @@ def linear_gradient(*args):
def to__owg():
args = [
'linear',
- position(position_and_angle or 'center top'),
- opposite_position(position_and_angle or 'center top'),
+ position(position_and_angle or ['center', 'top']),
+ opposite_position(position_and_angle or ['center', 'top']),
]
args.extend('color-stop(%s, %s)' % (to_str(s), c) for s, c in color_stops)
ret = '-webkit-gradient(' + ', '.join(to_str(a) for a in args or [] if a is not None) + ')'
@@ -395,5 +396,3 @@ def __radial_svg(color_stops, cx, cy, r):
__color_stops_svg(color_stops)
)
return __svg_template(gradient)
-
-
diff --git a/scss/functions/compass/helpers.py b/scss/functions/compass/helpers.py
index 9de1d13..bde12ef 100644
--- a/scss/functions/compass/helpers.py
+++ b/scss/functions/compass/helpers.py
@@ -14,6 +14,8 @@ import mimetypes
import os.path
import time
+import six
+
from scss import config
from scss.functions.library import FunctionLibrary
from scss.types import BooleanValue, List, Null, NumberValue, QuotedStringValue, StringValue
@@ -376,10 +378,11 @@ def _position(opposite, positions):
ret = []
for pos in positions:
- if isinstance(pos, StringValue):
- if pos.value in OPPOSITE_POSITIONS:
+ if isinstance(pos, (StringValue, six.string_types)):
+ _pos = getattr(pos, 'value', pos)
+ if _pos in OPPOSITE_POSITIONS:
if opposite:
- opp = OPPOSITE_POSITIONS[pos.value]
+ opp = OPPOSITE_POSITIONS[pos]
ret.append(StringValue(opp, quotes=None))
else:
ret.append(pos)