public inbox for gentoo-catalyst@lists.gentoo.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
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	[thread overview]
Message-ID: <1444624562-26162-2-git-send-email-vapier@gentoo.org> (raw)
In-Reply-To: <1444624562-26162-1-git-send-email-vapier@gentoo.org>

---
 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 <wking@drexel.edu>
 # Copyright (C) 2012 Sebastian Pipping <sebastian@pipping.org>
 # Copyright (C) 2013 Brian dolbec <dolsen@gentoo.org>
@@ -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



  reply	other threads:[~2015-10-12  4:36 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-12  4:35 [gentoo-catalyst] [PATCH 1/9] convert octals to py3 compat Mike Frysinger
2015-10-12  4:35 ` Mike Frysinger [this message]
2015-10-28 14:46   ` [gentoo-catalyst] [PATCH 2/9] make_target_table: rewrite for py3/stability Brian Dolbec
2015-10-28 16:49     ` Mike Frysinger
2015-10-28 17:15       ` Brian Dolbec
2015-10-12  4:35 ` [gentoo-catalyst] [PATCH 3/9] stagebase: disable undefined-variable lint warning Mike Frysinger
2015-10-12  4:35 ` [gentoo-catalyst] [PATCH 4/9] log: make sure NOTICE is an int Mike Frysinger
2015-10-12  4:35 ` [gentoo-catalyst] [PATCH 5/9] genbase: use sorted() with dict keys Mike Frysinger
2015-10-12  4:35 ` [gentoo-catalyst] [PATCH 6/9] hash_utils: fix bad keyword w/CatalystError Mike Frysinger
2015-10-12  4:36 ` [gentoo-catalyst] [PATCH 7/9] hash_utils: decode output of popen Mike Frysinger
2015-10-28 14:49   ` Brian Dolbec
2015-10-12  4:36 ` [gentoo-catalyst] [PATCH 8/9] lint: convert type/types to isinstance Mike Frysinger
2015-10-28 14:55   ` Brian Dolbec
2015-10-12  4:36 ` [gentoo-catalyst] [PATCH 9/9] lint: fix redefined-outer-name warnings Mike Frysinger
2015-10-28 14:58   ` Brian Dolbec
2015-10-12  4:41 ` [gentoo-catalyst] [PATCH 1/9] convert octals to py3 compat Mike Frysinger
2015-10-22  5:17   ` Mike Frysinger
2015-10-24  7:00     ` Mike Frysinger
2015-10-28 14:25       ` Brian Dolbec
2015-10-24 11:37     ` Anthony G. Basile
2015-10-24 14:16       ` Anthony G. Basile
2015-11-09  4:52         ` Brian Dolbec
2015-11-19  4:19           ` Brian Dolbec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1444624562-26162-2-git-send-email-vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=gentoo-catalyst@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox