root/galaxy-central/eggs/docutils-0.4-py2.6.egg/docutils/transforms/components.py

リビジョン 3, 2.0 KB (コミッタ: kohda, 14 年 前)

Install Unix tools  http://hannonlab.cshl.edu/galaxy_unix_tools/galaxy.html

行番号 
1# Author: David Goodger
2# Contact: goodger@users.sourceforge.net
3# Revision: $Revision: 3909 $
4# Date: $Date: 2005-09-26 20:17:31 +0200 (Mon, 26 Sep 2005) $
5# Copyright: This module has been placed in the public domain.
6
7"""
8Docutils component-related transforms.
9"""
10
11__docformat__ = 'reStructuredText'
12
13import sys
14import os
15import re
16import time
17from docutils import nodes, utils
18from docutils import ApplicationError, DataError
19from docutils.transforms import Transform, TransformError
20
21
22class Filter(Transform):
23
24    """
25    Include or exclude elements which depend on a specific Docutils component.
26
27    For use with `nodes.pending` elements.  A "pending" element's dictionary
28    attribute ``details`` must contain the keys "component" and "format".  The
29    value of ``details['component']`` must match the type name of the
30    component the elements depend on (e.g. "writer").  The value of
31    ``details['format']`` is the name of a specific format or context of that
32    component (e.g. "html").  If the matching Docutils component supports that
33    format or context, the "pending" element is replaced by the contents of
34    ``details['nodes']`` (a list of nodes); otherwise, the "pending" element
35    is removed.
36
37    For example, the reStructuredText "meta" directive creates a "pending"
38    element containing a "meta" element (in ``pending.details['nodes']``).
39    Only writers (``pending.details['component'] == 'writer'``) supporting the
40    "html" format (``pending.details['format'] == 'html'``) will include the
41    "meta" element; it will be deleted from the output of all other writers.
42    """
43
44    default_priority = 780
45
46    def apply(self):
47        pending = self.startnode
48        component_type = pending.details['component'] # 'reader' or 'writer'
49        format = pending.details['format']
50        component = self.document.transformer.components[component_type]
51        if component.supports(format):
52            pending.replace_self(pending.details['nodes'])
53        else:
54            pending.parent.remove(pending)
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。