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 7455513888F for ; Mon, 12 Oct 2015 04:36:11 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 1FEECE0858; Mon, 12 Oct 2015 04:36:08 +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 974FDE0818 for ; Mon, 12 Oct 2015 04:36:06 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id BDF2633D3CF for ; Mon, 12 Oct 2015 04:36:05 +0000 (UTC) From: Mike Frysinger To: gentoo-catalyst@lists.gentoo.org Subject: [gentoo-catalyst] [PATCH 2/9] make_target_table: rewrite for py3/stability Date: Mon, 12 Oct 2015 00:35:55 -0400 Message-Id: <1444624562-26162-2-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 2.5.2 In-Reply-To: <1444624562-26162-1-git-send-email-vapier@gentoo.org> References: <1444624562-26162-1-git-send-email-vapier@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-catalyst@lists.gentoo.org Reply-to: gentoo-catalyst@lists.gentoo.org X-Archives-Salt: 3028d61d-3ddd-41ae-a719-a681751be040 X-Archives-Hash: 9270f4d993448d92a470215c3a1f58ed --- doc/make_target_table.py | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/doc/make_target_table.py b/doc/make_target_table.py index f127c37..9eb072b 100755 --- a/doc/make_target_table.py +++ b/doc/make_target_table.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/python # Copyright (C) 2012 W. Trevor King # Copyright (C) 2012 Sebastian Pipping # Copyright (C) 2013 Brian dolbec @@ -10,34 +10,38 @@ from __future__ import print_function -import sys as _sys - import glob -import re +import locale +import os +import sys -def key_netboot_before_netboot2((target_name, _module)): - return target_name + '1' +def main(_argv): + source_root = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) + # Force consistent sorting order. + locale.setlocale(locale.LC_COLLATE, 'C') -if __name__ == '__main__': - extractor = re.compile('^catalyst/targets/(([^ ]+)).py$') targets = list() - for filename in sorted(glob.glob('catalyst/targets/*.py')): + for filename in glob.glob(os.path.join(source_root, 'catalyst/targets/*.py')): if '__init__' in filename: continue - match = extractor.match(filename) - target_name = match.group(2).replace('_', '-') - module_name = 'catalyst.targets.' + match.group(1) + name = os.path.basename(filename)[0:-3] + target_name = name.replace('_', '-') + module_name = 'catalyst.targets.' + name __import__(module_name) - module = _sys.modules[module_name] + module = sys.modules[module_name] targets.append((target_name, module)) - for target_name, module in sorted(targets, key=key_netboot_before_netboot2): + for target_name, module in sorted(targets, key=lambda x: x[0]): print('`%s`;;' % target_name) # Replace blank lines with `+` (asciidoc list item continuation) print(module.__doc__.strip().replace('\n\n', '\n+\n')) print('') + + +if __name__ == '__main__': + main(sys.argv[1:]) -- 2.5.2