def exportText(self, client, filename): try: filename = Path(filename) log.debug("exportWebsite, filename=%s" % filename) # Append an extension if required if not filename.lower().endswith('.txt'): filename += '.txt' if Path(filename).exists(): msg = _('"%s" already exists.\nPlease try again with a different filename') % filename client.alert(_('EXPORT FAILED!\n%s' % msg)) return # Do the export textExport = TextExport(filename) textExport.export(package) except Exception as e: client.alert(_('EXPORT FAILED!\n%s' % str(e))) raise client.alert(_('Exported to %s') % filename)
def exportText(self, client, filename): try: filename = Path(filename) log.debug("exportWebsite, filename=%s" % filename) # Append an extension if required if not filename.lower().endswith('.txt'): filename += '.txt' if Path(filename).exists(): msg = _( '"%s" already exists.\nPlease try again with a different filename' ) % filename client.alert(_('EXPORT FAILED!\n%s' % msg)) return # Do the export textExport = TextExport(filename) textExport.export(package) except Exception as e: client.alert(_('EXPORT FAILED!\n%s' % str(e))) raise client.alert(_('Exported to %s') % filename)
def extractPackage(request, package, 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( _('Cannot access directory named ') + str(saveDir) + _('. 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 = _( '"%s" already exists.\nPlease try again with a different filename' ) % filename client.alert(_('EXTRACT FAILED!\n%s' % msg)) return try: # Create a new package for the extracted nodes newPackage = 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 as e: client.alert(_('EXTRACT FAILED!\n%s' % str(e))) raise client.alert(_('Package extracted to: %s' % filename))
def exportScorm(request, client, filename, stylesDir, scormType): """ Exports this package to a scorm package file """ try: filename = Path(filename) log.debug("exportScorm, filename=%s" % filename) # Append an extension if required if not filename.lower().endswith('.zip'): filename += '.zip' if Path(filename).exists(): msg = _('"%s" already exists.\nPlease try again with a different filename') % filename client.alert(_('EXPORT FAILED!\n%s' % msg)) return # Do the export scormExport = ScormExport(self.config, stylesDir, filename, scormType) scormExport.export(package) except Exception as e: client.alert(_('EXPORT FAILED!\n%s' % str(e))) raise client.alert(_('Exported to %s') % filename)
def extractPackage(request, package, 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(_('Cannot access directory named ') + str(saveDir) + _('. 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 = _('"%s" already exists.\nPlease try again with a different filename') % filename client.alert(_('EXTRACT FAILED!\n%s' % msg)) return try: # Create a new package for the extracted nodes newPackage = 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 as e: client.alert(_('EXTRACT FAILED!\n%s' % str(e))) raise client.alert(_('Package extracted to: %s' % filename))
def exportScorm(request, client, filename, stylesDir, scormType): """ Exports this package to a scorm package file """ try: filename = Path(filename) log.debug("exportScorm, filename=%s" % filename) # Append an extension if required if not filename.lower().endswith('.zip'): filename += '.zip' if Path(filename).exists(): msg = _( '"%s" already exists.\nPlease try again with a different filename' ) % filename client.alert(_('EXPORT FAILED!\n%s' % msg)) return # Do the export scormExport = ScormExport(self.config, stylesDir, filename, scormType) scormExport.export(package) except Exception as e: client.alert(_('EXPORT FAILED!\n%s' % str(e))) raise client.alert(_('Exported to %s') % filename)