Skip to content

Commit 39a7d57

Browse files
MAINT: Formatting
1 parent de420fe commit 39a7d57

2 files changed

Lines changed: 14 additions & 16 deletions

File tree

‎pytransform3d/test/test_urdf.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,14 @@ def test_xml_namespace():
211211

212212
robot_name, links, joints = parse_urdf(urdf)
213213

214-
assert robot_name == 'robot_name'
214+
assert robot_name == "robot_name"
215215
assert len(links) == 2
216216
assert len(joints) == 1
217217

218218
for link in links:
219-
assert link.name in ['link0', 'link1']
219+
assert link.name in ["link0", "link1"]
220220

221-
assert joints[0].joint_name == 'joint0'
221+
assert joints[0].joint_name == "joint0"
222222

223223

224224
def test_reference_to_unknown_child():

‎pytransform3d/urdf.py‎

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -413,13 +413,13 @@ def parse_urdf(urdf_xml, mesh_path=None, package_dir=None, strict_check=True):
413413
# URDF XML schema:
414414
# https://github.com/ros/urdfdom/blob/master/xsd/urdf.xsd
415415

416-
# If there is an XML namespace (xmlns=...) specified, this will break parsing as
417-
# the root tag, and the tag of all elements underneath root, will have a {namespace}
418-
# prefix. As such, normalize the namespace to the default (i.e. no namespace).
416+
# If there is an XML namespace (xmlns=...) specified, this will break
417+
# parsing as the root tag, and the tag of all elements underneath root,
418+
# will have a {namespace} prefix. As such, normalize the namespace to the
419+
# default (i.e. no namespace).
419420

420421
_normalize_namespace(root)
421422

422-
423423
if root.tag != "robot":
424424
raise UrdfException("Robot tag is missing.")
425425

@@ -470,6 +470,13 @@ def initialize_urdf_transform_manager(tm, robot_name, links, joints):
470470
_add_joints(tm, joints)
471471

472472

473+
def _normalize_namespace(root):
474+
"""Normalizes the namespace of the root node and all elements underneath."""
475+
root.tag = re.sub(r"\{.*?\}", "", root.tag)
476+
for element in root.iter():
477+
element.tag = re.sub(r"\{.*?\}", "", element.tag)
478+
479+
473480
def _parse_material(material):
474481
"""Parse material."""
475482
if "name" not in material.attrib:
@@ -754,15 +761,6 @@ def _add_joints(tm, joints):
754761
"fixed",
755762
)
756763

757-
def _normalize_namespace(root):
758-
"""Normalizes the namespace of the root node and all elements underneath it.
759-
"""
760-
761-
root.tag = re.sub(r"\{.*?\}", "", root.tag)
762-
763-
for element in root.iter():
764-
element.tag = re.sub(r"\{.*?\}", "", element.tag)
765-
766764

767765
class Link(object):
768766
"""Link from URDF file.

0 commit comments

Comments
 (0)