本文整理汇总了Python中exe.engine.path.TempDirPath.files方法的典型用法代码示例。如果您正苦于以下问题:Python TempDirPath.files方法的具体用法?Python TempDirPath.files怎么用?Python TempDirPath.files使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类exe.engine.path.TempDirPath
的用法示例。
在下文中一共展示了TempDirPath.files方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: exportZip
# 需要导入模块: from exe.engine.path import TempDirPath [as 别名]
# 或者: from exe.engine.path.TempDirPath import files [as 别名]
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)
zipped = ZipFile(self.filename, "w")
for scormFile in outputDir.files():
zipped.write(scormFile,
scormFile.basename().encode('utf8'),
ZIP_DEFLATED)
zipped.close()
outputDir.rmtree()
示例2: export
# 需要导入模块: from exe.engine.path import TempDirPath [as 别名]
# 或者: from exe.engine.path.TempDirPath import files [as 别名]
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')
zipped = ZipFile(self.filename, "w")
for scormFile in outputDir.files():
zipped.write(scormFile,
scormFile.basename().encode('utf8'),
ZIP_DEFLATED)
zipped.close()
outputDir.rmtree()
示例3: Package
# 需要导入模块: from exe.engine.path import TempDirPath [as 别名]
# 或者: from exe.engine.path.TempDirPath import files [as 别名]
#.........这里部分代码省略.........
"""
log.debug(u"findNode" + repr(nodeId))
node = self._nodeIdDict.get(nodeId)
if node and node.package is self:
return node
else:
return None
def levelName(self, level):
"""
Return the level name
"""
if level < len(self._levelNames):
return _(self._levelNames[level])
else:
return _(u"?????")
def save(self, filename=None):
"""
Save package to disk
pass an optional filename
"""
if filename:
filename = Path(filename)
name = filename.splitpath()[1]
self.name = name.basename().splitext()[0]
elif self.filename:
filename = Path(self.filename)
else:
raise AssertionError(u'No name passed when saving a new package')
self.filename = filename
log.debug(u"Will save %s to: %s" % (self.name, filename))
self.isChanged = 0
zippedFile = zipfile.ZipFile(filename, "w", zipfile.ZIP_DEFLATED)
try:
for resourceFile in self.resourceDir.files():
zippedFile.write(unicode(resourceFile.normpath()),
resourceFile.name.encode('utf8'))
zippedFile.writestr("content.data", encodeObject(self))
finally:
zippedFile.close()
@staticmethod
def load(filename):
"""
Load package from disk, returns a package
"""
if not zipfile.is_zipfile(filename):
return None
zippedFile = zipfile.ZipFile(filename, "r", zipfile.ZIP_DEFLATED)
toDecode = zippedFile.read(u"content.data")
try:
newPackage = decodeObjectRaw(toDecode)
newPackage.afterUpgradeHandlers = []
doUpgrade()
except:
import traceback
traceback.print_exc()
raise
newPackage.filename = Path(filename)
newPackage.resourceDir = TempDirPath()
for filename in zippedFile.namelist():
if unicode(filename, 'utf8') != u"content.data":
outFile = open(newPackage.resourceDir/filename, "wb")
outFile.write(zippedFile.read(filename))
for handler in newPackage.afterUpgradeHandlers:
handler()
del newPackage.afterUpgradeHandlers
return newPackage
示例4: Package
# 需要导入模块: from exe.engine.path import TempDirPath [as 别名]
# 或者: from exe.engine.path.TempDirPath import files [as 别名]
#.........这里部分代码省略.........
else:
# Update our new filename for future saves
self.filename = filename
filename.safeSave(self.doSave, _("SAVE FAILED!\nLast succesful save is %s."))
self.isChanged = False
self.updateRecentDocuments(filename)
def updateRecentDocuments(self, filename):
"""
Updates the list of recent documents
"""
# Don't update the list for the generic.data "package"
genericData = G.application.config.configDir / "idevices" / "generic.data"
if genericData.isfile() or genericData.islink():
if Path(filename).samefile(genericData):
return
# Save in recentDocuments list
recentProjects = G.application.config.recentProjects
if filename in recentProjects:
# If we're already number one, carry on
if recentProjects[0] == filename:
return
recentProjects.remove(filename)
recentProjects.insert(0, filename)
del recentProjects[5:] # Delete any older names from the list
G.application.config.configParser.write() # Save the settings
def doSave(self, fileObj):
"""
Actually performs the save to 'fileObj'.
"""
zippedFile = zipfile.ZipFile(fileObj, "w", zipfile.ZIP_DEFLATED)
try:
for resourceFile in self.resourceDir.files():
zippedFile.write(
unicode(resourceFile.normpath()), resourceFile.name.encode("utf8"), zipfile.ZIP_DEFLATED
)
zinfo = zipfile.ZipInfo(filename="content.data", date_time=time.localtime()[0:6])
zinfo.external_attr = 0100644 << 16L
zippedFile.writestr(zinfo, encodeObject(self))
finally:
zippedFile.close()
def extractNode(self):
"""
Clones and extracts the currently selected node into a new package.
"""
newPackage = Package("NoName") # Name will be set once it is saved..
newPackage.title = self.currentNode.title
newPackage.style = self.style
newPackage.author = self.author
newPackage._nextNodeId = self._nextNodeId
# Copy the nodes from the original package
# and merge into the root of the new package
self.currentNode.copyToPackage(newPackage)
return newPackage
@staticmethod
def load(filename, newLoad=True, destinationPackage=None):
"""
Load package from disk, returns a package.
"""
if not zipfile.is_zipfile(filename):
return None