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
564168c3
Commit
564168c3
authored
Mar 23, 2015
by
Maxime Perrotin
Browse files
Compute combinations of arrays
parent
08698895
Changes
2
Hide whitespace changes
Inline
Side-by-side
asn1_value_editor/resources.py
View file @
564168c3
...
...
@@ -2,7 +2,7 @@
# Resource object code
#
# Created:
Su
n Mar 2
2
2
1:50:51
2015
# Created:
Mo
n Mar 2
3
2
2:08:12
2015
# by: The Resource Compiler for PySide (Qt v4.8.6)
#
# WARNING! All changes made in this file will be lost!
...
...
asn1_value_editor/sdlHandler.py
View file @
564168c3
...
...
@@ -84,9 +84,14 @@ def compute_combinations(asn1_ty, pool):
yield
each
def
compute_integer_combinations
(
asn1_ty
):
''' Generator returning all combinations of integer '''
for
each
in
xrange
(
int
(
asn1_ty
.
Min
),
int
(
asn1_ty
.
Max
)):
def
compute_integer_combinations
(
asn1_ty
,
max_iter
=
None
):
''' Generator returning all integer values, with optional limit '''
# Do not use xrange, it needs a value that fits in a C long
max_iter
=
(
long
(
asn1_ty
.
Min
)
+
max_iter
)
if
max_iter
!=
0
else
long
(
asn1_ty
.
Max
)
for
each
in
itertools
.
count
(
long
(
asn1_ty
.
Min
)):
if
each
==
max_iter
:
break
yield
str
(
each
)
...
...
@@ -132,7 +137,12 @@ def compute_sequence_combinations(asn1_ty, pool):
def
compute_sequenceof_combinations
(
asn1_ty
,
pool
):
''' Generator returning all combinations of arrays '''
pass
for
size
in
xrange
(
int
(
asn1_ty
.
Min
),
int
(
asn1_ty
.
Max
)):
elems
=
[]
for
_
in
xrange
(
size
):
elems
.
append
(
compute_combinations
(
asn1_ty
,
pool
))
for
each
in
itertools
.
product
(
*
elems
):
yield
'{{ {} }}'
.
format
(
', '
.
join
(
each
))
class
SendTC
(
QUndoCommand
):
...
...
@@ -484,10 +494,10 @@ class sdlHandler(QObject):
param
or
''
))
self
.
check_properties
(
new_hash
)
# TEMP TO TEST
# for name, typedef in self.proc.dataview.viewitems():
# print 'All combinations of ', name
# for combi in compute_combinations(typedef, self.proc.dataview):
# print combi
#
for name, typedef in self.proc.dataview.viewitems():
#
print 'All combinations of ', name
#
for combi in compute_combinations(typedef, self.proc.dataview):
#
print combi
# END TEMP
return
new_hash
...
...
Write
Preview
Markdown
is supported
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