Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
What's new
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
Menu
Open sidebar
Inkscape
extensions
Commits
5a2fd158
Commit
5a2fd158
authored
Jun 09, 2020
by
Thomas Lachmann
Committed by
Martin Owens
Jun 09, 2020
Browse files
Fix for issue 193
parent
636e9b88
Changes
2
Hide whitespace changes
Inline
Side-by-side
inkex/utils.py
View file @
5a2fd158
...
...
@@ -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
...
...
tests/test_inkex_utils.py
View file @
5a2fd158
...
...
@@ -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'
)
...
...
odaki
@odaki
mentioned in merge request
!273 (merged)
·
Jan 16, 2021
mentioned in merge request
!273 (merged)
mentioned in merge request !273
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment