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
2.1 --- a/moinformat/input/manifest.py Wed Oct 06 00:00:30 2021 +0200 2.2 +++ b/moinformat/input/manifest.py Wed Oct 06 00:03:06 2021 +0200 2.3 @@ -3,7 +3,7 @@ 2.4 """ 2.5 Input context implementation manifest. 2.6 2.7 -Copyright (C) 2017, 2018 Paul Boddie <paul@boddie.org.uk> 2.8 +Copyright (C) 2017, 2018, 2021 Paul Boddie <paul@boddie.org.uk> 2.9 2.10 This program is free software; you can redistribute it and/or modify it under 2.11 the terms of the GNU General Public License as published by the Free Software 2.12 @@ -30,6 +30,6 @@ 2.13 # Use names declared in each class to register the contexts: 2.14 # input.name -> input 2.15 2.16 -inputs = get_mapping(modules, lambda n, m: m.input.name, lambda m: m.input) 2.17 +inputs = get_mapping(modules, lambda n, m: [m.input.name], lambda m: m.input) 2.18 2.19 # vim: tabstop=4 expandtab shiftwidth=4
3.1 --- a/moinformat/links/manifest.py Wed Oct 06 00:00:30 2021 +0200 3.2 +++ b/moinformat/links/manifest.py Wed Oct 06 00:03:06 2021 +0200 3.3 @@ -3,7 +3,7 @@ 3.4 """ 3.5 Linking scheme implementation manifest. 3.6 3.7 -Copyright (C) 2017, 2018 Paul Boddie <paul@boddie.org.uk> 3.8 +Copyright (C) 2017, 2018, 2021 Paul Boddie <paul@boddie.org.uk> 3.9 3.10 This program is free software; you can redistribute it and/or modify it under 3.11 the terms of the GNU General Public License as published by the Free Software 3.12 @@ -30,6 +30,6 @@ 3.13 # Use names declared in each class to register the linkers: 3.14 # linker.name -> linker 3.15 3.16 -linkers = get_mapping(modules, lambda n, m: m.linker.name, lambda m: m.linker) 3.17 +linkers = get_mapping(modules, lambda n, m: [m.linker.name], lambda m: m.linker) 3.18 3.19 # vim: tabstop=4 expandtab shiftwidth=4
4.1 --- a/moinformat/macros/manifest.py Wed Oct 06 00:00:30 2021 +0200 4.2 +++ b/moinformat/macros/manifest.py Wed Oct 06 00:03:06 2021 +0200 4.3 @@ -3,7 +3,7 @@ 4.4 """ 4.5 Moin macro implementation manifest. 4.6 4.7 -Copyright (C) 2017, 2018 Paul Boddie <paul@boddie.org.uk> 4.8 +Copyright (C) 2017, 2018, 2021 Paul Boddie <paul@boddie.org.uk> 4.9 4.10 This program is free software; you can redistribute it and/or modify it under 4.11 the terms of the GNU General Public License as published by the Free Software 4.12 @@ -30,6 +30,6 @@ 4.13 # Use names declared in each class to register the handlers: 4.14 # macro.name -> macro 4.15 4.16 -macros = get_mapping(modules, lambda n, m: m.macro.name, lambda m: m.macro) 4.17 +macros = get_mapping(modules, lambda n, m: [m.macro.name], lambda m: m.macro) 4.18 4.19 # vim: tabstop=4 expandtab shiftwidth=4
5.1 --- a/moinformat/output/manifest.py Wed Oct 06 00:00:30 2021 +0200 5.2 +++ b/moinformat/output/manifest.py Wed Oct 06 00:03:06 2021 +0200 5.3 @@ -3,7 +3,7 @@ 5.4 """ 5.5 Output context implementation manifest. 5.6 5.7 -Copyright (C) 2017, 2018 Paul Boddie <paul@boddie.org.uk> 5.8 +Copyright (C) 2017, 2018, 2021 Paul Boddie <paul@boddie.org.uk> 5.9 5.10 This program is free software; you can redistribute it and/or modify it under 5.11 the terms of the GNU General Public License as published by the Free Software 5.12 @@ -30,6 +30,6 @@ 5.13 # Use names declared in each class to register the contexts: 5.14 # output.name -> output 5.15 5.16 -outputs = get_mapping(modules, lambda n, m: m.output.name, lambda m: m.output) 5.17 +outputs = get_mapping(modules, lambda n, m: [m.output.name], lambda m: m.output) 5.18 5.19 # vim: tabstop=4 expandtab shiftwidth=4
6.1 --- a/moinformat/parsers/graphviz.py Wed Oct 06 00:00:30 2021 +0200 6.2 +++ b/moinformat/parsers/graphviz.py Wed Oct 06 00:03:06 2021 +0200 6.3 @@ -34,7 +34,7 @@ 6.4 6.5 "A parser for Graphviz content, identifying format directives." 6.6 6.7 - format = "graphviz" 6.8 + formats = ["graphviz", "dot"] 6.9 6.10 # Parser handler methods. 6.11
7.1 --- a/moinformat/parsers/manifest.py Wed Oct 06 00:00:30 2021 +0200 7.2 +++ b/moinformat/parsers/manifest.py Wed Oct 06 00:03:06 2021 +0200 7.3 @@ -3,7 +3,7 @@ 7.4 """ 7.5 Moin wiki parser manifest. 7.6 7.7 -Copyright (C) 2017, 2018 Paul Boddie <paul@boddie.org.uk> 7.8 +Copyright (C) 2017, 2018, 2021 Paul Boddie <paul@boddie.org.uk> 7.9 7.10 This program is free software; you can redistribute it and/or modify it under 7.11 the terms of the GNU General Public License as published by the Free Software 7.12 @@ -28,8 +28,8 @@ 7.13 # Obtain all parsers. 7.14 7.15 # Use names declared in each class to register the parsers: 7.16 -# parser.format -> parser 7.17 +# parser.formats -> parser 7.18 7.19 -parsers = get_mapping(modules, lambda n, m: m.parser.format, lambda m: m.parser) 7.20 +parsers = get_mapping(modules, lambda n, m: m.parser.formats, lambda m: m.parser) 7.21 7.22 # vim: tabstop=4 expandtab shiftwidth=4
8.1 --- a/moinformat/parsers/moin.py Wed Oct 06 00:00:30 2021 +0200 8.2 +++ b/moinformat/parsers/moin.py Wed Oct 06 00:03:06 2021 +0200 8.3 @@ -54,7 +54,7 @@ 8.4 8.5 "A wiki region parser." 8.6 8.7 - format = "moin" 8.8 + formats = ["moin", "wiki"] 8.9 8.10 def __init__(self, metadata, parsers=None, root=None): 8.11
9.1 --- a/moinformat/parsers/table.py Wed Oct 06 00:00:30 2021 +0200 9.2 +++ b/moinformat/parsers/table.py Wed Oct 06 00:03:06 2021 +0200 9.3 @@ -3,7 +3,7 @@ 9.4 """ 9.5 Moin wiki table parser. 9.6 9.7 -Copyright (C) 2017, 2018 Paul Boddie <paul@boddie.org.uk> 9.8 +Copyright (C) 2017, 2018, 2021 Paul Boddie <paul@boddie.org.uk> 9.9 9.10 This program is free software; you can redistribute it and/or modify it under 9.11 the terms of the GNU General Public License as published by the Free Software 9.12 @@ -33,7 +33,7 @@ 9.13 9.14 "A parser for improved table syntax." 9.15 9.16 - format = "table" 9.17 + formats = ["table"] 9.18 9.19 # Principal parser methods. 9.20
10.1 --- a/moinformat/parsers/wiki.py Wed Oct 06 00:00:30 2021 +0200 10.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 10.3 @@ -1,34 +0,0 @@ 10.4 -#!/usr/bin/env python 10.5 - 10.6 -""" 10.7 -Moin wiki table parser (alias). 10.8 - 10.9 -Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> 10.10 - 10.11 -This program is free software; you can redistribute it and/or modify it under 10.12 -the terms of the GNU General Public License as published by the Free Software 10.13 -Foundation; either version 3 of the License, or (at your option) any later 10.14 -version. 10.15 - 10.16 -This program is distributed in the hope that it will be useful, but WITHOUT 10.17 -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 10.18 -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 10.19 -details. 10.20 - 10.21 -You should have received a copy of the GNU General Public License along with 10.22 -this program. If not, see <http://www.gnu.org/licenses/>. 10.23 -""" 10.24 - 10.25 -from moinformat.parsers.moin import MoinParser 10.26 - 10.27 -# Parser functionality. 10.28 - 10.29 -class WikiParser(MoinParser): 10.30 - 10.31 - "An alias for the Moin parser." 10.32 - 10.33 - format = "wiki" 10.34 - 10.35 -parser = WikiParser 10.36 - 10.37 -# vim: tabstop=4 expandtab shiftwidth=4
11.1 --- a/moinformat/serialisers/common.py Wed Oct 06 00:00:30 2021 +0200 11.2 +++ b/moinformat/serialisers/common.py Wed Oct 06 00:03:06 2021 +0200 11.3 @@ -3,7 +3,7 @@ 11.4 """ 11.5 Moin serialiser support. 11.6 11.7 -Copyright (C) 2017, 2018, 2019 Paul Boddie <paul@boddie.org.uk> 11.8 +Copyright (C) 2017, 2018, 2019, 2021 Paul Boddie <paul@boddie.org.uk> 11.9 11.10 This program is free software; you can redistribute it and/or modify it under 11.11 the terms of the GNU General Public License as published by the Free Software 11.12 @@ -23,7 +23,8 @@ 11.13 11.14 "General serialisation support." 11.15 11.16 - format = None # defined by subclasses 11.17 + input_formats = None # defined by subclasses 11.18 + formats = None # defined by subclasses 11.19 11.20 def __init__(self, metadata, serialisers=None): 11.21
12.1 --- a/moinformat/serialisers/html/graphviz.py Wed Oct 06 00:00:30 2021 +0200 12.2 +++ b/moinformat/serialisers/html/graphviz.py Wed Oct 06 00:03:06 2021 +0200 12.3 @@ -49,6 +49,9 @@ 12.4 12.5 "Serialisation of Graphviz regions." 12.6 12.7 + input_formats = ["graphviz", "dot"] 12.8 + formats = ["html"] 12.9 + 12.10 def init(self): 12.11 self.directives = {} 12.12
13.1 --- a/moinformat/serialisers/html/moin.py Wed Oct 06 00:00:30 2021 +0200 13.2 +++ b/moinformat/serialisers/html/moin.py Wed Oct 06 00:03:06 2021 +0200 13.3 @@ -27,7 +27,8 @@ 13.4 13.5 "Serialisation of the page." 13.6 13.7 - format = "html" 13.8 + input_formats = ["moin", "wiki"] 13.9 + formats = ["html"] 13.10 13.11 def _region_tag(self, type): 13.12
14.1 --- a/moinformat/serialisers/html/table.py Wed Oct 06 00:00:30 2021 +0200 14.2 +++ b/moinformat/serialisers/html/table.py Wed Oct 06 00:03:06 2021 +0200 14.3 @@ -3,7 +3,7 @@ 14.4 """ 14.5 HTML serialiser. 14.6 14.7 -Copyright (C) 2017, 2018 Paul Boddie <paul@boddie.org.uk> 14.8 +Copyright (C) 2017, 2018, 2021 Paul Boddie <paul@boddie.org.uk> 14.9 14.10 This program is free software; you can redistribute it and/or modify it under 14.11 the terms of the GNU General Public License as published by the Free Software 14.12 @@ -26,6 +26,8 @@ 14.13 14.14 "Serialisation of the page." 14.15 14.16 + input_formats = ["table"] 14.17 + 14.18 def continuation(self, text): 14.19 pass 14.20
15.1 --- a/moinformat/serialisers/manifest.py Wed Oct 06 00:00:30 2021 +0200 15.2 +++ b/moinformat/serialisers/manifest.py Wed Oct 06 00:03:06 2021 +0200 15.3 @@ -3,7 +3,7 @@ 15.4 """ 15.5 Moin wiki serialiser manifest. 15.6 15.7 -Copyright (C) 2017, 2018 Paul Boddie <paul@boddie.org.uk> 15.8 +Copyright (C) 2017, 2018, 2021 Paul Boddie <paul@boddie.org.uk> 15.9 15.10 This program is free software; you can redistribute it and/or modify it under 15.11 the terms of the GNU General Public License as published by the Free Software 15.12 @@ -30,6 +30,19 @@ 15.13 # Use module paths to register the handlers: 15.14 # output_format.input_format -> serialiser 15.15 15.16 -serialisers = get_mapping(modules, lambda n, m: n, lambda m: m.serialiser) 15.17 +def get_formats(n, m): 15.18 + 15.19 + """ 15.20 + Given module name 'n', inspect the serialiser in module 'm', returning a 15.21 + list of format names. 15.22 + """ 15.23 + 15.24 + l = [] 15.25 + for output_format in m.serialiser.formats: 15.26 + for input_format in m.serialiser.input_formats: 15.27 + l.append("%s.%s" % (output_format, input_format)) 15.28 + return l 15.29 + 15.30 +serialisers = get_mapping(modules, get_formats, lambda m: m.serialiser) 15.31 15.32 # vim: tabstop=4 expandtab shiftwidth=4
16.1 --- a/moinformat/serialisers/moin/graphviz.py Wed Oct 06 00:00:30 2021 +0200 16.2 +++ b/moinformat/serialisers/moin/graphviz.py Wed Oct 06 00:03:06 2021 +0200 16.3 @@ -3,7 +3,7 @@ 16.4 """ 16.5 Moin Graphviz region serialiser. 16.6 16.7 -Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> 16.8 +Copyright (C) 2018, 2021 Paul Boddie <paul@boddie.org.uk> 16.9 16.10 This program is free software; you can redistribute it and/or modify it under 16.11 the terms of the GNU General Public License as published by the Free Software 16.12 @@ -25,6 +25,9 @@ 16.13 16.14 "Serialisation of the page." 16.15 16.16 + input_formats = ["graphviz", "dot"] 16.17 + formats = ["moin", "wiki"] 16.18 + 16.19 def start_block(self): 16.20 pass 16.21
17.1 --- a/moinformat/serialisers/moin/moin.py Wed Oct 06 00:00:30 2021 +0200 17.2 +++ b/moinformat/serialisers/moin/moin.py Wed Oct 06 00:03:06 2021 +0200 17.3 @@ -3,7 +3,7 @@ 17.4 """ 17.5 Moin wiki text serialiser. 17.6 17.7 -Copyright (C) 2017, 2018 Paul Boddie <paul@boddie.org.uk> 17.8 +Copyright (C) 2017, 2018, 2021 Paul Boddie <paul@boddie.org.uk> 17.9 17.10 This program is free software; you can redistribute it and/or modify it under 17.11 the terms of the GNU General Public License as published by the Free Software 17.12 @@ -25,7 +25,8 @@ 17.13 17.14 "Serialisation of the page." 17.15 17.16 - format = "moin" 17.17 + input_formats = ["moin", "wiki"] 17.18 + formats = ["moin", "wiki"] 17.19 17.20 def start_region(self, level, indent, type, extra): 17.21 out = self.out
18.1 --- a/moinformat/serialisers/moin/table.py Wed Oct 06 00:00:30 2021 +0200 18.2 +++ b/moinformat/serialisers/moin/table.py Wed Oct 06 00:03:06 2021 +0200 18.3 @@ -3,7 +3,7 @@ 18.4 """ 18.5 Moin wiki table serialiser. 18.6 18.7 -Copyright (C) 2017, 2018 Paul Boddie <paul@boddie.org.uk> 18.8 +Copyright (C) 2017, 2018, 2021 Paul Boddie <paul@boddie.org.uk> 18.9 18.10 This program is free software; you can redistribute it and/or modify it under 18.11 the terms of the GNU General Public License as published by the Free Software 18.12 @@ -25,6 +25,8 @@ 18.13 18.14 "Serialisation of the page." 18.15 18.16 + input_formats = ["table"] 18.17 + 18.18 def init(self): 18.19 self.first_cell = False 18.20 self.first_row = False
19.1 --- a/moinformat/themes/manifest.py Wed Oct 06 00:00:30 2021 +0200 19.2 +++ b/moinformat/themes/manifest.py Wed Oct 06 00:03:06 2021 +0200 19.3 @@ -3,7 +3,7 @@ 19.4 """ 19.5 Theme implementation manifest. 19.6 19.7 -Copyright (C) 2017, 2018 Paul Boddie <paul@boddie.org.uk> 19.8 +Copyright (C) 2017, 2018, 2021 Paul Boddie <paul@boddie.org.uk> 19.9 19.10 This program is free software; you can redistribute it and/or modify it under 19.11 the terms of the GNU General Public License as published by the Free Software 19.12 @@ -38,6 +38,6 @@ 19.13 # Use module paths to register the contexts: 19.14 # theme_name.output_format -> theme 19.15 19.16 -themes = get_mapping(modules, lambda n, m: n, lambda m: m.theme) 19.17 +themes = get_mapping(modules, lambda n, m: [n], lambda m: m.theme) 19.18 19.19 # vim: tabstop=4 expandtab shiftwidth=4
20.1 --- a/moinformat/tree/moin.py Wed Oct 06 00:00:30 2021 +0200 20.2 +++ b/moinformat/tree/moin.py Wed Oct 06 00:03:06 2021 +0200 20.3 @@ -230,7 +230,7 @@ 20.4 # Retain the same serialiser if no appropriate serialiser could be 20.5 # obtained. 20.6 20.7 - serialiser_name = "%s.%s" % (out.format, self.type) 20.8 + serialiser_name = "%s.%s" % (out.formats[0], self.type) 20.9 serialiser = out.get_serialiser(serialiser_name) 20.10 20.11 # Serialise the region.