예제 #1
0
def basic_test_document(text='', settings_overrides={}):
    reader_name = 'standalone'
    parser_name = 'restructuredtext'

    reader_class = readers.get_reader_class(reader_name)
    reader = reader_class(parser_name=parser_name)
    parser = reader.parser

    # we test some things that generate warnings, but don't want those warnings to pollute the test output
    settings_overrides['warning_stream'] = sys.stdout
    options = frontend.OptionParser(components=(parser,reader), defaults=settings_overrides)
    settings = options.get_default_values()
    document = utils.new_document('rst_test_utils', settings)

    parser.parse(text, document)

    #print 'parser.parse(), document=\n%s' % document.asdom().childNodes[0].toprettyxml('    ','\n')
    return document
예제 #2
0
def basic_test_document(text='', settings_overrides={}):
    reader_name = 'standalone'
    parser_name = 'restructuredtext'

    reader_class = readers.get_reader_class(reader_name)
    reader = reader_class(parser_name=parser_name)
    parser = reader.parser

    # we test some things that generate warnings, but don't want those warnings to pollute the test output
    settings_overrides['warning_stream'] = sys.stdout
    options = frontend.OptionParser(components=(parser, reader),
                                    defaults=settings_overrides)
    settings = options.get_default_values()
    document = utils.new_document('rst_test_utils', settings)

    parser.parse(text, document)

    #print 'parser.parse(), document=\n%s' % document.asdom().childNodes[0].toprettyxml('    ','\n')
    return document
예제 #3
0
 def set_reader(self, reader_name, parser, parser_name):
     """Set `self.reader` by name."""
     reader_class = readers.get_reader_class(reader_name)
     self.reader = reader_class(parser, parser_name)
     self.parser = self.reader.parser
예제 #4
0
 def set_reader(self, reader_name, parser, parser_name):
     """Set `self.reader` by name."""
     reader_class = readers.get_reader_class(reader_name)
     self.reader = reader_class(parser, parser_name)
     self.parser = self.reader.parser
 def test_local_reader(self):
     # requires local-reader.py in test directory (testroot)
     wr = get_reader_class('local-reader')
 def test_registered_reader(self):
     rdr = get_reader_class('pep')
예제 #7
0
파일: page.py 프로젝트: hforge/wiki
# Import from itools
from itools.gettext import MSG
from itools.handlers import checkid
from itools.uri import get_reference
from itools.web import get_context

# Import from ikaaro
from ikaaro.text import Text
from ikaaro.resource_ import DBResource
from page_views import WikiPage_View, WikiPage_Edit, WikiPage_Help
from page_views import WikiPage_ToPDF, WikiPage_ToODT, WikiPage_HelpODT
from page_views import is_external, BacklinksMenu



StandaloneReader = get_reader_class('standalone')



def language(argument):
    try:
        return argument.encode()
    except UnicodeEncodeError:
        raise ValueError('expected "xx-YY" language-COUNTRY code')


def yesno(argument):
    return directives.choice(argument, ('yes', 'no'))


예제 #8
0
 def test_local_reader(self):
     # requires local-reader.py in test directory (testroot)
     wr = get_reader_class('local-reader')
예제 #9
0
 def test_registered_reader(self):
     rdr = get_reader_class('pep')