1.1 --- a/moinformat/parsers/manifest.py Mon Jul 30 23:19:51 2018 +0200
1.2 +++ b/moinformat/parsers/manifest.py Tue Jul 31 00:00:49 2018 +0200
1.3 @@ -3,7 +3,7 @@
1.4 """
1.5 Moin wiki parser manifest.
1.6
1.7 -Copyright (C) 2017 Paul Boddie <paul@boddie.org.uk>
1.8 +Copyright (C) 2017, 2018 Paul Boddie <paul@boddie.org.uk>
1.9
1.10 This program is free software; you can redistribute it and/or modify it under
1.11 the terms of the GNU General Public License as published by the Free Software
1.12 @@ -19,26 +19,17 @@
1.13 this program. If not, see <http://www.gnu.org/licenses/>.
1.14 """
1.15
1.16 -from moinformat.imports import get_extensions
1.17 -from os.path import split
1.18 -
1.19 -reserved = ["__init__", "common", "manifest"]
1.20 -
1.21 -# Obtain details of this module's package.
1.22 -
1.23 -dirname = split(__file__)[0]
1.24 -package = __name__.rsplit(".", 1)[0]
1.25 +from moinformat.imports import get_extensions, get_mapping, get_modules
1.26
1.27 # Define an attribute mapping names to modules.
1.28
1.29 -modules = {}
1.30 -get_extensions(dirname, package, modules, reserved)
1.31 +modules = get_modules(__file__, __name__)
1.32
1.33 # Obtain all parsers.
1.34
1.35 -parsers = {}
1.36 +# Use names declared in each class to register the parsers:
1.37 +# parser.format -> parser
1.38
1.39 -for module_name, module in modules.items():
1.40 - parsers[module_name] = module.parser
1.41 +parsers = get_mapping(modules, lambda n, m: m.parser.format, lambda m: m.parser)
1.42
1.43 # vim: tabstop=4 expandtab shiftwidth=4