dr.botzo/markov/forms.py

41 lines
1.3 KiB
Python

"""Forms for manipulating markov data."""
import logging
from django.forms import Form, CharField, ChoiceField, FileField, ModelChoiceField
from markov.models import MarkovContext
log = logging.getLogger('markov.forms')
class LogUploadForm(Form):
"""Accept a file upload that will be imported into Markov stuff."""
FILE_FORMAT_WEECHAT = 'WEECHAT'
FILE_FORMAT_RAW_TEXT = 'RAW'
FILE_FORMAT_CHOICES = (
(FILE_FORMAT_WEECHAT, "Weechat"),
(FILE_FORMAT_RAW_TEXT, "Raw text file"),
)
text_file = FileField()
text_file_format = ChoiceField(choices=FILE_FORMAT_CHOICES)
context = ModelChoiceField(queryset=MarkovContext.objects.all())
ignore_nicks = CharField(help_text="Comma-separated list of nicks to ignore. For Weechat logs.",
required=False)
strip_prefixes = CharField(help_text="Space-separated list of line prefixes to strip. For Weechat logs.",
required=False)
class TeachLineForm(Form):
"""Accept a line that will be imported into Markov stuff."""
context = ModelChoiceField(queryset=MarkovContext.objects.all())
line = CharField()
strip_prefixes = CharField(help_text="Space-separated list of line prefixes to strip.",
required=False)