Ejemplo n.º 1
0
    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()
Ejemplo n.º 2
0
    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()
Ejemplo n.º 3
0
 def _fake_open(path):
     if path == "bundles.ini":
         return StringIO(bundle_content)
     elif path == "manifest.json":
         return StringIO(manifest_content)
Ejemplo n.º 4
0
def _fake_open(path):
    if path == "bundles.ini":
        return StringIO(BUNDLE_INI)
    elif path == "manifest.json":
        return StringIO(MANIFEST_JSON)
Ejemplo n.º 5
0
 def _fake_open(path):
     if path == 'bundles.ini':
         return StringIO(bundle_content)
     elif path == 'manifest.json':
         return StringIO(manifest_content)