2015-05-21 21:57:54 -05:00
|
|
|
"""Forms for manipulating markov data."""
|
2014-04-05 10:52:29 -05:00
|
|
|
|
|
|
|
import logging
|
|
|
|
|
2016-11-16 12:10:42 -06:00
|
|
|
from django.forms import Form, CharField, ChoiceField, FileField, ModelChoiceField
|
2014-04-05 10:52:29 -05:00
|
|
|
|
|
|
|
from markov.models import MarkovContext
|
|
|
|
|
2015-05-21 22:05:10 -05:00
|
|
|
log = logging.getLogger('markov.forms')
|
2014-04-05 10:52:29 -05:00
|
|
|
|
|
|
|
|
|
|
|
class LogUploadForm(Form):
|
|
|
|
|
|
|
|
"""Accept a file upload that will be imported into Markov stuff."""
|
|
|
|
|
2016-11-16 12:10:42 -06:00
|
|
|
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)
|
2014-04-05 10:52:29 -05:00
|
|
|
context = ModelChoiceField(queryset=MarkovContext.objects.all())
|
2016-11-16 12:10:42 -06:00
|
|
|
ignore_nicks = CharField(help_text="Comma-separated list of nicks to ignore. For Weechat logs.",
|
2014-04-05 18:00:45 -05:00
|
|
|
required=False)
|
2016-11-16 12:10:42 -06:00
|
|
|
strip_prefixes = CharField(help_text="Space-separated list of line prefixes to strip. For Weechat logs.",
|
2014-04-05 18:00:45 -05:00
|
|
|
required=False)
|
2014-04-05 10:52:29 -05:00
|
|
|
|
2014-04-05 14:53:05 -05:00
|
|
|
|
|
|
|
class TeachLineForm(Form):
|
|
|
|
|
|
|
|
"""Accept a line that will be imported into Markov stuff."""
|
|
|
|
|
|
|
|
context = ModelChoiceField(queryset=MarkovContext.objects.all())
|
|
|
|
line = CharField()
|
2014-04-05 18:00:45 -05:00
|
|
|
strip_prefixes = CharField(help_text="Space-separated list of line prefixes to strip.",
|
|
|
|
required=False)
|