本文整理汇总了Python中exe.engine.path.Path.joinpath方法的典型用法代码示例。如果您正苦于以下问题:Python Path.joinpath方法的具体用法?Python Path.joinpath怎么用?Python Path.joinpath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exe.engine.path.Path
的用法示例。
在下文中一共展示了Path.joinpath方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: handleExport
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import joinpath [as 别名]
def handleExport(self, client, exportType, filename):
"""
Called by js.
Exports the current package to one of the above formats
'exportType' can be one of 'singlePage' 'webSite' 'zipFile'
'textFile' or 'scorm'
'filename' is a file for scorm pages, and a directory for websites
"""
webDir = Path(self.config.webDir)
stylesDir = webDir.joinpath('style', self.package.style)
exportDir = Path(filename).dirname()
if exportDir and not exportDir.exists():
client.alert(_(u'Cannot access directory named ') +
unicode(exportDir) +
_(u'. Please use ASCII names.'))
return
if exportType == 'singlePage':
self.exportSinglePage(client, filename, webDir, stylesDir)
elif exportType == 'webSite':
self.exportWebSite(client, filename, stylesDir)
elif exportType == 'zipFile':
self.exportWebZip(client, filename, stylesDir)
elif exportType == 'textFile':
self.exportText(client, filename)
elif exportType == "scorm":
self.exportScorm(client, filename, stylesDir, "scorm1.2")
elif exportType == "scorm2004":
self.exportScorm(client, filename, stylesDir, "scorm2004")
else:
self.exportIMS(client, filename, stylesDir)
示例2: _process
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import joinpath [as 别名]
def _process(self, request):
"""
Delegates processing of args to blocks
"""
# Still need to call parent (mainpage.py) process
# because the idevice pane needs to know that new idevices have been
# added/edited..
self.parent.process(request)
if ("action" in request.args and
request.args["action"][0] == u"saveChange"):
log.debug(u"process savachange:::::")
self.package.save()
log.debug(u"package name: " + self.package.name)
for block in self.blocks:
block.process(request)
# now that each block and corresponding elements have been processed,
# it's finally safe to remove any images/etc which made it into
# tinyMCE's previews directory, as they have now had their
# corresponding resources created:
webDir = Path(G.application.tempWebDir)
previewDir = webDir.joinpath('previews')
for root, dirs, files in os.walk(previewDir, topdown=False):
for name in files:
os.remove(os.path.join(root, name))
log.debug(u"After authoringPage process" + repr(request.args))
示例3: themeHasConfigXML
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import joinpath [as 别名]
def themeHasConfigXML(style):
themePath = Path(G.application.config.stylesDir / style)
themeXMLFile = themePath.joinpath("config.xml")
themeHasXML = False
if themeXMLFile.exists():
themeHasXML = True
return themeHasXML
示例4: __renderHeader
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import joinpath [as 别名]
def __renderHeader(self):
#TinyMCE lang (user preference)
myPreferencesPage = self.webServer.preferences
"""Generates the header for AuthoringPage"""
html = common.docType()
#################################################################################
#################################################################################
html += u'<html xmlns="http://www.w3.org/1999/xhtml" lang="'+myPreferencesPage.getSelectedLanguage()+'">\n'
html += u'<head>\n'
html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/exe.css\" />"
# Use the Style's base.css file if it exists
themePath = Path(G.application.config.stylesDir/self.package.style)
themeBaseCSS = themePath.joinpath("base.css")
if themeBaseCSS.exists():
html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"/style/%s/base.css\" />" % self.package.style
else:
html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"/style/base.css\" />"
html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"/css/exe_wikipedia.css\" />"
html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"/scripts/exe_effects/exe_effects.css\" />"
html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"/scripts/exe_highlighter/exe_highlighter.css\" />"
html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"/scripts/exe_games/exe_games.css\" />"
html += u"<link rel=\"stylesheet\" type=\"text/css\" href=\"/style/%s/content.css\" />" % self.package.style
if G.application.config.assumeMediaPlugins:
html += u"<script type=\"text/javascript\">var exe_assume_media_plugins = true;</script>\n"
#JR: anado una variable con el estilo
estilo = u'/style/%s/content.css' % self.package.style
html += common.getJavaScriptStrings()
# The games require additional strings
html += common.getGamesJavaScriptStrings()
html += u"<script type=\"text/javascript\">"
html += u"var exe_style = '%s';top.exe_style = exe_style;" % estilo
# editorpane.py uses exe_style_dirname to auto-select the current style (just a provisional solution)
html += u"var exe_style_dirname = '%s'; top.exe_style_dirname = exe_style_dirname;" % self.package.style
html += u"var exe_package_name='"+self.package.name+"';"
html += 'var exe_export_format="'+common.getExportDocType()+'".toLowerCase();'
html += 'var exe_editor_mode="'+myPreferencesPage.getEditorMode()+'";'
html += 'var exe_editor_version="'+myPreferencesPage.getEditorVersion()+'";'
html += '</script>\n'
html += u'<script type="text/javascript" src="../jsui/native.history.js"></script>\n'
html += u'<script type="text/javascript" src="/scripts/authoring.js"></script>\n'
html += u'<script type="text/javascript" src="/scripts/exe_jquery.js"></script>\n'
html += u'<script type="text/javascript" src="/scripts/exe_lightbox/exe_lightbox.js"></script>\n'
html += u'<script type="text/javascript" src="/scripts/exe_effects/exe_effects.js"></script>\n'
html += u'<script type="text/javascript" src="/scripts/exe_highlighter/exe_highlighter.js"></script>\n'
html += u'<script type="text/javascript" src="/scripts/exe_games/exe_games.js"></script>\n'
html += u'<script type="text/javascript" src="/scripts/common.js"></script>\n'
html += '<script type="text/javascript">document.write(unescape("%3Cscript src=\'" + eXeLearning_settings.wysiwyg_path + "\' type=\'text/javascript\'%3E%3C/script%3E"));</script>';
html += '<script type="text/javascript">document.write(unescape("%3Cscript src=\'" + eXeLearning_settings.wysiwyg_settings_path + "\' type=\'text/javascript\'%3E%3C/script%3E"));</script>';
html += u'<title>"+_("eXe : elearning XHTML editor")+"</title>\n'
html += u'<meta http-equiv="content-type" content="text/html; '
html += u' charset=UTF-8" />\n'
style = G.application.config.styleStore.getStyle(self.package.style)
if style.hasValidConfig:
html += style.get_edition_extra_head()
html += u'</head>\n'
return html
示例5: handleTinyMCEmath
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import joinpath [as 别名]
def handleTinyMCEmath(
self,
client,
tinyMCEwin,
tinyMCEwin_name,
tinyMCEfield,
latex_source,
math_fontsize,
preview_image_filename,
preview_math_srcfile,
):
"""
Based off of handleTinyMCEimageChoice(),
handleTinyMCEmath() is similar in that it places a .gif math image
(and a corresponding .tex LaTeX source file) into the previews dir.
Rather than copying the image from a user-selected directory, though,
this routine actually generates the math image using mimetex.
"""
server_filename = ""
callback_errors = ""
errors = 0
webDir = Path(G.application.tempWebDir)
previewDir = webDir.joinpath("previews")
if not previewDir.exists():
log.debug("image previews directory does not yet exist; " + "creating as %s " % previewDir)
previewDir.makedirs()
elif not previewDir.isdir():
client.alert(_(u"Preview directory %s is a file, cannot replace it") % previewDir)
log.error(
"Couldn't preview tinyMCE-chosen image: " + "Preview dir %s is a file, cannot replace it" % previewDir
)
callback_errors = "Preview dir is a file, cannot replace"
errors += 1
if latex_source <> "":
math_filename = previewDir.joinpath(preview_math_srcfile)
math_filename_str = math_filename.abspath().encode("utf-8")
log.info("handleTinyMCEmath: using LaTeX source: " + latex_source)
log.debug("writing LaTeX source into '" + math_filename_str + "'.")
math_file = open(math_filename, "wb")
math_file.write(latex_source)
math_file.flush()
math_file.close()
try:
use_latex_sourcefile = math_filename_str
tempFileName = compile(use_latex_sourcefile, math_fontsize, latex_is_file=True)
except Exception, e:
client.alert(_("MimeTeX compile failed!\n%s" % str(e)))
log.error("handleTinyMCEmath unable to compile LaTeX using " + "mimetex, error = " + str(e))
raise
server_filename = previewDir.joinpath(preview_image_filename)
log.debug(
"handleTinyMCEmath copying math image from '"
+ tempFileName
+ "' to '"
+ server_filename.abspath().encode("utf-8")
+ "'."
)
shutil.copyfile(tempFileName, server_filename.abspath().encode("utf-8"))
Path(tempFileName).remove()
示例6: handleExport
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import joinpath [as 别名]
def handleExport(self, client, exportType, filename, print_callback=''):
"""
Called by js.
Exports the current package to one of the above formats
'exportType' can be one of 'singlePage' 'webSite' 'zipFile' 'ipod'
'textFile' or 'scorm'
'filename' is a file for scorm pages, and a directory for websites
"""
webDir = Path(self.config.webDir)
stylesDir = webDir.joinpath('style', self.package.style)
exportDir = Path(filename).dirname()
if exportDir and not exportDir.exists():
client.alert(_(u'Cannot access directory named ') +
unicode(exportDir) +
_(u'. Please use ASCII names.'))
return
"""
adding the print feature in using the same export functionality:
"""
if exportType == 'singlePage' or exportType == 'printSinglePage':
printit = 0
if exportType == 'printSinglePage':
printit = 1
exported_dir = self.exportSinglePage(client, filename, webDir, \
stylesDir, printit)
# the above will return None if the desired exported directory
# already exists (printing always goes to a new temp dir, though):
if printit == 1 and not exported_dir is None:
web_printdir = self.get_printdir_relative2web(exported_dir)
# now that this has ben exported, go ahead and trigger
# the requested printing callback:
client.call(print_callback, filename, exported_dir, \
web_printdir)
elif exportType == 'webSite':
self.exportWebSite(client, filename, stylesDir)
elif exportType == 'zipFile':
filename = self.b4save(client, filename, '.zip', _(u'EXPORT FAILED!'))
self.exportWebZip(client, filename, stylesDir)
elif exportType == 'textFile':
self.exportText(client, filename)
elif exportType == 'ipod':
self.exportIpod(client, filename)
elif exportType == "scorm":
filename = self.b4save(client, filename, '.zip', _(u'EXPORT FAILED!'))
self.exportScorm(client, filename, stylesDir, "scorm1.2")
elif exportType == "scorm2004":
filename = self.b4save(client, filename, '.zip', _(u'EXPORT FAILED!'))
self.exportScorm(client, filename, stylesDir, "scorm2004")
elif exportType == "commoncartridge":
filename = self.b4save(client, filename, '.zip', _(u'EXPORT FAILED!'))
self.exportScorm(client, filename, stylesDir, "commoncartridge")
else:
filename = self.b4save(client, filename, '.zip', _(u'EXPORT FAILED!'))
self.exportIMS(client, filename, stylesDir)
示例7: handleTinyMCEimageChoice
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import joinpath [as 别名]
def handleTinyMCEimageChoice(self, client, tinyMCEwin, tinyMCEwin_name, \
tinyMCEfield, local_filename, preview_filename):
"""
Once an image is selected in the file browser that is spawned by the
TinyMCE image dialog, copy this file (which is local to the user's
machine) into the server space, under a preview directory
(after checking if this exists, and creating it if necessary).
Note that this IS a "cheat", in violation of the client-server
separation, but can be done since we know that the eXe server is
actually sitting on the client host.
"""
server_filename = ""
callback_errors = ""
errors = 0
webDir = Path(self.config.webDir)
previewDir = webDir.joinpath('previews')
if not previewDir.exists():
log.debug("image previews directory does not yet exist; " \
+ "creating as %s " % previewDir)
previewDir.makedirs()
elif not previewDir.isdir():
client.alert( \
_(u'Preview directory %s is a file, cannot replace it') \
% previewDir)
log.error("Couldn't preview tinyMCE-chosen image: "+
"Preview dir %s is a file, cannot replace it" \
% previewDir)
callback_errors = "Preview dir is a file, cannot replace"
errors += 1
if errors == 0:
localImagePath = Path(local_filename)
if not localImagePath.exists() or not localImagePath.isfile():
client.alert( \
_(u'Image file %s is not found, cannot preview it') \
% localImagePath)
log.error("Couldn't find tinyMCE-chosen image: %s" \
% localImagePath)
callback_errors = "Image file %s not found, cannot preview" \
% localImagePath
errors += 1
try:
server_filename = previewDir.joinpath(preview_filename);
log.debug("handleTinyMCEimageChoice copying image from \'"\
+ local_filename + "\' to \'" \
+ server_filename.abspath().encode('utf-8') + "\'.");
shutil.copyfile(local_filename, \
server_filename.abspath().encode('utf-8'));
except Exception, e:
client.alert(_('SAVE FAILED!\n%s' % str(e)))
log.error("handleTinyMCEimageChoice unable to copy local image "\
+"file to server prevew, error = " + str(e))
raise
示例8: _process
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import joinpath [as 别名]
def _process(self, request):
"""
Delegates processing of args to blocks
"""
self.parent.process(request)
if ("action" in request.args and
request.args["action"][0] == u"saveChange"):
log.debug(u"process savachange:::::")
self.package.save()
log.debug(u"package name: " + self.package.name)
for block in self.blocks:
block.process(request)
webDir = Path(G.application.config.webDir)
previewDir = webDir.joinpath('previews')
for root, dirs, files in os.walk(previewDir, topdown=False):
for name in files:
os.remove(os.path.join(root, name))
log.debug(u"After authoringPage process" + repr(request.args))
示例9: _process
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import joinpath [as 别名]
def _process(self, request):
"""
Delegates processing of args to blocks
"""
# Still need to call parent (mainpage.py) process
# because the idevice pane needs to know that new idevices have been
# added/edited..
self.parent.process(request)
for block in self.blocks:
block.process(request)
# now that each block and corresponding elements have been processed,
# it's finally safe to remove any images/etc which made it into
# tinyMCE's previews directory, as they have now had their
# corresponding resources created:
webDir = Path(G.application.tempWebDir)
previewDir = webDir.joinpath('previews')
for root, dirs, files in os.walk(previewDir, topdown=False):
for name in files:
if sys.platform[:3] == "win":
for i in range(3):
try:
os.remove(os.path.join(root, name))
break
except exceptions.WindowsError:
time.sleep(0.3)
else:
os.remove(os.path.join(root, name))
topNode = self.package.currentNode
if "action" in request.args:
if request.args["action"][0] == u"changeNode":
topNode = self.package.findNode(request.args["object"][0])
elif "currentNode" in request.args:
topNode = self.package.findNode(request.args["currentNode"][0])
elif "currentNode" in request.args:
topNode = self.package.findNode(request.args["currentNode"][0])
log.debug(u"After authoringPage process" + repr(request.args))
return topNode
示例10: export
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import joinpath [as 别名]
#.........这里部分代码省略.........
hasInstructions = True
if not hasMediaelement:
hasMediaelement = common.ideviceHasMediaelement(idevice)
if not hasTooltips:
hasTooltips = common.ideviceHasTooltips(idevice)
if not hasABCMusic:
hasABCMusic = common.ideviceHasABCMusic(idevice)
if hasattr(idevice, "_iDeviceDir"):
listIdevicesFiles.append((Path(idevice._iDeviceDir)/'export'))
common.exportJavaScriptIdevicesFiles(page.node.idevices, outputDir);
if hasFlowplayer:
videofile = (self.templatesDir/'flowPlayer.swf')
videofile.copyfile(outputDir/'flowPlayer.swf')
controlsfile = (self.templatesDir/'flowplayer.controls.swf')
controlsfile.copyfile(outputDir/'flowplayer.controls.swf')
if hasMagnifier:
videofile = (self.templatesDir/'mojomagnify.js')
videofile.copyfile(outputDir/'mojomagnify.js')
if hasXspfplayer:
videofile = (self.templatesDir/'xspf_player.swf')
videofile.copyfile(outputDir/'xspf_player.swf')
if hasGallery:
exeLightbox = (self.scriptsDir/'exe_lightbox')
exeLightbox.copyfiles(outputDir)
if hasFX:
exeEffects = (self.scriptsDir/'exe_effects')
exeEffects.copyfiles(outputDir)
if hasSH:
exeSH = (self.scriptsDir/'exe_highlighter')
exeSH.copyfiles(outputDir)
if hasGames:
exeGames = (self.scriptsDir/'exe_games')
exeGames.copyfiles(outputDir)
# Add game js string to common_i18n
langGameFile = open(outputDir + '/common_i18n.js', "a")
langGameFile.write(common.getGamesJavaScriptStrings(False))
langGameFile.close()
if hasElpLink or package.get_exportElp():
# Export the elp file
currentPackagePath = Path(package.filename)
currentPackagePath.copyfile(outputDir/package.name+'.elp')
if hasWikipedia:
wikipediaCSS = (self.cssDir/'exe_wikipedia.css')
wikipediaCSS.copyfile(outputDir/'exe_wikipedia.css')
if hasInstructions:
common.copyFileIfNotInStyle('panel-amusements.png', self, outputDir)
common.copyFileIfNotInStyle('stock-stop.png', self, outputDir)
if hasMediaelement:
mediaelement = (self.scriptsDir/'mediaelement')
mediaelement.copyfiles(outputDir)
if dT != "HTML5":
jsFile = (self.scriptsDir/'exe_html5.js')
if hasTooltips:
exe_tooltips = (self.scriptsDir/'exe_tooltips')
exe_tooltips.copyfiles(outputDir)
if hasABCMusic:
pluginScripts = (self.scriptsDir/'tinymce_4/js/tinymce/plugins/abcmusic/export')
pluginScripts.copyfiles(outputDir)
ext = ".html"
if G.application.config.cutFileName == "1":
ext = ".htm"
if self.scormType == "scorm1.2" or self.scormType == "scorm2004":
if package.license == "license GFDL":
# include a copy of the GNU Free Documentation Licence
(self.templatesDir/'fdl' + ext).copyfile(outputDir/'fdl' + ext)
if hasattr(package, 'scowsinglepage') and package.scowsinglepage:
page = SinglePage("singlepage_index", 1, package.root)
page.save(outputDir/"singlepage_index" + ext)
# Incluide eXe's icon if the Style doesn't have one
themePath = Path(G.application.config.stylesDir/package.style)
themeFavicon = themePath.joinpath("favicon.ico")
if not themeFavicon.exists():
faviconFile = (self.imagesDir/'favicon.ico')
faviconFile.copyfile(outputDir/'favicon.ico')
if hasattr(package, 'scowwebsite') and package.scowwebsite:
website = WebsiteExport(self.config, self.styleDir, outputDir, "website_")
website.export(package)
(self.styleDir/'nav.css').copyfile(outputDir/'nav.css')
# Incluide eXe's icon if the Style doesn't have one
themePath = Path(G.application.config.stylesDir/package.style)
themeFavicon = themePath.joinpath("favicon.ico")
if not themeFavicon.exists():
faviconFile = (self.imagesDir/'favicon.ico')
faviconFile.copyfile(outputDir/'favicon.ico')
if hasattr(package, 'exportSource') and package.exportSource:
(G.application.config.webDir/'templates'/'content.xsd').copyfile(outputDir/'content.xsd')
(outputDir/'content.data').write_bytes(encodeObject(package))
(outputDir/'contentv3.xml').write_bytes(encodeObjectToXML(package))
# Zip it up!
self.filename.safeSave(self.doZip, _('EXPORT FAILED!\nLast succesful export is %s.'), outputDir)
# Clean up the temporary dir
outputDir.rmtree()
return modifiedMetaData
示例11: export
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import joinpath [as 别名]
#.........这里部分代码省略.........
and hasInstructions
and hasMediaelement
):
isBreak = True
break
if not hasFlowplayer:
if "flowPlayer.swf" in idevice.systemResources:
hasFlowplayer = True
if not hasMagnifier:
if "mojomagnify.js" in idevice.systemResources:
hasMagnifier = True
if not hasXspfplayer:
if "xspf_player.swf" in idevice.systemResources:
hasXspfplayer = True
if not hasGallery:
hasGallery = common.ideviceHasGallery(idevice)
if not hasWikipedia:
if "WikipediaIdevice" == idevice.klass:
hasWikipedia = True
if not hasInstructions:
if (
"TrueFalseIdevice" == idevice.klass
or "MultichoiceIdevice" == idevice.klass
or "VerdaderofalsofpdIdevice" == idevice.klass
or "EleccionmultiplefpdIdevice" == idevice.klass
):
hasInstructions = True
if not hasMediaelement:
hasMediaelement = common.ideviceHasMediaelement(idevice)
if hasFlowplayer:
videofile = self.templatesDir / "flowPlayer.swf"
videofile.copyfile(outputDir / "flowPlayer.swf")
controlsfile = self.templatesDir / "flowplayer.controls.swf"
controlsfile.copyfile(outputDir / "flowplayer.controls.swf")
if hasMagnifier:
videofile = self.templatesDir / "mojomagnify.js"
videofile.copyfile(outputDir / "mojomagnify.js")
if hasXspfplayer:
videofile = self.templatesDir / "xspf_player.swf"
videofile.copyfile(outputDir / "xspf_player.swf")
if hasGallery:
imageGalleryCSS = self.cssDir / "exe_lightbox.css"
imageGalleryCSS.copyfile(outputDir / "exe_lightbox.css")
imageGalleryJS = self.scriptsDir / "exe_lightbox.js"
imageGalleryJS.copyfile(outputDir / "exe_lightbox.js")
self.imagesDir.copylist(
(
"exe_lightbox_close.png",
"exe_lightbox_loading.gif",
"exe_lightbox_next.png",
"exe_lightbox_prev.png",
),
outputDir,
)
if hasWikipedia:
wikipediaCSS = self.cssDir / "exe_wikipedia.css"
wikipediaCSS.copyfile(outputDir / "exe_wikipedia.css")
if hasInstructions:
common.copyFileIfNotInStyle("panel-amusements.png", self, outputDir)
common.copyFileIfNotInStyle("stock-stop.png", self, outputDir)
if hasMediaelement:
mediaelement = self.scriptsDir / "mediaelement"
mediaelement.copyfiles(outputDir)
if dT != "HTML5":
jsFile = self.scriptsDir / "exe_html5.js"
if self.scormType == "scorm1.2" or self.scormType == "scorm2004":
if package.license == "license GFDL":
# include a copy of the GNU Free Documentation Licence
(self.templatesDir / "fdl.html").copyfile(outputDir / "fdl.html")
if hasattr(package, "scowsinglepage") and package.scowsinglepage:
page = SinglePage("singlepage_index", 1, package.root)
page.save(outputDir / "singlepage_index.html")
# Incluide eXe's icon if the Style doesn't have one
themePath = Path(G.application.config.stylesDir / package.style)
themeFavicon = themePath.joinpath("favicon.ico")
if not themeFavicon.exists():
faviconFile = self.imagesDir / "favicon.ico"
faviconFile.copyfile(outputDir / "favicon.ico")
if hasattr(package, "scowwebsite") and package.scowwebsite:
website = WebsiteExport(self.config, self.styleDir, outputDir, "website_")
website.export(package)
(self.styleDir / "nav.css").copyfile(outputDir / "nav.css")
# Incluide eXe's icon if the Style doesn't have one
themePath = Path(G.application.config.stylesDir / package.style)
themeFavicon = themePath.joinpath("favicon.ico")
if not themeFavicon.exists():
faviconFile = self.imagesDir / "favicon.ico"
faviconFile.copyfile(outputDir / "favicon.ico")
if hasattr(package, "exportSource") and package.exportSource:
(G.application.config.webDir / "templates" / "content.xsd").copyfile(outputDir / "content.xsd")
(outputDir / "content.data").write_bytes(encodeObject(package))
(outputDir / "contentv3.xml").write_bytes(encodeObjectToXML(package))
# Zip it up!
self.filename.safeSave(self.doZip, _("EXPORT FAILED!\nLast succesful export is %s."), outputDir)
# Clean up the temporary dir
outputDir.rmtree()
示例12: handleTinyMCEmath
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import joinpath [as 别名]
def handleTinyMCEmath(self, client, tinyMCEwin, tinyMCEwin_name, \
tinyMCEfield, latex_source, math_fontsize, \
preview_image_filename, preview_math_srcfile):
"""
Based off of handleTinyMCEimageChoice(),
handleTinyMCEmath() is similar in that it places a .gif math image
(and a corresponding .tex LaTeX source file) into the previews dir.
Rather than copying the image from a user-selected directory, though,
this routine actually generates the math image using mimetex.
"""
server_filename = ""
callback_errors = ""
errors = 0
webDir = Path(G.application.tempWebDir)
previewDir = webDir.joinpath('previews')
if not previewDir.exists():
log.debug("image previews directory does not yet exist; " \
+ "creating as %s " % previewDir)
previewDir.makedirs()
elif not previewDir.isdir():
client.alert( \
_(u'Preview directory %s is a file, cannot replace it') \
% previewDir)
log.error("Couldn't preview tinyMCE-chosen image: "+
"Preview dir %s is a file, cannot replace it" \
% previewDir)
callback_errors = "Preview dir is a file, cannot replace"
errors += 1
#if errors == 0:
# localImagePath = Path(local_filename)
# if not localImagePath.exists() or not localImagePath.isfile():
# client.alert( \
# _(u'Image file %s is not found, cannot preview it') \
# % localImagePath)
# log.error("Couldn't find tinyMCE-chosen image: %s" \
# % localImagePath)
# callback_errors = "Image file %s not found, cannot preview" \
# % localImagePath
# errors += 1
# the mimetex usage code was swiped from the Math iDevice:
if latex_source <> "":
# first write the latex_source out into the preview_math_srcfile,
# such that it can then be passed into the compile command:
math_filename = previewDir.joinpath(preview_math_srcfile)
math_filename_str = math_filename.abspath().encode('utf-8')
log.info("handleTinyMCEmath: using LaTeX source: " + latex_source)
log.debug("writing LaTeX source into \'" \
+ math_filename_str + "\'.")
math_file = open(math_filename, 'wb')
# do we need to append a \n here?:
math_file.write(latex_source)
math_file.flush()
math_file.close()
try:
use_latex_sourcefile = math_filename_str
tempFileName = compile(use_latex_sourcefile, math_fontsize, \
latex_is_file=True)
except Exception, e:
client.alert(_('MimeTeX compile failed!\n%s' % str(e)))
log.error("handleTinyMCEmath unable to compile LaTeX using "\
+"mimetex, error = " + str(e))
raise
# copy the file into previews
server_filename = previewDir.joinpath(preview_image_filename);
log.debug("handleTinyMCEmath copying math image from \'"\
+ tempFileName + "\' to \'" \
+ server_filename.abspath().encode('utf-8') + "\'.");
shutil.copyfile(tempFileName, \
server_filename.abspath().encode('utf-8'));
# Delete the temp file made by compile
Path(tempFileName).remove()
示例13: ideviceHeader
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import joinpath [as 别名]
def ideviceHeader(e, style, mode):
dT = getExportDocType()
lb = "\n" # Line breaks
# Default HTML tags:
sectionTag = "div"
articleTag = "div"
headerTag = "div"
titleTag = "h2"
if dT == "HTML5":
sectionTag = "section"
articleTag = "article"
headerTag = "header"
titleTag = "h1"
themePath = Path(G.application.config.stylesDir / style)
themeXMLFile = themePath.joinpath("config.xml")
themeHasXML = themeHasConfigXML(style)
w = "" # Common wrapper
o = "" # Old HTML (themes with no config.xml file)
h = "" # New HTML
w2 = ""
eEm = ""
if e.idevice.emphasis > 0:
w2 = "<" + sectionTag + ' class="iDevice_inner">' + lb
w2 += "<" + sectionTag + ' class="iDevice_content_wrapper">' + lb
eEm = " em_iDevice"
if mode == "preview" and themeHasXML:
w += "<" + sectionTag + ' class="iDevice_wrapper ' + e.idevice.klass + eEm + '" id="id' + e.id + '">' + lb
w += u"<" + articleTag + ' class="iDevice emphasis' + unicode(e.idevice.emphasis) + '" '
if mode == "preview":
w += u"ondblclick=\"submitLink('edit', " + e.id + ', 0);"'
w += ">" + lb
if e.idevice.emphasis > 0:
h += "<" + headerTag + ' class="iDevice_header"'
if e.idevice.icon:
displayIcon = True
# The following lines should be replaced by something like:
"""
if hasattr(e.idevice, 'originalicon'):
if e.idevice.icon==e.idevice.originalicon:
displayIcon = False
"""
k = e.idevice.klass
i = e.idevice.icon
if (
(k == "ListaIdevice" and i == "question")
or (k == "CasestudyIdevice" and i == "casestudy")
or (k == "GalleryIdevice" and i == "gallery")
or (k == "ClozeIdevice" and i == "question")
or (k == "ReflectionIdevice" and i == "reflection")
or (k == "QuizTestIdevice" and i == "question")
or (k == "TrueFalseIdevice" and i == "question")
or (k == "MultiSelectIdevice" and i == "question")
or (k == "MultichoiceIdevice" and i == "question")
):
displayIcon = False
# /end
iconPath = "/style/" + style + "/icon_" + e.idevice.icon + ".gif"
if mode == "view":
iconPath = "icon_" + e.idevice.icon + ".gif"
myIcon = themePath.joinpath("icon_" + e.idevice.icon + ".gif")
if myIcon.exists():
o += u'<img alt="" class="iDevice_icon" src="' + iconPath + '" />'
if (e.idevice.icon + "Idevice") != e.idevice.klass:
if myIcon.exists() and displayIcon:
h += ' style="background-image:url(' + iconPath + ')"'
else:
log.debug("Idevice %s at node %s has no icon" % (e.idevice._title, e.idevice.parentNode._title))
t = e.idevice.title
fullT = u"<" + titleTag + ' class="iDeviceTitle">' + t + "</" + titleTag + ">"
if t == "":
fullT = u'<span class="iDeviceTitle"> </span>'
o += u"<" + titleTag + ' class="iDeviceTitle">' + t + "</" + titleTag + ">"
h += ">"
h += fullT
h += "</" + headerTag + ">" + lb
if e.idevice.emphasis <= 0:
h = ""
o = ""
if themeHasXML:
return w + h + w2
else:
return w + o + w2
示例14: process_previewed_images
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import joinpath [as 别名]
#.........这里部分代码省略.........
# DESIGN NOTE: eventually the following processing should be
# enhanced to look at the HTML tags passed in, and ensure that
# what is being found as 'src="../previews/.."' is really within
# an IMG tag, etc.
# For now, though, this easy parsing is working well:
# JR search_str = "src=\"../previews/"
search_str = "src=\"/previews/"
# BEWARE OF THE ABOVE in regards to ProcessPreviewedMedia(),
# which takes advantage of the fact that the embedded media
# actually gets stored as src="previews/".
# If this little weirdness of Images being stored as src="../previews/"
# even changes to src="previews/", so more processing will be needed!
found_pos = new_content.find(search_str)
while found_pos >= 0:
end_pos = new_content.find('\"', found_pos + len(search_str))
if end_pos == -1:
# now unlikely that this has already been quoted out,
# since the search_str INCLUDES a \", but check anyway:
end_pos = new_content.find('"', found_pos + 1)
else:
# okay, the end position \" was found, BUT beware of this
# strange case, where the image file:/// URLs
# were entered manually in one part of it
# (and therefore escaped to "), AND another quote occurs
# further below (perhaps even in a non-quoted file:/// via
# a tinyMCE browser, but really from anything!)
# So..... see if a " is found in the file-name, and
# if so, back the end_pos up to there.
# NOTE: until actually looking at the HTML tags, and/or
# we might be able to do this more programmatically by
# first seeing HOW the file:// is initially quoted,
# whether by a \" or by ", but for now,
# just check this one.
end_pos2 = new_content.find('"', found_pos + 1)
if end_pos2 > 0 and end_pos2 < end_pos:
end_pos = end_pos2
if end_pos >= found_pos:
# next, extract the actual file url, to be replaced later
# by the local resource file:
file_url_str = new_content[found_pos:end_pos]
# and to get the actual file path,
# rather than the complete URL:
# first compensate for how TinyMCE HTML-escapes accents:
pre_input_file_name_str = file_url_str[len(search_str):]
log.debug("ProcessPreviewedImages: found escaped file = " \
+ pre_input_file_name_str)
converter = HtmlToText(pre_input_file_name_str)
input_file_name_str = converter.convertToText()
log.debug("ProcessPreviewedImages: unescaped filename = " \
+ input_file_name_str)
webDir = Path(G.application.tempWebDir)
previewDir = webDir.joinpath('previews')
server_filename = previewDir.joinpath(input_file_name_str);
# and now, extract just the filename string back out of that:
file_name_str = server_filename.abspath().encode('utf-8');
# Be sure to check that this file even exists before even
# attempting to create a corresponding GalleryImage resource:
if os.path.exists(file_name_str) \
and os.path.isfile(file_name_str):
# Although full filenames (including flatted representations
# of their source directory tree) were used to help keep the
# filenames here in previewDir unique, this does cause
# problems with the filenames being too long, if they
# are kept that way.
# So.... if an optional .exe_info file is coupled to
# this one, go ahead and read in its original basename,
# in order to rename the file back to something shorter.
# After all, the resource process has its own uniqueifier.
# test for the optional .exe_info:
basename_value = os.path.basename(file_name_str)
descrip_file_path = Path(server_filename + ".exe_info")
if os.path.exists(descrip_file_path) \
and os.path.isfile(descrip_file_path):
descrip_file = open(descrip_file_path, 'rb')
basename_info = descrip_file.read().decode('utf-8')
log.debug("ProcessPreviewedImages: decoded basename = " \
+ basename_info)
# split out the value of this "basename=file" key
basename_key_str = "basename="
basename_found_pos = basename_info.find(basename_key_str)
# should be right there at the very beginning:
if basename_found_pos == 0:
basename_value = \
basename_info[len(basename_key_str):]
#now we add the file to the package...
new_entry = self.add_user_file_to_idevice(idevice_id, file_name_str,
new_basename = basename_value)
new_content = new_content.replace(file_url_str, "src=\"%s" % new_entry[1])
found_pos = new_content.find(search_str, found_pos + 1)
return new_content
示例15: copyFiles
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import joinpath [as 别名]
def copyFiles(self, package, outputDir):
"""
Copy all the files used by the website.
"""
if os.path.isdir(self.stylesDir):
# Copy the style files to the output dir
styleFiles = [self.stylesDir/'..'/'popup_bg.gif']
styleFiles += self.stylesDir.files("*.*")
self.stylesDir.copylist(styleFiles, outputDir)
# copy the package's resource files
for resourceFile in package.resourceDir.walkfiles():
file = package.resourceDir.relpathto(resourceFile)
if ("/" in file):
Dir = Path(outputDir/file[:file.rindex("/")])
if not Dir.exists():
Dir.makedirs()
resourceFile.copy(outputDir/Dir)
else:
resourceFile.copy(outputDir)
listCSSFiles=getFilesCSSToMinify('website', self.stylesDir)
exportMinFileCSS(listCSSFiles, outputDir)
# copy script files.
my_style = G.application.config.styleStore.getStyle(package.style)
# jQuery
listFiles=[]
listOutFiles=[]
if my_style.hasValidConfig:
if my_style.get_jquery() == True:
jsFile = (self.scriptsDir/'exe_jquery.js')
jsFile.copyfile(outputDir/'exe_jquery.js')
else:
listFiles+=[self.scriptsDir/'exe_jquery.js']
listOutFiles+=[outputDir/'exe_jquery.js']
# Minify common.js file
listFiles=getFilesJSToMinify('website', self.scriptsDir)
exportMinFileJS(listFiles, outputDir)
# Create lang file
langFile = open(outputDir + '/common_i18n.js', "w")
langFile.write(common.getJavaScriptStrings(False))
langFile.close()
#dT = common.getExportDocType()
dT=common.getExportDocType();
if dT == "HTML5":
jsFile = (self.scriptsDir/'exe_html5.js')
jsFile.copyfile(outputDir/'exe_html5.js')
# Incluide eXe's icon if the Style doesn't have one
themePath = Path(G.application.config.stylesDir/package.style)
themeFavicon = themePath.joinpath("favicon.ico")
if not themeFavicon.exists():
faviconFile = (self.imagesDir/'favicon.ico')
faviconFile.copyfile(outputDir/'favicon.ico')
# copy players for media idevices.
hasFlowplayer = False
hasMagnifier = False
hasXspfplayer = False
hasGallery = False
hasFX = False
hasSH = False
hasGames = False
hasElpLink = False
hasWikipedia = False
isBreak = False
hasInstructions = False
hasMediaelement = False
hasTooltips = False
hasABCMusic = False
listIdevicesFiles = []
for page in self.pages:
if isBreak:
break
for idevice in page.node.idevices:
if (hasFlowplayer and hasMagnifier and hasXspfplayer and hasGallery and hasFX and hasSH and hasGames and hasElpLink and hasWikipedia and hasInstructions and hasMediaelement and hasTooltips and hasABCMusic):
isBreak = True
break
if not hasFlowplayer:
if 'flowPlayer.swf' in idevice.systemResources:
hasFlowplayer = True
if not hasMagnifier:
if 'mojomagnify.js' in idevice.systemResources:
hasMagnifier = True
if not hasXspfplayer:
if 'xspf_player.swf' in idevice.systemResources:
hasXspfplayer = True
if not hasGallery:
hasGallery = common.ideviceHasGallery(idevice)
if not hasFX:
hasFX = common.ideviceHasFX(idevice)
if not hasSH:
#.........这里部分代码省略.........