def write_png_to_string(buffer, dpi=100, gray=0): width = buffer.shape[1] height = buffer.shape[0] fileobj = cStringIO() _png.write_png(buffer, width, height, fileobj, dpi) png_str = fileobj.getvalue() fileobj.close() return png_str
def parse_header(self): """docstring for parse_header""" # Pre-process ascfile = self.HTTPArray(self.header) max_header_size = 1024 * 1024 lines = cStringIO(ascfile[:max_header_size].data[:]) while True: l = lines.readline() if self._eof in l: break self.parse_line(l, lines) hoff = lines.tell() if self.header != self.filename: hoff = 0 self.parameters['header_offset'] = hoff
def parse_header(self): """docstring for parse_header""" # Pre-process ascfile = HTTPArray(self.header) max_header_size = 1024*1024 lines = cStringIO(ascfile[:max_header_size].data[:]) while True: l = lines.readline() if self._eof in l: break self.parse_line(l, lines) hoff = lines.tell() if self.header != self.filename: hoff = 0 self.parameters['header_offset'] = hoff
def write_on_root(self, fn): if not self._distributed: return open(fn, "w") if self.comm.rank == 0: return open(fn, "w") else: return cStringIO()