From ae3d73a61f9e67ca758a75ddca59bf9d93a75787 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Gosselin?= Date: Tue, 11 Jun 2019 09:39:45 -0400 Subject: [PATCH 1/3] Save abs path of rel path throws an error --- gwhat/mainwindow.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gwhat/mainwindow.py b/gwhat/mainwindow.py index e0d05619f..7b3ae0ce2 100644 --- a/gwhat/mainwindow.py +++ b/gwhat/mainwindow.py @@ -307,7 +307,15 @@ def __init__(self, parent=None): # ======================================= def save_pref_file(self): print('\nSaving WHAT preferences to file...') - fcontent = [['Project File:', os.path.relpath(self.projectfile)], + try: + fpath = osp.relpath(self.projectfile) + except ValueError: + # This probably means that the gwhat project is not saved on the + # same drive as the one where GHWAT is installed. + # See jnsebgosselin/gwhat#289. + fpath = osp.abspath(self.projectfile) + + fcontent = [['Project File:', fpath], ['Language:', self.language], ['Font-Size-General:', self.fontsize_general], ['Font-Size-Console:', self.fontsize_console], From 64ed5d9d1b2cc9ebd30a303c4de17e8a561883c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Gosselin?= Date: Tue, 11 Jun 2019 09:39:56 -0400 Subject: [PATCH 2/3] Codestyle --- gwhat/mainwindow.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gwhat/mainwindow.py b/gwhat/mainwindow.py index 7b3ae0ce2..9c0096d1f 100644 --- a/gwhat/mainwindow.py +++ b/gwhat/mainwindow.py @@ -294,7 +294,7 @@ class WHATPref(object): of graphs). """ - def __init__(self, parent=None): # ======================================= + def __init__(self, parent=None): self.projectfile = os.path.join( '..', 'Projects', 'Example', 'Example.gwt') @@ -306,7 +306,7 @@ def __init__(self, parent=None): # ======================================= self.load_pref_file() def save_pref_file(self): - print('\nSaving WHAT preferences to file...') + print('\n\rSaving WHAT preferences to file...', end=' ') try: fpath = osp.relpath(self.projectfile) except ValueError: @@ -321,7 +321,7 @@ def save_pref_file(self): ['Font-Size-Console:', self.fontsize_console], ['Font-Size-Menubar:', self.fontsize_menubar]] save_content_to_csv('WHAT.pref', fcontent) - print('WHAT preferences saved.') + print('done') def load_pref_file(self, circloop=False): From 311ce6ce94c01f38d2e12b42693758c769518fe6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20Gosselin?= Date: Tue, 11 Jun 2019 09:40:05 -0400 Subject: [PATCH 3/3] Add docstring to save_pref_file --- gwhat/mainwindow.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gwhat/mainwindow.py b/gwhat/mainwindow.py index 9c0096d1f..653d2f10c 100644 --- a/gwhat/mainwindow.py +++ b/gwhat/mainwindow.py @@ -306,6 +306,9 @@ def __init__(self, parent=None): self.load_pref_file() def save_pref_file(self): + """ + Save the GWHAT user preferences to file. + """ print('\n\rSaving WHAT preferences to file...', end=' ') try: fpath = osp.relpath(self.projectfile)