From bfe4f5c8b186233aaf79314bdac6f820586822a6 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 27 Nov 2012 09:55:10 +0530 Subject: [PATCH] Add function to get OS X version --- src/calibre/constants.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/calibre/constants.py b/src/calibre/constants.py index f69668ffe1..8cc2e6409d 100644 --- a/src/calibre/constants.py +++ b/src/calibre/constants.py @@ -44,6 +44,19 @@ winerror = importlib.import_module('winerror') if iswindows else None win32api = importlib.import_module('win32api') if iswindows else None fcntl = None if iswindows else importlib.import_module('fcntl') +_osx_ver = None +def get_osx_version(): + global _osx_ver + if _osx_ver is None: + import platform + from collections import namedtuple + OSX = namedtuple('OSX', 'major minor tertiary') + try: + _osx_ver = OSX(*(map(int, platform.mac_ver()[0].split('.')))) + except: + _osx_ver = OSX(0, 0, 0) + return _osx_ver + filesystem_encoding = sys.getfilesystemencoding() if filesystem_encoding is None: filesystem_encoding = 'utf-8' else: