Commits

Michał Górny committed d3cc523

Use hardcoded list to generate AttributeMatches from kwargs.

  • Participants
  • Parent commits a10932d

Comments (0)

Files changed (1)

File gentoopm/basepm/filter.py

 			raise KeyError('Invalid keyword argument: %s' % self._k)
 
 class PMTransformedKeywordFilter(PMPackageMatcher):
-	# XXX: transform this to subclass of ..filters.AttributeMatch
-	# hardcode 'foo_bar' -> 'foo.bar' mappings instead of doing magic
-	def __init__(self, key, val):
-		self._getter = SmartAttrGetter(key)
-		self._val = val
-
-	def __call__(self, pkg):
-		return self._val == self._getter(pkg)
+	_map = {
+		'key_category': 'key.category',
+		'key_package': 'key.package',
+		'key_state': 'key.state',
+		'description_short': 'description.short',
+		'description_long': 'description.long'
+	}
+
+	def __new__(self, key, val):
+		from ..filters import AttributeMatch
+		if key in self._map:
+			key = self._map[key]
+		return AttributeMatch(key, val)
 
 def transform_keyword_filters(kwargs):
 	"""