From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 1B676138D02 for ; Wed, 24 Jun 2015 12:14:23 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id E2597E09A1; Wed, 24 Jun 2015 12:14:21 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 13743E0999 for ; Wed, 24 Jun 2015 12:14:21 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 393AE340912 for ; Wed, 24 Jun 2015 12:14:20 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 2191AA54 for ; Wed, 24 Jun 2015 12:14:18 +0000 (UTC) From: "Gilles Dartiguelongue" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Gilles Dartiguelongue" Message-ID: <1435148006.e2bca7ae46a92bd68f9335ac8b809364ff7f4814.eva@gentoo> Subject: [gentoo-commits] proj/gnome:gen_archlist_cleanup commit in: scripts/ X-VCS-Repository: proj/gnome X-VCS-Files: scripts/gen_archlist.py X-VCS-Directories: scripts/ X-VCS-Committer: eva X-VCS-Committer-Name: Gilles Dartiguelongue X-VCS-Revision: e2bca7ae46a92bd68f9335ac8b809364ff7f4814 X-VCS-Branch: gen_archlist_cleanup Date: Wed, 24 Jun 2015 12:14:18 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: b70e5480-efd0-4c82-993e-d71fd9a2a432 X-Archives-Hash: f4d9a9f7d6d12c916a2b07db5b95ba4d commit: e2bca7ae46a92bd68f9335ac8b809364ff7f4814 Author: Gilles Dartiguelongue gentoo org> AuthorDate: Wed Jun 24 11:26:24 2015 +0000 Commit: Gilles Dartiguelongue gentoo org> CommitDate: Wed Jun 24 12:13:26 2015 +0000 URL: https://gitweb.gentoo.org/proj/gnome.git/commit/?id=e2bca7ae scripts/gen_archlist: Move dev style configuration to argparse This commit actually breaks the script since some functions do not have proper arguments to handle configuration from main entry-point. scripts/gen_archlist.py | 71 ++++++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 39 deletions(-) diff --git a/scripts/gen_archlist.py b/scripts/gen_archlist.py index e41b20d..1a57fe2 100755 --- a/scripts/gen_archlist.py +++ b/scripts/gen_archlist.py @@ -23,6 +23,7 @@ from __future__ import division +import argparse import os import sys @@ -50,36 +51,19 @@ EXTREME_DEBUG = False CHECK_DEPS = False APPEND_SLOTS = False # Check for stable keywords +# This is intended to switch between keywordreq (for ~arch) +# and stablereq (for moving from ~arch to arch) STABLE = True +# if not STABLE: +# print 'Currently broken for anything except STABLEREQ' +# print 'Please set STABLE to True' +# sys.exit(1) + ############### # Preparation # ############### ALL_CPV_KWS = [] -OLD_REL = None -NEW_REL = None - -if __name__ == "__main__": - try: - CP_FILE = sys.argv[1] # File which has the cp list - except IndexError: - print """Usage: %s [old_rel] [new_rel] - -Where is a file with a category/package list - [old_rel] is an optional argument for specifying which release cycle - to use to get the cpv which has the keyword we need - i.e., which cpvs will we get the list of keywords from? - [new_rel] is an optional argument for specifying which release cycle - to use to get the latest cpv on which we want keywords - i.e., which cpvs will go in the list? -WARNING: the logic for old_rel & new_rel is very incomplete. See TODO -""" % sys.argv[0] - sys.exit(0) - -if len(sys.argv) > 2: - OLD_REL = sys.argv[2] - if len(sys.argv) > 3: - NEW_REL = sys.argv[3] ARCHES = None if STABLE: @@ -87,17 +71,6 @@ if STABLE: else: ARCHES = UNSTABLE_ARCHES -if 'CHECK_DEPS' in os.environ: - CHECK_DEPS = os.environ['CHECK_DEPS'] - -if 'APPEND_SLOTS' in os.environ: - APPEND_SLOTS = os.environ['APPEND_SLOTS'] - -if not STABLE: - print 'Currently broken for anything except STABLEREQ' - print 'Please set STABLE to True' - sys.exit(1) - #################### # Define Functions # @@ -495,7 +468,26 @@ def prettify(cpv_kws): # cpvs that will make it to the final list def main(): """Where the magic happens!""" - for i in open(CP_FILE).readlines(): + parser = argparse.ArgumentParser( + description='Generate a stabilization request for multiple packages' + ) + parser.add_argument('-d', '--debug', help='Make output more verbose') + parser.add_argument('--extreme-debug', + help='Make output even more verbose') + parser.add_argument('--check-dependencies', help='') + parser.add_argument('--append-slots', help='Append slots to CPVs output') + parser.add_argument('file', help='File to read CP from') + parser.add_argument('old_version', nargs='?', + help='An optional argument specifying which release' + ' cycle to use to get CPVs which has the' + ' reference keywords for stabilization.') + parser.add_argument('new_version', nargs='?', + help='An optional argument specifying which release' + ' cycle to use to get the latest CPVs that needs' + ' to be stabilized') + args = parser.parse_args() + + for i in open(args.file).readlines(): cp = i[:-1] if cp.startswith('#') or cp.isspace() or not cp: ALL_CPV_KWS.append(cp) @@ -507,13 +499,14 @@ def main(): atoms = [cp] else: # Get all the atoms matching the given cp - cpvs = match_wanted_atoms(cp, release=NEW_REL) + cpvs = match_wanted_atoms(cp, release=args.new_version) for cpv in get_per_slot_cpvs(cpvs): if not cpv: debug('%s: Invalid cpv' % cpv) continue - kws_missing = max_kws(cpv, release=OLD_REL) + + kws_missing = max_kws(cpv, release=args.old_version) if kws_missing == []: # Current cpv has the max keywords => nothing to do nothing_to_be_done(cpv) @@ -524,7 +517,7 @@ def main(): arches = make_unstable(ARCHES) kws_missing = [kw[1:] for kw in get_kws(cpv, arches)] ALL_CPV_KWS += fix_nesting(gen_cpv_kws(cpv, kws_missing, set())) - if CHECK_DEPS: + if args.check_dependencies: ALL_CPV_KWS.append(LINE_SEP) ALL_CPV_KWS = consolidate_dupes(ALL_CPV_KWS)