Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
VIGNET Pierre
cadbiom
Commits
9448bd9d
Commit
9448bd9d
authored
Jan 21, 2020
by
VIGNET Pierre
Browse files
[lib] Homogeneization of encoding for names of nodes in the model
Note: check only for xml models
parent
6bf6e873
Changes
2
Hide whitespace changes
Inline
Side-by-side
library/cadbiom/models/guard_transitions/chart_model.py
View file @
9448bd9d
...
...
@@ -821,7 +821,7 @@ class CSimpleNode(CNode):
def
__init__
(
self
,
xcoord
,
ycoord
,
name
,
model
,
**
kwargs
):
CNode
.
__init__
(
self
,
xcoord
,
ycoord
,
model
,
**
kwargs
)
self
.
name
=
name
.
encode
(
"ascii"
)
self
.
name
=
name
self
.
father
=
None
# double linkage for coordinate computations
self
.
hloc
=
1.0
self
.
activated
=
False
...
...
library/cadbiom/models/guard_transitions/translators/chart_xml.py
View file @
9448bd9d
...
...
@@ -310,6 +310,8 @@ class MakeHandler(ContentHandler):
# Memorize the current node/transition because of inner text (note)
# processing
self
.
current_element
=
None
# Encoding of node names
self
.
encoding
=
"ascii"
def
init_node_functions
(
self
):
"""Bind functions to add different types of nodes to the cadbiom model
...
...
@@ -344,7 +346,7 @@ class MakeHandler(ContentHandler):
if
name
in
self
.
nodes_types
:
# TODO: Uniformization of API in CMacroNode() class;
# the attribute 'name' should be at the same last position...
element_name
=
att
.
get
(
"name"
,
""
).
encode
(
"ascii"
)
element_name
=
att
.
get
(
"name"
,
""
).
encode
(
self
.
encoding
)
self
.
current_element
=
self
.
add_node_functions
[
name
](
name
=
element_name
,
xcoord
=
float
(
att
.
get
(
"xloc"
,
"0"
)),
...
...
@@ -353,11 +355,10 @@ class MakeHandler(ContentHandler):
self
.
node_dict
[
element_name
]
=
self
.
current_element
elif
name
==
"transition"
:
# name = att.get('name', '').encode('ascii')
ori
=
att
.
get
(
"ori"
,
""
)
ext
=
att
.
get
(
"ext"
,
""
)
ori
=
att
.
get
(
"ori"
,
""
).
encode
(
self
.
encoding
)
ext
=
att
.
get
(
"ext"
,
""
).
encode
(
self
.
encoding
)
event
=
att
.
get
(
"event"
,
""
)
condition
=
att
.
get
(
"condition"
,
""
)
condition
=
att
.
get
(
"condition"
,
""
)
.
encode
(
self
.
encoding
)
action
=
att
.
get
(
"action"
,
""
)
fact_ids_text
=
att
.
get
(
"fact_ids"
,
""
)[
1
:
-
1
]
if
len
(
fact_ids_text
)
>
0
:
...
...
@@ -389,7 +390,7 @@ class MakeHandler(ContentHandler):
self
.
current_element
.
fact_ids
=
fact_ids
elif
name
==
"CMacroNode"
:
name
=
att
.
get
(
"name"
,
""
).
encode
(
"ascii"
)
name
=
att
.
get
(
"name"
,
""
).
encode
(
self
.
encoding
)
xloc
=
float
(
att
.
get
(
"xloc"
,
"0"
))
yloc
=
float
(
att
.
get
(
"yloc"
,
"0"
))
wloc
=
float
(
att
.
get
(
"wloc"
,
"5"
))
...
...
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