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

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

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

行番号 
1# Author: David Goodger
2# Contact: goodger@python.org
3# Revision: $Revision: 4260 $
4# Date: $Date: 2006-01-09 19:28:09 +0100 (Mon, 09 Jan 2006) $
5# Copyright: This module has been placed in the public domain.
6
7"""
8This is the Docutils (Python Documentation Utilities) package.
9
10Package Structure
11=================
12
13Modules:
14
15- __init__.py: Contains component base classes, exception classes, and
16  Docutils version information.
17
18- core.py: Contains the ``Publisher`` class and ``publish_*()`` convenience
19  functions.
20
21- frontend.py: Runtime settings (command-line interface, configuration files)
22  processing, for Docutils front-ends.
23
24- io.py: Provides a uniform API for low-level input and output.
25
26- nodes.py: Docutils document tree (doctree) node class library.
27
28- statemachine.py: A finite state machine specialized for
29  regular-expression-based text filters.
30
31- urischemes.py: Contains a complete mapping of known URI addressing
32  scheme names to descriptions.
33
34- utils.py: Contains the ``Reporter`` system warning class and miscellaneous
35  utilities.
36
37Subpackages:
38
39- languages: Language-specific mappings of terms.
40
41- parsers: Syntax-specific input parser modules or packages.
42
43- readers: Context-specific input handlers which understand the data
44  source and manage a parser.
45
46- transforms: Modules used by readers and writers to modify DPS
47  doctrees.
48
49- writers: Format-specific output translators.
50"""
51
52__docformat__ = 'reStructuredText'
53
54__version__ = '0.4'
55"""``major.minor.micro`` version number.  The micro number is bumped for API
56changes, for new functionality, and for interim project releases.  The minor
57number is bumped whenever there is a significant project release.  The major
58number will be bumped when the project is feature-complete, and perhaps if
59there is a major change in the design."""
60
61__version_details__ = 'release'
62"""Extra version details (e.g. 'snapshot 2005-05-29, r3410', 'repository',
63'release'), modified automatically & manually."""
64
65class ApplicationError(StandardError): pass
66class DataError(ApplicationError): pass
67
68
69class SettingsSpec:
70
71    """
72    Runtime setting specification base class.
73
74    SettingsSpec subclass objects used by `docutils.frontend.OptionParser`.
75    """
76
77    settings_spec = ()
78    """Runtime settings specification.  Override in subclasses.
79
80    Defines runtime settings and associated command-line options, as used by
81    `docutils.frontend.OptionParser`.  This is a tuple of:
82
83    - Option group title (string or `None` which implies no group, just a list
84      of single options).
85   
86    - Description (string or `None`).
87   
88    - A sequence of option tuples.  Each consists of:
89
90      - Help text (string)
91     
92      - List of option strings (e.g. ``['-Q', '--quux']``).
93     
94      - Dictionary of keyword arguments.  It contains arguments to the
95        OptionParser/OptionGroup ``add_option`` method, possibly with the
96        addition of a 'validator' keyword (see the
97        `docutils.frontend.OptionParser.validators` instance attribute).  Runtime
98        settings names are derived implicitly from long option names
99        ('--a-setting' becomes ``settings.a_setting``) or explicitly from the
100        'dest' keyword argument.  See optparse docs for more details.
101
102    - More triples of group title, description, options, as many times as
103      needed.  Thus, `settings_spec` tuples can be simply concatenated.
104    """
105
106    settings_defaults = None
107    """A dictionary of defaults for settings not in `settings_spec` (internal
108    settings, intended to be inaccessible by command-line and config file).
109    Override in subclasses."""
110
111    settings_default_overrides = None
112    """A dictionary of auxiliary defaults, to override defaults for settings
113    defined in other components.  Override in subclasses."""
114
115    relative_path_settings = ()
116    """Settings containing filesystem paths.  Override in subclasses.
117    Settings listed here are to be interpreted relative to the current working
118    directory."""
119
120    config_section = None
121    """The name of the config file section specific to this component
122    (lowercase, no brackets).  Override in subclasses."""
123
124    config_section_dependencies = None
125    """A list of names of config file sections that are to be applied before
126    `config_section`, in order (from general to specific).  In other words,
127    the settings in `config_section` are to be overlaid on top of the settings
128    from these sections.  The "general" section is assumed implicitly.
129    Override in subclasses."""
130
131
132class TransformSpec:
133
134    """
135    Runtime transform specification base class.
136
137    TransformSpec subclass objects used by `docutils.transforms.Transformer`.
138    """
139
140    def get_transforms(self):
141        """Transforms required by this class.  Override in subclasses."""
142        if self.default_transforms != ():
143            import warnings
144            warnings.warn('default_transforms attribute deprecated.\n'
145                          'Use get_transforms() method instead.',
146                          DeprecationWarning)
147            return list(self.default_transforms)
148        return []
149
150    # Deprecated; for compatibility.
151    default_transforms = ()
152
153    unknown_reference_resolvers = ()
154    """List of functions to try to resolve unknown references.  Unknown
155    references have a 'refname' attribute which doesn't correspond to any
156    target in the document.  Called when FinalCheckVisitor is unable to find a
157    correct target.  The list should contain functions which will try to
158    resolve unknown references, with the following signature::
159
160        def reference_resolver(node):
161            '''Returns boolean: true if resolved, false if not.'''
162
163    If the function is able to resolve the reference, it should also remove
164    the 'refname' attribute and mark the node as resolved::
165
166        del node['refname']
167        node.resolved = 1
168
169    Each function must have a "priority" attribute which will affect the order
170    the unknown_reference_resolvers are run::
171
172        reference_resolver.priority = 100
173
174    Override in subclasses."""
175
176
177class Component(SettingsSpec, TransformSpec):
178
179    """Base class for Docutils components."""
180
181    component_type = None
182    """Name of the component type ('reader', 'parser', 'writer').  Override in
183    subclasses."""
184
185    supported = ()
186    """Names for this component.  Override in subclasses."""
187   
188    def supports(self, format):
189        """
190        Is `format` supported by this component?
191
192        To be used by transforms to ask the dependent component if it supports
193        a certain input context or output format.
194        """
195        return format in self.supported
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。