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 F017713888F for ; Wed, 28 Oct 2015 14:47:26 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 6816C21C006; Wed, 28 Oct 2015 14:47: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 0251821C006 for ; Wed, 28 Oct 2015 14:47:20 +0000 (UTC) Received: from professor-x (S010634bdfa9ecf80.vc.shawcable.net [96.49.31.57]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: dolsen) by smtp.gentoo.org (Postfix) with ESMTPSA id E3BB8340662 for ; Wed, 28 Oct 2015 14:47:18 +0000 (UTC) Date: Wed, 28 Oct 2015 07:46:29 -0700 From: Brian Dolbec To: gentoo-catalyst@lists.gentoo.org Subject: Re: [gentoo-catalyst] [PATCH 2/9] make_target_table: rewrite for py3/stability Message-ID: <20151028074629.2305a8a2.dolsen@gentoo.org> In-Reply-To: <1444624562-26162-2-git-send-email-vapier@gentoo.org> References: <1444624562-26162-1-git-send-email-vapier@gentoo.org> <1444624562-26162-2-git-send-email-vapier@gentoo.org> Organization: Gentoo 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 MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Archives-Salt: eb843abd-327e-4bb4-a2d8-0d88d508afcd X-Archives-Hash: 7873a4872d3eb78efceffd803e6ab91a On Mon, 12 Oct 2015 00:35:55 -0400 Mike Frysinger wrote: > --- > 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:]) looks harmless enough ;) test will be when generating the docs making a release -- Brian Dolbec