1 |
commit: 6a38e62e143df9bda84da1ce8a54948c57e833fa |
2 |
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Oct 12 00:55:05 2015 +0000 |
4 |
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Oct 28 16:49:56 2015 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/catalyst.git/commit/?id=6a38e62e |
7 |
|
8 |
make_target_table: rewrite for py3/stability |
9 |
|
10 |
doc/make_target_table.py | 32 ++++++++++++++++++-------------- |
11 |
1 file changed, 18 insertions(+), 14 deletions(-) |
12 |
|
13 |
diff --git a/doc/make_target_table.py b/doc/make_target_table.py |
14 |
index f127c37..9eb072b 100755 |
15 |
--- a/doc/make_target_table.py |
16 |
+++ b/doc/make_target_table.py |
17 |
@@ -1,4 +1,4 @@ |
18 |
-#!/usr/bin/env python2 |
19 |
+#!/usr/bin/python |
20 |
# Copyright (C) 2012 W. Trevor King <wking@××××××.edu> |
21 |
# Copyright (C) 2012 Sebastian Pipping <sebastian@×××××××.org> |
22 |
# Copyright (C) 2013 Brian dolbec <dolsen@g.o> |
23 |
@@ -10,34 +10,38 @@ |
24 |
|
25 |
from __future__ import print_function |
26 |
|
27 |
-import sys as _sys |
28 |
- |
29 |
import glob |
30 |
-import re |
31 |
+import locale |
32 |
+import os |
33 |
+import sys |
34 |
|
35 |
|
36 |
-def key_netboot_before_netboot2((target_name, _module)): |
37 |
- return target_name + '1' |
38 |
+def main(_argv): |
39 |
+ source_root = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) |
40 |
|
41 |
+ # Force consistent sorting order. |
42 |
+ locale.setlocale(locale.LC_COLLATE, 'C') |
43 |
|
44 |
-if __name__ == '__main__': |
45 |
- extractor = re.compile('^catalyst/targets/(([^ ]+)).py$') |
46 |
targets = list() |
47 |
- for filename in sorted(glob.glob('catalyst/targets/*.py')): |
48 |
+ for filename in glob.glob(os.path.join(source_root, 'catalyst/targets/*.py')): |
49 |
if '__init__' in filename: |
50 |
continue |
51 |
|
52 |
- match = extractor.match(filename) |
53 |
- target_name = match.group(2).replace('_', '-') |
54 |
- module_name = 'catalyst.targets.' + match.group(1) |
55 |
+ name = os.path.basename(filename)[0:-3] |
56 |
+ target_name = name.replace('_', '-') |
57 |
+ module_name = 'catalyst.targets.' + name |
58 |
|
59 |
__import__(module_name) |
60 |
- module = _sys.modules[module_name] |
61 |
+ module = sys.modules[module_name] |
62 |
|
63 |
targets.append((target_name, module)) |
64 |
|
65 |
- for target_name, module in sorted(targets, key=key_netboot_before_netboot2): |
66 |
+ for target_name, module in sorted(targets, key=lambda x: x[0]): |
67 |
print('`%s`;;' % target_name) |
68 |
# Replace blank lines with `+` (asciidoc list item continuation) |
69 |
print(module.__doc__.strip().replace('\n\n', '\n+\n')) |
70 |
print('') |
71 |
+ |
72 |
+ |
73 |
+if __name__ == '__main__': |
74 |
+ main(sys.argv[1:]) |