本文整理汇总了Python中outwiker.pages.wiki.parserfactory.ParserFactory类的典型用法代码示例。如果您正苦于以下问题:Python ParserFactory类的具体用法?Python ParserFactory怎么用?Python ParserFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ParserFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
self.encoding = "utf8"
self.filesPath = u"../test/samplefiles/"
self.__createWiki()
factory = ParserFactory()
self.parser = factory.make (self.testPage, Application.config)
示例2: testCommandTest7
def testCommandTest7 (self):
factory = ParserFactory ()
factory.appendCommand (TestCommand)
parser = factory.make (self.testPage, Application.config)
text = u"""(: test Параметр1 Параметр2=2 Параметр3=3 :)
Текст внутри
команды
(:testend:)
(: test Параметры :)
Контент
(:testend:)"""
result_right = u"""Command name: test
params: Параметр1 Параметр2=2 Параметр3=3
content: Текст внутри
команды
Command name: test
params: Параметры
content: Контент"""
result = parser.toHtml (text)
self.assertEqual (result_right, result, result)
示例3: setUp
def setUp(self):
self.initApplication()
self.filesPath = "../test/samplefiles/"
self.__createWiki()
factory = ParserFactory()
self.parser = factory.make(self.testPage, self.application.config)
示例4: _getCountersList
def _getCountersList(self, page):
parser = ParserFactory().make(page, self._config)
parser.addCommand(NameHarvester(parser))
parser.toHtml(page.content)
result = [u""] + sorted(list(NameHarvester.counters))
return result
示例5: setUp
def setUp(self):
self.encoding = "utf8"
self.__createWiki()
factory = ParserFactory()
self.testPage = self.rootwiki[u"Страница 2"]
self.parser = factory.make (self.testPage, Application.config)
示例6: setUp
def setUp(self):
self.__createWiki()
dirlist = [u"../plugins/testwikicommand"]
loader = PluginsLoader(Application)
loader.load (dirlist)
factory = ParserFactory()
self.parser = factory.make (self.testPage, Application.config)
示例7: setUp
def setUp(self):
# Здесь будет создаваться вики
self.path = mkdtemp(prefix='Абырвалг абыр')
self.filesPath = "../test/samplefiles/"
self.__createWiki()
factory = ParserFactory()
self.parser = factory.make(self.testPage, Application.config)
示例8: testExceptionCommand
def testExceptionCommand (self):
factory = ParserFactory ()
factory.appendCommand (ExceptionCommand)
parser = factory.make (self.testPage, Application.config)
text = u"""(:exception:)"""
result = parser.toHtml(text)
# Исключение не должно бросаться, а должно быть выведено в результирующий текст
self.assertTrue ("Exception" in result, result)
示例9: setUp
def setUp(self):
self.encoding = "utf8"
self.__createWiki()
self.testPage = self.wikiroot[u"Страница 1"]
factory = ParserFactory()
self.parser = factory.make (self.testPage, Application.config)
filesPath = u"../test/samplefiles/"
self.files = [u"image.jpg", u"add.png", u"anchor.png", u"файл с пробелами.tmp", u"dir", u"for_sort"]
self.fullFilesPath = [os.path.join (filesPath, fname) for fname in self.files]
示例10: setUp
def setUp(self):
self.encoding = "utf8"
self.filesPath = u"../test/samplefiles/"
self.pagelinks = [u"Страница 1", u"/Страница 1", u"/Страница 2/Страница 3"]
self.pageComments = [u"Страницо 1", u"Страницо 1", u"Страницо 3"]
self.__createWiki()
factory = ParserFactory()
self.__wikiconfig = WikiConfig (Application.config)
self.__wikiconfig.thumbSizeOptions.value = WikiConfig.THUMB_SIZE_DEFAULT
self.parser = factory.make (self.testPage, Application.config)
示例11: setUp
def setUp(self):
self.initApplication()
self.filesPath = "../test/samplefiles/"
self.__createWiki()
self._config = GeneralGuiConfig(self.application.config)
self._srcDateFormat = self._config.dateTimeFormat.value
self.testPage = self.wikiroot["Страница 1"]
self.testPage.creationdatetime = datetime(2014, 8, 20, 11, 59, 1)
self.testPage.datetime = datetime(2015, 9, 21, 12, 10, 20)
factory = ParserFactory()
self.parser = factory.make(self.testPage, self.application.config)
示例12: setUp
def setUp(self):
self.__pluginname = u"Source"
self.__createWiki()
dirlist = [u"../plugins/source"]
# Путь, где лежат примеры исходников в разных кодировках
self.samplefilesPath = u"../test/samplefiles/sources"
# Пример программы
self.pythonSource = u'''import os
# Комментарий
def hello (count):
"""
Hello world
"""
for i in range (10):
print "Hello world!!!"
'''
self.loader = PluginsLoader(Application)
self.loader.load (dirlist)
self.config = self.loader[self.__pluginname].config
self.config.tabWidth.value = 4
self.config.defaultLanguage.remove_option()
Application.config.remove_section (self.config.section)
self.factory = ParserFactory()
self.parser = self.factory.make (self.testPage, Application.config)
示例13: WikiCounterCommandTest
class WikiCounterCommandTest (unittest.TestCase):
def setUp(self):
self.encoding = "utf8"
self.filesPath = u"../test/samplefiles/"
self.__createWiki()
dirlist = [u"../plugins/testcounter"]
self.loader = PluginsLoader(Application)
self.loader.load (dirlist)
self.factory = ParserFactory()
self.parser = self.factory.make (self.testPage, Application.config)
def __createWiki (self):
# Здесь будет создаваться вики
self.path = u"../test/testwiki"
removeWiki (self.path)
self.rootwiki = WikiDocument.create (self.path)
WikiPageFactory.create (self.rootwiki, u"Страница 1", [])
self.testPage = self.rootwiki[u"Страница 1"]
def tearDown(self):
removeWiki (self.path)
def testPluginLoad (self):
self.assertEqual ( len (self.loader), 1)
def testCounter (self):
text = u"(:counter:) (:counter:)"
validResult = u"1 2"
result = self.parser.toHtml (text)
self.assertEqual (result, validResult)
# Проверим, что для нового парсера счетчик сбрасывается
parser2 = self.factory.make (self.testPage, Application.config)
result2 = parser2.toHtml (text)
self.assertEqual (result2, validResult)
示例14: __createWiki
def __createWiki (self):
# Здесь будет создаваться вики
self.filesPath = u"../test/samplefiles/"
self.wikiroot = WikiDocument.create (self.path)
WikiPageFactory().create (self.wikiroot, u"Страница 2", [])
self.testPage = self.wikiroot[u"Страница 2"]
files = [u"accept.png", u"add.png", u"anchor.png", u"filename.tmp",
u"файл с пробелами.tmp", u"картинка с пробелами.png",
u"image.jpg", u"image.jpeg", u"image.png", u"image.tif", u"image.tiff", u"image.gif",
u"image_01.JPG", u"dir", u"dir.xxx", u"dir.png"]
fullFilesPath = [os.path.join (self.filesPath, fname) for fname in files]
# Прикрепим к двум страницам файлы
Attachment (self.testPage).attach (fullFilesPath)
factory = ParserFactory()
self.parser = factory.make (self.testPage, Application.config)
示例15: setUp
def setUp (self):
self.filesPath = u"../test/samplefiles/"
self.__createWiki()
dirlist = [u"../plugins/texequation"]
self.loader = PluginsLoader(Application)
self.loader.load (dirlist)
self.testPage = self.wikiroot[u"Страница 1"]
self.parser = ParserFactory().make (self.testPage, Application.config)