Better save file handling

By using the plugin_dir, we always save in the plugin's folder.
This is useful when the plugin folder has another name
(for example: EDMC_SpanshRouter) and works cross platform.
This commit is contained in:
Jan Vansteenkiste 2019-06-24 10:09:05 +02:00
parent 2080a40331
commit 5195c37d8b

View File

@ -18,12 +18,8 @@ this.parent = None
this.save_route_path = ""
def plugin_start():
if sys.platform == 'win32':
this.save_route_path = os.path.expandvars(r'%LOCALAPPDATA%\EDMarketConnector\plugins\SpanshRouter\route.csv')
else:
home = os.path.expanduser("~")
this.save_route_path = home + "/.local/share/EDMarketConnector/plugins/SpanshRouter/route.csv"
def plugin_start(plugin_dir):
this.save_route_path = os.path.join(plugin_dir, 'route.csv')
try:
# Open the last saved route