From 5c204ef7782a4f3b46f74a80a5231f64540828fa Mon Sep 17 00:00:00 2001 From: Noel Jimenez Date: Thu, 28 Aug 2025 15:59:10 +0200 Subject: [PATCH] Fix path regex substitution --- test/test_xacro.py | 10 ++++++++++ xacro/__init__.py | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/test/test_xacro.py b/test/test_xacro.py index 0fb58a4..fbb14d6 100644 --- a/test/test_xacro.py +++ b/test/test_xacro.py @@ -36,6 +36,7 @@ import itertools import math import os.path +import pathlib import re import shutil import subprocess @@ -1702,6 +1703,15 @@ def test_remove_property(self): ${p}''' self.assert_matches(self.quick_xacro(src), '2nd') + def test_process_file_types(self): + # Test that checks process_file method with different path types + # os.path + path = os.path.join(os.path.dirname(__file__), 'emoji.xacro') + self.assert_matches(xacro.process(path), '🍔') + + # pathlib.Path + path = pathlib.Path(os.path.join(os.path.dirname(__file__), 'emoji.xacro')) + self.assert_matches(xacro.process(path), '🍔') if __name__ == '__main__': unittest.main() diff --git a/xacro/__init__.py b/xacro/__init__.py index 09141df..ef224df 100644 --- a/xacro/__init__.py +++ b/xacro/__init__.py @@ -1115,7 +1115,7 @@ def process_file(input_file_name, **kwargs): banner = [xml.dom.minidom.Comment(c) for c in [" %s " % ('=' * 83), # replace consecutive dashes with a single one to yield a XML-compliant comment string - " | This document was autogenerated by xacro from %-30s | " % re.sub(r'-+', '-', input_file_name), + " | This document was autogenerated by xacro from %-30s | " % re.sub(r'-+', '-', str(input_file_name)), " | EDITING THIS FILE BY HAND IS NOT RECOMMENDED %-30s | " % "", " %s " % ('=' * 83)]] first = doc.firstChild