-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert node to list so that they are processed in order. #507
base: master
Are you sure you want to change the base?
Changes from 2 commits
68ff6ea
3972da4
fcf7d56
0662818
b3005cc
2118967
90b1aae
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,14 +4,13 @@ | |
import xml.dom.minidom as minidom | ||
import xml.etree.ElementTree as ET | ||
from typing import ( | ||
AbstractSet, | ||
Any, | ||
Collection, | ||
Dict, | ||
List, | ||
Mapping, | ||
Optional, | ||
Sequence, | ||
Set, | ||
Tuple, | ||
) | ||
|
||
|
@@ -32,9 +31,7 @@ | |
|
||
@attr.s(frozen=True, slots=True) | ||
class LaunchConfig: | ||
nodes: AbstractSet[NodeConfig] = attr.ib( | ||
default=frozenset(), converter=frozenset | ||
) | ||
nodes: Sequence[NodeConfig] = attr.ib(default=()) | ||
executables: Sequence[str] = attr.ib(default=()) | ||
roslaunch_files: Sequence[str] = attr.ib(default=()) | ||
params: Mapping[str, Any] = attr.ib(factory=dict) | ||
|
@@ -59,7 +56,7 @@ def with_launch_prefixes( | |
nodes: Dict[str, NodeConfig] = {n.name: n for n in self.nodes} | ||
for node_name, prefix in prefixes.items(): | ||
nodes[node_name] = nodes[node_name].with_launch_prefix(prefix) | ||
return attr.evolve(self, nodes=frozenset(nodes.values())) | ||
return attr.evolve(self, nodes=list(nodes.values())) | ||
|
||
def with_env(self, name: str, value: str) -> "LaunchConfig": | ||
"""Adds an environment variable to this configuration.""" | ||
|
@@ -117,12 +114,12 @@ def with_remappings( | |
self, | ||
node_to_remappings: Mapping[str, Collection[Tuple[str, str]]], # noqa | ||
) -> "LaunchConfig": | ||
nodes: Set[NodeConfig] = set() | ||
nodes: List[NodeConfig] = [] | ||
for node in self.nodes: | ||
if node.name in node_to_remappings: | ||
node = node.with_remappings(node_to_remappings[node.name]) | ||
nodes.add(node) | ||
return attr.evolve(self, nodes=frozenset(nodes)) | ||
nodes.append(node) | ||
return attr.evolve(self, nodes=nodes) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. beware: |
||
|
||
def with_executable(self, executable: str) -> "LaunchConfig": | ||
"""Specify an executable that should be run at launch.""" | ||
|
@@ -140,7 +137,7 @@ def with_node(self, node: NodeConfig) -> "LaunchConfig": | |
m = "multiple definitions of node [{}] in launch configuration" | ||
m = m.format(node.full_name) | ||
raise FailedToParseLaunchFile(m) | ||
nodes = self.nodes | frozenset({node}) | ||
nodes = self.nodes | list(node) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I haven't looked at the mypy output yet, but I suspect that this is the line that's causing it to fail. The set union operator doesn't make sense for a nodes = self.nodes + [node] There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I completely misread what this line was doing. Changed it to extend the tuple |
||
return attr.evolve(self, nodes=nodes) | ||
|
||
def to_xml_tree(self) -> ET.ElementTree: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefer (immutable)
tuple
overlist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done