Skip to content

Commit

Permalink
fix: cleanup configuration file location, especially on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
paulmueller committed Oct 8, 2020
1 parent d8ce596 commit 537f704
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
7 changes: 4 additions & 3 deletions .appveyor/pyjibe.iss_dummy
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

#define MyAppName "PyJibe"
#define MyAppVersion "0.1.0"
#define MyAppPublisher "Paul Müller"
#define MyAppURL "https://gucklab.com"
#define MyAppPublisher "AFM-Analysis"
#define MyAppURL "https://pyjibe.readthedocs.io"
#define MyAppExeName "pyjibe_ui.exe"
#define MyAppPlatform "win32"
#define MyAppDir = SourcePath + "..\dist\pyjibe\"
Expand All @@ -21,8 +21,9 @@ AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={localappdata}\{#MyAppName}
DefaultDirName={localappdata}\{#MyAppPublisher}{#MyAppName}
DisableDirPage=yes
UsePreviousAppDir=false
DefaultGroupName={#MyAppName}
AllowNoIcons=yes
OutputBaseFilename={#MyAppName}_{#MyAppVersion}_{#MyAppPlatform}_setup
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
0.8.3
- fix: main window not focused after startup
- fix: Windows installation location was confusing and did
not coincide configuration file location
0.8.2
- setup: bump matplotlib to >=3
(NavigationToolbar2QT modifications)
Expand Down
3 changes: 2 additions & 1 deletion pyjibe/fd/rating_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
import nanite.rate.rater


_cfg_dir = appdirs.user_config_dir(appname="PyJibe", appauthor="AFM-Analysis")
#: Rating configuration directory
CFG_DIR = pathlib.Path(appdirs.user_config_dir(appname="PyJibe")) / "rating"
CFG_DIR = pathlib.Path(_cfg_dir) / "rating"
#: Path to main rating configuration file
CFG_PATH = CFG_DIR / "rating_schemes.txt"

Expand Down
13 changes: 8 additions & 5 deletions pyjibe/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@

import appdirs

#: default settings file name
NAME = "pyjibe.cfg"
#: application name
NAME = "PyJibe"
#: application author
ORG = "AFM-Analysis"

#: default configuration parameters
DEFAULTS = {}
Expand All @@ -14,13 +16,14 @@
class SettingsFile(object):
"""Manages a settings file in the user's config dir"""

def __init__(self, name=NAME, defaults=DEFAULTS, directory=None):
def __init__(self, name=NAME, org=ORG, defaults=DEFAULTS, directory=None):
"""Initialize settings file (create if it does not exist)"""
if directory is None:
directory = appdirs.user_config_dir()
fname = pathlib.Path(directory) / name
directory = appdirs.user_config_dir(appname=name, appauthor=org)
fname = pathlib.Path(directory) / (name.replace(" ", "_") + ".cfg")
# create file if not existent
if not fname.exists():
fname.parent.mkdir(exist_ok=True, parents=True)
# Create the file
fname.open("w").close()

Expand Down

0 comments on commit 537f704

Please sign in to comment.