Commits

Michał Górny committed aba8a87

Paludis: use helper function for metadata gets.

This should fix issues with empty *DEPEND as well.

Comments (0)

Files changed (1)

gentoopm/paludispm/pkg.py

 	def version(self):
 		return PaludisPackageVersion(self._pkg.version)
 
+	def _get_meta(self, key):
+		if isinstance(key, str):
+			key = self._pkg.find_metadata(key)
+		if key is None:
+			return ()
+		return key.parse_value()
+
 	@property
 	def eapi(self):
-		k = self._pkg.find_metadata('EAPI')
-		return str(k.parse_value())
+		return str(self._get_meta('EAPI'))
 
 	@property
 	def description(self):
 
 	@property
 	def inherits(self):
-		k = self._pkg.find_metadata('INHERITED')
-		if k is None:
-			return SpaceSepFrozenSet(())
-		return SpaceSepFrozenSet(k.parse_value())
+		return SpaceSepFrozenSet(self._get_meta('INHERITED'))
 
 	@property
 	def defined_phases(self):
-		k = self._pkg.find_metadata('DEFINED_PHASES')
-		if k is None:
+		ret = SpaceSepFrozenSet(self._get_meta('DEFINED_PHASES'))
+		if not ret:
 			return None
-		ret = SpaceSepFrozenSet(k.parse_value())
-		if ret == ('-',):
+		elif ret == ('-',):
 			return SpaceSepFrozenSet(())
 		return ret
 
 	@property
 	def homepages(self):
-		spec = self._pkg.homepage_key().parse_value()
+		spec = self._get_meta(self._pkg.homepage_key())
 		return SpaceSepTuple([str(x) for x in spec])
 
 	@property
 	def keywords(self):
-		kws = self._pkg.keywords_key().parse_value()
+		kws = self._get_meta(self._pkg.keywords_key())
 		return SpaceSepFrozenSet([str(x) for x in kws])
 
 	@property
 	def slot(self):
-		k = self._pkg.slot_key()
-		return str(k.parse_value())
+		return str(self._get_meta(self._pkg.slot_key()))
 
 	@property
 	def repository(self):
 	@property
 	def build_dependencies(self):
 		return PaludisPackageDepSet(
-				self._pkg.build_dependencies_key().parse_value(),
+				self._get_meta(self._pkg.build_dependencies_key()),
 				self)
 
 	@property
 	def run_dependencies(self):
 		return PaludisPackageDepSet(
-				self._pkg.run_dependencies_key().parse_value(),
+				self._get_meta(self._pkg.run_dependencies_key()),
 				self)
 
 	@property
 	def post_dependencies(self):
 		return PaludisPackageDepSet(
-				self._pkg.post_dependencies_key().parse_value(),
+				self._get_meta(self._pkg.post_dependencies_key()),
 				self)
 
 	@property
 		k = self._pkg.find_metadata('REQUIRED_USE')
 		if k is None:
 			return None
-		return PaludisPackageDepSet(k.parse_value(), self,
-				PMRequiredUseAtom)
+		return PaludisPackageDepSet(
+				self._get_meta('REQUIRED_USE'),
+				self, PMRequiredUseAtom)
 
 	@property
 	def use(self):
-		iuse = self._pkg.find_metadata('IUSE').parse_value()
+		iuse = self._get_meta('IUSE')
 		return SpaceSepFrozenSet([PaludisUseFlag(x) for x in iuse])
 
 	@property
 class PaludisInstalledID(PaludisID, PMInstalledPackage):
 	@property
 	def contents(self):
-		return PaludisPackageContents(self._pkg.contents_key().parse_value())
+		return PaludisPackageContents(
+				self._get_meta(self._pkg.contents_key()))
 
 class PaludisMetadata(PMPackageMetadata):
 	def __init__(self, pkg):
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 ProjectModifiedEvent.java.
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.