Example #1
0
def generic_input(request, form, process_upload):
    flash = ""
    if form.accepts(request, session):
        ss_fname = form.vars.name + '.csv'
        ss_fpath = os.path.join(uploads.spreadsheet_dir(request), ss_fname)
        pt_fname = form.vars.name + '.txt'
        pt_fpath = os.path.join(uploads.plaintext_dir(request), pt_fname)
        if not os.path.isfile(ss_fpath) and not os.path.isfile(pt_fpath):
            ssheet, ptext = process_upload(form)
            uploads.save_spreadsheet(request, form.vars.name, ssheet)
            uploads.save_plaintext(request, form.vars.name, ptext)
            flash = "Submission successful."
        else:
            flash = "Corpus name in use. Please choose another"
    elif form.errors:
        flash = "There were errors in your submission."
    else:
        flash = "Please fill out the form"
    return {"form": form, "flash": flash}
Example #2
0
def csv():
    corpus = request.vars['corpus']
    with open(os.path.join(uploads.spreadsheet_dir(request), corpus)) as f:
        return f.read()
Example #3
0
def index():
    corpora = [fname[:-len(".csv")] for fname in os.listdir(uploads.spreadsheet_dir(request))]
    return {"corpora": corpora}