euscan: better output

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
This commit is contained in:
Corentin Chary 2011-09-21 10:58:41 +02:00
parent a13d593d8d
commit 7fb4e6edff
2 changed files with 37 additions and 20 deletions

View File

@ -23,9 +23,11 @@ import errno
import httplib
from portage.output import white, yellow, turquoise, green, EOutput
from portage.exception import AmbiguousPackageName
import gentoolkit.pprinter as pp
from gentoolkit import pprinter as pp
from gentoolkit.eclean.search import (port_settings)
from gentoolkit.errors import GentoolkitException
from euscan import CONFIG, output
from euscan.scan import scan_upstream
@ -77,7 +79,7 @@ def printUsage(_error=None, help=None):
if _error in ('global-options', 'packages',) or help == 'all':
print( " "+turquoise(__productname__),
yellow("[options]"),
green("<package>"), file=out)
green("<package> [<package> [...]]"), file=out)
if _error in ('global-options',) or help == 'all':
print( " "+turquoise(__productname__),
yellow("[--help, --version]"), file=out)
@ -103,7 +105,7 @@ def printUsage(_error=None, help=None):
print( file=out)
if _error in ('packages',) or help:
print( green(" package")+
" - the package (or ebuild) you want to scan", file=out)
" - the packages (or ebuilds) you want to scan", file=out)
print( file=out)
'''print( "More detailed instruction can be found in",
turquoise("`man %s`" % __productname__), file=out)'''
@ -167,10 +169,10 @@ def parseArgs():
' set options accordingly '
optionSwitch(opts)
if len(args) != 1:
if len(args) < 1:
raise ParseArgsException('packages')
return args[0]
return args
def main():
"""Parse command line and execute all actions."""
@ -180,7 +182,7 @@ def main():
pp.output.nocolor()
' parse command line options and actions '
try:
package = parseArgs()
packages = parseArgs()
except ParseArgsException as e:
if e.value == 'help':
printUsage(help='all')
@ -197,22 +199,39 @@ def main():
""" Change euscan's output """
output = EOutput(CONFIG['quiet'])
ret = scan_upstream(package)
if CONFIG['verbose'] > 2:
httplib.HTTPConnection.debuglevel = 1
print ()
for package in packages:
try:
ret = scan_upstream(package)
except AmbiguousPackageName as e:
pkgs = e.args[0]
for candidate in pkgs:
print(candidate)
for url, version in ret:
print ("Upstream Version: "
+ pp.number("%s" % version)
+ pp.path(" %s" % url))
from os.path import basename # To get the short name
if not len(ret):
print (pp.warn("Didn't find any new version, "
+ "check package's homepage for "
+ "more informations"));
print(file=sys.stderr)
print(pp.error("The short ebuild name '%s' is ambiguous. Please specify" % basename(pkgs[0])),
file=sys.stderr, end="")
pp.die(1, "one of the above fully-qualified ebuild names instead.")
except GentoolkitException as err:
pp.die(1, str(err))
finally:
ret = []
print ()
for url, version in ret:
print ("Upstream Version: "
+ pp.number("%s" % version)
+ pp.path(" %s" % url))
if not len(ret):
print (pp.warn("Didn't find any new version, "
+ "check package's homepage for "
+ "more informations"));
if __name__ == "__main__":

View File

@ -1,5 +1,3 @@
from __future__ import print_function
import os
import sys
@ -39,7 +37,7 @@ def scan_upstream_urls(cpv, urls):
for filename in urls:
for url in urls[filename]:
print ()
pp.uprint()
output.einfo("SRC_URI is '%s'" % url)
if '://' not in url: