blob: 3d7608dd7494c27bec34e764ce4634032c12c9bd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# Authors: Martin Blais
# Contact: blais@furius.ca
# Revision: $Revision$
# Date: $Date$
# Copyright: This module has been placed in the public domain.
"""
A writer that pickles the document tree to a binary string.
Later unpickling will allow you to publish with other Writers.
"""
from docutils import writers
import cPickle as pickle
class Writer(writers.UnfilteredWriter):
supported = ('pickle')
"""Formats this writer supports."""
config_section = 'pickle writer'
config_section_dependencies = ('writers',)
output = None
"""Final translated form of `document`."""
def translate(self):
# Remove stuff that cannot be pickled:
self.document.transformer = None
self.document.reporter = None
# Note: we use the highest protocol, it has some binary in it:
self.output = pickle.dumps(self.document)
|