# Path: pyston/conf.py
# CONVERTERS = (
#     'pyston.converters.JsonConverter',
#     'pyston.converters.XmlConverter',
#     'pyston.converters.CsvConverter',
#     'pyston.converters.TxtConverter',
# )
# DEFAULT_FILENAMES = (
#     (('pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'csv'), 'document'),
#     (('jpg', 'jpeg', 'png', 'gif', 'tiff', 'bmp', 'svg'), 'image'),
# )
# DEFAULT_FILENAME = 'attachment'
# DEFAULTS = {
#     'CONVERTERS': CONVERTERS,
#     'IGNORE_DUPE_MODELS': False,
#     'CORS': False,
#     'CORS_WHITELIST': (),
#     'CORS_MAX_AGE': 60 * 30,
#     'CORS_ALLOW_CREDENTIALS': True,
#     'CORS_ALLOWED_HEADERS': ('X-Base', 'X-Offset', 'X-Fields', 'Origin', 'Content-Type', 'Accept'),
#     'CORS_ALLOWED_EXPOSED_HEADERS': ('X-Total', 'X-Serialization-Format-Options', 'X-Fields-Options'),
#     'JSON_CONVERTER_OPTIONS': {
#         'indent': 4
#     },
#     'PDF_EXPORT_TEMPLATE': 'default_pdf_table.html',
#     'FILE_SIZE_LIMIT': 5000000,
#     'AUTO_RELATED_REVERSE_FIELDS': True,
#     'AUTO_RELATED_DIRECT_FIELDS': True,
#     'PARTIAL_PUT_UPDATE': False,
#     'PARTIAL_RELATED_UPDATE': False,
#     'ERRORS_RESPONSE_CLASS': 'pyston.response.RestErrorsResponse',
#     'ERROR_RESPONSE_CLASS': 'pyston.response.RestErrorResponse',
#     'AUTO_REGISTER_RESOURCE': True,
#     'ALLOW_TAGS': False,
#     'DEFAULT_FILENAMES': DEFAULT_FILENAMES,
#     'DEFAULT_FILENAME': DEFAULT_FILENAME,
#     'NONE_HUMANIZED_VALUE': '--',
# }
# class Settings:
#     def __getattr__(self, attr):


import os
import csv
import codecs
    import xlsxwriter
from datetime import datetime, date
from decimal import Decimal
from django.conf import settings as django_settings
from django.utils.encoding import force_text
from django.template.loader import get_template
    from xhtml2pdf import pisa
from pyston.conf import settings
                    elif isinstance(val, date):
                        ws.write(row, col, val, date_format)
                    elif isinstance(val, (Decimal, float)):
                        ws.write(row, col, val, decimal_format)
                    elif isinstance(val, str):
                        val = self._prepare_value(val)
                        ws.write(row, col, val)
                    else:
                        ws.write(row, col, val)
                row += 1
            wb.close()

if pisa:
    class PdfGenerator:

        encoding = 'utf-8'

        def generate(self, header, data, output_stream):
            def fetch_resources(uri, rel):
                urls = {
                    django_settings.MEDIA_ROOT: settings.MEDIA_URL,
                    django_settings.STATICFILES_ROOT: django_settings.STATIC_URL
                }
                for k, v in urls.items():
                    if (uri.startswith(v)):
                        return os.path.join(k, uri.replace(v, ""))
                return ''

            pisa.pisaDocument(
                force_text(

# Path: pyston/conf.py
# CONVERTERS = (
#     'pyston.converters.JsonConverter',
#     'pyston.converters.XmlConverter',
#     'pyston.converters.CsvConverter',
#     'pyston.converters.TxtConverter',
# )
# DEFAULT_FILENAMES = (
#     (('pdf', 'doc', 'docx', 'xls', 'xlsx', 'ppt', 'pptx', 'txt', 'csv'), 'document'),
#     (('jpg', 'jpeg', 'png', 'gif', 'tiff', 'bmp', 'svg'), 'image'),
# )
# DEFAULT_FILENAME = 'attachment'
# DEFAULTS = {
#     'CONVERTERS': CONVERTERS,
#     'IGNORE_DUPE_MODELS': False,
#     'CORS': False,
#     'CORS_WHITELIST': (),
#     'CORS_MAX_AGE': 60 * 30,
#     'CORS_ALLOW_CREDENTIALS': True,
#     'CORS_ALLOWED_HEADERS': ('X-Base', 'X-Offset', 'X-Fields', 'Origin', 'Content-Type', 'Accept'),
#     'CORS_ALLOWED_EXPOSED_HEADERS': ('X-Total', 'X-Serialization-Format-Options', 'X-Fields-Options'),
#     'JSON_CONVERTER_OPTIONS': {
#         'indent': 4
#     },
#     'PDF_EXPORT_TEMPLATE': 'default_pdf_table.html',
#     'FILE_SIZE_LIMIT': 5000000,
#     'AUTO_RELATED_REVERSE_FIELDS': True,
#     'AUTO_RELATED_DIRECT_FIELDS': True,
#     'PARTIAL_PUT_UPDATE': False,
#     'PARTIAL_RELATED_UPDATE': False,
#     'ERRORS_RESPONSE_CLASS': 'pyston.response.RestErrorsResponse',
#     'ERROR_RESPONSE_CLASS': 'pyston.response.RestErrorResponse',
#     'AUTO_REGISTER_RESOURCE': True,
#     'ALLOW_TAGS': False,
#     'DEFAULT_FILENAMES': DEFAULT_FILENAMES,
#     'DEFAULT_FILENAME': DEFAULT_FILENAME,
#     'NONE_HUMANIZED_VALUE': '--',
# }
# class Settings:
#     def __getattr__(self, attr):


# Path: pyston/converters/file_generators.py
import os
import csv
import codecs
    import xlsxwriter
from datetime import datetime, date
from decimal import Decimal
from django.conf import settings as django_settings
from django.utils.encoding import force_text
from django.template.loader import get_template
    from xhtml2pdf import pisa
from pyston.conf import settings

                    elif isinstance(val, date):
                        ws.write(row, col, val, date_format)
                    elif isinstance(val, (Decimal, float)):
                        ws.write(row, col, val, decimal_format)
                    elif isinstance(val, str):
                        val = self._prepare_value(val)
                        ws.write(row, col, val)
                    else:
                        ws.write(row, col, val)
                row += 1
            wb.close()

if pisa:
    class PdfGenerator:

        encoding = 'utf-8'

        def generate(self, header, data, output_stream):
            def fetch_resources(uri, rel):
                urls = {
                    django_settings.MEDIA_ROOT: settings.MEDIA_URL,
                    django_settings.STATICFILES_ROOT: django_settings.STATIC_URL
                }
                for k, v in urls.items():
                    if (uri.startswith(v)):
                        return os.path.join(k, uri.replace(v, ""))
                return ''

            pisa.pisaDocument(
                force_text(

                    get_template(settings.PDF_EXPORT_TEMPLATE).render(