def export(cls, filename, cube, options=None, progress=None): if options is None: options = dict() if 'interleave' not in options: root, ext = os.path.splitext(filename) if ext: options['interleave'] = ext[1:].lower() url = vfs.normalize(filename) dprint("writing cube to %s" % url) fh = vfs.open_write(url) cube.writeRawData(fh, options, progress) fh.close() headername = vfs.normalize(getCanonicalHeader(str(url))) dprint("writing header to %s" % headername) c = copy.copy(cube) for k, v in options.iteritems(): setattr(c, k, v) c.data_offset = 0 c.header_offset = 0 c.file_offset = 0 print c h = Header() h.getCubeAttributes(c) hfh = vfs.open_write(headername) hfh.write(str(h)) hfh.close()
def savePrefs(self): try: fh = vfs.open_write(self.project_config) text = self.configToText() fh.write(text) except: self.dprint("Failed writing project config file")
def finishedCallback(self, job): """Callback from the JobOutputMixin when the job terminates.""" del self.process fh = vfs.open_write(self.dot_output) fh.write(self.preview.getvalue()) fh.close() self.frame.findTabOrOpen(self.dot_output)
def action(self, index=-1, multiplier=1): url = ProjectPlugin.findProjectSettingsURL(self.mode) if url: locals = self.mode.classprefsDictFromLocals() fh = vfs.open_write(url) pickle.dump(locals, fh) fh.close()
def action(self, index=-1, multiplier=1): base = ProjectPlugin.findProjectConfigDir(self.mode) if base: url = base.resolve2(ProjectPlugin.classprefs.default_settings_file_name) locals = self.mode.classprefsDictFromLocals() fh = vfs.open_write(url) pickle.dump(locals, fh) fh.close()
def saveTemporaryCopy(self, temp_url): self.dprint(u"Saving backup copy to %s" % temp_url) try: self.stc.prepareEncoding() fh = vfs.open_write(temp_url) self.stc.writeTo(fh, temp_url) fh.close() except Exception, e: self.dprint(u"Failed autosaving to %s with %s" % (temp_url, e))
def save(self, url): """Save this macro to the specified macro: url """ dprint("Saving to %s" % url) self.rebuildMacroAndMetadata() fh = vfs.open_write(url) fh.write(self.data) fh.close()
def save(self, url): dprint("Saving to %s" % url) fh = vfs.open_write(url) self.cube.scale_factor = self.scale self.cube.writeRawData(fh, options={'interleave': self.output_interleave}) enviheader = ENVI.Header() enviheader.getCubeAttributes(self.cube) enviheader['interleave'] = self.output_interleave pathname = str(url) + ".hdr" enviheader.save(pathname)
def save(cls, url): bytes = cls.packVersion1() fh = vfs.open_write(url) fh.write(bytes) fh.close()
def openFileForWriting(self, url): return vfs.open_write(url)