<commit_before>from django import forms
from django.forms.util import ErrorList
from django.utils.translation import ugettext_lazy as _
from github import UnknownObjectException

from wtl.wtgithub.worker import GithubWorker, ParseError


class AnalyzeForm(forms.Form):
    git_url = forms.CharField()

    def analyze(self):
        if 'git_url' not in self._errors:
            self._errors['git_url'] = ErrorList()
        worker = GithubWorker()
        try:
            self.repository, self.project = worker.analyze_repo(
                self.cleaned_data['git_url'])
            return self.repository, self.project
        except UnknownObjectException:
            self._errors['git_url'].append(_('Repository not found.'))
        except ParseError:
            self._errors['git_url'].append(_('Failed to parse your repo.'))
<commit_msg>Minor refactoring for AnalyzeForm<commit_after>from django import forms
from django.forms.util import ErrorList
from django.utils.translation import ugettext_lazy as _
from github import UnknownObjectException

from wtl.wtgithub.worker import GithubWorker, ParseError


class AnalyzeForm(forms.Form):
    git_url = forms.CharField()

    def analyze(self):
        worker = GithubWorker()
        try:
            self.repository, self.project = worker.analyze_repo(
                self.cleaned_data['git_url'])
            return self.repository, self.project
        except UnknownObjectException:
            self._add_error('git_url', _('Repository not found.'))
        except ParseError:
            self._add_error('git_url', _('Failed to parse your repo.'))

    def _add_error(self, field, error):
        if field not in self._errors:
            self._errors[field] = ErrorList()
        self._errors[field].append(error)

{'fraction_non_alphanumeric': 0.09152161706906232, 'fraction_numerical': 0.0, 'mean_word_length': 2.9776785714285716, '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': '1260231', 'n_tokens_mistral': 493, 'n_tokens_neox': 476, 'n_words': 124}