diff --git a/src/Utils.py b/src/Utils.py index 071271056..9d217f50c 100644 --- a/src/Utils.py +++ b/src/Utils.py @@ -50,7 +50,7 @@ import gen.lib import Errors from QuestionDialog import WarningDialog, ErrorDialog -from const import TEMP_DIR, USER_HOME +from const import TEMP_DIR, USER_HOME, WINDOWS, MACOS, LINUX import shutil #------------------------------------------------------------------------- @@ -256,6 +256,37 @@ def add_menuitem(menu, msg, obj, func): item.show() menu.append(item) +#------------------------------------------------------------------------- +# +# Platform determination functions +# +#------------------------------------------------------------------------- + +def lin(): + """ + Return True if a linux system + Note: Normally do as linux in else statement of a check ! + """ + if platform.system() in LINUX: + return True + return False + +def mac(): + """ + Return True if a Macintosh system + """ + if platform.system() in MACOS: + return True + return False + +def win(): + """ + Return True if a windows system + """ + if platform.system() in WINDOWS: + return True + return False + #------------------------------------------------------------------------- # # diff --git a/src/const.py.in b/src/const.py.in index 20f462256..f59438349 100644 --- a/src/const.py.in +++ b/src/const.py.in @@ -193,6 +193,16 @@ XMLFILE = "data.gramps" NO_SURNAME = "(%s)" % _("none") NO_GIVEN = "(%s)" % _("none") +#------------------------------------------------------------------------- +# +# Platforms +# Never test on LINUX, handle Linux in the else statement as default +# +#------------------------------------------------------------------------- +LINUX = ["Linux", "linux"] +MACOS = ["Darwin", "darwin"] +WINDOWS = ["Windows", "win32"] + #------------------------------------------------------------------------- # # Options Constants