1.1 --- a/moinformat/serialisers/manifest.py Mon Jul 30 23:19:51 2018 +0200
1.2 +++ b/moinformat/serialisers/manifest.py Tue Jul 31 00:00:49 2018 +0200
1.3 @@ -3,7 +3,7 @@
1.4 """
1.5 Moin wiki serialiser 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 serialisers.
1.34
1.35 -serialisers = {}
1.36 +# Use names declared in each class to register the handlers:
1.37 +# serialiser.format -> serialiser
1.38
1.39 -for module_name, module in modules.items():
1.40 - serialisers[module_name] = module.serialiser
1.41 +serialisers = get_mapping(modules, lambda n, m: n, lambda m: m.serialiser)
1.42
1.43 # vim: tabstop=4 expandtab shiftwidth=4