1.1 --- a/moinformat/__init__.py Thu Jul 26 20:09:48 2018 +0200
1.2 +++ b/moinformat/__init__.py Thu Jul 26 20:30:14 2018 +0200
1.3 @@ -20,37 +20,7 @@
1.4 """
1.5
1.6 from moinformat.links import make_linker
1.7 -from moinformat.parsers import parse, parsers as all_parsers
1.8 -from moinformat.serialisers import serialise, serialisers as all_serialisers
1.9 -
1.10 -def get_parser(name="moin"):
1.11 -
1.12 - "Return the parser class supporting the format with the given 'name'."
1.13 -
1.14 - return all_parsers[name]
1.15 -
1.16 -def make_parser(name="moin"):
1.17 -
1.18 - "Return a parser instance for the format with the given 'name'."
1.19 -
1.20 - return get_parser(name)(all_parsers)
1.21 -
1.22 -def get_serialiser(name):
1.23 -
1.24 - "Return the main serialiser class for the format having the given 'name'."
1.25 -
1.26 - return all_serialisers["%s.moin" % name]
1.27 -
1.28 -def make_serialiser(name, linker=None):
1.29 -
1.30 - """
1.31 - Return a serialiser instance for the format having the given 'name'.
1.32 -
1.33 - The optional 'linker' is used to control which linking scheme is used with
1.34 - the serialiser, with the default having the same name as the serialiser.
1.35 - """
1.36 -
1.37 - linker = linker or make_linker(name, "")
1.38 - return get_serialiser(name)(formats=all_serialisers, linker=linker)
1.39 +from moinformat.parsers import get_parser, make_parser, parse
1.40 +from moinformat.serialisers import get_serialiser, make_serialiser, serialise
1.41
1.42 # vim: tabstop=4 expandtab shiftwidth=4
2.1 --- a/moinformat/parsers/__init__.py Thu Jul 26 20:09:48 2018 +0200
2.2 +++ b/moinformat/parsers/__init__.py Thu Jul 26 20:30:14 2018 +0200
2.3 @@ -24,6 +24,18 @@
2.4
2.5 # Top-level functions.
2.6
2.7 +def get_parser(name="moin"):
2.8 +
2.9 + "Return the parser class supporting the format with the given 'name'."
2.10 +
2.11 + return parsers[name]
2.12 +
2.13 +def make_parser(name="moin"):
2.14 +
2.15 + "Return a parser instance for the format with the given 'name'."
2.16 +
2.17 + return get_parser(name)(parsers)
2.18 +
2.19 def parse(s, parser=None):
2.20
2.21 "Parse 's' with 'parser' or the Moin format parser if omitted."
3.1 --- a/moinformat/serialisers/__init__.py Thu Jul 26 20:09:48 2018 +0200
3.2 +++ b/moinformat/serialisers/__init__.py Thu Jul 26 20:30:14 2018 +0200
3.3 @@ -19,11 +19,30 @@
3.4 this program. If not, see <http://www.gnu.org/licenses/>.
3.5 """
3.6
3.7 +from moinformat.links import make_linker
3.8 from moinformat.serialisers.manifest import serialisers
3.9 from moinformat.serialisers.moin.moin import MoinSerialiser
3.10
3.11 # Top-level functions.
3.12
3.13 +def get_serialiser(name):
3.14 +
3.15 + "Return the main serialiser class for the format having the given 'name'."
3.16 +
3.17 + return serialisers["%s.moin" % name]
3.18 +
3.19 +def make_serialiser(name, linker=None):
3.20 +
3.21 + """
3.22 + Return a serialiser instance for the format having the given 'name'.
3.23 +
3.24 + The optional 'linker' is used to control which linking scheme is used with
3.25 + the serialiser, with the default having the same name as the serialiser.
3.26 + """
3.27 +
3.28 + linker = linker or make_linker(name, "")
3.29 + return get_serialiser(name)(formats=serialisers, linker=linker)
3.30 +
3.31 def serialise(doc, serialiser=None):
3.32
3.33 """