Skip to content

Commit

Permalink
Change how ModelicaPaths are built so they also work on Windows compu…
Browse files Browse the repository at this point in the history
…ters (#590)

* enforce modelica-style paths in ModelicaPath resources_relative_dir property

* enforce modelica-style paths in the rest of the ModelicaPath class

* fix utils test to match new ModelicaPath output
  • Loading branch information
vtnate authored Oct 5, 2023
1 parent f3f1003 commit 423b966
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions geojson_modelica_translator/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def files_dir(self):
if self.root_dir is None:
return self.files_relative_dir
else:
return os.path.join(self.root_dir, self.name)
return f"{self.root_dir}/{self.name}"

@property
def resources_relative_dir(self):
Expand All @@ -93,7 +93,7 @@ def resources_relative_dir(self):
:return: string, relative resource's data path
"""
return os.path.join("Resources", "Data", self.name)
return f"Resources/Data/{self.name}"

@property
def scripts_relative_dir(self, platform='Dymola'):
Expand All @@ -102,7 +102,7 @@ def scripts_relative_dir(self, platform='Dymola'):
:return: string, relative scripts path
"""
return os.path.join("Resources", "Scripts", self.name, platform)
return f"Resources/Scripts/{self.name}/{platform}"

@property
def files_relative_dir(self):
Expand All @@ -120,7 +120,7 @@ def resources_dir(self):
if self.root_dir is None:
return self.resources_relative_dir
else:
return os.path.join(self.root_dir, self.resources_relative_dir)
return f"{self.root_dir}/{self.resources_relative_dir}"

@property
def scripts_dir(self):
Expand All @@ -133,7 +133,7 @@ def scripts_dir(self):
if self.root_dir is None:
return self.scripts_relative_dir
else:
return os.path.join(self.root_dir, self.scripts_relative_dir)
return f"{self.root_dir}/{self.scripts_relative_dir}"


# This is used for some test cases where we need deterministic IDs to be generated
Expand Down
2 changes: 1 addition & 1 deletion tests/geojson_modelica_translator/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def setUp(self):
def test_properties(self):
mp = ModelicaPath("Loads", root_dir=None)
self.assertEqual(mp.files_dir, "Loads")
self.assertEqual(mp.resources_dir, os.path.join("Resources", "Data", "Loads"))
self.assertEqual(mp.resources_dir, "Resources/Data/Loads")

def test_single_sub_resource(self):
root_dir = os.path.join(self.output_dir, "modelica_path_01")
Expand Down

0 comments on commit 423b966

Please sign in to comment.