当前位置: 首页>>代码示例>>Python>>正文


Python ParserFactory.make方法代码示例

本文整理汇总了Python中outwiker.pages.wiki.parserfactory.ParserFactory.make方法的典型用法代码示例。如果您正苦于以下问题:Python ParserFactory.make方法的具体用法?Python ParserFactory.make怎么用?Python ParserFactory.make使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在outwiker.pages.wiki.parserfactory.ParserFactory的用法示例。


在下文中一共展示了ParserFactory.make方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testCommandTest7

# 需要导入模块: from outwiker.pages.wiki.parserfactory import ParserFactory [as 别名]
# 或者: from outwiker.pages.wiki.parserfactory.ParserFactory import make [as 别名]
    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)
开发者ID:qyqx,项目名称:outwiker,代码行数:29,代码来源:wikicommands.py

示例2: setUp

# 需要导入模块: from outwiker.pages.wiki.parserfactory import ParserFactory [as 别名]
# 或者: from outwiker.pages.wiki.parserfactory.ParserFactory import make [as 别名]
    def setUp(self):
        self.encoding = "utf8"
        self.filesPath = u"../test/samplefiles/"

        self.__createWiki()
        factory = ParserFactory()
        self.parser = factory.make (self.testPage, Application.config)
开发者ID:qyqx,项目名称:outwiker,代码行数:9,代码来源:parserquote.py

示例3: WikiCounterCommandTest

# 需要导入模块: from outwiker.pages.wiki.parserfactory import ParserFactory [as 别名]
# 或者: from outwiker.pages.wiki.parserfactory.ParserFactory import make [as 别名]
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)
开发者ID:qyqx,项目名称:outwiker,代码行数:49,代码来源:wikicommandcounter.py

示例4: setUp

# 需要导入模块: from outwiker.pages.wiki.parserfactory import ParserFactory [as 别名]
# 或者: from outwiker.pages.wiki.parserfactory.ParserFactory import make [as 别名]
    def setUp(self):
        self.initApplication()

        self.filesPath = "../test/samplefiles/"
        self.__createWiki()

        factory = ParserFactory()
        self.parser = factory.make(self.testPage, self.application.config)
开发者ID:Jenyay,项目名称:outwiker,代码行数:10,代码来源:test_wikicommands.py

示例5: setUp

# 需要导入模块: from outwiker.pages.wiki.parserfactory import ParserFactory [as 别名]
# 或者: from outwiker.pages.wiki.parserfactory.ParserFactory import make [as 别名]
    def setUp(self):
        self.encoding = "utf8"

        self.__createWiki()
        
        factory = ParserFactory()
        self.testPage = self.rootwiki[u"Страница 2"]
        self.parser = factory.make (self.testPage, Application.config)
开发者ID:s200999900,项目名称:outwiker,代码行数:10,代码来源:parsertex.py

示例6: setUp

# 需要导入模块: from outwiker.pages.wiki.parserfactory import ParserFactory [as 别名]
# 或者: from outwiker.pages.wiki.parserfactory.ParserFactory import make [as 别名]
    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)
开发者ID:qyqx,项目名称:outwiker,代码行数:12,代码来源:testwikicommand.py

示例7: setUp

# 需要导入模块: from outwiker.pages.wiki.parserfactory import ParserFactory [as 别名]
# 或者: from outwiker.pages.wiki.parserfactory.ParserFactory import make [as 别名]
    def setUp(self):
        # Здесь будет создаваться вики
        self.path = mkdtemp(prefix='Абырвалг абыр')

        self.filesPath = "../test/samplefiles/"

        self.__createWiki()

        factory = ParserFactory()
        self.parser = factory.make(self.testPage, Application.config)
开发者ID:Jenyay,项目名称:outwiker,代码行数:12,代码来源:test_parserformat.py

示例8: testExceptionCommand

# 需要导入模块: from outwiker.pages.wiki.parserfactory import ParserFactory [as 别名]
# 或者: from outwiker.pages.wiki.parserfactory.ParserFactory import make [as 别名]
    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)
开发者ID:qyqx,项目名称:outwiker,代码行数:13,代码来源:wikicommands.py

示例9: setUp

# 需要导入模块: from outwiker.pages.wiki.parserfactory import ParserFactory [as 别名]
# 或者: from outwiker.pages.wiki.parserfactory.ParserFactory import make [as 别名]
    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]
开发者ID:LihMeh,项目名称:outwiker,代码行数:14,代码来源:wikicommandattachlist.py

示例10: setUp

# 需要导入模块: from outwiker.pages.wiki.parserfactory import ParserFactory [as 别名]
# 或者: from outwiker.pages.wiki.parserfactory.ParserFactory import make [as 别名]
    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)
开发者ID:LihMeh,项目名称:outwiker,代码行数:17,代码来源:parserthumb.py

示例11: setUp

# 需要导入模块: from outwiker.pages.wiki.parserfactory import ParserFactory [as 别名]
# 或者: from outwiker.pages.wiki.parserfactory.ParserFactory import make [as 别名]
    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)
开发者ID:Jenyay,项目名称:outwiker,代码行数:17,代码来源:test_wikicommanddates.py

示例12: __createWiki

# 需要导入模块: from outwiker.pages.wiki.parserfactory import ParserFactory [as 别名]
# 或者: from outwiker.pages.wiki.parserfactory.ParserFactory import make [as 别名]
    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)
开发者ID:theoden-dd,项目名称:outwiker,代码行数:22,代码来源:tokennames.py

示例13: setUp

# 需要导入模块: from outwiker.pages.wiki.parserfactory import ParserFactory [as 别名]
# 或者: from outwiker.pages.wiki.parserfactory.ParserFactory import make [as 别名]
    def setUp(self):
        self.initApplication()
        self.wikiroot = self.createWiki()
        self.testPage = WikiPageFactory().create(self.wikiroot,
                                                 "Страница 1",
                                                 [])
        plugins_dir = ["../plugins/snippets"]

        self.loader = PluginsLoader(self.application)
        self.loader.load(plugins_dir)

        factory = ParserFactory()
        self.parser = factory.make(self.testPage, self.application.config)

        from snippets.utils import getSnippetsDir
        root_snippets_dir = getSnippetsDir()

        # snippets dir for tests
        self._snippets_dir = os.path.join(
            root_snippets_dir, '__test_snippets')
        os.mkdir(self._snippets_dir)
开发者ID:Jenyay,项目名称:outwiker,代码行数:23,代码来源:test_wikicommand.py

示例14: setUp

# 需要导入模块: from outwiker.pages.wiki.parserfactory import ParserFactory [as 别名]
# 或者: from outwiker.pages.wiki.parserfactory.ParserFactory import make [as 别名]
    def setUp(self):
        self.__createWiki()
        self.testPage = self.wikiroot[u'Страница 1']

        factory = ParserFactory()
        self.parser = factory.make (self.testPage, Application.config)
开发者ID:LihMeh,项目名称:outwiker,代码行数:8,代码来源:wikicommandtable.py

示例15: SourceFilePluginTest

# 需要导入模块: from outwiker.pages.wiki.parserfactory import ParserFactory [as 别名]
# 或者: from outwiker.pages.wiki.parserfactory.ParserFactory import make [as 别名]
class SourceFilePluginTest(unittest.TestCase):
    """
    Тесты на работу с раскраской прикрепленных файлов
    """

    def setUp(self):
        self.__pluginname = u"Source"

        self.__createWiki()

        dirlist = [u"../plugins/source"]

        # Путь, где лежат примеры исходников в разных кодировках
        self.samplefilesPath = u"../test/samplefiles/sources"

        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()

        self.factory = ParserFactory()
        self.parser = self.factory.make(self.testPage, Application.config)

    def __readFile(self, path):
        with open(path) as fp:
            result = unicode(fp.read(), "utf8")

        return result

    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)
        self.loader.clear()

    def testHighlightFile1(self):
        Attachment(self.testPage).attach([os.path.join(self.samplefilesPath, u"source_utf8.py")])
        content = u'(:source file="source_utf8.py" lang="text":)'
        self.testPage.content = content

        generator = HtmlGenerator(self.testPage)
        htmlpath = generator.makeHtml(Style().getPageStyle(self.testPage))
        result = self.__readFile(htmlpath)

        self.assertTrue(u"__correctSysPath()" in result)
        self.assertTrue(u"Плагин, добавляющий обработку команды (:source:) в википарсер" in result)

    def testHighlightFile2(self):
        Attachment(self.testPage).attach([os.path.join(self.samplefilesPath, u"source_utf8.py")])
        content = u'(:source file="Attach:source_utf8.py" lang="text":)'
        self.testPage.content = content

        generator = HtmlGenerator(self.testPage)
        htmlpath = generator.makeHtml(Style().getPageStyle(self.testPage))
        result = self.__readFile(htmlpath)

        self.assertTrue(u"__correctSysPath()" in result)
        self.assertTrue(u"Плагин, добавляющий обработку команды (:source:) в википарсер" in result)

    def testHighlightFile3(self):
        Attachment(self.testPage).attach([os.path.join(self.samplefilesPath, u"source_utf8.py")])
        content = u'(:source file="  source_utf8.py  " lang="text":)'
        self.testPage.content = content

        generator = HtmlGenerator(self.testPage)
        htmlpath = generator.makeHtml(Style().getPageStyle(self.testPage))
        result = self.__readFile(htmlpath)

        self.assertTrue(u"__correctSysPath()" in result)
        self.assertTrue(u"Плагин, добавляющий обработку команды (:source:) в википарсер" in result)

    def testHighlightFile4(self):
        Attachment(self.testPage).attach([os.path.join(self.samplefilesPath, u"source_utf8.py")])
        content = u'(:source file="  Attach:source_utf8.py  " lang="text":)'
        self.testPage.content = content

        generator = HtmlGenerator(self.testPage)
        htmlpath = generator.makeHtml(Style().getPageStyle(self.testPage))
        result = self.__readFile(htmlpath)

        self.assertTrue(u"__correctSysPath()" in result)
        self.assertTrue(u"Плагин, добавляющий обработку команды (:source:) в википарсер" in result)

    def testHighlightFile5(self):
        Attachment(self.testPage).attach([os.path.join(self.samplefilesPath, u"source_utf8.py")])
        content = u'(:source file="source_utf8.py" lang="text":)(:sourceend:)'
        self.testPage.content = content

        generator = HtmlGenerator(self.testPage)
        htmlpath = generator.makeHtml(Style().getPageStyle(self.testPage))
#.........这里部分代码省略.........
开发者ID:qyqx,项目名称:outwiker,代码行数:103,代码来源:sourcefile.py


注:本文中的outwiker.pages.wiki.parserfactory.ParserFactory.make方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。