Commits

tarek  committed f733db9

Uses plistlib instead of re. Thanks Florian refs #92

  • Participants
  • Parent commits 7a6f295
  • Branches 0.6-maintenance

Comments (0)

Files changed (1)

File pkg_resources.py

         version = platform.mac_ver()[0]
         # fallback for MacPorts
         if version == '':
-            import re
-            version_file = '/System/Library/CoreServices/SystemVersion.plist'
-            version_regexp = r'<key>ProductVersion</key>\n\t<string>(.*?)</string>'
-            if os.path.exists(version_file):
-                osx_version = open(version_file).read()
-                osx_version = re.findall(version_regexp, osx_version, re.M)
-                if len(osx_version) > 0:
-                    version = osx_version[0]
+            import plistlib
+            plist = '/System/Library/CoreServices/SystemVersion.plist'
+            if os.path.exists(plist):
+                plist_content = plistlib.readPlist(plist)
+                if 'ProductVersion' in plist_content:
+                    version = plist_content['ProductVersion']
+
         _cache.append(version.split('.'))
     return _cache[0]