src
smach_viewer
utils.py
Go to the documentation of this file.
1
# Helper Functions
2
def
graph_attr_string
(attrs):
3
"""Generate an xdot graph attribute string."""
4
attrs_strs = [
'"'
+str(k)+
'"="'
+str(v)+
'"'
for
k, v
in
attrs.items()]
5
return
';\n'
.join(attrs_strs)+
';\n'
6
7
8
def
attr_string
(attrs):
9
"""Generate an xdot node attribute string."""
10
attrs_strs = [
'"'
+str(k)+
'"="'
+str(v)+
'"'
for
k, v
in
attrs.items()]
11
return
' ['
+(
', '
.join(attrs_strs))+
']'
12
13
14
def
get_parent_path
(path):
15
"""Get the parent path of an xdot node."""
16
path_tokens = path.split(
'/'
)
17
if
len(path_tokens) > 2:
18
parent_path =
'/'
.join(path_tokens[0:-1])
19
else
:
20
parent_path =
'/'
.join(path_tokens[0:1])
21
return
parent_path
22
23
24
def
get_label
(path):
25
"""Get the label of an xdot node."""
26
path_tokens = path.split(
'/'
)
27
return
path_tokens[-1]
28
29
30
def
hex2t
(color_str):
31
"""Convert a hexadecimal color strng into a color tuple."""
32
color_tuple = [
33
int(color_str[i:i+2], 16)/255.0
for
i
in
range(1, len(color_str), 2)]
34
return
color_tuple
smach_viewer.utils.attr_string
def attr_string(attrs)
Definition:
utils.py:8
smach_viewer.utils.hex2t
def hex2t(color_str)
Definition:
utils.py:30
smach_viewer.utils.get_label
def get_label(path)
Definition:
utils.py:24
smach_viewer.utils.get_parent_path
def get_parent_path(path)
Definition:
utils.py:14
smach_viewer.utils.graph_attr_string
def graph_attr_string(attrs)
Definition:
utils.py:2
smach_viewer
Author(s): Jonathan Bohren
autogenerated on Thu Feb 20 2025 03:09:09