<commit_before>from import_export import resources
from import_export import fields

from .models import (
    Locale,
    AppInfo,
    KeyString,
    AppInfoKeyString,
    LocalizedString,
    )

from .widgets import (
    AppInfoWidget,
    LocaleWidget,
    KeyStringWidget,
    )


class AppInfoResource(resources.ModelResource):

    base_locale = fields.Field(column_name='base_locale', 
        attribute='base_locale', 
        widget=LocaleWidget(Locale, 'code'))

    class Meta:
        model = AppInfo
        import_id_fields = ['slug']
        export_order = ('name', 'slug', 'base_locale',)
        fields = ('name', 'slug', 'base_locale',)


class LocaleResource(resources.ModelResource):

    class Meta:
        model = Locale
        import_id_fields = ['code']
        export_order = ('name', 'code',)
        fields = ('name', 'code',)


class LocalizedStringResource(resources.ModelResource):

    key = fields.Field(column_name='key', 
        attribute='key_string', 
        widget=KeyStringWidget(KeyString, 'key'))

    locale = fields.Field(column_name='locale', 
        attribute='locale', 
        widget=LocaleWidget(Locale, 'code'))

    class Meta:
        model = LocalizedString
        import_id_fields = ['key', 'locale']
        export_order = ('key', 'value', 'locale')
        fields = ('key', 'value', 'locale')


class AppInfoKeyStringResource(resources.ModelResource):

    app = fields.Field(column_name='app', <commit_msg>fixed metadata when using the importer.<commit_after>from import_export import resources
from import_export import fields

from .models import (
    Locale,
    AppInfo,
    KeyString,
    AppInfoKeyString,
    LocalizedString,
    )

from .widgets import (
    AppInfoWidget,
    LocaleWidget,
    KeyStringWidget,
    )


class AppInfoResource(resources.ModelResource):

    base_locale = fields.Field(column_name='base_locale', 
        attribute='base_locale', 
        widget=LocaleWidget(Locale, 'code'))

    class Meta:
        model = AppInfo
        import_id_fields = ['slug']
        export_order = ('name', 'slug', 'base_locale',)
        fields = ('name', 'slug', 'base_locale',)


class LocaleResource(resources.ModelResource):

    class Meta:
        model = Locale
        import_id_fields = ['code']
        export_order = ('name', 'code',)
        fields = ('name', 'code',)


class LocalizedStringResource(resources.ModelResource):

    key = fields.Field(column_name='key', 
        attribute='key_string', 
        widget=KeyStringWidget(KeyString, 'key'))

    locale = fields.Field(column_name='locale', 
        attribute='locale', 
        widget=LocaleWidget(Locale, 'code'))

    class Meta:
        model = LocalizedString
        import_id_fields = ['key', 'locale']
        export_order = ('key', 'value', 'locale')
        fields = ('key', 'value', 'locale')

    def after_import_instance(self, instance, new, **kwargs):
        if new:
            instance.created_by = kwargs['user']
        else:
            instance.modified_by = kwargs['user']
        return instance


class AppInfoKeyStringResource(resources.ModelResource):

    app = fields.Field(column_name='app', 
{'fraction_non_alphanumeric': 0.12177470106985526, 'fraction_numerical': 0.0, 'mean_word_length': 3.05484693877551, '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': '4861428', 'n_tokens_mistral': 928, 'n_tokens_neox': 894, 'n_words': 195}