def output(self): log(self.type) if hasattr(self.content, 'read'): self.type = "file" if self.type == "plaintext": return [ self.content, ] if self.type == "file": return self.content if self.type == "stream": def f(stream): for d in stream: yield 'data: ' + pico.to_json(d) + '\n\n' return f(self.content) if self.type == "chunks": def f(response): yield (' ' * 1200) + '\n' yield '[\n' delimeter = '' for r in response: yield delimeter + pico.to_json(r, self.json_dumpers) + '\n' delimeter = ',' yield "]\n" return f(self.content) else: s = pico.to_json(self.content, self.json_dumpers) if self.callback: s = self.callback + '(' + s + ')' return s
def output(self): if self._output: return self._output log(self.type) if hasattr(self.content, 'read'): self.type = "file" if self.type == "plaintext": return [self.content,] if self.type == "file": return self.content if self.type == "stream": def f(stream): for d in stream: yield 'data: ' + pico.to_json(d) + '\n\n' yield 'data: "PICO_CLOSE_STREAM"\n\n' return f(self.content) if self.type == "chunks": log("chunks") def f(response): yield (' ' * 1200) + '\n' yield '[\n' delimeter = '' for r in response: yield delimeter + pico.to_json(r, self.json_dumpers) + '\n' delimeter = ',' yield "]\n" return f(self.content) else: s = pico.to_json(self.content, self.json_dumpers) if self.callback: s = self.callback + '(' + s + ')' s = [s,] self._output = s return s
def f(response): yield (' ' * 1200) + '\n' yield '[\n' delimeter = '' for r in response: yield delimeter + pico.to_json(r, self.json_dumpers) + '\n' delimeter = ',' yield "]\n"
def json(self): properties = {} properties.update(self.ref.get('properties', None) or {}) response = {} response['bbox'] = self.bbox #[l, b, r, t] response['shape'] = self.shape response['data'] = np.around(self.view(np.ndarray), decimals=2) response['properties'] = properties return pico.to_json(response)
def output(self): print(self.type) if hasattr(self.content, 'read'): self.type = "file" if self.type == "plaintext": return [self.content,] if self.type == "file": return self.content if self.type == "stream": def f(stream): for d in stream: yield 'data: ' + pico.to_json(d) + '\n\n' return f(self.content) else: s = pico.to_json(self.content, self.json_dumpers) if self.callback: s = self.callback + '(' + s + ')' return s
def output(self): log(self.type) if hasattr(self.content, 'read'): self.type = "file" if self.type == "plaintext": return [ self.content, ] if self.type == "file": return self.content if self.type == "stream": def f(stream): for d in stream: yield 'data: ' + pico.to_json(d) + '\n\n' return f(self.content) else: s = pico.to_json(self.content, self.json_dumpers) if self.callback: s = self.callback + '(' + s + ')' return s
def f(stream): for d in stream: yield 'data: ' + pico.to_json(d) + '\n\n'
def _call_function(module, function, args, stream=False): for k in args: args[k] = pico.to_json(args[k]) # args['_function'] = function # args['_module'] = module return get(url + '%s/%s/' % (module, function), args, stream)
def _call_function(module, function, args, stream=False): for k in args: args[k] = pico.to_json(args[k]) # args['_function'] = function # args['_module'] = module return get(url + '%s/%s/'%(module, function), args, stream)
def f(stream): for d in stream: yield 'data: ' + pico.to_json(d) + '\n\n' yield 'data: "PICO_CLOSE_STREAM"\n\n'