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


Python Style.getPageStyle方法代码示例

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


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

示例1: testSelfDefault

# 需要导入模块: from outwiker.core.style import Style [as 别名]
# 或者: from outwiker.core.style.Style import getPageStyle [as 别名]
    def testSelfDefault(self):
        style = Style()

        page = self.rootwiki[u"Викистраница 1"]
        style.setPageStyle(page, style.getPageStyle(page))

        self.assertEqual(os.path.abspath(style.getPageStyle(page)), os.path.abspath(style.getDefaultStyle()))
开发者ID:qyqx,项目名称:outwiker,代码行数:9,代码来源:styles.py

示例2: testStylePageDefault

# 需要导入模块: from outwiker.core.style import Style [as 别名]
# 或者: from outwiker.core.style.Style import getPageStyle [as 别名]
    def testStylePageDefault(self):
        """
        Проверка на то, что если у страницы нет файла стиля, то возвращается стиль по умолчанию
        """
        style = Style()
        defaultStyle = style.getDefaultStyle()
        style_page1 = style.getPageStyle(self.rootwiki[u"Викистраница 1"])
        style_page2 = style.getPageStyle(self.rootwiki[u"Html-страница 2"])

        self.assertEqual(style_page1, defaultStyle)
        self.assertEqual(style_page2, defaultStyle)
开发者ID:qyqx,项目名称:outwiker,代码行数:13,代码来源:styles.py

示例3: generateHtml

# 需要导入模块: from outwiker.core.style import Style [as 别名]
# 或者: from outwiker.core.style.Style import getPageStyle [as 别名]
    def generateHtml (self, page):
        resultFileName = self.getHtmlPath()

        cache = self._getCacher (page, self._application)
        # Проверим, можно ли прочитать уже готовый HTML
        if (cache.canReadFromCache() and os.path.exists (resultFileName)) or page.readonly:
            try:
                return readTextFile (resultFileName)
            except IOError:
                MessageBox (_(u"Can't read file {}".format (resultFileName)),
                            _(u"Error"),
                            wx.ICON_ERROR | wx.OK)
                return u""

        style = Style()
        stylepath = style.getPageStyle (page)
        generator = self._getHtmlGenerator (page)

        try:
            html = generator.makeHtml(stylepath)
            cache.saveHash()
        except IOError:
            MessageBox (_(u"Can't create HTML file"),
                        _(u"Error"),
                        wx.ICON_ERROR | wx.OK)

        return html
开发者ID:LihMeh,项目名称:outwiker,代码行数:29,代码来源:basewikipageview.py

示例4: generateHtml

# 需要导入模块: from outwiker.core.style import Style [as 别名]
# 或者: from outwiker.core.style.Style import getPageStyle [as 别名]
    def generateHtml (self, page):
        path = self.getHtmlPath (page)

        if page.readonly and os.path.exists (path):
            # Если страница открыта только для чтения и html-файл уже существует, то покажем его
            return path

        style = Style()
        stylepath = style.getPageStyle (page)

        try:
            tpl = HtmlTemplate (stylepath)
        except:
            MessageBox (_(u"Page style Error. Style by default is used"),  
                    _(u"Error"),
                    wx.ICON_ERROR | wx.OK)

            tpl = HtmlTemplate (style.getDefaultStyle())

        if page.autoLineWrap:
            text = HtmlImprover.run (page.content)
            text = re.sub ("\n<br>\n(<li>)|(<li>)", "\n<LI>", text)
        else:
            text = page.content

        result = tpl.substitute (content=text)

        with open (path, "wb") as fp:
            fp.write (result.encode ("utf-8"))

        return path
开发者ID:qyqx,项目名称:outwiker,代码行数:33,代码来源:htmlpageview.py

示例5: _makeHtml

# 需要导入模块: from outwiker.core.style import Style [as 别名]
# 或者: from outwiker.core.style.Style import getPageStyle [as 别名]
    def _makeHtml(self, page):
        style = Style()
        stylepath = style.getPageStyle(page)

        try:
            tpl = HtmlTemplate(readTextFile(stylepath))
        except EnvironmentError:
            tpl = HtmlTemplate(readTextFile(style.getDefaultStyle()))

        content = self._changeContentByEvent(
            page,
            PreprocessingParams(page.content),
            self._application.onPreprocessing)

        if page.autoLineWrap:
            content = self._changeContentByEvent(
                page,
                PreHtmlImprovingParams(content),
                self._application.onPreHtmlImproving)

            config = HtmlRenderConfig(self._application.config)
            improverFactory = HtmlImproverFactory(self._application)
            text = improverFactory[config.HTMLImprover.value].run(content)
        else:
            text = content

        result = tpl.substitute(content=text,
                                title=page.display_title)

        result = self._changeContentByEvent(page,
                                            PostprocessingParams(result),
                                            self._application.onPostprocessing)
        return result
开发者ID:Jenyay,项目名称:outwiker,代码行数:35,代码来源:htmlpagecontroller.py

示例6: testFakeStyle

# 需要导入模块: from outwiker.core.style import Style [as 别名]
# 或者: from outwiker.core.style.Style import getPageStyle [as 别名]
    def testFakeStyle(self):
        style = Style()
        page = self.rootwiki[u"Викистраница 1"]
        os.mkdir(os.path.join(page.path, self._styleFname))

        validStyle = os.path.abspath(style.getDefaultStyle())
        pageStyle = os.path.abspath(style.getPageStyle(page))

        self.assertEqual(pageStyle, validStyle)
开发者ID:qyqx,项目名称:outwiker,代码行数:11,代码来源:styles.py

示例7: testStylePage2

# 需要导入模块: from outwiker.core.style import Style [as 别名]
# 或者: from outwiker.core.style.Style import getPageStyle [as 别名]
    def testStylePage2(self):
        style = Style()
        page = self.rootwiki[u"Html-страница 2"]
        shutil.copy(self._testStylePath, page.path)

        validStyle = os.path.abspath(os.path.join(page.path, self._styleFname))
        pageStyle = os.path.abspath(style.getPageStyle(page))

        self.assertEqual(pageStyle, validStyle)
开发者ID:qyqx,项目名称:outwiker,代码行数:11,代码来源:styles.py

示例8: testStylePage1

# 需要导入模块: from outwiker.core.style import Style [as 别名]
# 或者: from outwiker.core.style.Style import getPageStyle [as 别名]
    def testStylePage1(self):
        style = Style()
        page = self.wikiroot[u"Викистраница 1"]
        shutil.copy(self._testStylePath, page.path)

        validStyle = os.path.abspath(os.path.join(page.path, self._styleFname))
        pageStyle = os.path.abspath(style.getPageStyle(page))

        self.assertEqual(pageStyle, validStyle)
开发者ID:theoden-dd,项目名称:outwiker,代码行数:11,代码来源:styles.py

示例9: __getStyleContent

# 需要导入模块: from outwiker.core.style import Style [as 别名]
# 或者: from outwiker.core.style.Style import getPageStyle [as 别名]
    def __getStyleContent(self, page):
        """
        Возвращает содержимое шаблона
        """
        style = Style()

        try:
            stylecontent = readTextFile(style.getPageStyle(page))
        except (IOError, UnicodeDecodeError):
            stylecontent = ""

        return stylecontent
开发者ID:Jenyay,项目名称:outwiker,代码行数:14,代码来源:wikihashcalculator.py

示例10: __getStyleContent

# 需要导入模块: from outwiker.core.style import Style [as 别名]
# 或者: from outwiker.core.style.Style import getPageStyle [as 别名]
    def __getStyleContent (self, page):
        """
        Возвращает содержимое шаблона
        """
        style = Style ()

        try:
            with open (style.getPageStyle (page)) as fp:
                stylecontent = unicode (fp.read(), "utf8")
        except IOError:
            stylecontent = u""
        except UnicodeDecodeError:
            stylecontent = u""

        return stylecontent.encode (self._unicodeEncoding)
开发者ID:LihMeh,项目名称:outwiker,代码行数:17,代码来源:wikihashcalculator.py

示例11: generateHtml

# 需要导入模块: from outwiker.core.style import Style [as 别名]
# 或者: from outwiker.core.style.Style import getPageStyle [as 别名]
    def generateHtml (self, page):
        style = Style()
        stylepath = style.getPageStyle (page)
        generator = HtmlGenerator (page)

        try:
            html = generator.makeHtml(stylepath)
        except:
            MessageBox (_(u"Page style Error. Style by default is used"),  
                    _(u"Error"),
                    wx.ICON_ERROR | wx.OK)

            html = generator.makeHtml (style.getDefaultStyle())

        return html
开发者ID:s200999900,项目名称:outwiker,代码行数:17,代码来源:wikipanel.py

示例12: _updatePage

# 需要导入模块: from outwiker.core.style import Style [as 别名]
# 或者: from outwiker.core.style.Style import getPageStyle [as 别名]
    def _updatePage(self, page):
        path = page.getHtmlPath()
        cache = HtmlCache(page, self._application)

        # Проверим, можно ли прочитать уже готовый HTML
        if cache.canReadFromCache() and os.path.exists(path):
            return

        style = Style()
        stylepath = style.getPageStyle(page)
        generator = HtmlGenerator(page)

        html = generator.makeHtml(stylepath)
        writeTextFile(path, html)
        cache.saveHash()
开发者ID:Jenyay,项目名称:outwiker,代码行数:17,代码来源:wikipagecontroller.py

示例13: generateHtml

# 需要导入模块: from outwiker.core.style import Style [as 别名]
# 或者: from outwiker.core.style.Style import getPageStyle [as 别名]
    def generateHtml (self, page):
        path = self.getHtmlPath ()

        if page.readonly and os.path.exists (path):
            # Если страница открыта только для чтения и html-файл уже существует, то покажем его
            return readTextFile (path)

        style = Style()
        stylepath = style.getPageStyle (page)

        try:
            tpl = HtmlTemplate (readTextFile (stylepath))
        except:
            MessageBox (_(u"Page style Error. Style by default is used"),
                        _(u"Error"),
                        wx.ICON_ERROR | wx.OK)

            tpl = HtmlTemplate (readTextFile (style.getDefaultStyle()))

        content = self._changeContentByEvent (self.page,
                                              PreprocessingParams (page.content),
                                              Application.onPreprocessing)

        if page.autoLineWrap:
            content = self._changeContentByEvent (self.page,
                                                  PreHtmlImprovingParams (content),
                                                  Application.onPreHtmlImproving)

            config = HtmlRenderConfig (Application.config)
            improverFactory = HtmlImproverFactory (Application)
            text = improverFactory[config.HTMLImprover.value].run (content)
        else:
            text = content

        userhead = u"<title>{}</title>".format (page.title)
        result = tpl.substitute (content = text,
                                 userhead = userhead)

        result = self._changeContentByEvent (self.page,
                                             PostprocessingParams (result),
                                             Application.onPostprocessing)
        return result
开发者ID:LihMeh,项目名称:outwiker,代码行数:44,代码来源:htmlpageview.py

示例14: testSelfSpecial

# 需要导入模块: from outwiker.core.style import Style [as 别名]
# 或者: from outwiker.core.style.Style import getPageStyle [as 别名]
 def testSelfSpecial(self):
     style = Style()
     page = self.rootwiki[u"Викистраница 1"]
     style.setPageStyle(page, self._exampleStyleDir)
     style.setPageStyle(page, style.getPageStyle(page))
开发者ID:qyqx,项目名称:outwiker,代码行数:7,代码来源:styles.py


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