Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
asn1-value-editor
Commits
63ea9a53
Commit
63ea9a53
authored
Jul 16, 2016
by
Maxime Perrotin
Browse files
Add function to format gser strings
parent
2cc2dc0c
Changes
2
Hide whitespace changes
Inline
Side-by-side
asn1_value_editor/vn.py
View file @
63ea9a53
...
...
@@ -17,7 +17,10 @@
3) valueNotationToCTypes(gser, dest, sort, ASN1Mod, ASN1_AST, var=None)
Parse a Value Notation string and fill a ctypes instance with the values
Copyright (c) 2012-2015 European Space Agency
4) format(gser)
properly format a GSER string. useful for comparing them
Copyright (c) 2012-2016 European Space Agency
Designed and implemented by Maxime Perrotin
...
...
@@ -165,6 +168,12 @@ def fromValueNotationToPySide(varName, string):
raise
def
format_gser
(
gser
):
''' Reformat a GSER string '''
gser1
=
''
.
join
(
x
.
strip
()
for
x
in
gser
.
split
())
return
', '
.
join
(
gser1
.
split
(
','
)).
replace
(
':'
,
': '
)
def
toASN1ValueNotation
(
val
):
''' Create a GSER reprentation of the Python variable '''
result
=
''
...
...
test/pytest/test_standalone.py
View file @
63ea9a53
...
...
@@ -4,6 +4,7 @@ import sys
sys
.
path
.
insert
(
0
,
'../..'
)
from
asn1_value_editor
import
standalone_editor
as
editor
from
asn1_value_editor.vn
import
format_gser
editor
.
logger
.
setLevel
(
editor
.
logging
.
DEBUG
)
'''
...
...
@@ -69,23 +70,23 @@ def test_string(qtbot):
def
test_simpleseq
(
qtbot
):
''' Test SEQUENCE '''
typeName
=
"Type-SimpleSeq"
defValue
=
'{
item-a
42
,
item-b
TRUE
,
item-c
enum-two
,
item-d
"Hello world"
}'
defValue
=
'{item-a 42, item-b TRUE, item-c enum-two, item-d "Hello world"}'
result
=
common
(
typeName
,
defValue
)
assert
result
==
defValue
assert
format_gser
(
result
)
==
format_gser
(
defValue
)
def
test_simplechoice
(
qtbot
):
''' Test CHOICE '''
typeName
=
"Type-SingleChoice"
defValue
=
'choice-b:
TRUE'
defValue
=
'choice-b: TRUE'
result
=
common
(
typeName
,
defValue
)
assert
result
==
defValue
assert
format_gser
(
result
)
==
format_gser
(
defValue
)
def
test_simpleseqof
(
qtbot
):
''' Test SEQOF '''
typeName
=
"Type-SingleSeqOf"
defValue
=
'{
1 , 2 , 3 ,
4
,
5
}'
defValue
=
'{
1, 2, 3,
4,
5
}'
result
=
common
(
typeName
,
defValue
)
assert
result
==
defValue
assert
format_gser
(
result
)
==
format_gser
(
defValue
)
if
__name__
==
'__main__'
:
print
(
'You must run py.test-2.7 to execute this test script'
)
...
...
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