<commit_before># -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#

from django.shortcuts import render
from django import forms
from django.http import HttpResponse, HttpResponseNotAllowed, HttpResponseServerError
from django.views.decorators.csrf import csrf_exempt

from .handler import SymbolsUploadHandler

import os

class UploadSymbolsForm(forms.Form):
    symbols = forms.FileField()
    comment = forms.TextInput()

def handle_uploaded_file(f):
    # TODO: moggi: get the symbols localtion from the configuration
    file_path = os.path.join('/tmp/symbols_upload', f.name)
    print(file_path)
    with open(file_path, 'wb+') as destination:
        for chunk in f.chunks():
            destination.write(chunk)

    return file_path

@csrf_exempt
def upload_symbols(request):<commit_msg>use correct form field<commit_after># -*- Mode: python; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#

from django.shortcuts import render
from django import forms
from django.http import HttpResponse, HttpResponseNotAllowed, HttpResponseServerError
from django.views.decorators.csrf import csrf_exempt

from .handler import SymbolsUploadHandler

import os

class UploadSymbolsForm(forms.Form):
    symbols = forms.FileField()
    comment = forms.CharField()

def handle_uploaded_file(f):
    # TODO: moggi: get the symbols localtion from the configuration
    file_path = os.path.join('/tmp/symbols_upload', f.name)
    print(file_path)
    with open(file_path, 'wb+') as destination:
        for chunk in f.chunks():
            destination.write(chunk)

    return file_path

@csrf_exempt
def upload_symbols(request):
{'fraction_non_alphanumeric': 0.09666505558240696, 'fraction_numerical': 0.005799903334944417, 'mean_word_length': 3.9759615384615383, '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': '2629849', 'n_tokens_mistral': 640, 'n_tokens_neox': 627, 'n_words': 208}