Skip to content

Commit

Permalink
Refactor get_xml_string to raise FileExistsError for non-existent p…
Browse files Browse the repository at this point in the history
…aths
  • Loading branch information
xela-95 committed Nov 5, 2024
1 parent 8d6e550 commit 1512110
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/adam/model/std_factories/std_model.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import os
import pathlib
from typing import List
import xml.etree.ElementTree as ET
import os
from typing import List

import urdf_parser_py.urdf

from adam.core.spatial_math import SpatialMath
Expand Down Expand Up @@ -36,9 +37,12 @@ def get_xml_string(path: str | pathlib.Path):

# Checking if it is a path or an urdf
if not isPath:
if len(path) <= MAX_PATH and os.path.exists(path):
path = pathlib.Path(path)
isPath = True
if len(path) <= MAX_PATH:
if os.path.exists(path):
path = pathlib.Path(path)
isPath = True
else:
raise FileExistsError(path)
else:
root = ET.fromstring(path)

Expand Down

0 comments on commit 1512110

Please sign in to comment.