<commit_before>from django.utils.translation import ugettext_lazy as _

from corehq.apps.export.det.base import DETRow, DETTable, DETConfig
from corehq.apps.export.det.exceptions import DETConfigError
from corehq.apps.export.models import FormExportInstance, CaseExportInstance
from corehq.apps.userreports import datatypes

PROPERTIES_PREFIX = 'properties.'
ID_FIELD = 'id'
FORM_ID_SOURCE = 'form.meta.instanceID'
CASE_ID_SOURCE = 'case_id'

# maps Case fields to the API field names used in CommCareCaseResource
CASE_API_PATH_MAP = {
    'date_closed': 'date_closed',
    'date_modified': 'date_modified',
    'external_id': 'properties.external_id',
    'opened_on': 'properties.date_opened',
    'owner_id': 'properties.owner_id',
    '_id': 'id',
    'name': 'properties.case_name',
    'opened_by': 'opened_by',
    'server_modified_on': 'server_date_modified',
    'server_opened_on': 'server_date_opened',
    'type': 'properties.case_type',
    'user_id': 'user_id',
}

MAP_VIA_STR2DATE = 'str2date'
MAP_VIA_STR2NUM = 'str2num'

def generate_from_export_instance(export_instance, output_file):
    if isinstance(export_instance, CaseExportInstance):
        return generate_from_case_export_instance(export_instance, output_file)
    elif isinstance(export_instance, FormExportInstance):
        return generate_from_form_export_instance(export_instance, output_file)
    else:
        raise DETConfigError(_('Export instance type {name} not supported!').format(
            name=type(export_instance).__name__
        ))

<commit_msg>fix bad reference to "closed" property in case schemas<commit_after>from django.utils.translation import ugettext_lazy as _

from corehq.apps.export.det.base import DETRow, DETTable, DETConfig
from corehq.apps.export.det.exceptions import DETConfigError
from corehq.apps.export.models import FormExportInstance, CaseExportInstance
from corehq.apps.userreports import datatypes

PROPERTIES_PREFIX = 'properties.'
ID_FIELD = 'id'
FORM_ID_SOURCE = 'form.meta.instanceID'
CASE_ID_SOURCE = 'case_id'

# maps Case fields to the API field names used in CommCareCaseResource
CASE_API_PATH_MAP = {
    'closed': 'closed',
    'date_closed': 'date_closed',
    'date_modified': 'date_modified',
    'external_id': 'properties.external_id',
    'opened_on': 'properties.date_opened',
    'owner_id': 'properties.owner_id',
    '_id': 'id',
    'name': 'properties.case_name',
    'opened_by': 'opened_by',
    'server_modified_on': 'server_date_modified',
    'server_opened_on': 'server_date_opened',
    'type': 'properties.case_type',
    'user_id': 'user_id',
}

MAP_VIA_STR2DATE = 'str2date'
MAP_VIA_STR2NUM = 'str2num'

def generate_from_export_instance(export_instance, output_file):
    if isinstance(export_instance, CaseExportInstance):
        return generate_from_case_export_instance(export_instance, output_file)
    elif isinstance(export_instance, FormExportInstance):
        return generate_from_form_export_instance(export_instance, output_file)
    else:
        raise DETConfigError(_('Export instance type {name} not supported!').format(
            name=type(export_instance).__name__
        ))


{'fraction_non_alphanumeric': 0.1027592768791627, 'fraction_numerical': 0.002537266095781795, 'mean_word_length': 5.295409181636726, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '121125', 'n_tokens_mistral': 1018, 'n_tokens_neox': 992, 'n_words': 202}