Skip to content

Commit 9f41778

Browse files
committed
??? use OMPathBase
1 parent 1dfc613 commit 9f41778

1 file changed

Lines changed: 28 additions & 28 deletions

File tree

OMPython/OMCSession.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ def escape_str(value: str) -> str:
712712
return value.replace("\\", "\\\\").replace('"', '\\"')
713713

714714
@abc.abstractmethod
715-
def model_execution_prefix(self, cwd: Optional[OMPathABC] = None) -> list[str]:
715+
def model_execution_prefix(self, cwd: Optional[OMPathBase] = None) -> list[str]:
716716
"""
717717
Helper function which returns a command prefix.
718718
"""
@@ -724,28 +724,28 @@ def get_version(self) -> str:
724724
"""
725725

726726
@abc.abstractmethod
727-
def set_workdir(self, workdir: OMPathABC) -> None:
727+
def set_workdir(self, workdir: OMPathBase) -> None:
728728
"""
729729
Set the workdir for this session.
730730
"""
731731

732732
@abc.abstractmethod
733-
def omcpath(self, *path) -> OMPathABC:
733+
def omcpath(self, *path) -> OMPathBase:
734734
"""
735735
Create an OMPathBase object based on the given path segments and the current class.
736736
"""
737737

738738
@abc.abstractmethod
739-
def omcpath_tempdir(self, tempdir_base: Optional[OMCPath] = None) -> OMPathABC:
739+
def omcpath_tempdir(self, tempdir_base: Optional[OMCPath] = None) -> OMPathBase:
740740
"""
741741
Get a temporary directory based on the specific definition for this session.
742742
"""
743743

744744
@staticmethod
745-
def _tempdir(tempdir_base: OMPathABC) -> OMPathABC:
745+
def _tempdir(tempdir_base: OMPathBase) -> OMPathBase:
746746
names = [str(uuid.uuid4()) for _ in range(100)]
747747

748-
tempdir: Optional[OMPathABC] = None
748+
tempdir: Optional[OMPathBase] = None
749749
for name in names:
750750
# create a unique temporary directory name
751751
tempdir = tempdir_base / name
@@ -887,7 +887,7 @@ def escape_str(value: str) -> str:
887887
"""
888888
return value.replace("\\", "\\\\").replace('"', '\\"')
889889

890-
def model_execution_prefix(self, cwd: Optional[OMPathABC] = None) -> list[str]:
890+
def model_execution_prefix(self, cwd: Optional[OMPathBase] = None) -> list[str]:
891891
"""
892892
Helper function which returns a command prefix needed for docker and WSL. It defaults to an empty list.
893893
"""
@@ -902,14 +902,14 @@ def get_version(self) -> str:
902902
raise OMCSessionException(f"Invalid return value for get_version(): {retval} - expect str")
903903
return retval
904904

905-
def set_workdir(self, workdir: OMPathABC) -> None:
905+
def set_workdir(self, workdir: OMPathBase) -> None:
906906
"""
907907
Set the workdir for this session.
908908
"""
909909
exp = f'cd("{workdir.as_posix()}")'
910910
self.sendExpression(exp)
911911

912-
def omcpath(self, *path) -> OMPathABC:
912+
def omcpath(self, *path) -> OMPathBase:
913913
"""
914914
Create an OMCPath object based on the given path segments and the current OMCSession* class.
915915
"""
@@ -922,7 +922,7 @@ def omcpath(self, *path) -> OMPathABC:
922922
raise OMCSessionException("OMCPath is supported for Python < 3.12 only if OMCSessionLocal is used!")
923923
return OMCPath(*path, session=self)
924924

925-
def omcpath_tempdir(self, tempdir_base: Optional[OMPathABC] = None) -> OMPathABC:
925+
def omcpath_tempdir(self, tempdir_base: Optional[OMPathBase] = None) -> OMPathBase:
926926
"""
927927
Get a temporary directory using OMC. It is our own implementation as non-local usage relies on OMC to run all
928928
filesystem related access.
@@ -939,10 +939,10 @@ def omcpath_tempdir(self, tempdir_base: Optional[OMPathABC] = None) -> OMPathABC
939939
return self._tempdir(tempdir_base=tempdir_base)
940940

941941
@staticmethod
942-
def _tempdir(tempdir_base: OMPathABC) -> OMPathABC:
942+
def _tempdir(tempdir_base: OMPathBase) -> OMPathBase:
943943
names = [str(uuid.uuid4()) for _ in range(100)]
944944

945-
tempdir: Optional[OMPathABC] = None
945+
tempdir: Optional[OMPathBase] = None
946946
for name in names:
947947
# create a unique temporary directory name
948948
tempdir = tempdir_base / name
@@ -1284,13 +1284,13 @@ def escape_str(value: str) -> str:
12841284
"""
12851285
return OMCSessionABC.escape_str(value=value)
12861286

1287-
def omcpath(self, *path) -> OMPathABC:
1287+
def omcpath(self, *path) -> OMPathBase:
12881288
"""
12891289
Create an OMCPath object based on the given path segments and the current OMC process definition.
12901290
"""
12911291
return self.omc_process.omcpath(*path)
12921292

1293-
def omcpath_tempdir(self, tempdir_base: Optional[OMPathABC] = None) -> OMPathABC:
1293+
def omcpath_tempdir(self, tempdir_base: Optional[OMPathBase] = None) -> OMPathBase:
12941294
"""
12951295
Get a temporary directory using OMC. It is our own implementation as non-local usage relies on OMC to run all
12961296
filesystem related access.
@@ -1312,10 +1312,10 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
13121312
def get_version(self) -> str:
13131313
return self.omc_process.get_version()
13141314

1315-
def model_execution_prefix(self, cwd: Optional[OMPathABC] = None) -> list[str]:
1315+
def model_execution_prefix(self, cwd: Optional[OMPathBase] = None) -> list[str]:
13161316
return self.omc_process.model_execution_prefix(cwd=cwd)
13171317

1318-
def set_workdir(self, workdir: OMPathABC) -> None:
1318+
def set_workdir(self, workdir: OMPathBase) -> None:
13191319
return self.omc_process.set_workdir(workdir=workdir)
13201320

13211321

@@ -1466,15 +1466,15 @@ def get_docker_container_id(self) -> str:
14661466

14671467
return self._docker_container_id
14681468

1469-
def model_execution_prefix(self, cwd: Optional[OMPathABC] = None) -> list[str]:
1469+
def model_execution_prefix(self, cwd: Optional[OMPathBase] = None) -> list[str]:
14701470
"""
14711471
Helper function which returns a command prefix needed for docker and WSL. It defaults to an empty list.
14721472
"""
14731473
docker_cmd = [
14741474
"docker", "exec",
14751475
"--user", str(self._getuid()),
14761476
]
1477-
if isinstance(cwd, OMPathABC):
1477+
if isinstance(cwd, OMPathBase):
14781478
docker_cmd += ["--workdir", cwd.as_posix()]
14791479
docker_cmd += self._docker_extra_args
14801480
if isinstance(self._docker_container_id, str):
@@ -1762,7 +1762,7 @@ def __init__(
17621762

17631763
self._cmd_prefix = self.model_execution_prefix()
17641764

1765-
def model_execution_prefix(self, cwd: Optional[OMPathABC] = None) -> list[str]:
1765+
def model_execution_prefix(self, cwd: Optional[OMPathBase] = None) -> list[str]:
17661766
"""
17671767
Helper function which returns a command prefix needed for docker and WSL. It defaults to an empty list.
17681768
"""
@@ -1772,7 +1772,7 @@ def model_execution_prefix(self, cwd: Optional[OMPathABC] = None) -> list[str]:
17721772
wsl_cmd += ['--distribution', self._wsl_distribution]
17731773
if isinstance(self._wsl_user, str):
17741774
wsl_cmd += ['--user', self._wsl_user]
1775-
if isinstance(cwd, OMPathABC):
1775+
if isinstance(cwd, OMPathBase):
17761776
wsl_cmd += ['--cd', cwd.as_posix()]
17771777
wsl_cmd += ['--']
17781778

@@ -1890,7 +1890,7 @@ def mkdir(self, parents: bool = True, exist_ok: bool = False) -> None:
18901890
"""
18911891
self._path().mkdir(parents=parents, exist_ok=exist_ok)
18921892

1893-
def cwd(self) -> OMPathABC:
1893+
def cwd(self) -> OMPathBase:
18941894
"""
18951895
Returns the current working directory as an OMPathBase object.
18961896
"""
@@ -1902,7 +1902,7 @@ def unlink(self, missing_ok: bool = False) -> None:
19021902
"""
19031903
self._path().unlink(missing_ok=missing_ok)
19041904

1905-
def resolve(self, strict: bool = False) -> OMPathABC:
1905+
def resolve(self, strict: bool = False) -> OMPathBase:
19061906
"""
19071907
Resolve the path to an absolute path. This is done based on available OMC functions.
19081908
"""
@@ -2025,7 +2025,7 @@ def mkdir(self, parents: bool = True, exist_ok: bool = False) -> None:
20252025
except subprocess.CalledProcessError as exc:
20262026
raise OMCSessionException(f"Error on directory creation for {self.as_posix()}!") from exc
20272027

2028-
def cwd(self) -> OMPathABC:
2028+
def cwd(self) -> OMPathBase:
20292029
"""
20302030
Returns the current working directory as an OMPathBase object.
20312031
"""
@@ -2056,7 +2056,7 @@ def unlink(self, missing_ok: bool = False) -> None:
20562056
except subprocess.CalledProcessError as exc:
20572057
raise OSError(f"Cannot unlink file {self.as_posix()}: {exc}") from exc
20582058

2059-
def resolve(self, strict: bool = False) -> OMPathABC:
2059+
def resolve(self, strict: bool = False) -> OMPathBase:
20602060
"""
20612061
Resolve the path to an absolute path. This is done based on available OMC functions.
20622062
"""
@@ -2131,7 +2131,7 @@ def __post_init__(self) -> None:
21312131
No connection to an OMC server is created by this class!
21322132
"""
21332133

2134-
def model_execution_prefix(self, cwd: Optional[OMPathABC] = None) -> list[str]:
2134+
def model_execution_prefix(self, cwd: Optional[OMPathBase] = None) -> list[str]:
21352135
"""
21362136
Helper function which returns a command prefix.
21372137
"""
@@ -2144,19 +2144,19 @@ def get_version(self) -> str:
21442144
"""
21452145
return self._version
21462146

2147-
def set_workdir(self, workdir: OMPathABC) -> None:
2147+
def set_workdir(self, workdir: OMPathBase) -> None:
21482148
"""
21492149
Set the workdir for this session. For OMSessionRunner this is a nop. The workdir must be defined within the
21502150
definition of cmd_prefix.
21512151
"""
21522152

2153-
def omcpath(self, *path) -> OMPathABC:
2153+
def omcpath(self, *path) -> OMPathBase:
21542154
"""
21552155
Create an OMCPath object based on the given path segments and the current OMCSession* class.
21562156
"""
21572157
return self._ompath_runner(*path, session=self)
21582158

2159-
def omcpath_tempdir(self, tempdir_base: Optional[OMPathABC] = None) -> OMPathABC:
2159+
def omcpath_tempdir(self, tempdir_base: Optional[OMPathBase] = None) -> OMPathBase:
21602160
"""
21612161
Get a temporary directory without using OMC.
21622162
"""

0 commit comments

Comments
 (0)