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
07c44894
Commit
07c44894
authored
Jul 16, 2016
by
Maxime Perrotin
Browse files
Support simple sequences
parent
05e05533
Changes
4
Hide whitespace changes
Inline
Side-by-side
asn1_value_editor/asn1_value_editor.py
View file @
07c44894
...
...
@@ -366,10 +366,17 @@ class asn1Editor(QTreeView):
boolValue
=
value
==
'True'
ptr
.
Set
(
boolValue
)
elif
asnType
==
'ENUMERATED'
:
valNb
=
getattr
(
self
.
backend
.
DV
,
value
.
replace
(
'-'
,
'_'
))
intMappings
=
root
.
child
(
i
,
3
).
data
(
INTMAP
)
for
enumerant
,
num
in
intMappings
.
viewitems
():
if
enumerant
==
value
:
ptr
.
Set
(
num
)
break
else
:
raise
TypeError
(
'ENUMERATED value not found'
)
#valNb = getattr(self.backend.DV, value.replace('-', '_'))
# XXX not correct, get the value from the data field
# (there could be prefixes)
ptr
.
Set
(
valNb
)
#
ptr.Set(valNb)
else
:
# Strings
ptr
.
SetFromPyString
(
value
)
for
i
in
xrange
(
nbRows
):
# for each child row
...
...
asn1_value_editor/vn.py
View file @
07c44894
...
...
@@ -240,7 +240,7 @@ def valueNotationToCTypes(gser, dest, sort, ASN1Mod, ASN1_AST, var=None):
def
rec
(
inp
,
outp
,
sort
):
''' Recursively fill up the value '''
if
sort
.
kind
==
'ReferenceType'
:
sort
=
ASN1_AST
[
sort
.
ReferencedTypeName
]
sort
=
ASN1_AST
[
sort
.
ReferencedTypeName
]
.
type
if
isinstance
(
inp
,
list
):
# SEQUENCE OF
# get the path to the sequence of
...
...
test/pytest/data/dv1.asn
View file @
07c44894
...
...
@@ -17,6 +17,14 @@ Type-SingleChoice ::= CHOICE {
choice-a Type-SingleInt,
choice-b Type-SingleBool
}
Type-SimpleSeq ::= SEQUENCE {
item-a Type-SingleInt,
item-b Type-SingleBool,
item-c Type-SingleEnum,
item-d Type-SingleString
}
Type-Seq ::= SEQUENCE {
item-a Type-SingleReal,
item-b Type-SingleChoice,
...
...
test/pytest/test_standalone.py
View file @
07c44894
...
...
@@ -62,6 +62,13 @@ def test_string(qtbot):
result
=
common
(
typeName
,
defValue
)
assert
result
==
defValue
def
test_seq
(
qtbot
):
''' Test SEQUENCE '''
typeName
=
"Type-SimpleSeq"
defValue
=
'{ item-a 42 , item-b TRUE , item-c enum-two , item-d "Hello world" }'
result
=
common
(
typeName
,
defValue
)
assert
result
==
defValue
if
__name__
==
'__main__'
:
print
(
'You must run py.test-2.7 to execute this test script'
)
print
(
'Make sure you have pytest-qt (pip install --user pytest-qt)'
)
...
...
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