nopaque/app/corpora/background_functions.py

31 lines
923 B
Python

from ..models import Corpus, CorpusFile
def delete_corpus_(app, corpus_id):
with app.app_context():
corpus = Corpus.query.get(corpus_id)
if corpus is None:
# raise Exception('Corpus {} not found!'.format(corpus_id))
pass
else:
corpus.delete()
def delete_corpus_file_(app, corpus_file_id):
with app.app_context():
corpus_file = CorpusFile.query.get(corpus_file_id)
if corpus_file is None:
# raise Exception('Corpus file {} not found!'.format(corpus_file_id))
pass
else:
corpus_file.delete()
def edit_corpus_file_(app, corpus_file_id):
with app.app_context():
corpus_file = CorpusFile.query.get(corpus_file_id)
if corpus_file is None:
raise Exception('Corpus file {} not found!'.format(corpus_file_id))
else:
corpus_file.insert_metadata()