Set the encoding to 'utf_8', if the encoding returned by
[gentoolkit.git] / bin / epkginfo
1 #!/usr/bin/python
2 #
3 # Copyright 2009 Gentoo Technologies, Inc.
4 # Distributed under the terms of the GNU General Public License v2 or later
5 #
6 # $Header$
7
8 """Shortcut to equery meta"""
9
10 from __future__ import print_function
11
12 __authors__ = (
13         'Douglas Anderson <douglasjanderson@gmail.com>: equery meta',
14         'Ned Ludd <solar@gentoo.org>: first full implimentation'
15         'Eldad Zack <eldad@gentoo.org>: earch',
16         'Eric Olinger <EvvL AT RustedHalo DOT net>: metadata'
17         )
18
19 import sys
20
21 from gentoolkit import equery, errors
22 from gentoolkit.equery import mod_usage
23 from gentoolkit.equery.meta import main, print_help
24 from portage.exception import AmbiguousPackageName
25
26 def print_epkginfo_help():
27         print(mod_usage(mod_name="epkginfo"))
28         print()
29         print_help(with_usage=False)
30
31 equery.initialize_configuration()
32 args = sys.argv[1:]
33 if not args or set(('-h', '--help')).intersection(args):
34         print_epkginfo_help()
35 else:
36         try:
37                 main(args)
38         except AmbiguousPackageName as e:
39                 pkgs = e.args[0]
40                 for candidate in pkgs:
41                         print(candidate)
42
43                 from gentoolkit import pprinter as pp
44                 from os.path import basename # To get the short name
45
46                 print(file=sys.stderr)
47                 print(pp.error("The short ebuild name '%s' is ambiguous. Please specify" % basename(pkgs[0])),
48                                 file=sys.stderr, end="")
49                 pp.die(1, "one of the above fully-qualified ebuild names instead.")
50         except errors.GentoolkitException as err:
51                 from gentoolkit import pprinter as pp
52                 pp.die(1, str(err))
53
54 # vim: set ts=4 sw=4 tw=79: