From 57d328aa0117f6843e4a07c3020bdd99952460eb Mon Sep 17 00:00:00 2001 From: idziubenko Date: Mon, 4 Apr 2022 14:13:10 +0300 Subject: [PATCH] added relative paths to "link" --- pym/calculate/lib/cl_template.py | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/pym/calculate/lib/cl_template.py b/pym/calculate/lib/cl_template.py index 68c57d1..28a6fc6 100644 --- a/pym/calculate/lib/cl_template.py +++ b/pym/calculate/lib/cl_template.py @@ -5348,8 +5348,9 @@ gettext -d cl_template "$*" if crDirs is not True: createdDirs += crDirs if HParams.DirectoryLink in objHead.params: - templateFile = objHead.params[HParams.DirectoryLink] + templateFile = objHead.params[HParams.DirectoryLink] templateFile = pathJoin(self._baseDir, templateFile) + #TODO relative path for dirs? if not os.path.isdir(templateFile): self.setError(_("Source path %s is not a directory") % templateFile) @@ -5706,7 +5707,13 @@ gettext -d cl_template "$*" # Получаем директорию пользователя templateFile = os.path.join( self.homeDir, templateFile.partition("/")[2], "")[:-1] - templateFile = pathJoin(self._baseDir, templateFile) + if templateFile and templateFile[0] == "/": + templateFile = pathJoin(self._baseDir, templateFile) + else: + #relative path + templateFile = pathJoin(os.path.dirname(pathOldFile), templateFile) + templateFile = pathJoin(self._baseDir, templateFile) + templateFile = os.path.abspath(templateFile) if (not os.path.exists(templateFile) or not objHeadNew.params[HParams.Link]): if os.path.exists(pathOldFile): @@ -5730,7 +5737,14 @@ gettext -d cl_template "$*" # Получаем директорию пользователя templateFile = os.path.join( self.homeDir, templateFile.partition("/")[2], "")[:-1] - templateFile = pathJoin(self._baseDir, templateFile) + + if templateFile and templateFile[0] == "/": + templateFile = pathJoin(self._baseDir, templateFile) + else: + #relative path + templateFile = pathJoin(os.path.dirname(pathOldFile), templateFile) + templateFile = pathJoin(self._baseDir, templateFile) + templateFile = os.path.abspath(templateFile) foundTemplateFile = os.path.exists(templateFile) buff = None buff_is_unicode = False