# HG changeset patch # User Paul Boddie # Date 1532629814 -7200 # Node ID 14630fa05ae7c8cf7d49b5637e5a43df941f070c # Parent 68fb30a6392d275042f43d50f9abc234d37ec12e Moved convenience function implementations into the relevant subpackages. diff -r 68fb30a6392d -r 14630fa05ae7 moinformat/__init__.py --- a/moinformat/__init__.py Thu Jul 26 20:09:48 2018 +0200 +++ b/moinformat/__init__.py Thu Jul 26 20:30:14 2018 +0200 @@ -20,37 +20,7 @@ """ from moinformat.links import make_linker -from moinformat.parsers import parse, parsers as all_parsers -from moinformat.serialisers import serialise, serialisers as all_serialisers - -def get_parser(name="moin"): - - "Return the parser class supporting the format with the given 'name'." - - return all_parsers[name] - -def make_parser(name="moin"): - - "Return a parser instance for the format with the given 'name'." - - return get_parser(name)(all_parsers) - -def get_serialiser(name): - - "Return the main serialiser class for the format having the given 'name'." - - return all_serialisers["%s.moin" % name] - -def make_serialiser(name, linker=None): - - """ - Return a serialiser instance for the format having the given 'name'. - - The optional 'linker' is used to control which linking scheme is used with - the serialiser, with the default having the same name as the serialiser. - """ - - linker = linker or make_linker(name, "") - return get_serialiser(name)(formats=all_serialisers, linker=linker) +from moinformat.parsers import get_parser, make_parser, parse +from moinformat.serialisers import get_serialiser, make_serialiser, serialise # vim: tabstop=4 expandtab shiftwidth=4 diff -r 68fb30a6392d -r 14630fa05ae7 moinformat/parsers/__init__.py --- a/moinformat/parsers/__init__.py Thu Jul 26 20:09:48 2018 +0200 +++ b/moinformat/parsers/__init__.py Thu Jul 26 20:30:14 2018 +0200 @@ -24,6 +24,18 @@ # Top-level functions. +def get_parser(name="moin"): + + "Return the parser class supporting the format with the given 'name'." + + return parsers[name] + +def make_parser(name="moin"): + + "Return a parser instance for the format with the given 'name'." + + return get_parser(name)(parsers) + def parse(s, parser=None): "Parse 's' with 'parser' or the Moin format parser if omitted." diff -r 68fb30a6392d -r 14630fa05ae7 moinformat/serialisers/__init__.py --- a/moinformat/serialisers/__init__.py Thu Jul 26 20:09:48 2018 +0200 +++ b/moinformat/serialisers/__init__.py Thu Jul 26 20:30:14 2018 +0200 @@ -19,11 +19,30 @@ this program. If not, see . """ +from moinformat.links import make_linker from moinformat.serialisers.manifest import serialisers from moinformat.serialisers.moin.moin import MoinSerialiser # Top-level functions. +def get_serialiser(name): + + "Return the main serialiser class for the format having the given 'name'." + + return serialisers["%s.moin" % name] + +def make_serialiser(name, linker=None): + + """ + Return a serialiser instance for the format having the given 'name'. + + The optional 'linker' is used to control which linking scheme is used with + the serialiser, with the default having the same name as the serialiser. + """ + + linker = linker or make_linker(name, "") + return get_serialiser(name)(formats=serialisers, linker=linker) + def serialise(doc, serialiser=None): """