Commits

Michał Górny committed 156b874 Merge

Merge branch 'master' into 0.2.x

Comments (0)

Files changed (7)

gentoopm/__init__.py

 # (c) 2011 Michał Górny <mgorny@gentoo.org>
 # Released under the terms of the 2-clause BSD license.
 
-PV = '0.1.5'
+PV = '0.1.6'
 
 """
 The package version.

gentoopm/basepm/filter.py

 	@param kwargs: keyword arguments, as passed to L{PMPackageSet.filter()}
 	@type kwargs: dict
 	@return: positional arguments representing the keyword filters
-	@rtype: tuple
+	@rtype: iter(L{AttributeMatch})
 	"""
 
-	return tuple([PMTransformedKeywordFilter(k, v)
-			for k, v in kwargs.items()])
+	return itertools.starmap(PMTransformedKeywordFilter, kwargs.items())

gentoopm/basepm/pkgset.py

 # (c) 2011 Michał Górny <mgorny@gentoo.org>
 # Released under the terms of the 2-clause BSD license.
 
+import itertools
 from abc import abstractmethod
 
 from .filter import transform_keyword_filters
 class PMFilteredPackageSet(PMPackageSet):
 	def __init__(self, src, args, kwargs):
 		self._src = src
-		self._args = args + transform_keyword_filters(kwargs)
+		self._args = tuple(itertools.chain(args,
+				transform_keyword_filters(kwargs)))
 
 	def __iter__(self):
 		for el in self._src:

gentoopm/paludispm/pkg.py

 # (c) 2011 Michał Górny <mgorny@gentoo.org>
 # Released under the terms of the 2-clause BSD license.
 
+import itertools
 import paludis
 
 from ..basepm.depend import PMRequiredUseAtom
 	@property
 	def homepages(self):
 		spec = self._get_meta(self._pkg.homepage_key())
-		return SpaceSepTuple([str(x) for x in spec])
+		return SpaceSepTuple(itertools.imap(str, spec))
 
 	@property
 	def keywords(self):
 		kws = self._get_meta(self._pkg.keywords_key())
-		return SpaceSepFrozenSet([str(x) for x in kws])
+		return SpaceSepFrozenSet(itertools.imap(str, kws))
 
 	@property
 	def slot(self):

gentoopm/portagepm/pkg.py

 # (c) 2011 Michał Górny <mgorny@gentoo.org>
 # Released under the terms of the 2-clause BSD license.
 
+import itertools
 from portage.versions import cpv_getkey, cpv_getversion, vercmp
 
 from ..basepm.depend import PMRequiredUseAtom
 		return PortagePackageVersion(self._cpv)
 
 	def _aux_get(self, *keys):
-		val = [str(x) for x
-				in self._dbapi.aux_get(self._cpv, keys)]
+		val = itertools.imap(str, self._dbapi.aux_get(self._cpv, keys))
 		if len(keys) == 1:
-			return val[0]
+			return next(iter(val))
 		else:
 			return tuple(val)
 
 		return self._dbapi.getRepositoryName(self._tree)
 
 	def _aux_get(self, *keys):
-		val = [str(x) for x in self._dbapi.aux_get
-				(self._cpv, keys, mytree = self._tree)]
+		val = itertools.imap(str, self._dbapi.aux_get(self._cpv,
+				keys, mytree = self._tree))
 		if len(keys) == 1:
-			return val[0]
+			return next(iter(val))
 		else:
 			return tuple(val)
 

gentoopm/querycli.py

 import argparse, os.path
 from abc import abstractmethod
 
-from . import get_package_manager
+from . import PV, get_package_manager
 from .util import ABCObject
 
 def _reponame(val):
 		"""
 		Get the name of a working, preferred PM.
 		"""
+		def __init__(self, argparser):
+			PMQueryCommand.__init__(self, argparser)
+			argparser.add_argument('-v', '--with-version',
+				action='store_true', dest='version',
+				help='Print the version as well')
+
 		def __call__(self, pm, args):
-			print(pm.name)
+			if args.version:
+				print('%s %s' % (pm.name, pm.version))
+			else:
+				print(pm.name)
 
 	class repositories(PMQueryCommand):
 		"""
 	def __init__(self):
 		self.argparser = arg = argparse.ArgumentParser()
 
+		arg.add_argument('-V', '--version',
+			action='version', version='%s %s' % (arg.prog, PV))
+
 		subp = arg.add_subparsers(title = 'Sub-commands')
 		for cmd_name, cmd_help, cmd_class in PMQueryCommands():
 			p = subp.add_parser(cmd_name, help=cmd_help)
 		scripts = [
 			'gentoopmq'
 		],
-		
+
 		classifiers = [
-			'Development Status :: 3 - Alpha',
+			'Development Status :: 4 - Beta',
 			'Environment :: Console',
 			'Intended Audience :: System Administrators',
 			'License :: OSI Approved :: BSD License',