def handleExtractPackage(self, client, filename): """ Create a new package consisting of the current node and export """ filename = Path(filename) saveDir = filename.dirname() if saveDir and not saveDir.exists(): client.alert(_(u'Cannot access directory named ') + unicode(saveDir) + _(u'. Please use ASCII names.')) return if not filename.lower().endswith('.elp'): filename += '.elp' if Path(filename).exists(): client.alert(_(u'EXPORT FAILED.\n"%s" already exists.\n' 'Please try again with ' 'a different filename') % filename) return package = Package(filename.namebase) package.style = self.package.style package.author = self.package.author extractNode = self.package.currentNode.clone() extractNode.mergeIntoPackage(package) package.root = package.currentNode = extractNode package.save(filename) client.alert(_(u'Package saved to: %s' % filename))
def handleExtractPackage(self, client, filename, existOk): """ Create a new package consisting of the current node and export 'existOk' means the user has been informed of existance and ok'd it """ filename = Path(filename) saveDir = filename.dirname() if saveDir and not saveDir.exists(): client.alert(_(u'Cannot access directory named ') + unicode(saveDir) + _(u'. Please use ASCII names.')) return if not filename.lower().endswith('.elp'): filename += '.elp' if Path(filename).exists() and existOk != 'true': msg = _(u'"%s" already exists.\nPlease try again with a different filename') % filename client.alert(_(u'EXTRACT FAILED!\n%s' % msg)) return try: package = Package(filename.namebase) package.style = self.package.style package.author = self.package.author extractNode = self.package.currentNode.clone() extractNode.mergeIntoPackage(package) package.root = package.currentNode = extractNode package.save(filename) except Exception, e: client.alert(_('EXTRACT FAILED!\n%s' % str(e))) raise
def handleExtractPackage(self, client, filename, existOk): """ Create a new package consisting of the current node and export 'existOk' means the user has been informed of existance and ok'd it """ filename = Path(filename) saveDir = filename.dirname() if saveDir and not saveDir.exists(): client.alert(_(u"Cannot access directory named ") + unicode(saveDir) + _(u". Please use ASCII names.")) return if not filename.lower().endswith(".elp"): filename += ".elp" if Path(filename).exists() and existOk != "true": msg = _(u'"%s" already exists.\nPlease try again with a different filename') % filename client.alert(_(u"EXTRACT FAILED!\n%s" % msg)) return try: newPackage = self.package.extractNode() newNode = newPackage.root if newNode: newNode.RenamedNodePath(isExtract=True) newPackage.save(filename) except Exception, e: client.alert(_("EXTRACT FAILED!\n%s" % str(e))) raise
def handleSavePackage(self, client, filename=None, onDone=None): """ Save the current package 'filename' is the filename to save the package to 'onDone' will be evaled after saving instead or redirecting to the new location (in cases of package name changes). (This is used where the user goes file|open when their package is changed and needs saving) """ filename = Path(filename) saveDir = filename.dirname() if saveDir and not saveDir.exists(): client.alert(_(u'Cannot access directory named ') + unicode(saveDir) + _(u'. Please use ASCII names.')) return oldName = self.package.name if not filename: filename = self.package.filename assert (filename, ('Somehow save was called without a filename ' 'on a package that has no default filename.')) if not filename.lower().endswith('.elp'): filename += '.elp' self.package.save(filename) # This can change the package name client.alert(_(u'Package saved to: %s' % filename)) if onDone: client.sendScript(onDone) elif self.package.name != oldName: self.webServer.root.putChild(self.package.name, self) log.info('Package saved, redirecting client to /%s' % self.package.name) client.sendScript('top.location = "/%s"' % \ self.package.name.encode('utf8'))
def exportText(self, client, filename): try: filename = Path(filename) log.debug(u"exportWebsite, filename=%s" % filename) if not filename.lower().endswith('.txt'): filename += '.txt' if Path(filename).exists(): msg = _(u'"%s" already exists.\nPlease try again with a different filename') % filename client.alert(_(u'EXPORT FAILED!\n%s' % msg)) return textExport = TextExport(filename) textExport.export(self.package) except Exception, e: client.alert(_('EXPORT FAILED!\n%s' % str(e))) raise
def exportScorm(self, client, filename, stylesDir, scormType): """ Exports this package to a scorm package file """ try: filename = Path(filename) log.debug(u"exportScorm, filename=%s" % filename) if not filename.lower().endswith('.zip'): filename += '.zip' if Path(filename).exists(): msg = _(u'"%s" already exists.\nPlease try again with a different filename') % filename client.alert(_(u'EXPORT FAILED!\n%s' % msg)) return scormExport = ScormExport(self.config, stylesDir, filename, scormType) scormExport.export(self.package) except Exception, e: client.alert(_('EXPORT FAILED!\n%s' % str(e))) raise
def exportText(self, client, filename): try: filename = Path(filename) log.debug(u"exportWebsite, filename=%s" % filename) # Append an extension if required if not filename.lower().endswith('.txt'): filename += '.txt' if Path(filename).exists(): msg = _( u'"%s" already exists.\nPlease try again with a different filename' ) % filename client.alert(_(u'EXPORT FAILED!\n%s' % msg)) return # Do the export textExport = TextExport(filename) textExport.export(self.package) except Exception, e: client.alert(_('EXPORT FAILED!\n%s' % str(e))) raise
def handleExtractPackage(self, client, filename, existOk): """ Create a new package consisting of the current node and export 'existOk' means the user has been informed of existance and ok'd it """ filename = Path(filename) saveDir = filename.dirname() if saveDir and not saveDir.exists(): client.alert( _(u'Cannot access directory named ') + unicode(saveDir) + _(u'. Please use ASCII names.')) return # Add the extension if its not already there if not filename.lower().endswith('.elp'): filename += '.elp' if Path(filename).exists() and existOk != 'true': msg = _( u'"%s" already exists.\nPlease try again with a different filename' ) % filename client.alert(_(u'EXTRACT FAILED!\n%s' % msg)) return try: # Create a new package for the extracted nodes newPackage = self.package.extractNode() # trigger a rename of all of the internal nodes and links, # and to remove any old anchors from the dest package, # and remove any zombie links via isExtract: newNode = newPackage.root if newNode: newNode.RenamedNodePath(isExtract=True) # Save the new package newPackage.save(filename) except Exception, e: client.alert(_('EXTRACT FAILED!\n%s' % str(e))) raise
def exportScorm(self, client, filename, stylesDir, scormType): """ Exports this package to a scorm package file """ try: filename = Path(filename) log.debug(u"exportScorm, filename=%s" % filename) # Append an extension if required if not filename.lower().endswith('.zip'): filename += '.zip' if Path(filename).exists(): msg = _( u'"%s" already exists.\nPlease try again with a different filename' ) % filename client.alert(_(u'EXPORT FAILED!\n%s' % msg)) return # Do the export scormExport = ScormExport(self.config, stylesDir, filename, scormType) scormExport.export(self.package) except Exception, e: client.alert(_('EXPORT FAILED!\n%s' % str(e))) raise
def handleExtractPackage(self, client, filename, existOk): """ Create a new package consisting of the current node and export 'existOk' means the user has been informed of existance and ok'd it """ filename = Path(filename) saveDir = filename.dirname() if saveDir and not saveDir.exists(): client.alert(_(u'Cannot access directory named ') + unicode(saveDir) + _(u'. Please use ASCII names.')) return # Add the extension if its not already there if not filename.lower().endswith('.elp'): filename += '.elp' if Path(filename).exists() and existOk != 'true': msg = _(u'"%s" already exists.\nPlease try again with a different filename') % filename client.alert(_(u'EXTRACT FAILED!\n%s' % msg)) return try: # Create a new package for the extracted nodes newPackage = self.package.extractNode() # trigger a rename of all of the internal nodes and links, # and to remove any old anchors from the dest package, # and remove any zombie links via isExtract: newNode = newPackage.root if newNode: newNode.RenamedNodePath(isExtract=True) # Save the new package newPackage.save(filename) except Exception, e: client.alert(_('EXTRACT FAILED!\n%s' % str(e))) raise