paul@0 | 1 | #!/usr/bin/env python |
paul@0 | 2 | |
paul@0 | 3 | """ |
paul@42 | 4 | Moin wiki format tools. |
paul@0 | 5 | |
paul@62 | 6 | Copyright (C) 2017, 2018 Paul Boddie <paul@boddie.org.uk> |
paul@0 | 7 | |
paul@0 | 8 | This program is free software; you can redistribute it and/or modify it under |
paul@0 | 9 | the terms of the GNU General Public License as published by the Free Software |
paul@0 | 10 | Foundation; either version 3 of the License, or (at your option) any later |
paul@0 | 11 | version. |
paul@0 | 12 | |
paul@0 | 13 | This program is distributed in the hope that it will be useful, but WITHOUT |
paul@0 | 14 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
paul@0 | 15 | FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
paul@0 | 16 | details. |
paul@0 | 17 | |
paul@0 | 18 | You should have received a copy of the GNU General Public License along with |
paul@0 | 19 | this program. If not, see <http://www.gnu.org/licenses/>. |
paul@0 | 20 | """ |
paul@0 | 21 | |
paul@94 | 22 | from moinformat.links import make_linker |
paul@62 | 23 | from moinformat.parsers import parse, parsers as all_parsers |
paul@62 | 24 | from moinformat.serialisers import serialise, serialisers as all_serialisers |
paul@0 | 25 | |
paul@88 | 26 | def get_parser(name="moin"): |
paul@88 | 27 | |
paul@88 | 28 | "Return the parser class supporting the format with the given 'name'." |
paul@88 | 29 | |
paul@88 | 30 | return all_parsers[name] |
paul@88 | 31 | |
paul@88 | 32 | def make_parser(name="moin"): |
paul@88 | 33 | |
paul@88 | 34 | "Return a parser instance for the format with the given 'name'." |
paul@88 | 35 | |
paul@88 | 36 | return get_parser(name)(all_parsers) |
paul@88 | 37 | |
paul@85 | 38 | def get_serialiser(name): |
paul@85 | 39 | |
paul@88 | 40 | "Return the main serialiser class for the format having the given 'name'." |
paul@85 | 41 | |
paul@85 | 42 | return all_serialisers["%s.moin" % name] |
paul@85 | 43 | |
paul@94 | 44 | def make_serialiser(name, linker=None): |
paul@94 | 45 | |
paul@94 | 46 | """ |
paul@94 | 47 | Return a serialiser instance for the format having the given 'name'. |
paul@94 | 48 | |
paul@94 | 49 | The optional 'linker' is used to control which linking scheme is used with |
paul@94 | 50 | the serialiser, with the default having the same name as the serialiser. |
paul@94 | 51 | """ |
paul@94 | 52 | |
paul@94 | 53 | linker = linker or make_linker(name, "") |
paul@94 | 54 | return get_serialiser(name)(formats=all_serialisers, linker=linker) |
paul@94 | 55 | |
paul@0 | 56 | # vim: tabstop=4 expandtab shiftwidth=4 |