MoinLight

Annotated moinformat/__init__.py

85:15c19a3d61e9
2018-07-24 Paul Boddie Introduced families of serialisers for each output format, with parser-specific serialisers retaining knowledge of how their document tree nodes are to be serialised. Introduced a get_serialiser function as a convenience to replace general access to the all_serialisers dictionary. Changed the dynamic import mechanism to qualify identified module names using package name information.
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@62 22
from moinformat.parsers import parse, parsers as all_parsers
paul@62 23
from moinformat.serialisers import serialise, serialisers as all_serialisers
paul@0 24
paul@85 25
def get_serialiser(name):
paul@85 26
paul@85 27
    "Return the main serialiser for the format having the given 'name'."
paul@85 28
paul@85 29
    return all_serialisers["%s.moin" % name]
paul@85 30
paul@0 31
# vim: tabstop=4 expandtab shiftwidth=4