Commit 5a2fd158 authored by Thomas Lachmann's avatar Thomas Lachmann Committed by Martin Owens

Fix for issue 193

parent 636e9b88
......@@ -172,8 +172,10 @@ def to(kind): # pylint: disable=invalid-name
def strargs(string, kind=float):
"""Returns a list of floats from a string with commas or space separators"""
return [kind(val) for val in string.replace(',', ' ').split()]
"""Returns a list of floats from a string with commas or space separators,
also splits at -(minus) signs by adding a space in front of the - sign
"""
return [kind(val) for val in string.replace(',', ' ').replace('-', ' -').replace('e ', 'e').split()]
def addNS(tag, ns=None): # pylint: disable=invalid-name
......
......@@ -11,7 +11,7 @@ from argparse import ArgumentTypeError
import pytest
from inkex.utils import addNS, debug, errormsg, filename_arg, Boolean, to
from inkex.utils import addNS, debug, errormsg, filename_arg, Boolean, to, strargs
class TestInkexBasic(object):
......@@ -71,6 +71,15 @@ class TestInkexBasic(object):
assert addNS('car', 'http://www.inkscape.org/namespaces/inkscape') == '{http://www.inkscape.org/namespaces/inkscape}car'
assert addNS('{http://www.inkscape.org/namespaces/inkscape}bar', 'rdf') == '{http://www.w3.org/1999/02/22-rdf-syntax-ns#}bar'
def test_strargs(self):
"""Test strargs function"""
assert strargs('1.0 2.0 3.0 4.0') == [1.0, 2.0, 3.0, 4.0]
assert strargs('1 -2 3 -4') == [1.0, -2.0, 3.0, -4.0]
assert strargs('1,-2,3,-4') == [1.0, -2.0, 3.0, -4.0]
assert strargs('1-2 3-4') == [1.0, -2.0, 3.0, -4.0]
assert strargs('1-2,3-4') == [1.0, -2.0, 3.0, -4.0]
assert strargs('1-2-3-4') == [1.0, -2.0, -3.0, -4.0]
def test_ascii(self, capsys):
"""Parse ABCabc"""
errormsg('ABCabc')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment