本文整理汇总了Python中exe.export.websiteexport.WebsiteExport.export方法的典型用法代码示例。如果您正苦于以下问题:Python WebsiteExport.export方法的具体用法?Python WebsiteExport.export怎么用?Python WebsiteExport.export使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exe.export.websiteexport.WebsiteExport
的用法示例。
在下文中一共展示了WebsiteExport.export方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: exportWebSite
# 需要导入模块: from exe.export.websiteexport import WebsiteExport [as 别名]
# 或者: from exe.export.websiteexport.WebsiteExport import export [as 别名]
def exportWebSite(self, client, filename, stylesDir):
"""
Export 'client' to a web site,
'webDir' is just read from config.webDir
'stylesDir' is where to copy the style sheet information from
"""
try:
# filename is a directory where we will export the website to
# We assume that the user knows what they are doing
# and don't check if the directory is already full or not
# and we just overwrite what's already there
filename = Path(filename)
# Append the package name to the folder path if necessary
if filename.basename() != self.package.name:
filename /= self.package.name
if not filename.exists():
filename.makedirs()
elif not filename.isdir():
client.alert(_(u'Filename %s is a file, cannot replace it') %
filename)
log.error("Couldn't export web page: "+
"Filename %s is a file, cannot replace it" % filename)
return
else:
client.alert(_(u'Folder name %s already exists. '
'Please choose another one or delete existing one then try again.') % filename)
return
# Now do the export
websiteExport = WebsiteExport(self.config, stylesDir, filename)
websiteExport.export(self.package)
except Exception, e:
client.alert(_('EXPORT FAILED!\n%s') % str(e))
raise
示例2: testExport
# 需要导入模块: from exe.export.websiteexport import WebsiteExport [as 别名]
# 或者: from exe.export.websiteexport.WebsiteExport import export [as 别名]
def testExport(self):
# Delete the output dir
outdir = TempDirPath()
G.application = Application()
G.application.loadConfiguration()
G.application.preLaunch()
# Load a package
package = Package.load('testing/testPackage2.elp')
# Do the export
style_dir = G.application.config.stylesDir / package.style
exporter = WebsiteExport(G.application.config,
style_dir,
outdir)
exporter.export(package)
# Check that it all exists now
assert outdir.isdir()
assert (outdir / 'index.html').isfile()
# Check that the style sheets have been copied
for filename in style_dir.files():
assert ((outdir / filename.basename()).exists(),
'Style file "%s" not copied' % (outdir / filename.basename()))
# Check that each node in the package has had a page made
pagenodes = Set([p.node for p in exporter.pages])
othernodes = Set(self._getNodes([], package.root))
assert pagenodes == othernodes
for page in exporter.pages:
self._testPage(page, outdir)
示例3: export
# 需要导入模块: from exe.export.websiteexport import WebsiteExport [as 别名]
# 或者: from exe.export.websiteexport.WebsiteExport import export [as 别名]
def export(self, package):
"""
Export SCORM package
"""
# First do the export to a temporary directory
outputDir = TempDirPath()
self.metadataType = package.exportMetadataType
# copy the package's resource files
package.resourceDir.copyfiles(outputDir)
# copy the package's resource files, only non existant in outputDir
# outputDirFiles = outputDir.files()
# for rfile in package.resourceDir.files():
# if rfile not in outputDirFiles:
# rfile.copy(outputDir)
# copy the package's resource files, only indexed in package.resources
# for md5 in package.resources.values():
# for resource in md5:
# resource.path.copy(outputDir)
# Export the package content
# Import the Scorm Page class , if the secure mode is off. If the style has it's own page class
# use that, else use the default one.
if self.styleSecureMode == "0":
if (self.styleDir / "scormpage.py").exists():
global ScormPage
module = imp.load_source("ScormPage", self.styleDir / "scormpage.py")
ScormPage = module.ScormPage
self.pages = [ScormPage("index", 1, package.root, scormType=self.scormType, metadataType=self.metadataType)]
self.generatePages(package.root, 2)
uniquifyNames(self.pages)
for page in self.pages:
page.save(outputDir)
if not self.hasForum:
for idevice in page.node.idevices:
if hasattr(idevice, "isForum"):
if idevice.forum.lms.lms == "moodle":
self.hasForum = True
break
# Create the manifest file
manifest = Manifest(self.config, outputDir, package, self.pages, self.scormType, self.metadataType)
manifest.save("imsmanifest.xml")
if self.hasForum:
manifest.save("discussionforum.xml")
# Copy the style sheet files to the output dir
styleFiles = [self.styleDir / ".." / "base.css"]
styleFiles += [self.styleDir / ".." / "popup_bg.gif"]
# And with all the files of the style we avoid problems:
styleFiles += self.styleDir.files("*.*")
if self.scormType == "commoncartridge":
for sf in styleFiles[:]:
if sf.basename() not in manifest.dependencies:
styleFiles.remove(sf)
self.styleDir.copylist(styleFiles, outputDir)
# Copy the scripts
dT = common.getExportDocType()
if dT == "HTML5":
jsFile = self.scriptsDir / "exe_html5.js"
jsFile.copyfile(outputDir / "exe_html5.js")
# jQuery
my_style = G.application.config.styleStore.getStyle(page.node.package.style)
if my_style.hasValidConfig:
if my_style.get_jquery() == True:
jsFile = self.scriptsDir / "exe_jquery.js"
jsFile.copyfile(outputDir / "exe_jquery.js")
else:
jsFile = self.scriptsDir / "exe_jquery.js"
jsFile.copyfile(outputDir / "exe_jquery.js")
if self.scormType == "commoncartridge":
jsFile = self.scriptsDir / "common.js"
jsFile.copyfile(outputDir / "common.js")
if self.scormType == "scorm2004" or self.scormType == "scorm1.2":
self.scriptsDir.copylist(("SCORM_API_wrapper.js", "SCOFunctions.js", "common.js"), outputDir)
# about SCHEMAS:
schemasDir = ""
if self.scormType == "scorm1.2":
schemasDir = self.schemasDir / "scorm1.2"
schemasDir.copylist(
(
"imscp_rootv1p1p2.xsd",
"imsmd_rootv1p2p1.xsd",
"adlcp_rootv1p2.xsd",
"lom.xsd",
"lomCustom.xsd",
"ims_xml.xsd",
),
outputDir,
)
#.........这里部分代码省略.........
示例4: export_website
# 需要导入模块: from exe.export.websiteexport import WebsiteExport [as 别名]
# 或者: from exe.export.websiteexport.WebsiteExport import export [as 别名]
def export_website(self, pkg, outputf):
outputfp = Path(outputf)
outputfp.makedirs()
websiteExport = WebsiteExport(self.config, self.styles_dir, outputf)
websiteExport.export(pkg)
示例5: testExport
# 需要导入模块: from exe.export.websiteexport import WebsiteExport [as 别名]
# 或者: from exe.export.websiteexport.WebsiteExport import export [as 别名]
def testExport(self):
# Delete the output dir
outdir = TempDirPath()
G.application = Application()
G.application.loadConfiguration()
G.application.preLaunch()
# Load a package
package = Package.load('testing/testPackage2.elp')
# Do the export
style_dir = G.application.config.stylesDir / package.style
exporter = WebsiteExport(G.application.config,
style_dir,
outdir)
exporter.export(package)
# Check that it all exists now
assert outdir.isdir()
assert (outdir / 'index.html').isfile()
# Check that the style sheets have been copied
for filename in style_dir.files():
#Skip the styles config.xml - that should not be included
if filename.basename() == "config.xml":
continue
assert ((outdir / filename.basename()).exists(),
'Style file "%s" not copied' % (outdir / filename.basename()))
#check the modification time is correct
f_dst = Path(outdir/filename.basename())
f_src = Path(filename)
self.assertTrue(
TestUtils.mod_time_diff(f_dst, f_src) < 0.1,
"Modification time in style dir preserved")
for res_file in package.resourceDir.files():
dst_file = Path(outdir/ res_file.basename())
self.assertTrue(dst_file.isfile())
self.assertTrue(
TestUtils.mod_time_diff(res_file, dst_file) < 0.1,
"Resource file %s has same mod time as origin" \
% res_file.basename())
#test that everything that was copied hahs the right mod time
copy_list = package.make_system_copy_list(style_dir,
G.application.config.webDir/"scripts" ,
G.application.config.webDir/"templates",
G.application.config.webDir/"images",
G.application.config.webDir/"css",
outdir)
TestUtils.check_copy_list_mod_time(copy_list, self)
# Check that each node in the package has had a page made
pagenodes = Set([p.node for p in exporter.pages])
othernodes = Set(self._getNodes([], package.root))
assert pagenodes == othernodes
for page in exporter.pages:
self._testPage(page, outdir)
示例6: export_report
# 需要导入模块: from exe.export.websiteexport import WebsiteExport [as 别名]
# 或者: from exe.export.websiteexport.WebsiteExport import export [as 别名]
def export_report(self, pkg, outputf):
websiteExport = WebsiteExport(self.config, self.styles_dir, outputf, report=True)
websiteExport.export(pkg)
示例7: export
# 需要导入模块: from exe.export.websiteexport import WebsiteExport [as 别名]
# 或者: from exe.export.websiteexport.WebsiteExport import export [as 别名]
def export(self, package):
"""
Export SCORM package
"""
# First do the export to a temporary directory
outputDir = TempDirPath()
self.metadataType = package.exportMetadataType
# 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)
# copy the package's resource files, only non existant in outputDir
# outputDirFiles = outputDir.files()
# for rfile in package.resourceDir.files():
# if rfile not in outputDirFiles:
# rfile.copy(outputDir)
# copy the package's resource files, only indexed in package.resources
# for md5 in package.resources.values():
# for resource in md5:
# resource.path.copy(outputDir)
# Export the package content
# Import the Scorm Page class , if the secure mode is off. If the style has it's own page class
# use that, else use the default one.
if self.styleSecureMode=="0":
if (self.styleDir/"scormpage.py").exists():
global ScormPage
module = imp.load_source("ScormPage",self.styleDir/"scormpage.py")
ScormPage = module.ScormPage
self.pages = [ ScormPage("index", 1, package.root,
scormType=self.scormType, metadataType=self.metadataType) ]
self.generatePages(package.root, 2)
uniquifyNames(self.pages)
for page in self.pages:
page.save(outputDir, self.pages)
if not self.hasForum:
for idevice in page.node.idevices:
if hasattr(idevice, "isForum"):
if idevice.forum.lms.lms == "moodle":
self.hasForum = True
break
# Create the manifest file
manifest = Manifest(self.config, outputDir, package, self.pages, self.scormType, self.metadataType)
modifiedMetaData = manifest.save("imsmanifest.xml")
# Create lang file
langFile = open(outputDir + '/common_i18n.js', "w")
langFile.write(common.getJavaScriptStrings(False))
langFile.close()
if self.hasForum:
manifest.save("discussionforum.xml")
# Copy the style files to the output dir
styleFiles = [self.styleDir/'..'/'popup_bg.gif']
# And with all the files of the style we avoid problems:
styleFiles += self.styleDir.files("*.*")
if self.scormType == "commoncartridge":
for sf in styleFiles[:]:
if sf.basename() not in manifest.dependencies:
styleFiles.remove(sf)
self.styleDir.copylist(styleFiles, outputDir)
listCSSFiles=getFilesCSSToMinify('scorm', self.styleDir)
exportMinFileCSS(listCSSFiles, outputDir)
# Copy the scripts
dT = common.getExportDocType()
if dT == "HTML5":
#listFiles+=[self.scriptsDir/'exe_html5.js']
#listOutFiles+=[outputDir/'exe_html5.js']
jsFile = (self.scriptsDir/'exe_html5.js')
jsFile.copyfile(outputDir/'exe_html5.js')
# jQuery
my_style = G.application.config.styleStore.getStyle(page.node.package.style)
if my_style.hasValidConfig:
if my_style.get_jquery() == True:
#listFiles+=[self.scriptsDir/'exe_jquery.js']
#listOutFiles+=[outputDir/'exe_jquery.js']
#.........这里部分代码省略.........
示例8: export
# 需要导入模块: from exe.export.websiteexport import WebsiteExport [as 别名]
# 或者: from exe.export.websiteexport.WebsiteExport import export [as 别名]
def export(self, package):
"""
Export SCORM package
"""
# First do the export to a temporary directory
outputDir = TempDirPath()
# copy the package's resource files
package.resourceDir.copyfiles(outputDir)
# copy the package's resource files, only non existant in outputDir
# outputDirFiles = outputDir.files()
# for rfile in package.resourceDir.files():
# if rfile not in outputDirFiles:
# rfile.copy(outputDir)
# copy the package's resource files, only indexed in package.resources
# for md5 in package.resources.values():
# for resource in md5:
# resource.path.copy(outputDir)
# Export the package content
self.pages = [ ScormPage("index", 1, package.root,
scormType=self.scormType, metadataType=self.metadataType) ]
self.generatePages(package.root, 2)
uniquifyNames(self.pages)
for page in self.pages:
page.save(outputDir)
if not self.hasForum:
for idevice in page.node.idevices:
if hasattr(idevice, "isForum"):
if idevice.forum.lms.lms == "moodle":
self.hasForum = True
break
# Create the manifest file
manifest = Manifest(self.config, outputDir, package, self.pages, self.scormType, self.metadataType)
manifest.save("imsmanifest.xml")
if self.hasForum:
manifest.save("discussionforum.xml")
# Copy the style sheet files to the output dir
# But not nav.css
styleFiles = [self.styleDir/'..'/'base.css']
styleFiles += [self.styleDir/'..'/'popup_bg.gif']
styleFiles += [f for f in self.styleDir.files("*.css")
if f.basename() <> "nav.css"]
styleFiles += self.styleDir.files("*.jpg")
styleFiles += self.styleDir.files("*.gif")
styleFiles += self.styleDir.files("*.png")
styleFiles += self.styleDir.files("*.js")
styleFiles += self.styleDir.files("*.html")
styleFiles += self.styleDir.files("*.ttf")
styleFiles += self.styleDir.files("*.eot")
styleFiles += self.styleDir.files("*.otf")
styleFiles += self.styleDir.files("*.woff")
# FIXME for now, only copy files referenced in Common Cartridge
# this really should apply to all exports, but without a manifest
# of the files needed by an included stylesheet it is too restrictive
if self.scormType == "commoncartridge":
for sf in styleFiles[:]:
if sf.basename() not in manifest.dependencies:
styleFiles.remove(sf)
self.styleDir.copylist(styleFiles, outputDir)
# Copy the scripts
if self.scormType == "commoncartridge":
self.scriptsDir.copylist(('libot_drag.js',
'common.js'), outputDir)
if self.scormType == "scorm2004":
self.scriptsDir.copylist(('AC_RunActiveContent.js',
'SCORM_API_wrapper.js',
'SCOFunctions.js',
'libot_drag.js',
'common.js'), outputDir)
if self.scormType != "commoncartridge" and self.scormType != "scorm2004":
self.scriptsDir.copylist(('APIWrapper.js',
'SCOFunctions.js',
'libot_drag.js',
'common.js'), outputDir)
schemasDir = ""
if self.scormType == "scorm1.2":
schemasDir = self.schemasDir/"scorm1.2"
schemasDir.copylist(('imscp_rootv1p1p2.xsd',
'imsmd_rootv1p2p1.xsd',
'adlcp_rootv1p2.xsd',
'ims_xml.xsd'), outputDir)
elif self.scormType == "scorm2004":
schemasDir = self.schemasDir/"scorm2004"
schemasDir.copylist(('adlcp_v1p3.xsd',
'adlnav_v1p3.xsd',
'adlseq_v1p3.xsd',
'datatypes.dtd',
'imscp_v1p1.xsd',
'imsssp_v1p0.xsd',
'imsss_v1p0.xsd',
'imsss_v1p0auxresource.xsd',
'imsss_v1p0control.xsd',
#.........这里部分代码省略.........