<commit_before>from optparse import make_option
import tarfile
import os

from django.core.files import File
from django.core.management.base import BaseCommand, CommandError
from django.db.models import signals
from django.utils import simplejson

from moocng.courses.models import (Course, KnowledgeQuantum,
                                   Question, Option)

from moocng.courses.models import handle_kq_post_save, handle_question_post_save


IMG_FIXED_W = 620
IMG_FIXED_H = 372


def translate_position(max_s, max_t,  s):
    t = (s * (float(max_s) / float(max_t)))
    return int(round(t * 1.15))


class Command(BaseCommand):
    option_list = BaseCommand.option_list + (
        make_option('-c', '--course',
                    action='store',
                    dest='course',
                    default="",
                    help='Course slug to export'),
        make_option('-f', '--filename',
                    action='store',
                    dest='filename',
                    default="",
                    help="Filename to save the course (without file extension)"),
        make_option('-t', '--translatepositions',
                    action='store',
                    dest='translatepositions',
                    default=False,
                    help="Transalte options positions"
    )

    def error(self, message):
        self.stderr.write(u"%s\n" % message.encode("ascii", "replace"))

    def message(self, message):
        self.stdout.write(u"%s\n" % message.encode("ascii", "replace"))

    def create_object_with_files(self, manager, o_dict, fkey,
                                 filefields):
        fields = o_dict["fields"].copy()
        ffields = []
        for field in filefields:
            ffields.append((field, fields[field]))
            del fields[field]
        del fields[fkey]
        obj = manager.create(**fields)

        for field in filefields:<commit_msg>Include the translation option positions way<commit_after>from optparse import make_option
import tarfile
import os

from django.core.files import File
from django.core.management.base import BaseCommand, CommandError
from django.db.models import signals
from django.utils import simplejson

from moocng.courses.models import (Course, KnowledgeQuantum,
                                   Question, Option)

from moocng.courses.models import handle_kq_post_save, handle_question_post_save


IMG_FIXED_W = 620
IMG_FIXED_H = 372


def translate_position(max_s, max_t,  s):
    t = (s * (float(max_s) / float(max_t)))
    return int(round(t * 1.15))


class Command(BaseCommand):
    option_list = BaseCommand.option_list + (
        make_option('-c', '--course',
                    action='store',
                    dest='course',
                    default="",
                    help='Course slug to export'),
        make_option('-f', '--filename',
                    action='store',
                    dest='filename',
                    default="",
                    help="Filename to save the course (without file extension)"),
        make_option('-t', '--translatepositions',
                    action='store',
                    dest='translatepositions',
                    default=False,
                    help="Transalte options positions (from new to old)")
    )

    def error(self, message):
        self.stderr.write(u"%s\n" % message.encode("ascii", "replace"))

    def message(self, message):
        self.stdout.write(u"%s\n" % message.encode("ascii", "replace"))

    def create_object_with_files(self, manager, o_dict, fkey,
                                 filefields):
        fields = o_dict["fields"].copy()
        ffields = []
        for field in filefields:
            ffields.append((field, fields[field]))
            del fields[field]
        del fields[fkey]
        obj = manager.create(**fields)

        for field in filefields:
{'fraction_non_alphanumeric': 0.10977482088024565, 'fraction_numerical': 0.004605936540429887, 'mean_word_length': 2.05390625, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '409308', 'n_tokens_mistral': 1104, 'n_tokens_neox': 1031, 'n_words': 254}