<commit_before>from optparse import make_option

from django.conf import settings
from django.core.management.base import BaseCommand, CommandError

from database_files.models import File

class Command(BaseCommand):
    args = ''
    help = 'Regenerates hashes for all files.'
    option_list = BaseCommand.option_list + (
#        make_option('--dryrun',
#            action='store_true',
#            dest='dryrun',
#            default=False,
#            help='If given, only displays the names of orphaned files ' + \
#                'and does not delete them.'),
        )

    def handle(self, *args, **options):
        tmp_debug = settings.DEBUG
        settings.DEBUG = False
        dryrun = options['dryrun']
        try:
            q = File.objects.all()
            total = q.count()
            i = 1
            for f in q:
                print '%i of %i: %s' % (i, total, f.name)
                f._content_hash = None
                f.save()
                i += 1
        finally:
            settings.DEBUG = tmp_debug<commit_msg>Fixed management command.<commit_after>from optparse import make_option

from django.conf import settings
from django.core.management.base import BaseCommand, CommandError

from database_files.models import File

class Command(BaseCommand):
    args = ''
    help = 'Regenerates hashes for all files.'
    option_list = BaseCommand.option_list + (
#        make_option('--dryrun',
#            action='store_true',
#            dest='dryrun',
#            default=False,
#            help='If given, only displays the names of orphaned files ' + \
#                'and does not delete them.'),
        )

    def handle(self, *args, **options):
        tmp_debug = settings.DEBUG
        settings.DEBUG = False
        try:
            q = File.objects.all()
            total = q.count()
            i = 1
            for f in q:
                print '%i of %i: %s' % (i, total, f.name)
                f._content_hash = None
                f.save()
                i += 1
        finally:
            settings.DEBUG = tmp_debug
{'fraction_non_alphanumeric': 0.10158121705797796, 'fraction_numerical': 0.0019166267369429804, 'mean_word_length': 1.7294117647058824, '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': '3953701', 'n_tokens_mistral': 586, 'n_tokens_neox': 564, 'n_words': 165}