Skip to content

Commit ee00d77

Browse files
committed
Resolve conflicts
2 parents 7ff2a0a + d69deaa commit ee00d77

File tree

4 files changed

+32
-7
lines changed

4 files changed

+32
-7
lines changed

tests/testConverter.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2025 The Newton Developers
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 The Newton Developers
22
# SPDX-License-Identifier: Apache-2.0
33
import pathlib
44
import shutil
@@ -178,3 +178,16 @@ def test_ros_packages(self):
178178
self.assertEqual(diffuse_color, None)
179179
opacity = self.get_material_opacity(texture_material)
180180
self.assertAlmostEqual(opacity, 1.0, places=6)
181+
182+
def test_asset_identifer(self):
183+
model = pathlib.Path("tests/data/prismatic_joints.urdf")
184+
model_name = model.stem
185+
output_dir = pathlib.Path(self.tmpDir()) / model_name
186+
usdc_path = output_dir / f"{model_name}.usdc"
187+
188+
asset_identifier = urdf_usd_converter.Converter(layer_structure=False).convert(model, output_dir)
189+
self.assertTrue(usdc_path.exists())
190+
191+
# check that the asset identifier returned from convert() is the same as the usdc path
192+
flattened_usdc_path = pathlib.Path(asset_identifier.path).absolute().as_posix()
193+
self.assertEqual(flattened_usdc_path, usdc_path.absolute().as_posix())

tools/license_format.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2025 The Newton Developers
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 The Newton Developers
22
# SPDX-License-Identifier: Apache-2.0
33
import argparse
44
import logging
@@ -9,9 +9,20 @@
99

1010
__copyright = "# SPDX-FileCopyrightText: Copyright (c) {years} The Newton Developers"
1111
__identifier = "# SPDX-License-Identifier: Apache-2.0"
12+
__start_year = 2025
13+
14+
# Build regex to match valid year patterns
15+
# Valid: single year (2025-current) OR range (start_year-end_year) where both <= current year
16+
# Invalid: future years beyond current year
17+
__current_year = datetime.now().year
18+
__single_years = "|".join(str(year) for year in range(__start_year, __current_year + 1))
19+
__range_starts = "|".join(str(year) for year in range(__start_year, __current_year + 1))
20+
__range_ends = "|".join(str(year) for year in range(__start_year, __current_year + 1))
21+
__years_pattern = f"(?:{__single_years}|(?:{__range_starts})-(?:{__range_ends}))"
22+
1223
# Escape special regex characters in the copyright template
1324
__copyright_template = re.escape(__copyright).replace(re.escape("{years}"), "{years}")
14-
__copyright_years = __copyright_template.replace("{years}", f"(?:2025|(?:20[0-9][0-4])-{datetime.now().year})")
25+
__copyright_years = __copyright_template.replace("{years}", __years_pattern)
1526
__copyright_regex = re.compile(f"^{__copyright_years}$")
1627

1728

urdf_usd_converter/_impl/_flatten.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2025 The Newton Developers
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 The Newton Developers
22
# SPDX-License-Identifier: Apache-2.0
33
import pathlib
44
import shutil
@@ -11,7 +11,7 @@
1111
from .utils import get_authoring_metadata
1212

1313

14-
def export_flattened(asset_stage: Usd.Stage, output_dir: str, asset_dir: str, asset_stem: str, asset_format: str, comment: str):
14+
def export_flattened(asset_stage: Usd.Stage, output_dir: str, asset_dir: str, asset_stem: str, asset_format: str, comment: str) -> str:
1515
output_path = pathlib.Path(output_dir)
1616
layer: Sdf.Layer = asset_stage.Flatten()
1717
asset_identifier = f"{output_path.absolute().as_posix()}/{asset_stem}.{asset_format}"
@@ -40,3 +40,4 @@ def export_flattened(asset_stage: Usd.Stage, output_dir: str, asset_dir: str, as
4040
Tf.Status(f"Copied textures from {temp_textures_dir} to {output_textures_dir}")
4141

4242
shutil.rmtree(asset_dir, ignore_errors=True)
43+
return asset_identifier

urdf_usd_converter/_impl/convert.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: Copyright (c) 2025 The Newton Developers
1+
# SPDX-FileCopyrightText: Copyright (c) 2025-2026 The Newton Developers
22
# SPDX-License-Identifier: Apache-2.0
33
import pathlib
44
import tempfile
@@ -149,7 +149,7 @@ def convert(self, input_file: str, output_dir: str) -> Sdf.AssetPath:
149149

150150
# optionally flatten the asset
151151
if not self.params.layer_structure:
152-
export_flattened(asset_stage, output_dir, asset_dir, asset_stem, asset_format, self.params.comment)
152+
asset_identifier = export_flattened(asset_stage, output_dir, asset_dir, asset_stem, asset_format, self.params.comment)
153153
else:
154154
usdex.core.saveStage(asset_stage, comment=self.params.comment)
155155

0 commit comments

Comments
 (0)