1.1 --- a/moinformat/imports.py Wed Oct 06 00:00:30 2021 +0200
1.2 +++ b/moinformat/imports.py Wed Oct 06 00:03:06 2021 +0200
1.3 @@ -3,7 +3,7 @@
1.4 """
1.5 Import utilities.
1.6
1.7 -Copyright (C) 2017, 2018 Paul Boddie <paul@boddie.org.uk>
1.8 +Copyright (C) 2017, 2018, 2021 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 @@ -48,10 +48,10 @@
1.13 store_name = prefix and "%s.%s" % (prefix, leafname) or leafname
1.14 stores[store_name] = import_module("%s.%s" % (modname, leafname))
1.15
1.16 -def get_mapping(modules, get_key, get_value):
1.17 +def get_mapping(modules, get_keys, get_value):
1.18
1.19 """
1.20 - Using the 'modules' mapping, employ 'get_key' and 'get_value' to register
1.21 + Using the 'modules' mapping, employ 'get_keys' and 'get_value' to register
1.22 objects provided by the modules in a mapping.
1.23 """
1.24
1.25 @@ -60,7 +60,13 @@
1.26 # Use the callables to obtain the keys and values from modules.
1.27
1.28 for name, module in modules.items():
1.29 - mapping[get_key(name, module)] = get_value(module)
1.30 + keys = get_keys(name, module)
1.31 + if keys:
1.32 +
1.33 + # Make a mapping for each key to the module concerned.
1.34 +
1.35 + for key in keys:
1.36 + mapping[key] = get_value(module)
1.37
1.38 return mapping
1.39