Anonymous avatar Anonymous committed 539fd32

Parse the portage version to determine the correct set API.

Comments (0)

Files changed (1)


 # (c) 2010 Michał Górny <>
 # Released under the terms of the 3-clause BSD license or the GPL-2 license.
-import os
+import os, re
+from portage import VERSION as portage_ver
+# live git tree generates 'vX.Y_rcZ-N-...'
+# ebuilds use 'X.Y_rcZ_pN'
+vmatch = re.match(r'^v?((?:\d+\.)*\d+)(?:_rc(\d+))?(?:(?:_p|-)(\d+))?', str(portage_ver))
+if vmatch:
+	vmatch = vmatch.groups()
+	pv = [int(x) for x in vmatch[0].split('.')]
+	if pv[0] >= 2 or (pv[0] == 2 and len(pv) >= 2 or pv[1] >= 2):
+		if not vmatch[1] or int(vmatch[1]) > 72 or (int(vmatch[1]) == 72 and vmatch[2] and int(vmatch[2]) >= 12):
+			sets_api = 1
+		else:
+			sets_api = 0
+	else:
+		raise ImportError('Portage version %s is not supported.' % portage_ver)
+	raise ImportError('Unable to parse the portage version: %s.' % portage_ver)
+if sets_api == 0:
 	from portage.sets.base import PackageSet
 	from portage.sets import SetConfigError
-except ImportError:
+elif sets_api == 1:
 	from portage._sets.base import PackageSet
 	from portage._sets import SetConfigError
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.