def __call__(self, value, system): """ Returns a plain CSV-encoded string with content-type ``text/csv``. The content-type may be overridden by setting ``request.response.content_type``.""" request = system.get("request") if request is not None: response = request.response ct = response.content_type if ct == response.default_content_type: response.content_type = "text/csv" fout = StringIO() writer = csv.writer(fout, delimiter=",", quotechar=",", quoting=csv.QUOTE_MINIMAL) writer.writerow(value.get("header", [])) writer.writerows(value.get("rows", [])) return fout.getvalue()
def __call__(self, value, system): """ Returns a plain CSV-encoded string with content-type ``text/csv``. The content-type may be overridden by setting ``request.response.content_type``.""" request = system.get('request') if request is not None: response = request.response ct = response.content_type if ct == response.default_content_type: response.content_type = 'text/csv' fout = StringIO() writer = csv.writer(fout, delimiter=',', quotechar=',', quoting=csv.QUOTE_MINIMAL) writer.writerow(value.get('header', [])) writer.writerows(value.get('rows', [])) return fout.getvalue()
def _fake_open(path): if path == "bundles.ini": return StringIO(bundle_content) elif path == "manifest.json": return StringIO(manifest_content)
def _fake_open(path): if path == "bundles.ini": return StringIO(BUNDLE_INI) elif path == "manifest.json": return StringIO(MANIFEST_JSON)
def _fake_open(path): if path == 'bundles.ini': return StringIO(bundle_content) elif path == 'manifest.json': return StringIO(manifest_content)