euscan: added --ignore-pre-release and --ignore-pre-release-if-stable
options Signed-off-by: volpino <fox91@anche.no>
This commit is contained in:
parent
c4577c5279
commit
33a06d99fb
39
bin/euscan
39
bin/euscan
@ -102,34 +102,38 @@ def print_usage(_error=None, help=None):
|
||||
if _error in ('global-options',) or help:
|
||||
print("Available ", yellow("options") + ":", file=out)
|
||||
print(yellow(" -C, --nocolor") +
|
||||
" - turn off colors on output", file=out)
|
||||
" - turn off colors on output", file=out)
|
||||
print(yellow(" -q, --quiet") +
|
||||
" - be as quiet as possible", file=out)
|
||||
" - be as quiet as possible", file=out)
|
||||
print(yellow(" -h, --help") +
|
||||
" - display the help screen", file=out)
|
||||
" - display the help screen", file=out)
|
||||
print(yellow(" -V, --version") +
|
||||
" - display version info", file=out)
|
||||
" - display version info", file=out)
|
||||
print(file=out)
|
||||
print(yellow(" -1, --oneshot") +
|
||||
" - stop as soon as a new version is found",
|
||||
" - stop as soon as a new version is found",
|
||||
file=out)
|
||||
print(yellow(" -b, --brute-force=<level>") +
|
||||
" - define the brute force " + yellow("<level>") +
|
||||
" - define the brute force " + yellow("<level>") +
|
||||
" (default: 2)\n" +
|
||||
" " * 29 + "bigger levels will generate more versions numbers\n" +
|
||||
" " * 29 + "0 means disabled", file=out)
|
||||
" " * 38 + "bigger levels will generate more versions numbers\n" +
|
||||
" " * 38 + "0 means disabled", file=out)
|
||||
print(yellow(" -f, --format=<format>") +
|
||||
" - define the output " + yellow("<format>") +
|
||||
" - define the output " + yellow("<format>") +
|
||||
" (available: json)", file=out)
|
||||
print(yellow(" -p, --progress") +
|
||||
" - display a progress bar", file=out)
|
||||
print(yellow(" -m, --mirror") +
|
||||
" - use mirror:// urls", file=out)
|
||||
" - display a progress bar", file=out)
|
||||
print(yellow(" -i, --ignore-pre-release") +
|
||||
" " * 11 + "- Ignore non-stable versions", file=out)
|
||||
print(yellow(" -I, --ignore-pre-release-if-stable") +
|
||||
" - Ignore non-stable versions only if current\n" +
|
||||
" " * 38 + "version is stable", file=out)
|
||||
|
||||
print(file=out)
|
||||
|
||||
if _error in ('packages',) or help:
|
||||
print(green(" package") +
|
||||
" - the packages (or ebuilds) you want to scan",
|
||||
" " * 28 + "- the packages (or ebuilds) you want to scan",
|
||||
file=out)
|
||||
print(file=out)
|
||||
|
||||
@ -180,6 +184,10 @@ def parse_args():
|
||||
CONFIG['progress'] = isatty
|
||||
elif o in ("-m", "--mirror"):
|
||||
CONFIG['mirror'] = True
|
||||
elif o in ("-i", "--ignore-pre-release"):
|
||||
CONFIG['ignore-pre-release'] = True
|
||||
elif o in ("-I", "--ignore-pre-release-if-stable"):
|
||||
CONFIG['ignore-pre-release-if-stable'] = True
|
||||
else:
|
||||
return_code = False
|
||||
|
||||
@ -187,10 +195,11 @@ def parse_args():
|
||||
|
||||
# here are the different allowed command line options (getopt args)
|
||||
getopt_options = {'short': {}, 'long': {}}
|
||||
getopt_options['short']['global'] = "hVCqv1bf:pm"
|
||||
getopt_options['short']['global'] = "hVCqv1bf:pmiI"
|
||||
getopt_options['long']['global'] = [
|
||||
"help", "version", "nocolor", "quiet", "verbose", "oneshot",
|
||||
"brute-force=", "format=", "progress"
|
||||
"brute-force=", "format=", "progress", "mirror", "ignore-pre-release",
|
||||
"ignore-pre-release-if-stable",
|
||||
]
|
||||
|
||||
short_opts = getopt_options['short']['global']
|
||||
|
@ -22,6 +22,8 @@ CONFIG = {
|
||||
'indent': 2,
|
||||
'progress': False,
|
||||
'mirror': False,
|
||||
'ignore-pre-release': False,
|
||||
'ignore-pre-release-if-stable': False,
|
||||
}
|
||||
|
||||
BLACKLIST_VERSIONS = [
|
||||
|
@ -34,6 +34,10 @@ _v_end = '((-|_)(pre|p|beta|b|alpha|a|rc|r)\d*)'
|
||||
_v = r'((\d+)((\.\d+)*)([a-zA-Z]*?)(' + _v_end + '*))'
|
||||
|
||||
|
||||
def is_version_stable(version):
|
||||
return get_version_type(version) not in ("alpha", "beta", "pre", "rc")
|
||||
|
||||
|
||||
def get_version_type(version):
|
||||
types = []
|
||||
gentoo_types = ("alpha", "beta", "pre", "rc", "p")
|
||||
|
@ -12,7 +12,8 @@ from gentoolkit.query import Query
|
||||
from gentoolkit.package import Package
|
||||
|
||||
from euscan import CONFIG, BLACKLIST_PACKAGES
|
||||
from euscan import handlers, helpers, output
|
||||
from euscan import handlers, output
|
||||
from euscan.helpers import version_blacklisted, is_version_stable
|
||||
from euscan.ebuild import package_from_ebuild
|
||||
|
||||
|
||||
@ -26,7 +27,7 @@ def filter_versions(cp, versions):
|
||||
continue
|
||||
|
||||
# Remove blacklisted versions
|
||||
if helpers.version_blacklisted(cp, version):
|
||||
if version_blacklisted(cp, version):
|
||||
continue
|
||||
|
||||
filtered[version] = {
|
||||
@ -186,6 +187,10 @@ def scan_upstream(query, on_progress=None):
|
||||
output.metadata("description", pkg.environment("DESCRIPTION"))
|
||||
|
||||
cpv = pkg.cpv
|
||||
|
||||
_, _, ver, _ = portage.catpkgsplit(cpv)
|
||||
is_current_version_stable = is_version_stable(ver)
|
||||
|
||||
metadata = {
|
||||
"EAPI": portage.settings["EAPI"],
|
||||
"SRC_URI": pkg.environment("SRC_URI", False),
|
||||
@ -220,6 +225,13 @@ def scan_upstream(query, on_progress=None):
|
||||
print("\n", file=sys.stderr)
|
||||
|
||||
for cp, url, version, handler, confidence in result:
|
||||
if CONFIG["ignore-pre-release"]:
|
||||
if not is_version_stable(version):
|
||||
continue
|
||||
if CONFIG["ignore-pre-release-if-stable"]:
|
||||
if is_current_version_stable and \
|
||||
not is_version_stable(version):
|
||||
continue
|
||||
output.result(cp, version, url, handler, confidence)
|
||||
|
||||
return result
|
||||
|
Loading…
Reference in New Issue
Block a user