本文整理汇总了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()))
示例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)
示例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
示例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
示例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
示例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)
示例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)
示例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)
示例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
示例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)
示例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
示例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()
示例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
示例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))