Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/docutils/transforms/components.py @ 2:6af9afd405e9 draft
"planemo upload commit 0a63dd5f4d38a1f6944587f52a8cd79874177fc1"
| author | shellac |
|---|---|
| date | Thu, 14 May 2020 14:56:58 -0400 |
| parents | 26e78fe6e8c4 |
| children |
comparison
equal
deleted
inserted
replaced
| 1:75ca89e9b81c | 2:6af9afd405e9 |
|---|---|
| 1 # $Id: components.py 4564 2006-05-21 20:44:42Z wiemann $ | |
| 2 # Author: David Goodger <goodger@python.org> | |
| 3 # Copyright: This module has been placed in the public domain. | |
| 4 | |
| 5 """ | |
| 6 Docutils component-related transforms. | |
| 7 """ | |
| 8 | |
| 9 __docformat__ = 'reStructuredText' | |
| 10 | |
| 11 import sys | |
| 12 import os | |
| 13 import re | |
| 14 import time | |
| 15 from docutils import nodes, utils | |
| 16 from docutils import ApplicationError, DataError | |
| 17 from docutils.transforms import Transform, TransformError | |
| 18 | |
| 19 | |
| 20 class Filter(Transform): | |
| 21 | |
| 22 """ | |
| 23 Include or exclude elements which depend on a specific Docutils component. | |
| 24 | |
| 25 For use with `nodes.pending` elements. A "pending" element's dictionary | |
| 26 attribute ``details`` must contain the keys "component" and "format". The | |
| 27 value of ``details['component']`` must match the type name of the | |
| 28 component the elements depend on (e.g. "writer"). The value of | |
| 29 ``details['format']`` is the name of a specific format or context of that | |
| 30 component (e.g. "html"). If the matching Docutils component supports that | |
| 31 format or context, the "pending" element is replaced by the contents of | |
| 32 ``details['nodes']`` (a list of nodes); otherwise, the "pending" element | |
| 33 is removed. | |
| 34 | |
| 35 For example, the reStructuredText "meta" directive creates a "pending" | |
| 36 element containing a "meta" element (in ``pending.details['nodes']``). | |
| 37 Only writers (``pending.details['component'] == 'writer'``) supporting the | |
| 38 "html" format (``pending.details['format'] == 'html'``) will include the | |
| 39 "meta" element; it will be deleted from the output of all other writers. | |
| 40 """ | |
| 41 | |
| 42 default_priority = 780 | |
| 43 | |
| 44 def apply(self): | |
| 45 pending = self.startnode | |
| 46 component_type = pending.details['component'] # 'reader' or 'writer' | |
| 47 format = pending.details['format'] | |
| 48 component = self.document.transformer.components[component_type] | |
| 49 if component.supports(format): | |
| 50 pending.replace_self(pending.details['nodes']) | |
| 51 else: | |
| 52 pending.parent.remove(pending) |
