Gentoo Archives: gentoo-catalyst

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

Replies