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

リビジョン 3, 1.5 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: 1645 $
4# Date: $Date: 2003-08-27 22:50:43 +0200 (Wed, 27 Aug 2003) $
5# Copyright: This module has been placed in the public domain.
6
7"""
8This package contains Docutils parser modules.
9"""
10
11__docformat__ = 'reStructuredText'
12
13from docutils import Component
14
15
16class Parser(Component):
17
18    component_type = 'parser'
19    config_section = 'parsers'
20
21    def parse(self, inputstring, document):
22        """Override to parse `inputstring` into document tree `document`."""
23        raise NotImplementedError('subclass must override this method')
24
25    def setup_parse(self, inputstring, document):
26        """Initial parse setup.  Call at start of `self.parse()`."""
27        self.inputstring = inputstring
28        self.document = document
29        document.reporter.attach_observer(document.note_parse_message)
30
31    def finish_parse(self):
32        """Finalize parse details.  Call at end of `self.parse()`."""
33        self.document.reporter.detach_observer(
34            self.document.note_parse_message)
35
36
37_parser_aliases = {
38      'restructuredtext': 'rst',
39      'rest': 'rst',
40      'restx': 'rst',
41      'rtxt': 'rst',}
42
43def get_parser_class(parser_name):
44    """Return the Parser class from the `parser_name` module."""
45    parser_name = parser_name.lower()
46    if _parser_aliases.has_key(parser_name):
47        parser_name = _parser_aliases[parser_name]
48    module = __import__(parser_name, globals(), locals())
49    return module.Parser
Note: リポジトリブラウザについてのヘルプは TracBrowser を参照してください。