Skip to content

Commit 7fa6aa9

Browse files
committed
[OMCPath] update resolve()
1 parent 19a1484 commit 7fa6aa9

1 file changed

Lines changed: 10 additions & 10 deletions

File tree

OMPython/OMCSession.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -370,15 +370,20 @@ def resolve(self, strict: bool = False):
370370
raise OMCSessionException(f"Path {self.as_posix()} does not exist!")
371371

372372
if self.is_file():
373-
omcpath = self._omc_resolve(self.parent.as_posix()) / self.name
373+
pathstr_resolved = self._omc_resolve(self.parent.as_posix())
374+
omcpath_resolved = self._session.omcpath(pathstr_resolved) / self.name
374375
elif self.is_dir():
375-
omcpath = self._omc_resolve(self.as_posix())
376+
pathstr_resolved = self._omc_resolve(self.as_posix())
377+
omcpath_resolved = self._session.omcpath(pathstr_resolved)
376378
else:
377379
raise OMCSessionException(f"Path {self.as_posix()} is neither a file nor a directory!")
378380

379-
return omcpath
381+
if not omcpath_resolved.is_file() and not omcpath_resolved.is_dir():
382+
raise OMCSessionException(f"OMCPath resolve failed for {self.as_posix()} - path does not exist!")
380383

381-
def _omc_resolve(self, pathstr: str):
384+
return omcpath_resolved
385+
386+
def _omc_resolve(self, pathstr: str) -> str:
382387
"""
383388
Internal function to resolve the path of the OMCPath object using OMC functions *WITHOUT* changing the cwd
384389
within OMC.
@@ -392,15 +397,10 @@ def _omc_resolve(self, pathstr: str):
392397
result_parts = result.split('\n')
393398
pathstr_resolved = result_parts[1]
394399
pathstr_resolved = pathstr_resolved[1:-1] # remove quotes
395-
396-
omcpath_resolved = self._session.omcpath(pathstr_resolved)
397400
except OMCSessionException as ex:
398401
raise OMCSessionException(f"OMCPath resolve failed for {pathstr}!") from ex
399402

400-
if not omcpath_resolved.is_file() and not omcpath_resolved.is_dir():
401-
raise OMCSessionException(f"OMCPath resolve failed for {pathstr} - path does not exist!")
402-
403-
return omcpath_resolved
403+
return pathstr_resolved
404404

405405
def absolute(self):
406406
"""

0 commit comments

Comments
 (0)