Skip to content

Commit

Permalink
convert the path to relative to store and to absolute for ili2db
Browse files Browse the repository at this point in the history
  • Loading branch information
signedav committed Sep 25, 2023
1 parent 085caa4 commit ec25d23
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions QgisModelBaker/gui/validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,10 @@ def _run(self, edited_command=None):
validator.configuration.skip_geometry_errors = (
self.skip_geometry_errors_check_box.isChecked()
)
validator.configuration.valid_config = self.config_file_line_edit.text()
validator.configuration.valid_config = self._absolute_path(
self.config_file_line_edit.text()
)
print(validator.configuration.valid_config)

self.progress_bar.setValue(20)
validation_result_state = False
Expand Down Expand Up @@ -671,7 +674,18 @@ def _load_config_file(self):
self.config_file_line_edit.setText(self._relative_path(filename))

def _relative_path(self, path):
return os.path.relpath(QgsProject.instance().homePath(), path)
if QgsProject.instance().homePath() and os.path.isabs(path):
# if it's a saved project and the path is not (yet) relative
return os.path.relpath(path, QgsProject.instance().homePath())
else:
return path

def _absolute_path(self, path):
if path and QgsProject.instance().homePath() and not os.path.isabs(path):
# if it's a saved project and the path is not not absolute
return os.path.join(path, QgsProject.instance().homePath(), path)
else:
return path

def _validator_stdout(self, txt):
lines = txt.strip().split("\n")
Expand Down

0 comments on commit ec25d23

Please sign in to comment.