<commit_before># -*- coding: utf-8 -*-
from __future__ import unicode_literals

import collections
import datetime
import logging
import os
import shutil
import sys
import tablib
import StringIO

from itertools import chain, groupby
from operator import attrgetter

from lxml import etree

from django.core.urlresolvers import reverse
from django.contrib.sites import models as site_models
from django.template.defaultfilters import slugify
from django.utils.encoding import force_text
from django.utils.timezone import now
from django.utils import timezone
from django.utils.text import slugify

from . import models
from pyconde.sponsorship import models as sponsorship_models
from pyconde.conference import models as conference_models
from pyconde.accounts.utils import get_full_name


LOG = logging.getLogger('pyconde.schedule.exporters')


def _format_cospeaker(s):
    """
    Format the speaker's name for secondary speaker export and removes
    our separator characters to avoid confusion.
    """
    return force_text(s).replace('|', ' ')


class AbstractExporter(object):
    def as_csv_value(self, value):
        """
        If a value is None, returns it as empty string instead of 'None'.
        """
        if value is None:
            return ''
        return value


class SimpleSessionExporter(AbstractExporter):
    def __init__(self, queryset):
        self.queryset = queryset

    def __call__(self):
        queryset = self.queryset.select_related('duration', 'track', 'proposal',
            'speaker', 'latest_proposalversion__track', 'audience_level')<commit_msg>Fix missing import in exporters module<commit_after># -*- coding: utf-8 -*-
from __future__ import unicode_literals

import collections
import datetime
import logging
import os
import shutil
import sys
import tablib
import StringIO

from itertools import chain, groupby
from operator import attrgetter

from lxml import etree

from django.core.urlresolvers import reverse
from django.contrib.sites import models as site_models
from django.template.defaultfilters import slugify
from django.utils.encoding import force_text
from django.utils.timezone import now
from django.utils import timezone
from django.utils.text import slugify

from . import models
from pyconde.sponsorship import models as sponsorship_models
from pyconde.conference import models as conference_models
from pyconde.accounts.utils import get_full_name
from pyconde.accounts.utils import get_display_name


LOG = logging.getLogger('pyconde.schedule.exporters')


def _format_cospeaker(s):
    """
    Format the speaker's name for secondary speaker export and removes
    our separator characters to avoid confusion.
    """
    return force_text(s).replace('|', ' ')


class AbstractExporter(object):
    def as_csv_value(self, value):
        """
        If a value is None, returns it as empty string instead of 'None'.
        """
        if value is None:
            return ''
        return value


class SimpleSessionExporter(AbstractExporter):
    def __init__(self, queryset):
        self.queryset = queryset

    def __call__(self):
        queryset = self.queryset.select_related('duration', 'track', 'proposal',
            'speaker', 'latest_proposalversion__track', 'audience_level')
{'fraction_non_alphanumeric': 0.07110021452650934, 'fraction_numerical': 0.0006129328838492185, 'mean_word_length': 4.037037037037037, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3601787', 'n_tokens_mistral': 891, 'n_tokens_neox': 872, 'n_words': 304}