-
Notifications
You must be signed in to change notification settings - Fork 7
/
configmanager.py
43 lines (39 loc) · 1.27 KB
/
configmanager.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# -*- coding: utf-8 -*-
#-------------------------------------------------
#-- configuration loader
#--
#-- microelly 2015
#--
#-- GNU Lesser General Public License (LGPL)
#-------------------------------------------------
import FreeCAD
class ConfigManager():
def __init__(self,name):
if name=='':
self.name="Plugins"
else:
self.name="Plugins/"+name
def get(self,param,default,defaultWindows=None,defaultMac=None):
if not defaultWindows:
defaultWindows=default
if not defaultMac:
defaultMac=default
if default.__class__ == int:
v=FreeCAD.ParamGet('User parameter:'+self.name).GetInt(param)
if not v:
FreeCAD.ParamGet('User parameter:'+self.name).SetInt(param,default)
if default.__class__ == float:
v=FreeCAD.ParamGet('User parameter:'+self.name).GetFloat(param)
if not v:
FreeCAD.ParamGet('User parameter:'+self.name).SetFloat(param,default)
if default.__class__ == str:
v=FreeCAD.ParamGet('User parameter:'+self.name).GetString(param)
if not v:
FreeCAD.ParamGet('User parameter:'+self.name).SetString(param,default)
if default.__class__ == bool:
v=FreeCAD.ParamGet('User parameter:'+self.name).GetBool(param)
if not v:
FreeCAD.ParamGet('User parameter:'+self.name).SetBool(param,default)
if not v:
v=default
return v