From 124d2ae38d3fb61da520658a3a1d8de5a643520a Mon Sep 17 00:00:00 2001 From: Youness Alaoui Date: Tue, 3 Mar 2015 16:02:11 -0500 Subject: [PATCH] Add support for machine-independent quickprint ini settings --- Cura/util/resources.py | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/Cura/util/resources.py b/Cura/util/resources.py index 22ba918c..2a9e8eeb 100644 --- a/Cura/util/resources.py +++ b/Cura/util/resources.py @@ -12,6 +12,7 @@ import platform import locale import gettext +import profile if sys.platform.startswith('darwin'): try: @@ -51,26 +52,27 @@ def getDefaultMachineProfiles(): path = os.path.normpath(os.path.join(resourceBasePath, 'machine_profiles', '*.ini')) return glob.glob(path) +def getSimpleModeIniFiles(subdir): + machine_type = profile.getMachineSetting('machine_type') + paths = [] + paths.append(os.path.normpath(os.path.expanduser(os.path.join('~', '.Cura', 'quickprint', machine_type, subdir)))) + paths.append(os.path.normpath(os.path.expanduser(os.path.join('~', '.Cura', 'quickprint', subdir)))) + paths.append(os.path.normpath(os.path.join(resourceBasePath, 'quickprint', machine_type, subdir))) + paths.append(os.path.normpath(os.path.join(resourceBasePath, 'quickprint', subdir))) + for path in paths: + if os.path.isdir(path): + return sorted(glob.glob(os.path.join(path, '*.ini'))) + return [] + + def getSimpleModeProfiles(): - path = os.path.normpath(os.path.join(resourceBasePath, 'quickprint', 'profiles', '*.ini')) - user_path = os.path.normpath(os.path.expanduser(os.path.join('~', '.Cura', 'quickprint', 'profiles'))) - if os.path.isdir(user_path): - return sorted(glob.glob(user_path)) - return sorted(glob.glob(path)) + return getSimpleModeIniFiles('profiles') def getSimpleModeMaterials(): - path = os.path.normpath(os.path.join(resourceBasePath, 'quickprint', 'materials', '*.ini')) - user_path = os.path.normpath(os.path.expanduser(os.path.join('~', '.Cura', 'quickprint', 'materials'))) - if os.path.isdir(user_path): - return sorted(glob.glob(user_path)) - return sorted(glob.glob(path)) + return getSimpleModeIniFiles('materials') def getSimpleModeOptions(): - path = os.path.normpath(os.path.join(resourceBasePath, 'quickprint', 'options', '*.ini')) - user_path = os.path.normpath(os.path.expanduser(os.path.join('~', '.Cura', 'quickprint', 'options'))) - if os.path.isdir(user_path): - return sorted(glob.glob(user_path)) - return sorted(glob.glob(path)) + return getSimpleModeIniFiles('options') def setupLocalization(selectedLanguage = None): #Default to english -- 2.30.2