euscan: don't mix spaces and tabs

Signed-off-by: Corentin Chary <corentincj@iksaif.net>
This commit is contained in:
Corentin Chary 2011-09-06 17:35:17 +02:00
parent 2210b2610d
commit c5af0e1937
2 changed files with 46 additions and 55 deletions

View File

@ -37,8 +37,8 @@ def setupSignals():
def exithandler(signum,frame): def exithandler(signum,frame):
signal.signal(signal.SIGINT, signal.SIG_IGN) signal.signal(signal.SIGINT, signal.SIG_IGN)
signal.signal(signal.SIGTERM, signal.SIG_IGN) signal.signal(signal.SIGTERM, signal.SIG_IGN)
print () print ()
sys.exit(errno.EINTR) sys.exit(errno.EINTR)
signal.signal(signal.SIGINT, exithandler) signal.signal(signal.SIGINT, exithandler)
signal.signal(signal.SIGTERM, exithandler) signal.signal(signal.SIGTERM, exithandler)
@ -74,37 +74,37 @@ def printUsage(_error=None, help=None):
print( white("Usage:"), file=out) print( white("Usage:"), file=out)
if _error in ('global-options', 'packages',) or help == 'all': if _error in ('global-options', 'packages',) or help == 'all':
print( " "+turquoise(__productname__), print( " "+turquoise(__productname__),
yellow("[options]"), yellow("[options]"),
green("<package>"), file=out) green("<package>"), file=out)
if _error in ('global-options',) or help == 'all': if _error in ('global-options',) or help == 'all':
print( " "+turquoise(__productname__), print( " "+turquoise(__productname__),
yellow("[--help, --version]"), file=out) yellow("[--help, --version]"), file=out)
print(file=out) print(file=out)
if _error in ('global-options',) or help: if _error in ('global-options',) or help:
print( "Available ", yellow("options")+":", file=out) print( "Available ", yellow("options")+":", file=out)
print( yellow(" -C, --nocolor")+ print( yellow(" -C, --nocolor")+
" - turn off colors on output", file=out) " - turn off colors on output", file=out)
print( yellow(" -q, --quiet")+ print( yellow(" -q, --quiet")+
" - be as quiet as possible", file=out) " - be as quiet as possible", file=out)
print( yellow(" -h, --help")+ \ print( yellow(" -h, --help")+ \
" - display the help screen", file=out) " - display the help screen", file=out)
print( yellow(" -V, --version")+ print( yellow(" -V, --version")+
" - display version info", file=out) " - display version info", file=out)
print( file=out) print( file=out)
print( yellow(" -1, --oneshot")+ print( yellow(" -1, --oneshot")+
" - stop as soon as a new version is found", file=out) " - stop as soon as a new version is found", file=out)
print( yellow(" -b, --brute-force=<level>")+ print( yellow(" -b, --brute-force=<level>")+
" - define the brute force "+yellow("<level>")+" (default: 2)\n" + " - define the brute force "+yellow("<level>")+" (default: 2)\n" +
" " * 29 + "bigger levels will generate more versions numbers\n" + " " * 29 + "bigger levels will generate more versions numbers\n" +
" " * 29 + "0 means disabled", file=out) " " * 29 + "0 means disabled", file=out)
print( file=out) print( file=out)
if _error in ('packages',) or help: if _error in ('packages',) or help:
print( green(" package")+ print( green(" package")+
" - the package (or ebuild) you want to scan", file=out) " - the package (or ebuild) you want to scan", file=out)
print( file=out) print( file=out)
'''print( "More detailed instruction can be found in", '''print( "More detailed instruction can be found in",
turquoise("`man %s`" % __productname__), file=out)''' turquoise("`man %s`" % __productname__), file=out)'''
class ParseArgsException(Exception): class ParseArgsException(Exception):

View File

@ -2,18 +2,9 @@ from __future__ import print_function
import os import os
import sys import sys
import re
import time
import getopt
import random
import urllib2
import StringIO
import pkg_resources
import portage import portage
import portage.versions
from portage import dep
from portage.dbapi import porttree from portage.dbapi import porttree
from portage.output import white, yellow, turquoise, green, teal, red, EOutput from portage.output import white, yellow, turquoise, green, teal, red, EOutput
@ -83,22 +74,22 @@ def scan_upstream(query):
sys.stderr.write(pp.warn("No package matching '%s'" % pp.pkgquery(query))) sys.stderr.write(pp.warn("No package matching '%s'" % pp.pkgquery(query)))
return [] return []
matches = sorted(matches) matches = sorted(matches)
pkg = matches.pop() pkg = matches.pop()
if '9999' in pkg.version: if '9999' in pkg.version:
if len(matches) == 0: if len(matches) == 0:
sys.stderr.write(pp.warn("Package '%s' only have a dev version (9999)" % pp.pkgquery(pkg.cp))) sys.stderr.write(pp.warn("Package '%s' only have a dev version (9999)" % pp.pkgquery(pkg.cp)))
return [] return []
else: else:
pkg = matches.pop() pkg = matches.pop()
if pkg.cp in BLACKLIST_PACKAGES: if pkg.cp in BLACKLIST_PACKAGES:
sys.stderr.write(pp.warn("Package '%s' is blacklisted" % pp.pkgquery(pkg.cp))) sys.stderr.write(pp.warn("Package '%s' is blacklisted" % pp.pkgquery(pkg.cp)))
return [] return []
pp.uprint(" * %s [%s]" % (pp.cpv(pkg.cpv), pp.section(pkg.repo_name()))) pp.uprint(" * %s [%s]" % (pp.cpv(pkg.cpv), pp.section(pkg.repo_name())))
pp.uprint() pp.uprint()
ebuild_path = pkg.ebuild_path() ebuild_path = pkg.ebuild_path()
if ebuild_path: if ebuild_path:
@ -108,23 +99,23 @@ def scan_upstream(query):
pp.uprint('Homepage: ' + pkg.environment("HOMEPAGE")) pp.uprint('Homepage: ' + pkg.environment("HOMEPAGE"))
pp.uprint('Description: ' + pkg.environment("DESCRIPTION")) pp.uprint('Description: ' + pkg.environment("DESCRIPTION"))
cpv = pkg.cpv cpv = pkg.cpv
metadata = { metadata = {
"EAPI" : port_settings["EAPI"], "EAPI" : port_settings["EAPI"],
"SRC_URI" : pkg.environment("SRC_URI", False), "SRC_URI" : pkg.environment("SRC_URI", False),
} }
use = frozenset(port_settings["PORTAGE_USE"].split()) use = frozenset(port_settings["PORTAGE_USE"].split())
try: try:
alist = porttree._parse_uri_map(cpv, metadata, use=use) alist = porttree._parse_uri_map(cpv, metadata, use=use)
aalist = porttree._parse_uri_map(cpv, metadata) aalist = porttree._parse_uri_map(cpv, metadata)
except Exception as e: except Exception as e:
sys.stderr.write(pp.warn("%s\n" % str(e))) sys.stderr.write(pp.warn("%s\n" % str(e)))
sys.stderr.write(pp.warn("Invalid SRC_URI for '%s'" % pp.pkgquery(cpv))) sys.stderr.write(pp.warn("Invalid SRC_URI for '%s'" % pp.pkgquery(cpv)))
return [] return []
if "mirror" in portage.settings.features: if "mirror" in portage.settings.features:
urls = aalist urls = aalist
else: else:
urls = alist urls = alist
return scan_upstream_urls(pkg.cpv, urls) return scan_upstream_urls(pkg.cpv, urls)