Commit b9554b5b authored by tarek's avatar tarek

Uses plistlib instead of re. Thanks Florian refs #92

--HG--
branch : distribute
extra : rebase_source : f3e61a21dc640a621364736b2a60fa9eb337ae1b
parent b74e204f
...@@ -188,14 +188,13 @@ def _macosx_vers(_cache=[]): ...@@ -188,14 +188,13 @@ def _macosx_vers(_cache=[]):
version = platform.mac_ver()[0] version = platform.mac_ver()[0]
# fallback for MacPorts # fallback for MacPorts
if version == '': if version == '':
import re import plistlib
version_file = '/System/Library/CoreServices/SystemVersion.plist' plist = '/System/Library/CoreServices/SystemVersion.plist'
version_regexp = r'<key>ProductVersion</key>\n\t<string>(.*?)</string>' if os.path.exists(plist):
if os.path.exists(version_file): plist_content = plistlib.readPlist(plist)
osx_version = open(version_file).read() if 'ProductVersion' in plist_content:
osx_version = re.findall(version_regexp, osx_version, re.M) version = plist_content['ProductVersion']
if len(osx_version) > 0:
version = osx_version[0]
_cache.append(version.split('.')) _cache.append(version.split('.'))
return _cache[0] return _cache[0]
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment