blob: 75f6f4abfe7db8c2e8f957599975a40c90793e0d [file] [log] [blame]
martin f. krafftf37f0682013-06-14 16:36:20 +02001#
2# -*- coding: utf-8 -*-
3#
4# This file is part of reclass (http://github.com/madduck/reclass)
5#
6# Copyright © 2007–13 martin f. krafft <madduck@madduck.net>
7# Released under the terms of the Artistic Licence 2.0
8#
9class OutputterBase(object):
10
11 def __init__(self):
12 pass
13
14 def dump(self, data, pretty_print=False):
15 raise NotImplementedError, "dump() method not yet implemented"
16
17
18class OutputLoader(object):
19
20 def __init__(self, outputter):
21 self._name = outputter + '_outputter'
22 try:
23 self._module = __import__(self._name, globals(), locals(),
24 self._name)
25 except ImportError:
26 raise NotImplementedError
27
28 def load(self, attr='Outputter'):
29 klass = getattr(self._module, attr, None)
30 if klass is None:
31 raise AttributeError, \
32 'Outputter class {0} does not export "{1}"'.format(self._name, klass)
33 return klass