本文整理汇总了Python中exe.engine.path.Path.copylist方法的典型用法代码示例。如果您正苦于以下问题:Python Path.copylist方法的具体用法?Python Path.copylist怎么用?Python Path.copylist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exe.engine.path.Path
的用法示例。
在下文中一共展示了Path.copylist方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: WebsiteExport
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import copylist [as 别名]
#.........这里部分代码省略.........
if not self.report:
thisPage.save(outputDir, prevPage, None, self.pages)
if self.prefix == "":
self.copyFiles(package, outputDir)
return outputDir
else:
self.filename.write_text(self.report, 'utf-8')
def copyFiles(self, package, outputDir):
"""
Copy all the files used by the website.
"""
if os.path.isdir(self.stylesDir):
# Copy the style sheet files to the output dir
styleFiles = [self.stylesDir/'..'/'base.css']
styleFiles += [self.stylesDir/'..'/'popup_bg.gif']
styleFiles += self.stylesDir.files("*.css")
styleFiles += self.stylesDir.files("*.jpg")
styleFiles += self.stylesDir.files("*.gif")
styleFiles += self.stylesDir.files("*.png")
styleFiles += self.stylesDir.files("*.js")
styleFiles += self.stylesDir.files("*.html")
styleFiles += self.stylesDir.files("*.ico")
styleFiles += self.stylesDir.files("*.ttf")
styleFiles += self.stylesDir.files("*.eot")
styleFiles += self.stylesDir.files("*.otf")
styleFiles += self.stylesDir.files("*.woff")
self.stylesDir.copylist(styleFiles, outputDir)
# copy the package's resource files
package.resourceDir.copyfiles(outputDir)
# copy script files.
my_style = G.application.config.styleStore.getStyle(package.style)
# jQuery
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')
jsFile = (self.scriptsDir/'common.js')
jsFile.copyfile(outputDir/'common.js')
#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
示例2: SinglePageExport
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import copylist [as 别名]
class SinglePageExport(object):
"""
SinglePageExport will export a package as a website of HTML pages
"""
def __init__(self, stylesDir, outputDir, imagesDir, scriptsDir, cssDir, templatesDir):
"""
'stylesDir' is the directory where we can copy the stylesheets from
'outputDir' is the directory that will be [over]written
with the website
"""
self.html = ""
self.style = None
self.name = None
self.stylesDir = Path(stylesDir)
self.outputDir = Path(outputDir)
self.imagesDir = Path(imagesDir)
self.scriptsDir = Path(scriptsDir)
self.cssDir = Path(cssDir)
self.templatesDir = Path(templatesDir)
self.page = None
# Create the output dir if it doesn't already exist
if not self.outputDir.exists():
self.outputDir.mkdir()
def export(self, package, for_print=0):
"""
Export web site
Cleans up the previous packages pages and performs the export
"""
self.style = package.style
self.page = SinglePage("index", 1, package.root)
self.page.save(self.outputDir/"index.html", for_print)
if hasattr(package, 'exportSource') and package.exportSource and not for_print:
(G.application.config.webDir/'templates'/'content.xsd').copyfile(self.outputDir/'content.xsd')
(self.outputDir/'content.data').write_bytes(encodeObject(package))
(self.outputDir/'contentv3.xml').write_bytes(encodeObjectToXML(package))
self.copyFiles(package)
def copyFiles(self, package):
"""
Copy all the files used by the website.
"""
# Copy the style sheet files to the output dir
# But not nav.css
if os.path.isdir(self.stylesDir):
# Copy the style sheet files to the output dir
styleFiles = [self.stylesDir/'..'/'base.css']
styleFiles += [self.stylesDir/'..'/'popup_bg.gif']
styleFiles += self.stylesDir.files("*.css")
if "nav.css" in styleFiles:
styleFiles.remove("nav.css")
styleFiles += self.stylesDir.files("*.jpg")
styleFiles += self.stylesDir.files("*.gif")
styleFiles += self.stylesDir.files("*.png")
styleFiles += self.stylesDir.files("*.js")
styleFiles += self.stylesDir.files("*.html")
styleFiles += self.stylesDir.files("*.ico")
styleFiles += self.stylesDir.files("*.ttf")
styleFiles += self.stylesDir.files("*.eot")
styleFiles += self.stylesDir.files("*.otf")
styleFiles += self.stylesDir.files("*.woff")
self.stylesDir.copylist(styleFiles, self.outputDir)
# copy the package's resource files
package.resourceDir.copyfiles(self.outputDir)
# copy script files.
my_style = G.application.config.styleStore.getStyle(package.style)
# jQuery
if my_style.hasValidConfig:
if my_style.get_jquery() == True:
jsFile = (self.scriptsDir/'exe_jquery.js')
jsFile.copyfile(self.outputDir/'exe_jquery.js')
else:
jsFile = (self.scriptsDir/'exe_jquery.js')
jsFile.copyfile(self.outputDir/'exe_jquery.js')
jsFile = (self.scriptsDir/'common.js')
jsFile.copyfile(self.outputDir/'common.js')
jsFile = (self.scriptsDir/'lernmodule_net.js')
jsFile.copyfile(self.outputDir/'lernmodule_net.js')
dT = common.getExportDocType()
if dT == "HTML5":
jsFile = (self.scriptsDir/'exe_html5.js')
jsFile.copyfile(self.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(self.outputDir/'favicon.ico')
#.........这里部分代码省略.........
示例3: Epub3Export
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import copylist [as 别名]
class Epub3Export(object):
"""
Exports an eXe package as a epub 3 package
The 'Hello World' of a epub 3 publication might contain files:
mimetype
META-INF/container.xml
Content/HelloWorld.opf
Content/HelloWorld.xhtml
"""
def __init__(self, config, styleDir, filename):
"""
Initialize
'styleDir' is the directory from which we will copy our style sheets
(and some gifs)
"""
self.config = config
self.imagesDir = config.webDir / "images"
self.scriptsDir = config.webDir / "scripts"
self.cssDir = config.webDir / "css"
self.templatesDir = config.webDir / "templates"
self.schemasDir = config.webDir / "schemas/ims"
self.styleDir = Path(styleDir)
self.filename = Path(filename)
self.pages = []
def export(self, package):
"""
Export epub 3 package
"""
# First do the export to a temporary directory
outputDir = TempDirPath()
'''
fileDir = outputDir/"META-INF"
fileDir.mkdir()
fileDir = outputDir/"Content"
fileDir.mkdir()
'''
metainfPages = Path(outputDir.abspath() + '/META-INF')
# metainfPages = outputDir/'META-INF'
metainfPages.mkdir()
contentPages = Path(outputDir.abspath() + '/EPUB')
# contentPages = outputDir/'Content'
contentPages.mkdir()
# print contentPages.abspath()
# print outputDir.abspath()
# Export the package content
self.pages = [self.make_cover_page(package)]
self.generatePages(package.root, 2)
uniquifyNames(self.pages, suffix = ".xhtml")
cover = None
for page in self.pages:
page.save(contentPages)
if hasattr(page, 'cover'):
cover = page.cover
# Create mimetype file
mimetypeFile = open(outputDir.abspath() + '/mimetype', "w")
mimetypeFile.write('application/epub+zip')
mimetypeFile.close()
# 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
package.resourceDir.copyfiles(contentPages)
self.styleDir.copylist(styleFiles, contentPages)
self.scriptsDir.copylist(('common.js',), contentPages)
# copy players for media idevices.
hasFlowplayer = False
hasMagnifier = False
hasXspfplayer = False
hasGallery = False
hasWikipedia = False
isBreak = False
hasInstructions = False
for page in self.pages:
if isBreak:
break
#.........这里部分代码省略.........
示例4: ScormExport
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import copylist [as 别名]
class ScormExport(object):
"""
Exports an eXe package as a SCORM package
"""
def __init__(self, config, styleDir, filename, scormType):
"""
Initialize
'styleDir' is the directory from which we will copy our style sheets
(and some gifs)
"""
self.config = config
self.imagesDir = config.webDir/"images"
self.scriptsDir = config.webDir/"scripts"
self.templatesDir = config.webDir/"templates"
self.styleDir = Path(styleDir)
self.filename = Path(filename)
self.pages = []
self.hasForum = False
self.scormType = scormType
def export(self, package):
"""
Export SCORM package
"""
outputDir = TempDirPath()
styleFiles = [self.styleDir/'..'/'base.css']
styleFiles += [self.styleDir/'..'/'popup_bg.gif']
styleFiles += self.styleDir.files("*.css")
if "nav.css" in styleFiles:
styleFiles.remove("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")
self.styleDir.copylist(styleFiles, outputDir)
package.resourceDir.copyfiles(outputDir)
self.pages = [ ScormPage("index", 1, package.root) ]
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
manifest = Manifest(self.config, outputDir, package, self.pages, self.scormType)
manifest.save("imsmanifest.xml")
if self.hasForum:
manifest.save("discussionforum.xml")
self.scriptsDir.copylist(('APIWrapper.js',
'imscp_rootv1p1p2.xsd',
'imsmd_rootv1p2p1.xsd',
'ims_xml.xsd',
'adlcp_rootv1p2.xsd',
'SCOFunctions.js',
'libot_drag.js',
'common.js'), outputDir)
self.templatesDir.copylist(('videoContainer.swf', 'magnifier.swf',
'xspf_player.swf'),outputDir)
(self.templatesDir/'fdl.html').copyfile(outputDir/'fdl.html')
self.filename.safeSave(self.doZip, _('EXPORT FAILED!\nLast succesful export is %s.'), outputDir)
outputDir.rmtree()
def doZip(self, fileObj, outputDir):
"""
Actually does the zipping of the file. Called by 'Path.safeSave'
"""
zipped = ZipFile(fileObj, "w")
for scormFile in outputDir.files():
zipped.write(scormFile,
scormFile.basename().encode('utf8'),
ZIP_DEFLATED)
zipped.close()
def generatePages(self, node, depth):
"""
Recursive function for exporting a node.
'node' is the node that we are making a page for
'depth' is the number of ancestors that the page has +1 (ie. root is 1)
"""
for child in node.children:
pageName = child.titleShort.lower().replace(" ", "_")
pageName = re.sub(r"\W", "", pageName)
if not pageName:
pageName = "__"
page = ScormPage(pageName, depth, child)
self.pages.append(page)
self.generatePages(child, depth + 1)
示例5: ScormExport
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import copylist [as 别名]
class ScormExport(object):
"""
Exports an eXe package as a SCORM package
"""
def __init__(self, config, styleDir, filename, scormType):
"""
Initialize
'styleDir' is the directory from which we will copy our style sheets
(and some gifs)
"""
self.config = config
self.imagesDir = config.webDir/"images"
self.scriptsDir = config.webDir/"scripts"
self.templatesDir = config.webDir/"templates"
self.schemasDir = config.webDir/"schemas"
self.styleDir = Path(styleDir)
self.filename = Path(filename)
self.pages = []
self.hasForum = False
self.scormType = scormType
def export(self, package):
"""
Export SCORM package
"""
# First do the export to a temporary directory
outputDir = TempDirPath()
# Export the package content
self.pages = [ ScormPage("index", 1, package.root,
scormType=self.scormType) ]
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)
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")
# 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 package's resource files
package.resourceDir.copyfiles(outputDir)
# Copy the scripts
if self.scormType == "commoncartridge":
self.scriptsDir.copylist(('libot_drag.js',
'common.js'), outputDir)
else:
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(('imscp_rootv1p1p2.xsd',
'imsmd_rootv1p2p1.xsd',
'adlcp_rootv1p2.xsd',
'ims_xml.xsd'), outputDir)
# copy players for media idevices.
hasFlowplayer = False
#.........这里部分代码省略.........
示例6: IMSExport
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import copylist [as 别名]
class IMSExport(object):
"""
Exports an eXe package as a SCORM package
"""
def __init__(self, config, styleDir, filename):
""" Initialize
'styleDir' is the directory from which we will copy our style sheets
(and some gifs)
"""
self.config = config
self.imagesDir = config.webDir/"images"
self.scriptsDir = config.webDir/"scripts"
self.templatesDir = config.webDir/"templates"
self.schemasDir = config.webDir/"schemas/ims"
self.styleDir = Path(styleDir)
self.filename = Path(filename)
self.pages = []
def export(self, package):
"""
Export SCORM package
"""
outputDir = TempDirPath()
styleFiles = [self.styleDir/'..'/'base.css']
styleFiles += [self.styleDir/'..'/'popup_bg.gif']
styleFiles += self.styleDir.files("*.css")
if "nav.css" in styleFiles:
styleFiles.remove("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")
self.styleDir.copylist(styleFiles, outputDir)
package.resourceDir.copyfiles(outputDir)
self.pages = [ IMSPage("index", 1, package.root) ]
self.generatePages(package.root, 2)
uniquifyNames(self.pages)
for page in self.pages:
page.save(outputDir)
manifest = Manifest(self.config, outputDir, package, self.pages)
manifest.save()
self.scriptsDir.copylist(('libot_drag.js',
'common.js'), outputDir)
self.schemasDir.copylist(('imscp_v1p1.xsd',
'imsmd_v1p2p2.xsd',
'ims_xml.xsd'), outputDir)
hasFlowplayer = False
hasMagnifier = False
hasXspfplayer = False
isBreak = False
for page in self.pages:
if isBreak:
break
for idevice in page.node.idevices:
if (hasFlowplayer and hasMagnifier and hasXspfplayer):
isBreak = True
break
if not hasFlowplayer:
if 'flowPlayer.swf' in idevice.systemResources:
hasFlowplayer = True
if not hasMagnifier:
if 'magnifier.swf' in idevice.systemResources:
hasMagnifier = True
if not hasXspfplayer:
if 'xspf_player.swf' in idevice.systemResources:
hasXspfplayer = True
if hasFlowplayer:
videofile = (self.templatesDir/'flowPlayer.swf')
videofile.copyfile(outputDir/'flowPlayer.swf')
if hasMagnifier:
videofile = (self.templatesDir/'magnifier.swf')
videofile.copyfile(outputDir/'magnifier.swf')
if hasXspfplayer:
videofile = (self.templatesDir/'xspf_player.swf')
videofile.copyfile(outputDir/'xspf_player.swf')
(self.templatesDir/'fdl.html').copyfile(outputDir/'fdl.html')
self.filename.safeSave(self.doZip, _('EXPORT FAILED!\nLast succesful export is %s.'), outputDir)
outputDir.rmtree()
def doZip(self, fileObj, outputDir):
"""
Actually does the zipping of the file. Called by 'Path.safeSave'
"""
zipped = ZipFile(fileObj, "w")
for scormFile in outputDir.files():
zipped.write(scormFile,
scormFile.basename().encode('utf8'), ZIP_DEFLATED)
zipped.close()
def generatePages(self, node, depth):
"""
Recursive function for exporting a node.
'outputDir' is the temporary directory that we are exporting to
before creating zip file
"""
for child in node.children:
pageName = child.titleShort.lower().replace(" ", "_")
pageName = re.sub(r"\W", "", pageName)
if not pageName:
pageName = "__"
page = IMSPage(pageName, depth, child)
self.pages.append(page)
#.........这里部分代码省略.........
示例7: SinglePageExport
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import copylist [as 别名]
class SinglePageExport(object):
"""
SinglePageExport will export a package as a website of HTML pages
"""
def __init__(self, stylesDir, outputDir, imagesDir, scriptsDir, cssDir, templatesDir):
"""
'stylesDir' is the directory where we can copy the stylesheets from
'outputDir' is the directory that will be [over]written
with the website
"""
self.html = ""
self.style = None
self.name = None
self.stylesDir = Path(stylesDir)
self.outputDir = Path(outputDir)
self.imagesDir = Path(imagesDir)
self.scriptsDir = Path(scriptsDir)
self.cssDir = Path(cssDir)
self.templatesDir = Path(templatesDir)
self.page = None
# Create the output dir if it doesn't already exist
if not self.outputDir.exists():
self.outputDir.mkdir()
def export(self, package, for_print=0):
"""
Export web site
Cleans up the previous packages pages and performs the export
"""
self.style = package.style
self.page = SinglePage("index", 1, package.root)
ext = 'html'
if G.application.config.cutFileName == "1":
ext = 'htm'
self.page.save(self.outputDir/"index" + '.' + ext, for_print)
if hasattr(package, 'exportSource') and package.exportSource and not for_print:
(G.application.config.webDir/'templates'/'content.xsd').copyfile(self.outputDir/'content.xsd')
(self.outputDir/'content.data').write_bytes(encodeObject(package))
(self.outputDir/'contentv3.xml').write_bytes(encodeObjectToXML(package))
self.copyFiles(package)
def copyFiles(self, package):
"""
Copy all the files used by the website.
"""
# Copy the style files to the output dir
# But not nav.css
if os.path.isdir(self.stylesDir):
styleFiles = [self.stylesDir/'..'/'popup_bg.gif']
styleFiles += self.stylesDir.files("*.*")
if "nav.css" in styleFiles:
styleFiles.remove("nav.css")
self.stylesDir.copylist(styleFiles, self.outputDir)
# copy the package's resource files
for resourceFile in package.resourceDir.walkfiles():
file = package.resourceDir.relpathto(resourceFile)
if ("/" in file):
Dir = Path(self.outputDir/file[:file.rindex("/")])
if not Dir.exists():
Dir.makedirs()
resourceFile.copy(self.outputDir/Dir)
else:
resourceFile.copy(self.outputDir)
listCSSFiles=getFilesCSSToMinify('singlepage', self.stylesDir)
exportMinFileCSS(listCSSFiles, self.outputDir)
# copy script files.
my_style = G.application.config.styleStore.getStyle(package.style)
# jQuery
if my_style.hasValidConfig:
if my_style.get_jquery() == True:
jsFile = (self.scriptsDir/'exe_jquery.js')
jsFile.copyfile(self.outputDir/'exe_jquery.js')
else:
jsFile = (self.scriptsDir/'exe_jquery.js')
jsFile.copyfile(self.outputDir/'exe_jquery.js')
dT = common.getExportDocType()
if dT == "HTML5":
jsFile = (self.scriptsDir/'exe_html5.js')
jsFile.copyfile(self.outputDir/'exe_html5.js')
# Minify common.js file
listFiles=getFilesJSToMinify('singlepage', self.scriptsDir)
exportMinFileJS(listFiles, self.outputDir)
# Create lang file
langFile = open(self.outputDir + '/common_i18n.js', "w")
#.........这里部分代码省略.........
示例8: SinglePageExport
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import copylist [as 别名]
class SinglePageExport(object):
"""
SinglePageExport will export a package as a website of HTML pages
"""
def __init__(self, stylesDir, outputDir, imagesDir, scriptsDir, templatesDir):
"""
'stylesDir' is the directory where we can copy the stylesheets from
'outputDir' is the directory that will be [over]written
with the website
"""
self.html = ""
self.style = None
self.name = None
self.stylesDir = Path(stylesDir)
self.outputDir = Path(outputDir)
self.imagesDir = Path(imagesDir)
self.scriptsDir = Path(scriptsDir)
self.templatesDir = Path(templatesDir)
self.page = None
# Create the output dir if it doesn't already exist
if not self.outputDir.exists():
self.outputDir.mkdir()
def export(self, package, for_print=0):
"""
Export web site
Cleans up the previous packages pages and performs the export
"""
self.style = package.style
self.page = SinglePage("index", 1, package.root)
self.page.save(self.outputDir/"index.html", for_print)
self.copyFiles(package)
def copyFiles(self, package):
"""
Copy all the files used by the website.
"""
# Copy the style sheet files to the output dir
# But not nav.css
styleFiles = [self.stylesDir/'..'/'base.css']
styleFiles += [self.stylesDir/'..'/'popup_bg.gif']
styleFiles += self.stylesDir.files("*.css")
if "nav.css" in styleFiles:
styleFiles.remove("nav.css")
styleFiles += self.stylesDir.files("*.jpg")
styleFiles += self.stylesDir.files("*.gif")
styleFiles += self.stylesDir.files("*.png")
styleFiles += self.stylesDir.files("*.js")
styleFiles += self.stylesDir.files("*.html")
self.stylesDir.copylist(styleFiles, self.outputDir)
# copy the package's resource files
package.resourceDir.copyfiles(self.outputDir)
# copy script files.
self.scriptsDir.copylist(('libot_drag.js', 'common.js'),
self.outputDir)
# copy players for media idevices.
hasFlowplayer = False
hasMagnifier = False
hasXspfplayer = False
for idevice in self.page.node.idevices:
if (hasFlowplayer and hasMagnifier and hasXspfplayer):
break
if not hasFlowplayer:
if 'flowPlayer.swf' in idevice.systemResources:
hasFlowplayer = True
if not hasMagnifier:
if 'magnifier.swf' in idevice.systemResources:
hasMagnifier = True
if not hasXspfplayer:
if 'xspf_player.swf' in idevice.systemResources:
hasXspfplayer = True
if hasFlowplayer:
videofile = (self.templatesDir/'flowPlayer.swf')
videofile.copyfile(self.outputDir/'flowPlayer.swf')
if hasMagnifier:
videofile = (self.templatesDir/'magnifier.swf')
videofile.copyfile(self.outputDir/'magnifier.swf')
if hasXspfplayer:
videofile = (self.templatesDir/'xspf_player.swf')
videofile.copyfile(self.outputDir/'xspf_player.swf')
if package.license == "GNU Free Documentation License":
# include a copy of the GNU Free Documentation Licence
(self.templatesDir/'fdl.html').copyfile(self.outputDir/'fdl.html')
示例9: ScormExport
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import copylist [as 别名]
#.........这里部分代码省略.........
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']
jsFile = (self.scriptsDir/'exe_jquery.js')
jsFile.copyfile(outputDir/'exe_jquery.js')
else:
#listFiles+=[self.scriptsDir/'exe_jquery.js']
#listOutFiles+=[outputDir/'exe_jquery.js']
jsFile = (self.scriptsDir/'exe_jquery.js')
jsFile.copyfile(outputDir/'exe_jquery.js')
if self.scormType == "commoncartridge" or self.scormType == "scorm2004" or self.scormType == "scorm1.2":
listFiles=getFilesJSToMinify('scorm', self.scriptsDir)
exportMinFileJS(listFiles, outputDir)
示例10: WebsiteExport
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import copylist [as 别名]
class WebsiteExport(object):
"""
WebsiteExport will export a package as a website of HTML pages
"""
def __init__(self, config, styleDir, filename):
"""
'stylesDir' is the directory where we can copy the stylesheets from
'outputDir' is the directory that will be [over]written
with the website
"""
self.config = config
self.imagesDir = config.webDir/"images"
self.scriptsDir = config.webDir/"scripts"
self.templatesDir = config.webDir/"templates"
self.stylesDir = Path(styleDir)
self.filename = Path(filename)
self.pages = []
def exportZip(self, package):
"""
Export web site
Cleans up the previous packages pages and performs the export
"""
outputDir = TempDirPath()
self.copyFiles(package, outputDir)
if (self.stylesDir/"websitepage.py").exists():
global WebsitePage
module = imp.load_source("websitepage",
self.stylesDir/"websitepage.py")
WebsitePage = module.WebsitePage
self.pages = [ WebsitePage("index", 1, package.root) ]
self.generatePages(package.root, 1)
uniquifyNames(self.pages)
prevPage = None
thisPage = self.pages[0]
for nextPage in self.pages[1:]:
thisPage.save(outputDir, prevPage, nextPage, self.pages)
prevPage = thisPage
thisPage = nextPage
thisPage.save(outputDir, prevPage, None, self.pages)
self.filename.safeSave(self.doZip, _('EXPORT FAILED!\nLast succesful export is %s.'), outputDir)
outputDir.rmtree()
def doZip(self, fileObj, outputDir):
"""
Actually saves the zip data. Called by 'Path.safeSave'
"""
zipped = ZipFile(fileObj, "w")
for scormFile in outputDir.files():
zipped.write(scormFile, scormFile.basename().encode('utf8'), ZIP_DEFLATED)
zipped.close()
def export(self, package):
"""
Export web site
Cleans up the previous packages pages and performs the export
"""
outputDir = self.filename
if not outputDir.exists():
outputDir.mkdir()
self.copyFiles(package, outputDir)
if (self.stylesDir/"websitepage.py").exists():
global WebsitePage
module = imp.load_source("websitepage",
self.stylesDir/"websitepage.py")
WebsitePage = module.WebsitePage
self.pages = [ WebsitePage("index", 1, package.root) ]
self.generatePages(package.root, 1)
uniquifyNames(self.pages)
prevPage = None
thisPage = self.pages[0]
for nextPage in self.pages[1:]:
thisPage.save(outputDir, prevPage, nextPage, self.pages)
prevPage = thisPage
thisPage = nextPage
thisPage.save(outputDir, prevPage, None, self.pages)
def copyFiles(self, package, outputDir):
"""
Copy all the files used by the website.
"""
styleFiles = [self.stylesDir/'..'/'base.css']
styleFiles += [self.stylesDir/'..'/'popup_bg.gif']
styleFiles += self.stylesDir.files("*.css")
styleFiles += self.stylesDir.files("*.jpg")
styleFiles += self.stylesDir.files("*.gif")
styleFiles += self.stylesDir.files("*.png")
styleFiles += self.stylesDir.files("*.js")
styleFiles += self.stylesDir.files("*.html")
self.stylesDir.copylist(styleFiles, outputDir)
package.resourceDir.copyfiles(outputDir)
self.scriptsDir.copylist(('libot_drag.js', 'common.js'),
outputDir)
self.templatesDir.copylist(('videoContainer.swf', 'magnifier.swf',
'xspf_player.swf'), outputDir)
(self.templatesDir/'fdl.html').copyfile(outputDir/'fdl.html')
def generatePages(self, node, depth):
"""
Recursively generate pages and store in pages member variable
for retrieving later
"""
for child in node.children:
pageName = child.titleShort.lower().replace(" ", "_")
pageName = re.sub(r"\W", "", pageName)
#.........这里部分代码省略.........
示例11: WebsiteExport
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import copylist [as 别名]
#.........这里部分代码省略.........
if not self.report:
thisPage.save(outputDir, prevPage, None, self.pages)
if self.prefix == "":
self.copyFiles(package, outputDir)
return outputDir
else:
self.filename.write_text(self.report, 'utf-8')
def copyFiles(self, package, outputDir):
"""
Copy all the files used by the website.
"""
if os.path.isdir(self.stylesDir):
# Copy the style sheet files to the output dir
styleFiles = [self.stylesDir/'..'/'base.css']
styleFiles += [self.stylesDir/'..'/'popup_bg.gif']
styleFiles += self.stylesDir.files("*.css")
styleFiles += self.stylesDir.files("*.jpg")
styleFiles += self.stylesDir.files("*.gif")
styleFiles += self.stylesDir.files("*.png")
styleFiles += self.stylesDir.files("*.js")
styleFiles += self.stylesDir.files("*.html")
styleFiles += self.stylesDir.files("*.ico")
styleFiles += self.stylesDir.files("*.ttf")
styleFiles += self.stylesDir.files("*.eot")
styleFiles += self.stylesDir.files("*.otf")
styleFiles += self.stylesDir.files("*.woff")
self.stylesDir.copylist(styleFiles, outputDir)
# copy the package's resource files
package.resourceDir.copyfiles(outputDir)
# copy script files.
my_style = G.application.config.styleStore.getStyle(package.style)
# jQuery
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')
jsFile = (self.scriptsDir/'common.js')
jsFile.copyfile(outputDir/'common.js')
#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
示例12: ScormExport
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import copylist [as 别名]
class ScormExport(object):
"""
Exports an eXe package as a SCORM package
"""
def __init__(self, config, styleDir, filename, scormType, metadataType='DC'):
"""
Initialize
'styleDir' is the directory from which we will copy our style sheets
(and some gifs)
"""
self.config = config
self.imagesDir = config.webDir/"images"
self.scriptsDir = config.webDir/"scripts"
self.cssDir = config.webDir/"css"
self.templatesDir = config.webDir/"templates"
self.schemasDir = config.webDir/"schemas"
self.styleDir = Path(styleDir)
self.filename = Path(filename)
self.pages = []
self.hasForum = False
self.scormType = scormType
self.metadataType = metadataType
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',
#.........这里部分代码省略.........
示例13: Epub3Export
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import copylist [as 别名]
class Epub3Export(object):
"""
Exports an eXe package as a epub 3 package
The 'Hello World' of a epub 3 publication might contain files:
mimetype
META-INF/container.xml
Content/HelloWorld.opf
Content/HelloWorld.xhtml
"""
def __init__(self, config, styleDir, filename):
"""
Initialize
'styleDir' is the directory from which we will copy our style sheets
(and some gifs)
"""
self.config = config
self.imagesDir = config.webDir / "images"
self.scriptsDir = config.webDir / "scripts"
self.cssDir = config.webDir / "css"
self.templatesDir = config.webDir / "templates"
self.schemasDir = config.webDir / "schemas/ims"
self.styleDir = Path(styleDir)
self.filename = Path(filename)
self.pages = []
def export(self, package):
"""
Export epub 3 package
"""
# First do the export to a temporary directory
outputDir = TempDirPath()
'''
fileDir = outputDir/"META-INF"
fileDir.mkdir()
fileDir = outputDir/"Content"
fileDir.mkdir()
'''
metainfPages = Path(outputDir.abspath() + '/META-INF')
# metainfPages = outputDir/'META-INF'
metainfPages.mkdir()
contentPages = Path(outputDir.abspath() + '/EPUB')
# contentPages = outputDir/'Content'
contentPages.mkdir()
# print contentPages.abspath()
# print outputDir.abspath()
# Export the package content
self.pages = [Epub3Cover("cover", 1, package.root)]
self.generatePages(package.root, 2)
uniquifyNames(self.pages)
cover = None
for page in self.pages:
page.save(contentPages, self.pages)
if hasattr(page, 'cover'):
cover = page.cover
# Create mimetype file
mimetypeFile = open(outputDir.abspath() + '/mimetype', "w")
mimetypeFile.write('application/epub+zip')
mimetypeFile.close()
# Create common_i18n file
langFile = open(contentPages + '/common_i18n.js', "w")
langFile.write(common.getJavaScriptStrings(False))
langFile.close()
# Copy the style files to the output dir
# But not nav.css
styleFiles = [self.styleDir /'..'/ 'popup_bg.gif']
styleFiles += [f for f in self.styleDir.files("*.*") if f.basename() not in ['nav.css']]
# 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
# Add fallback document for possible image links
if Path(self.styleDir/'fallback.xhtml').exists():
styleFiles += [self.styleDir /'fallback.xhtml']
else:
styleFiles += [self.styleDir/'..'/'fallback.xhtml']
# copy the package's resource files
for resourceFile in package.resourceDir.walkfiles():
fn = package.resourceDir.relpathto(resourceFile)
if ("/" in fn):
Dir = Path(contentPages/fn[:fn.rindex("/")])
if not Dir.exists():
Dir.makedirs()
resourceFile.copy(contentPages/Dir)
else:
resourceFile.copy(contentPages)
self.styleDir.copylist(styleFiles, contentPages)
#.........这里部分代码省略.........
示例14: HandoutExport
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import copylist [as 别名]
class HandoutExport(object):
"""
This class transform a exe-package to a DOMPresenatation
"""
def __init__(self, config, styleDir, filename):
""" 'stylesDir' is the directory where we can copy the stylesheets from
'outputDir' is the directory that will be [over]written
with the website
"""
self.config = config
self.imagesDir = config.webDir/"images"
self.scriptsDir = config.webDir/"scripts"
self.templatesDir = config.webDir/"templates"
self.stylesDir = Path(styleDir)
self.filename = Path(filename)
self.pages = []
def export(self, package):
"""
exports package to a dom presentation
"""
outputDir = self.filename
if not outputDir.exists():
outputDir.mkdir()
self.pages = [ HandoutPage("Index", 1, package.root) ]
self.generatePages(package.root, 1)
log.debug(map(lambda x : getattr(x, "name"), self.pages))
html = u'''<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html dir="ltr" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>%s</title>
<style type="text/css" media="screen">
@import url(base.css);
@import url(content.css);
</style>
<script type="text/javascript">
function print_page() {
window.print();
window.close();
}
</script>
</head>
<body onload=print_page()>
<div id="boundary">
<h1 align="center">%s</h1>
''' % (package.name, package.name)
for page in self.pages:
slidehtml = page.render()
if slidehtml != "":
html += u'<div class="page">'
html += u'<p id="nodeTitle">%s</p>' % escape(page.node.titleLong)
html += slidehtml
html += u'</div>'
log.debug(type(html))
html = html.encode("utf8")
log.debug(type(html))
log.debug(html)
output = open(outputDir / "index.html", "w")
output.write(html)
output.close()
self.copyFiles(package, outputDir)
def copyFiles(self, package, outputDir):
"""
Copy all the files used by the website.
"""
print outputDir
# Copy the style sheet files to the output dir
styleFiles = [self.stylesDir/'..'/'base.css']
styleFiles += [self.stylesDir/'..'/'ds_styles.css']
styleFiles += [self.stylesDir/'..'/'popup_bg.gif']
styleFiles += self.stylesDir.files("*.css")
styleFiles += self.stylesDir.files("*.jpg")
styleFiles += self.stylesDir.files("*.gif")
styleFiles += self.stylesDir.files("*.png")
styleFiles += self.stylesDir.files("*.js")
styleFiles += self.stylesDir.files("*.html")
self.stylesDir.copylist(styleFiles, outputDir)
# copy the package's resource files
package.resourceDir.copyfiles(outputDir)
def generatePages(self, node, depth):
"""
#.........这里部分代码省略.........
示例15: IMSExport
# 需要导入模块: from exe.engine.path import Path [as 别名]
# 或者: from exe.engine.path.Path import copylist [as 别名]
class IMSExport(object):
"""
Exports an eXe package as a SCORM package
"""
def __init__(self, config, styleDir, filename):
""" Initialize
'styleDir' is the directory from which we will copy our style sheets
(and some gifs)
"""
self.config = config
self.imagesDir = config.webDir/"images"
self.scriptsDir = config.webDir/"scripts"
self.cssDir = config.webDir/"css"
self.templatesDir = config.webDir/"templates"
self.schemasDir = config.webDir/"schemas/ims"
self.styleDir = Path(styleDir)
self.filename = Path(filename)
self.pages = []
def export(self, package):
"""
Export SCORM package
"""
# First do the export to a temporary directory
outputDir = TempDirPath()
# 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 += self.styleDir.files("*.css")
if "nav.css" in styleFiles:
styleFiles.remove("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")
self.styleDir.copylist(styleFiles, outputDir)
# copy the package's resource files
package.resourceDir.copyfiles(outputDir)
# Export the package content
self.pages = [ IMSPage("index", 1, package.root) ]
self.generatePages(package.root, 2)
uniquifyNames(self.pages)
for page in self.pages:
page.save(outputDir)
# Create the manifest file
manifest = Manifest(self.config, outputDir, package, self.pages)
manifest.save()
# Copy the scripts
self.scriptsDir.copylist(('libot_drag.js',
'common.js'), outputDir)
self.schemasDir.copylist(('imscp_v1p1.xsd',
'imsmd_v1p2p2.xsd',
'ims_xml.xsd'), outputDir)
# copy players for media idevices.
hasFlowplayer = False
hasMagnifier = False
hasXspfplayer = False
hasGallery = False
isBreak = False
for page in self.pages:
if isBreak:
break
for idevice in page.node.idevices:
if (hasFlowplayer and hasMagnifier and hasXspfplayer and hasGallery):
isBreak = True
break
if not hasFlowplayer:
if 'flowPlayer.swf' in idevice.systemResources:
hasFlowplayer = True
if not hasMagnifier:
if 'magnifier.swf' in idevice.systemResources:
hasMagnifier = True
if not hasXspfplayer:
if 'xspf_player.swf' in idevice.systemResources:
hasXspfplayer = True
if not hasGallery:
if 'GalleryIdevice' == idevice.klass:
hasGallery = True
if hasFlowplayer:
videofile = (self.templatesDir/'flowPlayer.swf')
videofile.copyfile(outputDir/'flowPlayer.swf')
controlsfile = (self.templatesDir/'flowplayer.controls.swf')
#.........这里部分代码省略.........