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
OpenGEODE
Commits
db3177e3
Commit
db3177e3
authored
Dec 25, 2015
by
Maxime Perrotin
Browse files
Add helper functions
parent
214b2ee7
Changes
2
Hide whitespace changes
Inline
Side-by-side
asn1-value-editor
@
b1f0cd80
Compare
59a97144
...
b1f0cd80
Subproject commit
59a971440f0b96144d4910abefcfd6f698186c92
Subproject commit
b1f0cd80a6e68b98cc31c74958d30ddb2c27dd70
opengeode/Helper.py
View file @
db3177e3
...
@@ -16,6 +16,8 @@
...
@@ -16,6 +16,8 @@
state_aggregations: enrich AST with state aggregation flags,
state_aggregations: enrich AST with state aggregation flags,
and return the list of substates of aggregations
and return the list of substates of aggregations
parallel_states: return a list of strings naming all parallel states
parallel_states: return a list of strings naming all parallel states
statenames: return a list of properly-formatted state names
rec_findstates: recursively find parallel/composite statenames
Copyright (c) 2012-2015 European Space Agency
Copyright (c) 2012-2015 European Space Agency
...
@@ -37,7 +39,27 @@ LOG = logging.getLogger(__name__)
...
@@ -37,7 +39,27 @@ LOG = logging.getLogger(__name__)
__all__
=
[
'flatten'
,
'rename_everything'
,
'inner_labels_to_floating'
,
__all__
=
[
'flatten'
,
'rename_everything'
,
'inner_labels_to_floating'
,
'map_input_state'
,
'sorted_fields'
,
'state_aggregations'
,
'map_input_state'
,
'sorted_fields'
,
'state_aggregations'
,
'parallel_states'
]
'parallel_states'
,
'statenames'
,
'rec_findstates'
]
def
statenames
(
context
,
sep
=
u
'
\u00dc
'
):
''' Return the list of states (just the names) of a given context
Format the output by replacing unicode separator symbol with a dot '''
return
(
s
.
replace
(
sep
,
u
'.'
)
for
s
in
context
.
mapping
.
viewkeys
()
if
not
s
.
endswith
(
u
'START'
))
def
rec_findstates
(
context
,
prefix
=
''
):
''' In case of state compositions/aggregations, find substates '''
for
each
in
context
.
composite_states
:
if
not
isinstance
(
each
,
ogAST
.
StateAggregation
):
# Aggregations are just containers, not states
for
name
in
statenames
(
each
):
yield
u
'{}{}.{}'
.
format
(
prefix
,
each
.
statename
,
name
)
for
substate
in
rec_findstates
(
each
,
prefix
=
u
'{}{}.'
.
format
(
prefix
,
each
.
statename
)):
yield
substate
def
state_aggregations
(
process
):
def
state_aggregations
(
process
):
...
...
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